]>
Commit | Line | Data |
---|---|---|
ccefe4c4 | 1 | /* Partial symbol tables. |
95cf5869 | 2 | |
3666a048 | 3 | Copyright (C) 2009-2021 Free Software Foundation, Inc. |
ccefe4c4 TT |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "defs.h" | |
21 | #include "symtab.h" | |
ccefe4c4 | 22 | #include "objfiles.h" |
b22a7c6a | 23 | #include "psympriv.h" |
ccefe4c4 TT |
24 | #include "block.h" |
25 | #include "filenames.h" | |
26 | #include "source.h" | |
27 | #include "addrmap.h" | |
28 | #include "gdbtypes.h" | |
ccefe4c4 TT |
29 | #include "ui-out.h" |
30 | #include "command.h" | |
e0eac551 | 31 | #include "readline/tilde.h" |
ccefe4c4 | 32 | #include "gdb_regex.h" |
40658b94 | 33 | #include "dictionary.h" |
c00f8484 KS |
34 | #include "language.h" |
35 | #include "cp-support.h" | |
dfc7bb5b | 36 | #include "gdbcmd.h" |
af5bf4ad | 37 | #include <algorithm> |
71a3c369 | 38 | #include <set> |
ccefe4c4 | 39 | |
5c80ed9d TT |
40 | static struct partial_symbol *lookup_partial_symbol (struct objfile *, |
41 | struct partial_symtab *, | |
8c072cb6 TT |
42 | const lookup_name_info &, |
43 | int, | |
ccefe4c4 TT |
44 | domain_enum); |
45 | ||
da5132d3 | 46 | static const char *psymtab_to_fullname (struct partial_symtab *ps); |
ccefe4c4 | 47 | |
5c80ed9d TT |
48 | static struct partial_symbol *find_pc_sect_psymbol (struct objfile *, |
49 | struct partial_symtab *, | |
ccefe4c4 TT |
50 | CORE_ADDR, |
51 | struct obj_section *); | |
52 | ||
43f3e411 DE |
53 | static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile, |
54 | struct partial_symtab *pst); | |
ccefe4c4 | 55 | |
d320c2b5 TT |
56 | psymtab_storage::~psymtab_storage () |
57 | { | |
6f17252b TT |
58 | partial_symtab *iter = psymtabs; |
59 | while (iter != nullptr) | |
60 | { | |
61 | partial_symtab *next = iter->next; | |
62 | delete iter; | |
63 | iter = next; | |
64 | } | |
d320c2b5 TT |
65 | } |
66 | ||
b596a3c7 TT |
67 | /* See psymtab.h. */ |
68 | ||
abaa2f23 TT |
69 | void |
70 | psymtab_storage::install_psymtab (partial_symtab *pst) | |
b596a3c7 | 71 | { |
abaa2f23 TT |
72 | pst->next = psymtabs; |
73 | psymtabs = pst; | |
b596a3c7 TT |
74 | } |
75 | ||
d320c2b5 TT |
76 | \f |
77 | ||
d1eef86d TT |
78 | /* Ensure that the partial symbols for OBJFILE have been loaded. This |
79 | will print a message when symbols are loaded. This function | |
80 | returns a range adapter suitable for iterating over the psymtabs of | |
81 | OBJFILE. */ | |
b11896a5 | 82 | |
3aa31ce7 TT |
83 | psymtab_storage::partial_symtab_range |
84 | psymbol_functions::require_partial_symbols (struct objfile *objfile) | |
b11896a5 | 85 | { |
d1eef86d | 86 | objfile->require_partial_symbols (true); |
3aa31ce7 | 87 | return m_partial_symtabs->range (); |
b11896a5 TT |
88 | } |
89 | ||
ccefe4c4 TT |
90 | /* Find which partial symtab contains PC and SECTION starting at psymtab PST. |
91 | We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */ | |
92 | ||
93 | static struct partial_symtab * | |
5c80ed9d TT |
94 | find_pc_sect_psymtab_closer (struct objfile *objfile, |
95 | CORE_ADDR pc, struct obj_section *section, | |
ccefe4c4 | 96 | struct partial_symtab *pst, |
77e371c0 | 97 | struct bound_minimal_symbol msymbol) |
ccefe4c4 | 98 | { |
ccefe4c4 TT |
99 | struct partial_symtab *tpst; |
100 | struct partial_symtab *best_pst = pst; | |
79748972 | 101 | CORE_ADDR best_addr = pst->text_low (objfile); |
ccefe4c4 | 102 | |
9750bca9 JK |
103 | gdb_assert (!pst->psymtabs_addrmap_supported); |
104 | ||
ccefe4c4 TT |
105 | /* An objfile that has its functions reordered might have |
106 | many partial symbol tables containing the PC, but | |
107 | we want the partial symbol table that contains the | |
108 | function containing the PC. */ | |
95cf5869 DE |
109 | if (!(objfile->flags & OBJF_REORDERED) |
110 | && section == NULL) /* Can't validate section this way. */ | |
ccefe4c4 TT |
111 | return pst; |
112 | ||
77e371c0 | 113 | if (msymbol.minsym == NULL) |
95cf5869 | 114 | return pst; |
ccefe4c4 TT |
115 | |
116 | /* The code range of partial symtabs sometimes overlap, so, in | |
117 | the loop below, we need to check all partial symtabs and | |
0df8b418 | 118 | find the one that fits better for the given PC address. We |
ccefe4c4 TT |
119 | select the partial symtab that contains a symbol whose |
120 | address is closest to the PC address. By closest we mean | |
121 | that find_pc_sect_symbol returns the symbol with address | |
122 | that is closest and still less than the given PC. */ | |
123 | for (tpst = pst; tpst != NULL; tpst = tpst->next) | |
124 | { | |
79748972 | 125 | if (pc >= tpst->text_low (objfile) && pc < tpst->text_high (objfile)) |
ccefe4c4 TT |
126 | { |
127 | struct partial_symbol *p; | |
128 | CORE_ADDR this_addr; | |
129 | ||
130 | /* NOTE: This assumes that every psymbol has a | |
131 | corresponding msymbol, which is not necessarily | |
132 | true; the debug info might be much richer than the | |
133 | object's symbol table. */ | |
5c80ed9d | 134 | p = find_pc_sect_psymbol (objfile, tpst, pc, section); |
ccefe4c4 | 135 | if (p != NULL |
02e9e7f7 | 136 | && (p->address (objfile) == BMSYMBOL_VALUE_ADDRESS (msymbol))) |
ccefe4c4 TT |
137 | return tpst; |
138 | ||
139 | /* Also accept the textlow value of a psymtab as a | |
140 | "symbol", to provide some support for partial | |
141 | symbol tables with line information but no debug | |
142 | symbols (e.g. those produced by an assembler). */ | |
143 | if (p != NULL) | |
02e9e7f7 | 144 | this_addr = p->address (objfile); |
ccefe4c4 | 145 | else |
79748972 | 146 | this_addr = tpst->text_low (objfile); |
ccefe4c4 TT |
147 | |
148 | /* Check whether it is closer than our current | |
149 | BEST_ADDR. Since this symbol address is | |
150 | necessarily lower or equal to PC, the symbol closer | |
151 | to PC is the symbol which address is the highest. | |
152 | This way we return the psymtab which contains such | |
0df8b418 | 153 | best match symbol. This can help in cases where the |
ccefe4c4 TT |
154 | symbol information/debuginfo is not complete, like |
155 | for instance on IRIX6 with gcc, where no debug info | |
0df8b418 MS |
156 | is emitted for statics. (See also the nodebug.exp |
157 | testcase.) */ | |
ccefe4c4 TT |
158 | if (this_addr > best_addr) |
159 | { | |
160 | best_addr = this_addr; | |
161 | best_pst = tpst; | |
162 | } | |
163 | } | |
164 | } | |
165 | return best_pst; | |
166 | } | |
167 | ||
3aa31ce7 | 168 | /* See psympriv.h. */ |
95cf5869 | 169 | |
3aa31ce7 TT |
170 | struct partial_symtab * |
171 | psymbol_functions::find_pc_sect_psymtab (struct objfile *objfile, | |
172 | CORE_ADDR pc, | |
173 | struct obj_section *section, | |
174 | struct bound_minimal_symbol msymbol) | |
ccefe4c4 | 175 | { |
3dd9bb46 AB |
176 | /* Try just the PSYMTABS_ADDRMAP mapping first as it has better |
177 | granularity than the later used TEXTLOW/TEXTHIGH one. However, we need | |
178 | to take care as the PSYMTABS_ADDRMAP can hold things other than partial | |
179 | symtabs in some cases. | |
180 | ||
181 | This function should only be called for objfiles that are using partial | |
182 | symtabs, not for objfiles that are using indexes (.gdb_index or | |
183 | .debug_names), however 'maintenance print psymbols' calls this function | |
184 | directly for all objfiles. If we assume that PSYMTABS_ADDRMAP contains | |
185 | partial symtabs then we will end up returning a pointer to an object | |
186 | that is not a partial_symtab, which doesn't end well. */ | |
187 | ||
3aa31ce7 TT |
188 | if (m_partial_symtabs->psymtabs != NULL |
189 | && m_partial_symtabs->psymtabs_addrmap != NULL) | |
ccefe4c4 | 190 | { |
b3b3bada | 191 | CORE_ADDR baseaddr = objfile->text_section_offset (); |
3dd9bb46 | 192 | |
b22a7c6a TT |
193 | struct partial_symtab *pst |
194 | = ((struct partial_symtab *) | |
3aa31ce7 | 195 | addrmap_find (m_partial_symtabs->psymtabs_addrmap, |
d320c2b5 | 196 | pc - baseaddr)); |
ccefe4c4 TT |
197 | if (pst != NULL) |
198 | { | |
199 | /* FIXME: addrmaps currently do not handle overlayed sections, | |
200 | so fall back to the non-addrmap case if we're debugging | |
201 | overlays and the addrmap returned the wrong section. */ | |
95cf5869 | 202 | if (overlay_debugging && msymbol.minsym != NULL && section != NULL) |
ccefe4c4 TT |
203 | { |
204 | struct partial_symbol *p; | |
ad3bbd48 | 205 | |
ccefe4c4 TT |
206 | /* NOTE: This assumes that every psymbol has a |
207 | corresponding msymbol, which is not necessarily | |
208 | true; the debug info might be much richer than the | |
209 | object's symbol table. */ | |
5c80ed9d | 210 | p = find_pc_sect_psymbol (objfile, pst, pc, section); |
95cf5869 | 211 | if (p == NULL |
02e9e7f7 TT |
212 | || (p->address (objfile) |
213 | != BMSYMBOL_VALUE_ADDRESS (msymbol))) | |
ccefe4c4 TT |
214 | goto next; |
215 | } | |
216 | ||
217 | /* We do not try to call FIND_PC_SECT_PSYMTAB_CLOSER as | |
218 | PSYMTABS_ADDRMAP we used has already the best 1-byte | |
219 | granularity and FIND_PC_SECT_PSYMTAB_CLOSER may mislead us into | |
220 | a worse chosen section due to the TEXTLOW/TEXTHIGH ranges | |
221 | overlap. */ | |
222 | ||
223 | return pst; | |
224 | } | |
225 | } | |
226 | ||
227 | next: | |
228 | ||
229 | /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs | |
230 | which still have no corresponding full SYMTABs read. But it is not | |
231 | present for non-DWARF2 debug infos not supporting PSYMTABS_ADDRMAP in GDB | |
232 | so far. */ | |
233 | ||
234 | /* Check even OBJFILE with non-zero PSYMTABS_ADDRMAP as only several of | |
235 | its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying | |
236 | debug info type in single OBJFILE. */ | |
237 | ||
d1eef86d | 238 | for (partial_symtab *pst : require_partial_symbols (objfile)) |
9750bca9 | 239 | if (!pst->psymtabs_addrmap_supported |
79748972 | 240 | && pc >= pst->text_low (objfile) && pc < pst->text_high (objfile)) |
ccefe4c4 TT |
241 | { |
242 | struct partial_symtab *best_pst; | |
243 | ||
5c80ed9d TT |
244 | best_pst = find_pc_sect_psymtab_closer (objfile, pc, section, pst, |
245 | msymbol); | |
ccefe4c4 TT |
246 | if (best_pst != NULL) |
247 | return best_pst; | |
248 | } | |
249 | ||
250 | return NULL; | |
251 | } | |
252 | ||
95cf5869 DE |
253 | /* Psymtab version of find_pc_sect_compunit_symtab. See its definition in |
254 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 255 | |
39298a5d TT |
256 | struct compunit_symtab * |
257 | psymbol_functions::find_pc_sect_compunit_symtab | |
258 | (struct objfile *objfile, | |
259 | struct bound_minimal_symbol msymbol, | |
260 | CORE_ADDR pc, | |
261 | struct obj_section *section, | |
262 | int warn_if_readin) | |
ccefe4c4 | 263 | { |
17d66340 | 264 | struct partial_symtab *ps = find_pc_sect_psymtab (objfile, |
17d66340 | 265 | pc, section, |
ccefe4c4 | 266 | msymbol); |
95cf5869 | 267 | if (ps != NULL) |
ccefe4c4 | 268 | { |
5717c425 | 269 | if (warn_if_readin && ps->readin_p (objfile)) |
ccefe4c4 TT |
270 | /* Might want to error() here (in case symtab is corrupt and |
271 | will cause a core dump), but maybe we can successfully | |
272 | continue, so let's not. */ | |
273 | warning (_("\ | |
274 | (Internal error: pc %s in read in psymtab, but not in symtab.)\n"), | |
08feed99 | 275 | paddress (objfile->arch (), pc)); |
5c80ed9d | 276 | psymtab_to_symtab (objfile, ps); |
5717c425 | 277 | return ps->get_compunit_symtab (objfile); |
ccefe4c4 TT |
278 | } |
279 | return NULL; | |
280 | } | |
281 | ||
282 | /* Find which partial symbol within a psymtab matches PC and SECTION. | |
95cf5869 | 283 | Return NULL if none. */ |
ccefe4c4 TT |
284 | |
285 | static struct partial_symbol * | |
5c80ed9d TT |
286 | find_pc_sect_psymbol (struct objfile *objfile, |
287 | struct partial_symtab *psymtab, CORE_ADDR pc, | |
ccefe4c4 TT |
288 | struct obj_section *section) |
289 | { | |
af5bf4ad | 290 | struct partial_symbol *best = NULL; |
ccefe4c4 | 291 | CORE_ADDR best_pc; |
79748972 | 292 | const CORE_ADDR textlow = psymtab->text_low (objfile); |
ccefe4c4 TT |
293 | |
294 | gdb_assert (psymtab != NULL); | |
295 | ||
0df8b418 | 296 | /* Cope with programs that start at address 0. */ |
79748972 | 297 | best_pc = (textlow != 0) ? textlow - 1 : 0; |
ccefe4c4 TT |
298 | |
299 | /* Search the global symbols as well as the static symbols, so that | |
300 | find_pc_partial_function doesn't use a minimal symbol and thus | |
301 | cache a bad endaddr. */ | |
932539d7 | 302 | for (partial_symbol *p : psymtab->global_psymbols) |
ccefe4c4 | 303 | { |
8a6d4234 TT |
304 | if (p->domain == VAR_DOMAIN |
305 | && p->aclass == LOC_BLOCK | |
02e9e7f7 TT |
306 | && pc >= p->address (objfile) |
307 | && (p->address (objfile) > best_pc | |
79748972 | 308 | || (psymtab->text_low (objfile) == 0 |
02e9e7f7 | 309 | && best_pc == 0 && p->address (objfile) == 0))) |
ccefe4c4 | 310 | { |
95cf5869 | 311 | if (section != NULL) /* Match on a specific section. */ |
ccefe4c4 | 312 | { |
8a6d4234 | 313 | if (!matching_obj_sections (p->obj_section (objfile), |
e27d198c | 314 | section)) |
ccefe4c4 TT |
315 | continue; |
316 | } | |
02e9e7f7 | 317 | best_pc = p->address (objfile); |
ccefe4c4 TT |
318 | best = p; |
319 | } | |
320 | } | |
321 | ||
932539d7 | 322 | for (partial_symbol *p : psymtab->static_psymbols) |
ccefe4c4 | 323 | { |
8a6d4234 TT |
324 | if (p->domain == VAR_DOMAIN |
325 | && p->aclass == LOC_BLOCK | |
02e9e7f7 TT |
326 | && pc >= p->address (objfile) |
327 | && (p->address (objfile) > best_pc | |
79748972 | 328 | || (psymtab->text_low (objfile) == 0 |
02e9e7f7 | 329 | && best_pc == 0 && p->address (objfile) == 0))) |
ccefe4c4 | 330 | { |
95cf5869 | 331 | if (section != NULL) /* Match on a specific section. */ |
ccefe4c4 | 332 | { |
8a6d4234 | 333 | if (!matching_obj_sections (p->obj_section (objfile), |
e27d198c | 334 | section)) |
ccefe4c4 TT |
335 | continue; |
336 | } | |
02e9e7f7 | 337 | best_pc = p->address (objfile); |
ccefe4c4 TT |
338 | best = p; |
339 | } | |
340 | } | |
341 | ||
342 | return best; | |
343 | } | |
344 | ||
d3214198 TV |
345 | /* Psymtab version of lookup_global_symbol_language. See its definition in |
346 | the definition of quick_symbol_functions in symfile.h. */ | |
347 | ||
39298a5d TT |
348 | enum language |
349 | psymbol_functions::lookup_global_symbol_language (struct objfile *objfile, | |
350 | const char *name, | |
351 | domain_enum domain, | |
352 | bool *symbol_found_p) | |
d3214198 TV |
353 | { |
354 | *symbol_found_p = false; | |
355 | if (objfile->sf == NULL) | |
356 | return language_unknown; | |
357 | ||
358 | lookup_name_info lookup_name (name, symbol_name_match_type::FULL); | |
359 | ||
d1eef86d | 360 | for (partial_symtab *ps : require_partial_symbols (objfile)) |
d3214198 TV |
361 | { |
362 | struct partial_symbol *psym; | |
5717c425 | 363 | if (ps->readin_p (objfile)) |
d3214198 TV |
364 | continue; |
365 | ||
366 | psym = lookup_partial_symbol (objfile, ps, lookup_name, 1, domain); | |
367 | if (psym) | |
368 | { | |
369 | *symbol_found_p = true; | |
370 | return psym->ginfo.language (); | |
371 | } | |
372 | } | |
373 | ||
374 | return language_unknown; | |
375 | } | |
376 | ||
b5ec771e PA |
377 | /* Returns true if PSYM matches LOOKUP_NAME. */ |
378 | ||
379 | static bool | |
380 | psymbol_name_matches (partial_symbol *psym, | |
381 | const lookup_name_info &lookup_name) | |
382 | { | |
c1b5c1eb | 383 | const language_defn *lang = language_def (psym->ginfo.language ()); |
b5ec771e | 384 | symbol_name_matcher_ftype *name_match |
c9debfb9 | 385 | = lang->get_symbol_name_matcher (lookup_name); |
c9d95fa3 | 386 | return name_match (psym->ginfo.search_name (), lookup_name, NULL); |
b5ec771e PA |
387 | } |
388 | ||
40658b94 PH |
389 | /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search |
390 | the global block of PST if GLOBAL, and otherwise the static block. | |
391 | MATCH is the comparison operation that returns true iff MATCH (s, | |
392 | NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is | |
393 | non-null, the symbols in the block are assumed to be ordered | |
394 | according to it (allowing binary search). It must be compatible | |
395 | with MATCH. Returns the symbol, if found, and otherwise NULL. */ | |
396 | ||
397 | static struct partial_symbol * | |
5c80ed9d TT |
398 | match_partial_symbol (struct objfile *objfile, |
399 | struct partial_symtab *pst, int global, | |
b054970d | 400 | const lookup_name_info &name, domain_enum domain, |
2edb89d3 | 401 | symbol_compare_ftype *ordered_compare) |
40658b94 PH |
402 | { |
403 | struct partial_symbol **start, **psym; | |
404 | struct partial_symbol **top, **real_top, **bottom, **center; | |
932539d7 TT |
405 | int length = (global |
406 | ? pst->global_psymbols.size () | |
407 | : pst->static_psymbols.size ()); | |
40658b94 PH |
408 | int do_linear_search = 1; |
409 | ||
410 | if (length == 0) | |
b5ec771e PA |
411 | return NULL; |
412 | ||
40658b94 | 413 | start = (global ? |
932539d7 TT |
414 | &pst->global_psymbols[0] : |
415 | &pst->static_psymbols[0]); | |
40658b94 PH |
416 | |
417 | if (global && ordered_compare) /* Can use a binary search. */ | |
418 | { | |
419 | do_linear_search = 0; | |
420 | ||
421 | /* Binary search. This search is guaranteed to end with center | |
dda83cd7 SM |
422 | pointing at the earliest partial symbol whose name might be |
423 | correct. At that point *all* partial symbols with an | |
424 | appropriate name will be checked against the correct | |
425 | domain. */ | |
40658b94 PH |
426 | |
427 | bottom = start; | |
428 | top = start + length - 1; | |
429 | real_top = top; | |
430 | while (top > bottom) | |
431 | { | |
432 | center = bottom + (top - bottom) / 2; | |
433 | gdb_assert (center < top); | |
b5ec771e | 434 | |
c1b5c1eb | 435 | enum language lang = (*center)->ginfo.language (); |
e0802d59 | 436 | const char *lang_ln = name.language_lookup_name (lang); |
b5ec771e | 437 | |
c9d95fa3 | 438 | if (ordered_compare ((*center)->ginfo.search_name (), |
af97b416 | 439 | lang_ln) >= 0) |
40658b94 PH |
440 | top = center; |
441 | else | |
442 | bottom = center + 1; | |
443 | } | |
444 | gdb_assert (top == bottom); | |
445 | ||
446 | while (top <= real_top | |
b054970d | 447 | && psymbol_name_matches (*top, name)) |
40658b94 | 448 | { |
c1b5c1eb | 449 | if (symbol_matches_domain ((*top)->ginfo.language (), |
8a6d4234 | 450 | (*top)->domain, domain)) |
40658b94 PH |
451 | return *top; |
452 | top++; | |
453 | } | |
454 | } | |
455 | ||
456 | /* Can't use a binary search or else we found during the binary search that | |
457 | we should also do a linear search. */ | |
458 | ||
459 | if (do_linear_search) | |
460 | { | |
461 | for (psym = start; psym < start + length; psym++) | |
462 | { | |
c1b5c1eb | 463 | if (symbol_matches_domain ((*psym)->ginfo.language (), |
8a6d4234 | 464 | (*psym)->domain, domain) |
b054970d | 465 | && psymbol_name_matches (*psym, name)) |
40658b94 PH |
466 | return *psym; |
467 | } | |
468 | } | |
469 | ||
470 | return NULL; | |
471 | } | |
472 | ||
8c072cb6 TT |
473 | /* Look, in partial_symtab PST, for symbol whose natural name is |
474 | LOOKUP_NAME. Check the global symbols if GLOBAL, the static | |
475 | symbols if not. */ | |
ccefe4c4 | 476 | |
18430289 | 477 | static struct partial_symbol * |
5c80ed9d | 478 | lookup_partial_symbol (struct objfile *objfile, |
8c072cb6 TT |
479 | struct partial_symtab *pst, |
480 | const lookup_name_info &lookup_name, | |
ccefe4c4 TT |
481 | int global, domain_enum domain) |
482 | { | |
ccefe4c4 TT |
483 | struct partial_symbol **start, **psym; |
484 | struct partial_symbol **top, **real_top, **bottom, **center; | |
932539d7 TT |
485 | int length = (global |
486 | ? pst->global_psymbols.size () | |
487 | : pst->static_psymbols.size ()); | |
ccefe4c4 TT |
488 | int do_linear_search = 1; |
489 | ||
490 | if (length == 0) | |
95cf5869 | 491 | return NULL; |
c00f8484 | 492 | |
ccefe4c4 | 493 | start = (global ? |
932539d7 TT |
494 | &pst->global_psymbols[0] : |
495 | &pst->static_psymbols[0]); | |
ccefe4c4 | 496 | |
0df8b418 | 497 | if (global) /* This means we can use a binary search. */ |
ccefe4c4 TT |
498 | { |
499 | do_linear_search = 0; | |
500 | ||
501 | /* Binary search. This search is guaranteed to end with center | |
dda83cd7 SM |
502 | pointing at the earliest partial symbol whose name might be |
503 | correct. At that point *all* partial symbols with an | |
504 | appropriate name will be checked against the correct | |
505 | domain. */ | |
ccefe4c4 TT |
506 | |
507 | bottom = start; | |
508 | top = start + length - 1; | |
509 | real_top = top; | |
510 | while (top > bottom) | |
511 | { | |
512 | center = bottom + (top - bottom) / 2; | |
e2ff18a0 SM |
513 | |
514 | gdb_assert (center < top); | |
515 | ||
c9d95fa3 | 516 | if (strcmp_iw_ordered ((*center)->ginfo.search_name (), |
e0802d59 | 517 | lookup_name.c_str ()) >= 0) |
ccefe4c4 TT |
518 | { |
519 | top = center; | |
520 | } | |
521 | else | |
522 | { | |
523 | bottom = center + 1; | |
524 | } | |
525 | } | |
e2ff18a0 SM |
526 | |
527 | gdb_assert (top == bottom); | |
ccefe4c4 | 528 | |
559a7a62 JK |
529 | /* For `case_sensitivity == case_sensitive_off' strcmp_iw_ordered will |
530 | search more exactly than what matches SYMBOL_MATCHES_SEARCH_NAME. */ | |
af97b416 TT |
531 | while (top >= start && symbol_matches_search_name (&(*top)->ginfo, |
532 | lookup_name)) | |
559a7a62 JK |
533 | top--; |
534 | ||
535 | /* Fixup to have a symbol which matches SYMBOL_MATCHES_SEARCH_NAME. */ | |
536 | top++; | |
537 | ||
af97b416 TT |
538 | while (top <= real_top && symbol_matches_search_name (&(*top)->ginfo, |
539 | lookup_name)) | |
ccefe4c4 | 540 | { |
c1b5c1eb | 541 | if (symbol_matches_domain ((*top)->ginfo.language (), |
8a6d4234 | 542 | (*top)->domain, domain)) |
56f37645 | 543 | return *top; |
ccefe4c4 TT |
544 | top++; |
545 | } | |
546 | } | |
547 | ||
548 | /* Can't use a binary search or else we found during the binary search that | |
40658b94 | 549 | we should also do a linear search. */ |
ccefe4c4 TT |
550 | |
551 | if (do_linear_search) | |
552 | { | |
553 | for (psym = start; psym < start + length; psym++) | |
554 | { | |
c1b5c1eb | 555 | if (symbol_matches_domain ((*psym)->ginfo.language (), |
8a6d4234 | 556 | (*psym)->domain, domain) |
af97b416 | 557 | && symbol_matches_search_name (&(*psym)->ginfo, lookup_name)) |
56f37645 | 558 | return *psym; |
ccefe4c4 TT |
559 | } |
560 | } | |
561 | ||
95cf5869 | 562 | return NULL; |
ccefe4c4 TT |
563 | } |
564 | ||
565 | /* Get the symbol table that corresponds to a partial_symtab. | |
f194fefb DE |
566 | This is fast after the first time you do it. |
567 | The result will be NULL if the primary symtab has no symbols, | |
568 | which can happen. Otherwise the result is the primary symtab | |
569 | that contains PST. */ | |
ccefe4c4 | 570 | |
43f3e411 | 571 | static struct compunit_symtab * |
5c80ed9d | 572 | psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst) |
ccefe4c4 | 573 | { |
9439a077 TT |
574 | /* If it is a shared psymtab, find an unshared psymtab that includes |
575 | it. Any such psymtab will do. */ | |
576 | while (pst->user != NULL) | |
577 | pst = pst->user; | |
578 | ||
0df8b418 | 579 | /* If it's been looked up before, return it. */ |
5717c425 TT |
580 | if (pst->get_compunit_symtab (objfile)) |
581 | return pst->get_compunit_symtab (objfile); | |
ccefe4c4 TT |
582 | |
583 | /* If it has not yet been read in, read it. */ | |
5717c425 | 584 | if (!pst->readin_p (objfile)) |
ccefe4c4 | 585 | { |
c83dd867 | 586 | scoped_restore decrementer = increment_reading_symtab (); |
ad3bbd48 | 587 | |
077cbab2 TT |
588 | if (info_verbose) |
589 | { | |
fd760e79 | 590 | printf_filtered (_("Reading in symbols for %s...\n"), |
077cbab2 TT |
591 | pst->filename); |
592 | gdb_flush (gdb_stdout); | |
593 | } | |
594 | ||
891813be | 595 | pst->read_symtab (objfile); |
ccefe4c4 TT |
596 | } |
597 | ||
5717c425 | 598 | return pst->get_compunit_symtab (objfile); |
ccefe4c4 TT |
599 | } |
600 | ||
95cf5869 DE |
601 | /* Psymtab version of find_last_source_symtab. See its definition in |
602 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 603 | |
39298a5d TT |
604 | struct symtab * |
605 | psymbol_functions::find_last_source_symtab (struct objfile *ofp) | |
ccefe4c4 | 606 | { |
95cf5869 | 607 | struct partial_symtab *cs_pst = NULL; |
ccefe4c4 | 608 | |
d1eef86d | 609 | for (partial_symtab *ps : require_partial_symbols (ofp)) |
ccefe4c4 TT |
610 | { |
611 | const char *name = ps->filename; | |
612 | int len = strlen (name); | |
ad3bbd48 | 613 | |
ccefe4c4 TT |
614 | if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0 |
615 | || strcmp (name, "<<C++-namespaces>>") == 0))) | |
616 | cs_pst = ps; | |
617 | } | |
618 | ||
619 | if (cs_pst) | |
620 | { | |
5717c425 | 621 | if (cs_pst->readin_p (ofp)) |
ccefe4c4 TT |
622 | { |
623 | internal_error (__FILE__, __LINE__, | |
624 | _("select_source_symtab: " | |
625 | "readin pst found and no symtabs.")); | |
626 | } | |
627 | else | |
43f3e411 DE |
628 | { |
629 | struct compunit_symtab *cust = psymtab_to_symtab (ofp, cs_pst); | |
630 | ||
631 | if (cust == NULL) | |
632 | return NULL; | |
633 | return compunit_primary_filetab (cust); | |
634 | } | |
ccefe4c4 TT |
635 | } |
636 | return NULL; | |
637 | } | |
638 | ||
95cf5869 DE |
639 | /* Psymtab version of forget_cached_source_info. See its definition in |
640 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 641 | |
39298a5d TT |
642 | void |
643 | psymbol_functions::forget_cached_source_info (struct objfile *objfile) | |
ccefe4c4 | 644 | { |
d1eef86d | 645 | for (partial_symtab *pst : require_partial_symbols (objfile)) |
ccefe4c4 TT |
646 | { |
647 | if (pst->fullname != NULL) | |
648 | { | |
649 | xfree (pst->fullname); | |
650 | pst->fullname = NULL; | |
651 | } | |
652 | } | |
653 | } | |
654 | ||
655 | static void | |
02e9e7f7 | 656 | print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile, |
932539d7 TT |
657 | const std::vector<partial_symbol *> &symbols, |
658 | const char *what, struct ui_file *outfile) | |
ccefe4c4 TT |
659 | { |
660 | fprintf_filtered (outfile, " %s partial symbols:\n", what); | |
932539d7 | 661 | for (partial_symbol *p : symbols) |
ccefe4c4 | 662 | { |
27618ce4 | 663 | QUIT; |
932539d7 TT |
664 | fprintf_filtered (outfile, " `%s'", p->ginfo.linkage_name ()); |
665 | if (p->ginfo.demangled_name () != NULL) | |
ccefe4c4 | 666 | { |
af97b416 | 667 | fprintf_filtered (outfile, " `%s'", |
932539d7 | 668 | p->ginfo.demangled_name ()); |
ccefe4c4 TT |
669 | } |
670 | fputs_filtered (", ", outfile); | |
932539d7 | 671 | switch (p->domain) |
ccefe4c4 TT |
672 | { |
673 | case UNDEF_DOMAIN: | |
674 | fputs_filtered ("undefined domain, ", outfile); | |
675 | break; | |
676 | case VAR_DOMAIN: | |
0df8b418 | 677 | /* This is the usual thing -- don't print it. */ |
ccefe4c4 TT |
678 | break; |
679 | case STRUCT_DOMAIN: | |
680 | fputs_filtered ("struct domain, ", outfile); | |
681 | break; | |
06ff036e AB |
682 | case MODULE_DOMAIN: |
683 | fputs_filtered ("module domain, ", outfile); | |
684 | break; | |
ccefe4c4 TT |
685 | case LABEL_DOMAIN: |
686 | fputs_filtered ("label domain, ", outfile); | |
687 | break; | |
06ff036e AB |
688 | case COMMON_BLOCK_DOMAIN: |
689 | fputs_filtered ("common block domain, ", outfile); | |
690 | break; | |
ccefe4c4 TT |
691 | default: |
692 | fputs_filtered ("<invalid domain>, ", outfile); | |
693 | break; | |
694 | } | |
932539d7 | 695 | switch (p->aclass) |
ccefe4c4 TT |
696 | { |
697 | case LOC_UNDEF: | |
698 | fputs_filtered ("undefined", outfile); | |
699 | break; | |
700 | case LOC_CONST: | |
701 | fputs_filtered ("constant int", outfile); | |
702 | break; | |
703 | case LOC_STATIC: | |
704 | fputs_filtered ("static", outfile); | |
705 | break; | |
706 | case LOC_REGISTER: | |
707 | fputs_filtered ("register", outfile); | |
708 | break; | |
709 | case LOC_ARG: | |
710 | fputs_filtered ("pass by value", outfile); | |
711 | break; | |
712 | case LOC_REF_ARG: | |
713 | fputs_filtered ("pass by reference", outfile); | |
714 | break; | |
715 | case LOC_REGPARM_ADDR: | |
716 | fputs_filtered ("register address parameter", outfile); | |
717 | break; | |
718 | case LOC_LOCAL: | |
719 | fputs_filtered ("stack parameter", outfile); | |
720 | break; | |
721 | case LOC_TYPEDEF: | |
722 | fputs_filtered ("type", outfile); | |
723 | break; | |
724 | case LOC_LABEL: | |
725 | fputs_filtered ("label", outfile); | |
726 | break; | |
727 | case LOC_BLOCK: | |
728 | fputs_filtered ("function", outfile); | |
729 | break; | |
730 | case LOC_CONST_BYTES: | |
731 | fputs_filtered ("constant bytes", outfile); | |
732 | break; | |
733 | case LOC_UNRESOLVED: | |
734 | fputs_filtered ("unresolved", outfile); | |
735 | break; | |
736 | case LOC_OPTIMIZED_OUT: | |
737 | fputs_filtered ("optimized out", outfile); | |
738 | break; | |
739 | case LOC_COMPUTED: | |
740 | fputs_filtered ("computed at runtime", outfile); | |
741 | break; | |
742 | default: | |
743 | fputs_filtered ("<invalid location>", outfile); | |
744 | break; | |
745 | } | |
746 | fputs_filtered (", ", outfile); | |
932539d7 | 747 | fputs_filtered (paddress (gdbarch, p->unrelocated_address ()), outfile); |
ccefe4c4 | 748 | fprintf_filtered (outfile, "\n"); |
ccefe4c4 TT |
749 | } |
750 | } | |
751 | ||
752 | static void | |
753 | dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, | |
754 | struct ui_file *outfile) | |
755 | { | |
08feed99 | 756 | struct gdbarch *gdbarch = objfile->arch (); |
ccefe4c4 TT |
757 | int i; |
758 | ||
b4c41fc7 DE |
759 | if (psymtab->anonymous) |
760 | { | |
761 | fprintf_filtered (outfile, "\nAnonymous partial symtab (%s) ", | |
762 | psymtab->filename); | |
763 | } | |
764 | else | |
765 | { | |
766 | fprintf_filtered (outfile, "\nPartial symtab for source file %s ", | |
767 | psymtab->filename); | |
768 | } | |
ccefe4c4 TT |
769 | fprintf_filtered (outfile, "(object "); |
770 | gdb_print_host_address (psymtab, outfile); | |
771 | fprintf_filtered (outfile, ")\n\n"); | |
22068491 TT |
772 | fprintf_filtered (outfile, " Read from object file %s (", |
773 | objfile_name (objfile)); | |
ccefe4c4 | 774 | gdb_print_host_address (objfile, outfile); |
22068491 | 775 | fprintf_filtered (outfile, ")\n"); |
ccefe4c4 | 776 | |
5717c425 | 777 | if (psymtab->readin_p (objfile)) |
ccefe4c4 TT |
778 | { |
779 | fprintf_filtered (outfile, | |
780 | " Full symtab was read (at "); | |
5717c425 | 781 | gdb_print_host_address (psymtab->get_compunit_symtab (objfile), outfile); |
ccefe4c4 TT |
782 | fprintf_filtered (outfile, ")\n"); |
783 | } | |
784 | ||
ccefe4c4 | 785 | fprintf_filtered (outfile, " Symbols cover text addresses "); |
79748972 | 786 | fputs_filtered (paddress (gdbarch, psymtab->text_low (objfile)), outfile); |
ccefe4c4 | 787 | fprintf_filtered (outfile, "-"); |
79748972 | 788 | fputs_filtered (paddress (gdbarch, psymtab->text_high (objfile)), outfile); |
ccefe4c4 | 789 | fprintf_filtered (outfile, "\n"); |
9750bca9 JK |
790 | fprintf_filtered (outfile, " Address map supported - %s.\n", |
791 | psymtab->psymtabs_addrmap_supported ? "yes" : "no"); | |
ccefe4c4 TT |
792 | fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", |
793 | psymtab->number_of_dependencies); | |
794 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
795 | { | |
796 | fprintf_filtered (outfile, " %d ", i); | |
797 | gdb_print_host_address (psymtab->dependencies[i], outfile); | |
798 | fprintf_filtered (outfile, " %s\n", | |
799 | psymtab->dependencies[i]->filename); | |
800 | } | |
9439a077 TT |
801 | if (psymtab->user != NULL) |
802 | { | |
803 | fprintf_filtered (outfile, " Shared partial symtab with user "); | |
804 | gdb_print_host_address (psymtab->user, outfile); | |
805 | fprintf_filtered (outfile, "\n"); | |
806 | } | |
932539d7 | 807 | if (!psymtab->global_psymbols.empty ()) |
ccefe4c4 | 808 | { |
d320c2b5 | 809 | print_partial_symbols |
932539d7 TT |
810 | (gdbarch, objfile, psymtab->global_psymbols, |
811 | "Global", outfile); | |
ccefe4c4 | 812 | } |
932539d7 | 813 | if (!psymtab->static_psymbols.empty ()) |
ccefe4c4 | 814 | { |
d320c2b5 | 815 | print_partial_symbols |
932539d7 TT |
816 | (gdbarch, objfile, psymtab->static_psymbols, |
817 | "Static", outfile); | |
ccefe4c4 TT |
818 | } |
819 | fprintf_filtered (outfile, "\n"); | |
820 | } | |
821 | ||
4829711b TT |
822 | /* Count the number of partial symbols in OBJFILE. */ |
823 | ||
caf8c1e5 TT |
824 | int |
825 | psymbol_functions::count_psyms () | |
4829711b TT |
826 | { |
827 | int count = 0; | |
caf8c1e5 | 828 | for (partial_symtab *pst : m_partial_symtabs->range ()) |
4829711b TT |
829 | { |
830 | count += pst->global_psymbols.size (); | |
831 | count += pst->static_psymbols.size (); | |
832 | } | |
833 | return count; | |
834 | } | |
835 | ||
95cf5869 DE |
836 | /* Psymtab version of print_stats. See its definition in |
837 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 838 | |
39298a5d | 839 | void |
4829711b | 840 | psymbol_functions::print_stats (struct objfile *objfile, bool print_bcache) |
ccefe4c4 TT |
841 | { |
842 | int i; | |
ad3bbd48 | 843 | |
4829711b TT |
844 | if (!print_bcache) |
845 | { | |
caf8c1e5 | 846 | int n_psyms = count_psyms (); |
4829711b TT |
847 | if (n_psyms > 0) |
848 | printf_filtered (_(" Number of \"partial\" symbols read: %d\n"), | |
849 | n_psyms); | |
850 | ||
851 | i = 0; | |
d1eef86d | 852 | for (partial_symtab *ps : require_partial_symbols (objfile)) |
4829711b TT |
853 | { |
854 | if (!ps->readin_p (objfile)) | |
855 | i++; | |
856 | } | |
857 | printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), | |
858 | i); | |
859 | printf_filtered (_(" Total memory used for psymbol cache: %d\n"), | |
17d66340 | 860 | m_partial_symtabs->psymbol_cache.memory_used ()); |
4829711b TT |
861 | } |
862 | else | |
ccefe4c4 | 863 | { |
4829711b | 864 | printf_filtered (_("Psymbol byte cache statistics:\n")); |
17d66340 | 865 | m_partial_symtabs->psymbol_cache.print_statistics |
4829711b | 866 | ("partial symbol cache"); |
ccefe4c4 | 867 | } |
ccefe4c4 TT |
868 | } |
869 | ||
95cf5869 DE |
870 | /* Psymtab version of dump. See its definition in |
871 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 872 | |
39298a5d TT |
873 | void |
874 | psymbol_functions::dump (struct objfile *objfile) | |
ccefe4c4 TT |
875 | { |
876 | struct partial_symtab *psymtab; | |
877 | ||
17d66340 | 878 | if (m_partial_symtabs->psymtabs) |
ccefe4c4 TT |
879 | { |
880 | printf_filtered ("Psymtabs:\n"); | |
17d66340 | 881 | for (psymtab = m_partial_symtabs->psymtabs; |
ccefe4c4 TT |
882 | psymtab != NULL; |
883 | psymtab = psymtab->next) | |
884 | { | |
885 | printf_filtered ("%s at ", | |
886 | psymtab->filename); | |
887 | gdb_print_host_address (psymtab, gdb_stdout); | |
b9f90c72 | 888 | printf_filtered ("\n"); |
ccefe4c4 TT |
889 | } |
890 | printf_filtered ("\n\n"); | |
891 | } | |
892 | } | |
893 | ||
95cf5869 DE |
894 | /* Psymtab version of expand_all_symtabs. See its definition in |
895 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 896 | |
39298a5d TT |
897 | void |
898 | psymbol_functions::expand_all_symtabs (struct objfile *objfile) | |
ccefe4c4 | 899 | { |
d1eef86d | 900 | for (partial_symtab *psymtab : require_partial_symbols (objfile)) |
b22a7c6a | 901 | psymtab_to_symtab (objfile, psymtab); |
ccefe4c4 TT |
902 | } |
903 | ||
95cf5869 DE |
904 | /* Psymtab version of map_symbol_filenames. See its definition in |
905 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 906 | |
39298a5d | 907 | void |
f4655dee TT |
908 | psymbol_functions::map_symbol_filenames |
909 | (struct objfile *objfile, | |
910 | gdb::function_view<symbol_filename_ftype> fun, | |
911 | bool need_fullname) | |
ccefe4c4 | 912 | { |
d1eef86d | 913 | for (partial_symtab *ps : require_partial_symbols (objfile)) |
ccefe4c4 TT |
914 | { |
915 | const char *fullname; | |
916 | ||
5717c425 | 917 | if (ps->readin_p (objfile)) |
ccefe4c4 TT |
918 | continue; |
919 | ||
f80c6f3f DE |
920 | /* We can skip shared psymtabs here, because any file name will be |
921 | attached to the unshared psymtab. */ | |
922 | if (ps->user != NULL) | |
923 | continue; | |
924 | ||
b4c41fc7 DE |
925 | /* Anonymous psymtabs don't have a file name. */ |
926 | if (ps->anonymous) | |
927 | continue; | |
928 | ||
821296b7 | 929 | QUIT; |
74e2f255 DE |
930 | if (need_fullname) |
931 | fullname = psymtab_to_fullname (ps); | |
932 | else | |
933 | fullname = NULL; | |
f4655dee | 934 | fun (ps->filename, fullname); |
ccefe4c4 TT |
935 | } |
936 | } | |
937 | ||
ccefe4c4 TT |
938 | /* Finds the fullname that a partial_symtab represents. |
939 | ||
940 | If this functions finds the fullname, it will save it in ps->fullname | |
941 | and it will also return the value. | |
942 | ||
943 | If this function fails to find the file that this partial_symtab represents, | |
944 | NULL will be returned and ps->fullname will be set to NULL. */ | |
256f06f3 | 945 | |
da5132d3 | 946 | static const char * |
ccefe4c4 TT |
947 | psymtab_to_fullname (struct partial_symtab *ps) |
948 | { | |
fbd9ab74 | 949 | gdb_assert (!ps->anonymous); |
ccefe4c4 | 950 | |
256f06f3 DE |
951 | /* Use cached copy if we have it. |
952 | We rely on forget_cached_source_info being called appropriately | |
953 | to handle cases like the file being moved. */ | |
fbd9ab74 JK |
954 | if (ps->fullname == NULL) |
955 | { | |
e0cc99a6 | 956 | gdb::unique_xmalloc_ptr<char> fullname; |
2179fbc3 TT |
957 | scoped_fd fd = find_and_open_source (ps->filename, ps->dirname, |
958 | &fullname); | |
e0cc99a6 | 959 | ps->fullname = fullname.release (); |
256f06f3 | 960 | |
2179fbc3 | 961 | if (fd.get () < 0) |
fbd9ab74 | 962 | { |
fbd9ab74 JK |
963 | /* rewrite_source_path would be applied by find_and_open_source, we |
964 | should report the pathname where GDB tried to find the file. */ | |
ccefe4c4 | 965 | |
fbd9ab74 | 966 | if (ps->dirname == NULL || IS_ABSOLUTE_PATH (ps->filename)) |
0b581c69 | 967 | fullname.reset (xstrdup (ps->filename)); |
fbd9ab74 | 968 | else |
0b581c69 TT |
969 | fullname.reset (concat (ps->dirname, SLASH_STRING, |
970 | ps->filename, (char *) NULL)); | |
fbd9ab74 | 971 | |
0b581c69 | 972 | ps->fullname = rewrite_source_path (fullname.get ()).release (); |
fbd9ab74 | 973 | if (ps->fullname == NULL) |
0b581c69 | 974 | ps->fullname = fullname.release (); |
fbd9ab74 | 975 | } |
95cf5869 | 976 | } |
fbd9ab74 JK |
977 | |
978 | return ps->fullname; | |
ccefe4c4 TT |
979 | } |
980 | ||
0b7b2c2a | 981 | /* Psymtab version of expand_matching_symbols. See its definition in |
95cf5869 | 982 | the definition of quick_symbol_functions in symfile.h. */ |
40658b94 | 983 | |
39298a5d | 984 | void |
0b7b2c2a | 985 | psymbol_functions::expand_matching_symbols |
199b4314 | 986 | (struct objfile *objfile, |
b054970d | 987 | const lookup_name_info &name, domain_enum domain, |
199b4314 | 988 | int global, |
199b4314 | 989 | symbol_compare_ftype *ordered_compare) |
ccefe4c4 | 990 | { |
d1eef86d | 991 | for (partial_symtab *ps : require_partial_symbols (objfile)) |
ccefe4c4 TT |
992 | { |
993 | QUIT; | |
0b7b2c2a TT |
994 | if (!ps->readin_p (objfile) |
995 | && match_partial_symbol (objfile, ps, global, name, domain, | |
40658b94 | 996 | ordered_compare)) |
0b7b2c2a | 997 | psymtab_to_symtab (objfile, ps); |
ccefe4c4 | 998 | } |
95cf5869 | 999 | } |
ccefe4c4 | 1000 | |
14bc53a8 PA |
1001 | /* A helper for psym_expand_symtabs_matching that handles searching |
1002 | included psymtabs. This returns true if a symbol is found, and | |
1003 | false otherwise. It also updates the 'searched_flag' on the | |
9439a077 TT |
1004 | various psymtabs that it searches. */ |
1005 | ||
14bc53a8 PA |
1006 | static bool |
1007 | recursively_search_psymtabs | |
d2f7dcb2 JB |
1008 | (struct partial_symtab *ps, |
1009 | struct objfile *objfile, | |
03a8ea51 | 1010 | block_search_flags search_flags, |
3bfa51a7 TT |
1011 | domain_enum domain, |
1012 | enum search_domain search, | |
b5ec771e | 1013 | const lookup_name_info &lookup_name, |
14bc53a8 | 1014 | gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher) |
9439a077 | 1015 | { |
9439a077 | 1016 | int keep_going = 1; |
f486487f | 1017 | enum psymtab_search_status result = PST_SEARCHED_AND_NOT_FOUND; |
9439a077 TT |
1018 | int i; |
1019 | ||
1020 | if (ps->searched_flag != PST_NOT_SEARCHED) | |
1021 | return ps->searched_flag == PST_SEARCHED_AND_FOUND; | |
1022 | ||
1023 | /* Recurse into shared psymtabs first, because they may have already | |
1024 | been searched, and this could save some time. */ | |
1025 | for (i = 0; i < ps->number_of_dependencies; ++i) | |
1026 | { | |
1027 | int r; | |
1028 | ||
1029 | /* Skip non-shared dependencies, these are handled elsewhere. */ | |
1030 | if (ps->dependencies[i]->user == NULL) | |
1031 | continue; | |
1032 | ||
1033 | r = recursively_search_psymtabs (ps->dependencies[i], | |
3bfa51a7 | 1034 | objfile, search_flags, domain, search, |
03a8ea51 | 1035 | lookup_name, sym_matcher); |
9439a077 TT |
1036 | if (r != 0) |
1037 | { | |
1038 | ps->searched_flag = PST_SEARCHED_AND_FOUND; | |
14bc53a8 | 1039 | return true; |
9439a077 TT |
1040 | } |
1041 | } | |
1042 | ||
932539d7 TT |
1043 | partial_symbol **gbound = (ps->global_psymbols.data () |
1044 | + ps->global_psymbols.size ()); | |
1045 | partial_symbol **sbound = (ps->static_psymbols.data () | |
1046 | + ps->static_psymbols.size ()); | |
af5bf4ad | 1047 | partial_symbol **bound = gbound; |
9439a077 TT |
1048 | |
1049 | /* Go through all of the symbols stored in a partial | |
1050 | symtab in one loop. */ | |
932539d7 | 1051 | partial_symbol **psym = ps->global_psymbols.data (); |
03a8ea51 TT |
1052 | |
1053 | if ((search_flags & SEARCH_GLOBAL_BLOCK) == 0) | |
1054 | { | |
1055 | if (ps->static_psymbols.empty ()) | |
1056 | keep_going = 0; | |
1057 | else | |
1058 | { | |
1059 | psym = ps->static_psymbols.data (); | |
1060 | bound = sbound; | |
1061 | } | |
1062 | } | |
1063 | ||
9439a077 TT |
1064 | while (keep_going) |
1065 | { | |
1066 | if (psym >= bound) | |
1067 | { | |
03a8ea51 TT |
1068 | if (bound == gbound && !ps->static_psymbols.empty () |
1069 | && (search_flags & SEARCH_STATIC_BLOCK) != 0) | |
9439a077 | 1070 | { |
932539d7 | 1071 | psym = ps->static_psymbols.data (); |
9439a077 TT |
1072 | bound = sbound; |
1073 | } | |
1074 | else | |
1075 | keep_going = 0; | |
1076 | continue; | |
1077 | } | |
1078 | else | |
1079 | { | |
1080 | QUIT; | |
1081 | ||
3bfa51a7 TT |
1082 | if ((domain == UNDEF_DOMAIN |
1083 | || symbol_matches_domain ((*psym)->ginfo.language (), | |
1084 | (*psym)->domain, domain)) | |
1085 | && (search == ALL_DOMAIN | |
1086 | || (search == MODULES_DOMAIN | |
1087 | && (*psym)->domain == MODULE_DOMAIN) | |
1088 | || (search == VARIABLES_DOMAIN | |
1089 | && (*psym)->aclass != LOC_TYPEDEF | |
1090 | && (*psym)->aclass != LOC_BLOCK) | |
1091 | || (search == FUNCTIONS_DOMAIN | |
1092 | && (*psym)->aclass == LOC_BLOCK) | |
1093 | || (search == TYPES_DOMAIN | |
1094 | && (*psym)->aclass == LOC_TYPEDEF)) | |
b5ec771e | 1095 | && psymbol_name_matches (*psym, lookup_name) |
af97b416 | 1096 | && (sym_matcher == NULL |
c9d95fa3 | 1097 | || sym_matcher ((*psym)->ginfo.search_name ()))) |
9439a077 TT |
1098 | { |
1099 | /* Found a match, so notify our caller. */ | |
1100 | result = PST_SEARCHED_AND_FOUND; | |
1101 | keep_going = 0; | |
1102 | } | |
1103 | } | |
1104 | psym++; | |
1105 | } | |
1106 | ||
1107 | ps->searched_flag = result; | |
1108 | return result == PST_SEARCHED_AND_FOUND; | |
1109 | } | |
1110 | ||
95cf5869 DE |
1111 | /* Psymtab version of expand_symtabs_matching. See its definition in |
1112 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 1113 | |
df35e626 | 1114 | bool |
39298a5d | 1115 | psymbol_functions::expand_symtabs_matching |
f8eba3c6 | 1116 | (struct objfile *objfile, |
14bc53a8 | 1117 | gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher, |
c1a66c06 | 1118 | const lookup_name_info *lookup_name, |
14bc53a8 PA |
1119 | gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher, |
1120 | gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify, | |
03a8ea51 | 1121 | block_search_flags search_flags, |
3bfa51a7 TT |
1122 | domain_enum domain, |
1123 | enum search_domain search) | |
ccefe4c4 | 1124 | { |
9439a077 | 1125 | /* Clear the search flags. */ |
d1eef86d | 1126 | for (partial_symtab *ps : require_partial_symbols (objfile)) |
b22a7c6a | 1127 | ps->searched_flag = PST_NOT_SEARCHED; |
ccefe4c4 | 1128 | |
e2cd5ca4 TT |
1129 | gdb::optional<lookup_name_info> psym_lookup_name; |
1130 | if (lookup_name != nullptr) | |
1131 | psym_lookup_name = lookup_name->make_ignore_params (); | |
1132 | ||
17d66340 | 1133 | for (partial_symtab *ps : m_partial_symtabs->range ()) |
9439a077 | 1134 | { |
30b3dd9d DE |
1135 | QUIT; |
1136 | ||
5717c425 | 1137 | if (ps->readin_p (objfile)) |
ccefe4c4 TT |
1138 | continue; |
1139 | ||
b4c41fc7 DE |
1140 | if (file_matcher) |
1141 | { | |
14bc53a8 | 1142 | bool match; |
680d1742 | 1143 | |
b4c41fc7 DE |
1144 | if (ps->anonymous) |
1145 | continue; | |
fbd9ab74 | 1146 | |
14bc53a8 | 1147 | match = file_matcher (ps->filename, false); |
680d1742 DE |
1148 | if (!match) |
1149 | { | |
1150 | /* Before we invoke realpath, which can get expensive when many | |
1151 | files are involved, do a quick comparison of the basenames. */ | |
1152 | if (basenames_may_differ | |
14bc53a8 PA |
1153 | || file_matcher (lbasename (ps->filename), true)) |
1154 | match = file_matcher (psymtab_to_fullname (ps), false); | |
680d1742 DE |
1155 | } |
1156 | if (!match) | |
b4c41fc7 DE |
1157 | continue; |
1158 | } | |
ccefe4c4 | 1159 | |
c1a66c06 | 1160 | if ((symbol_matcher == NULL && lookup_name == NULL) |
3bfa51a7 TT |
1161 | || recursively_search_psymtabs (ps, objfile, search_flags, |
1162 | domain, search, | |
e2cd5ca4 | 1163 | *psym_lookup_name, |
c1a66c06 | 1164 | symbol_matcher)) |
276d885b GB |
1165 | { |
1166 | struct compunit_symtab *symtab = | |
1167 | psymtab_to_symtab (objfile, ps); | |
1168 | ||
1169 | if (expansion_notify != NULL) | |
df35e626 TT |
1170 | if (!expansion_notify (symtab)) |
1171 | return false; | |
276d885b | 1172 | } |
ccefe4c4 | 1173 | } |
df35e626 TT |
1174 | |
1175 | return true; | |
ccefe4c4 TT |
1176 | } |
1177 | ||
95cf5869 DE |
1178 | /* Psymtab version of has_symbols. See its definition in |
1179 | the definition of quick_symbol_functions in symfile.h. */ | |
83827540 | 1180 | |
39298a5d TT |
1181 | bool |
1182 | psymbol_functions::has_symbols (struct objfile *objfile) | |
ccefe4c4 | 1183 | { |
17d66340 | 1184 | return m_partial_symtabs->psymtabs != NULL; |
ccefe4c4 TT |
1185 | } |
1186 | ||
71a3c369 | 1187 | /* Helper function for psym_find_compunit_symtab_by_address that fills |
75336a5a | 1188 | in m_psymbol_map for a given range of psymbols. */ |
71a3c369 | 1189 | |
75336a5a TT |
1190 | void |
1191 | psymbol_functions::fill_psymbol_map | |
1192 | (struct objfile *objfile, | |
1193 | struct partial_symtab *psymtab, | |
1194 | std::set<CORE_ADDR> *seen_addrs, | |
1195 | const std::vector<partial_symbol *> &symbols) | |
71a3c369 | 1196 | { |
932539d7 | 1197 | for (partial_symbol *psym : symbols) |
71a3c369 | 1198 | { |
8a6d4234 | 1199 | if (psym->aclass == LOC_STATIC) |
71a3c369 | 1200 | { |
02e9e7f7 | 1201 | CORE_ADDR addr = psym->address (objfile); |
71a3c369 TT |
1202 | if (seen_addrs->find (addr) == seen_addrs->end ()) |
1203 | { | |
1204 | seen_addrs->insert (addr); | |
75336a5a | 1205 | m_psymbol_map.emplace_back (addr, psymtab); |
71a3c369 TT |
1206 | } |
1207 | } | |
1208 | } | |
1209 | } | |
1210 | ||
1211 | /* See find_compunit_symtab_by_address in quick_symbol_functions, in | |
1212 | symfile.h. */ | |
1213 | ||
39298a5d TT |
1214 | compunit_symtab * |
1215 | psymbol_functions::find_compunit_symtab_by_address (struct objfile *objfile, | |
1216 | CORE_ADDR address) | |
71a3c369 | 1217 | { |
75336a5a | 1218 | if (m_psymbol_map.empty ()) |
71a3c369 | 1219 | { |
71a3c369 TT |
1220 | std::set<CORE_ADDR> seen_addrs; |
1221 | ||
d1eef86d | 1222 | for (partial_symtab *pst : require_partial_symbols (objfile)) |
b22a7c6a | 1223 | { |
75336a5a TT |
1224 | fill_psymbol_map (objfile, pst, |
1225 | &seen_addrs, | |
1226 | pst->global_psymbols); | |
1227 | fill_psymbol_map (objfile, pst, | |
1228 | &seen_addrs, | |
1229 | pst->static_psymbols); | |
b22a7c6a | 1230 | } |
71a3c369 | 1231 | |
75336a5a | 1232 | m_psymbol_map.shrink_to_fit (); |
71a3c369 | 1233 | |
75336a5a | 1234 | std::sort (m_psymbol_map.begin (), m_psymbol_map.end (), |
71a3c369 TT |
1235 | [] (const std::pair<CORE_ADDR, partial_symtab *> &a, |
1236 | const std::pair<CORE_ADDR, partial_symtab *> &b) | |
1237 | { | |
1238 | return a.first < b.first; | |
1239 | }); | |
1240 | } | |
1241 | ||
1242 | auto iter = std::lower_bound | |
75336a5a | 1243 | (m_psymbol_map.begin (), m_psymbol_map.end (), address, |
71a3c369 TT |
1244 | [] (const std::pair<CORE_ADDR, partial_symtab *> &a, |
1245 | CORE_ADDR b) | |
1246 | { | |
1247 | return a.first < b; | |
1248 | }); | |
1249 | ||
75336a5a | 1250 | if (iter == m_psymbol_map.end () || iter->first != address) |
71a3c369 TT |
1251 | return NULL; |
1252 | ||
1253 | return psymtab_to_symtab (objfile, iter->second); | |
1254 | } | |
1255 | ||
ccefe4c4 TT |
1256 | \f |
1257 | ||
c3693a1d TT |
1258 | /* Partially fill a partial symtab. It will be completely filled at |
1259 | the end of the symbol list. */ | |
ccefe4c4 | 1260 | |
c3693a1d | 1261 | partial_symtab::partial_symtab (const char *filename, |
7b249e47 | 1262 | psymtab_storage *partial_symtabs, |
0072c873 | 1263 | objfile_per_bfd_storage *objfile_per_bfd, |
c3693a1d | 1264 | CORE_ADDR textlow) |
0072c873 | 1265 | : partial_symtab (filename, partial_symtabs, objfile_per_bfd) |
ccefe4c4 | 1266 | { |
c3693a1d TT |
1267 | set_text_low (textlow); |
1268 | set_text_high (raw_text_low ()); /* default */ | |
ccefe4c4 TT |
1269 | } |
1270 | ||
8763cede DE |
1271 | /* Perform "finishing up" operations of a partial symtab. */ |
1272 | ||
1273 | void | |
ae7754b2 | 1274 | partial_symtab::end () |
8763cede | 1275 | { |
ae7754b2 TT |
1276 | global_psymbols.shrink_to_fit (); |
1277 | static_psymbols.shrink_to_fit (); | |
8763cede | 1278 | |
ae7754b2 TT |
1279 | /* Sort the global list; don't sort the static list. */ |
1280 | std::sort (global_psymbols.begin (), | |
1281 | global_psymbols.end (), | |
1282 | [] (partial_symbol *s1, partial_symbol *s2) | |
1283 | { | |
1284 | return strcmp_iw_ordered (s1->ginfo.search_name (), | |
1285 | s2->ginfo.search_name ()) < 0; | |
1286 | }); | |
8763cede DE |
1287 | } |
1288 | ||
89806626 | 1289 | /* See psymtab.h. */ |
cbd70537 | 1290 | |
89806626 SM |
1291 | unsigned long |
1292 | psymbol_bcache::hash (const void *addr, int length) | |
cbd70537 SW |
1293 | { |
1294 | unsigned long h = 0; | |
1295 | struct partial_symbol *psymbol = (struct partial_symbol *) addr; | |
c1b5c1eb | 1296 | unsigned int lang = psymbol->ginfo.language (); |
8a6d4234 TT |
1297 | unsigned int domain = psymbol->domain; |
1298 | unsigned int theclass = psymbol->aclass; | |
cbd70537 | 1299 | |
4cbd39b2 CB |
1300 | h = fast_hash (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h); |
1301 | h = fast_hash (&lang, sizeof (unsigned int), h); | |
1302 | h = fast_hash (&domain, sizeof (unsigned int), h); | |
1303 | h = fast_hash (&theclass, sizeof (unsigned int), h); | |
4d4eaa30 | 1304 | /* Note that psymbol names are interned via compute_and_set_names, so |
e793c052 | 1305 | there's no need to hash the contents of the name here. */ |
4d4eaa30 | 1306 | h = fast_hash (&psymbol->ginfo.m_name, sizeof (psymbol->ginfo.m_name), h); |
cbd70537 SW |
1307 | |
1308 | return h; | |
1309 | } | |
1310 | ||
89806626 | 1311 | /* See psymtab.h. */ |
cbd70537 | 1312 | |
89806626 SM |
1313 | int |
1314 | psymbol_bcache::compare (const void *addr1, const void *addr2, int length) | |
cbd70537 SW |
1315 | { |
1316 | struct partial_symbol *sym1 = (struct partial_symbol *) addr1; | |
1317 | struct partial_symbol *sym2 = (struct partial_symbol *) addr2; | |
1318 | ||
af97b416 | 1319 | return (memcmp (&sym1->ginfo.value, &sym2->ginfo.value, |
dda83cd7 | 1320 | sizeof (sym1->ginfo.value)) == 0 |
c1b5c1eb | 1321 | && sym1->ginfo.language () == sym2->ginfo.language () |
dda83cd7 SM |
1322 | && sym1->domain == sym2->domain |
1323 | && sym1->aclass == sym2->aclass | |
e793c052 | 1324 | /* Note that psymbol names are interned via |
4d4eaa30 | 1325 | compute_and_set_names, so there's no need to compare the |
e793c052 | 1326 | contents of the name here. */ |
dda83cd7 | 1327 | && sym1->ginfo.linkage_name () == sym2->ginfo.linkage_name ()); |
cbd70537 SW |
1328 | } |
1329 | ||
703a86c2 | 1330 | /* See psympriv.h. */ |
ccefe4c4 | 1331 | |
7dc25483 | 1332 | void |
932539d7 TT |
1333 | partial_symtab::add_psymbol (const partial_symbol &psymbol, |
1334 | psymbol_placement where, | |
7b249e47 | 1335 | psymtab_storage *partial_symtabs, |
932539d7 | 1336 | struct objfile *objfile) |
ccefe4c4 | 1337 | { |
ef5e5b0b | 1338 | bool added; |
ccefe4c4 | 1339 | |
0df8b418 | 1340 | /* Stash the partial symbol away in the cache. */ |
7b249e47 TT |
1341 | partial_symbol *psym |
1342 | = ((struct partial_symbol *) | |
1343 | partial_symtabs->psymbol_cache.insert | |
1344 | (&psymbol, sizeof (struct partial_symbol), &added)); | |
ccefe4c4 TT |
1345 | |
1346 | /* Do not duplicate global partial symbols. */ | |
75aedd27 | 1347 | if (where == psymbol_placement::GLOBAL && !added) |
7dc25483 | 1348 | return; |
ccefe4c4 | 1349 | |
0df8b418 | 1350 | /* Save pointer to partial symbol in psymtab, growing symtab if needed. */ |
932539d7 | 1351 | std::vector<partial_symbol *> &list |
75aedd27 | 1352 | = (where == psymbol_placement::STATIC |
932539d7 TT |
1353 | ? static_psymbols |
1354 | : global_psymbols); | |
0684bb51 | 1355 | list.push_back (psym); |
ccefe4c4 TT |
1356 | } |
1357 | ||
6eee24ce | 1358 | /* See psympriv.h. */ |
ccefe4c4 | 1359 | |
2467f4f6 | 1360 | void |
932539d7 TT |
1361 | partial_symtab::add_psymbol (gdb::string_view name, bool copy_name, |
1362 | domain_enum domain, | |
1363 | enum address_class theclass, | |
1364 | short section, | |
1365 | psymbol_placement where, | |
1366 | CORE_ADDR coreaddr, | |
7b249e47 TT |
1367 | enum language language, |
1368 | psymtab_storage *partial_symtabs, | |
1369 | struct objfile *objfile) | |
2467f4f6 TT |
1370 | { |
1371 | struct partial_symbol psymbol; | |
1372 | memset (&psymbol, 0, sizeof (psymbol)); | |
1373 | ||
1374 | psymbol.set_unrelocated_address (coreaddr); | |
a52d653e | 1375 | psymbol.ginfo.set_section_index (section); |
2467f4f6 TT |
1376 | psymbol.domain = domain; |
1377 | psymbol.aclass = theclass; | |
7b249e47 | 1378 | psymbol.ginfo.set_language (language, partial_symtabs->obstack ()); |
2467f4f6 TT |
1379 | psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd); |
1380 | ||
7b249e47 | 1381 | add_psymbol (psymbol, where, partial_symtabs, objfile); |
2467f4f6 TT |
1382 | } |
1383 | ||
1384 | /* See psympriv.h. */ | |
1385 | ||
7b249e47 TT |
1386 | partial_symtab::partial_symtab (const char *filename_, |
1387 | psymtab_storage *partial_symtabs, | |
0072c873 | 1388 | objfile_per_bfd_storage *objfile_per_bfd) |
32caafd0 TT |
1389 | : searched_flag (PST_NOT_SEARCHED), |
1390 | text_low_valid (0), | |
1391 | text_high_valid (0) | |
ccefe4c4 | 1392 | { |
7b249e47 | 1393 | partial_symtabs->install_psymtab (this); |
ccefe4c4 | 1394 | |
0072c873 | 1395 | filename = objfile_per_bfd->intern (filename_); |
ccefe4c4 | 1396 | |
45cfd468 DE |
1397 | if (symtab_create_debug) |
1398 | { | |
1399 | /* Be a bit clever with debugging messages, and don't print objfile | |
1400 | every time, only when it changes. */ | |
0072c873 SM |
1401 | static std::string last_bfd_name; |
1402 | const char *this_bfd_name | |
1403 | = bfd_get_filename (objfile_per_bfd->get_bfd ()); | |
45cfd468 | 1404 | |
0072c873 | 1405 | if (last_bfd_name.empty () || last_bfd_name != this_bfd_name) |
45cfd468 | 1406 | { |
0072c873 | 1407 | last_bfd_name = this_bfd_name; |
22068491 | 1408 | fprintf_filtered (gdb_stdlog, |
0072c873 SM |
1409 | "Creating one or more psymtabs for %s ...\n", |
1410 | this_bfd_name); | |
45cfd468 | 1411 | } |
22068491 TT |
1412 | fprintf_filtered (gdb_stdlog, |
1413 | "Created psymtab %s for module %s.\n", | |
32caafd0 | 1414 | host_address_to_string (this), filename); |
45cfd468 | 1415 | } |
ccefe4c4 TT |
1416 | } |
1417 | ||
0494dbec TT |
1418 | /* See psympriv.h. */ |
1419 | ||
1420 | void | |
48993951 | 1421 | partial_symtab::expand_dependencies (struct objfile *objfile) |
0494dbec TT |
1422 | { |
1423 | for (int i = 0; i < number_of_dependencies; ++i) | |
1424 | { | |
5717c425 | 1425 | if (!dependencies[i]->readin_p (objfile) |
1eb73179 | 1426 | && dependencies[i]->user == NULL) |
0494dbec TT |
1427 | { |
1428 | /* Inform about additional files to be read in. */ | |
1429 | if (info_verbose) | |
1430 | { | |
1431 | fputs_filtered (" ", gdb_stdout); | |
1432 | wrap_here (""); | |
1433 | fputs_filtered ("and ", gdb_stdout); | |
1434 | wrap_here (""); | |
1435 | printf_filtered ("%s...", dependencies[i]->filename); | |
1436 | wrap_here (""); /* Flush output */ | |
1437 | gdb_flush (gdb_stdout); | |
1438 | } | |
1439 | dependencies[i]->expand_psymtab (objfile); | |
1440 | } | |
1441 | } | |
1442 | } | |
1443 | ||
1444 | ||
ccefe4c4 | 1445 | void |
d320c2b5 | 1446 | psymtab_storage::discard_psymtab (struct partial_symtab *pst) |
ccefe4c4 TT |
1447 | { |
1448 | struct partial_symtab **prev_pst; | |
1449 | ||
1450 | /* From dbxread.c: | |
1451 | Empty psymtabs happen as a result of header files which don't | |
1452 | have any symbols in them. There can be a lot of them. But this | |
1453 | check is wrong, in that a psymtab with N_SLINE entries but | |
1454 | nothing else is not empty, but we don't realize that. Fixing | |
1455 | that without slowing things down might be tricky. */ | |
1456 | ||
0df8b418 | 1457 | /* First, snip it out of the psymtab chain. */ |
ccefe4c4 | 1458 | |
d320c2b5 | 1459 | prev_pst = &psymtabs; |
ccefe4c4 TT |
1460 | while ((*prev_pst) != pst) |
1461 | prev_pst = &((*prev_pst)->next); | |
1462 | (*prev_pst) = pst->next; | |
6f17252b | 1463 | delete pst; |
ccefe4c4 TT |
1464 | } |
1465 | ||
ccefe4c4 TT |
1466 | \f |
1467 | ||
372405a5 DE |
1468 | /* We need to pass a couple of items to the addrmap_foreach function, |
1469 | so use a struct. */ | |
1470 | ||
1471 | struct dump_psymtab_addrmap_data | |
1472 | { | |
1473 | struct objfile *objfile; | |
1474 | struct partial_symtab *psymtab; | |
1475 | struct ui_file *outfile; | |
1476 | ||
1477 | /* Non-zero if the previously printed addrmap entry was for PSYMTAB. | |
1478 | If so, we want to print the next one as well (since the next addrmap | |
1479 | entry defines the end of the range). */ | |
1480 | int previous_matched; | |
1481 | }; | |
1482 | ||
1483 | /* Helper function for dump_psymtab_addrmap to print an addrmap entry. */ | |
1484 | ||
1485 | static int | |
1486 | dump_psymtab_addrmap_1 (void *datap, CORE_ADDR start_addr, void *obj) | |
1487 | { | |
709b5518 PA |
1488 | struct dump_psymtab_addrmap_data *data |
1489 | = (struct dump_psymtab_addrmap_data *) datap; | |
08feed99 | 1490 | struct gdbarch *gdbarch = data->objfile->arch (); |
709b5518 | 1491 | struct partial_symtab *addrmap_psymtab = (struct partial_symtab *) obj; |
372405a5 DE |
1492 | const char *psymtab_address_or_end = NULL; |
1493 | ||
1494 | QUIT; | |
1495 | ||
1496 | if (data->psymtab == NULL | |
1497 | || data->psymtab == addrmap_psymtab) | |
1498 | psymtab_address_or_end = host_address_to_string (addrmap_psymtab); | |
1499 | else if (data->previous_matched) | |
1500 | psymtab_address_or_end = "<ends here>"; | |
1501 | ||
1502 | if (data->psymtab == NULL | |
1503 | || data->psymtab == addrmap_psymtab | |
1504 | || data->previous_matched) | |
1505 | { | |
1506 | fprintf_filtered (data->outfile, " %s%s %s\n", | |
1507 | data->psymtab != NULL ? " " : "", | |
1508 | paddress (gdbarch, start_addr), | |
1509 | psymtab_address_or_end); | |
1510 | } | |
1511 | ||
1512 | data->previous_matched = (data->psymtab == NULL | |
1513 | || data->psymtab == addrmap_psymtab); | |
1514 | ||
1515 | return 0; | |
1516 | } | |
1517 | ||
1518 | /* Helper function for maintenance_print_psymbols to print the addrmap | |
1519 | of PSYMTAB. If PSYMTAB is NULL print the entire addrmap. */ | |
1520 | ||
1521 | static void | |
17d66340 TT |
1522 | dump_psymtab_addrmap (struct objfile *objfile, |
1523 | psymtab_storage *partial_symtabs, | |
1524 | struct partial_symtab *psymtab, | |
372405a5 DE |
1525 | struct ui_file *outfile) |
1526 | { | |
1527 | struct dump_psymtab_addrmap_data addrmap_dump_data; | |
1528 | ||
34c41c68 DE |
1529 | if ((psymtab == NULL |
1530 | || psymtab->psymtabs_addrmap_supported) | |
17d66340 | 1531 | && partial_symtabs->psymtabs_addrmap != NULL) |
372405a5 DE |
1532 | { |
1533 | addrmap_dump_data.objfile = objfile; | |
1534 | addrmap_dump_data.psymtab = psymtab; | |
1535 | addrmap_dump_data.outfile = outfile; | |
1536 | addrmap_dump_data.previous_matched = 0; | |
1537 | fprintf_filtered (outfile, "%sddress map:\n", | |
1538 | psymtab == NULL ? "Entire a" : " A"); | |
17d66340 | 1539 | addrmap_foreach (partial_symtabs->psymtabs_addrmap, |
d320c2b5 | 1540 | dump_psymtab_addrmap_1, &addrmap_dump_data); |
372405a5 DE |
1541 | } |
1542 | } | |
1543 | ||
dfc7bb5b | 1544 | static void |
990b9f9f | 1545 | maintenance_print_psymbols (const char *args, int from_tty) |
ccefe4c4 | 1546 | { |
34c41c68 | 1547 | struct ui_file *outfile = gdb_stdout; |
34c41c68 | 1548 | char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL; |
34c41c68 DE |
1549 | int i, outfile_idx, found; |
1550 | CORE_ADDR pc = 0; | |
1551 | struct obj_section *section = NULL; | |
ccefe4c4 TT |
1552 | |
1553 | dont_repeat (); | |
1554 | ||
773a1edc | 1555 | gdb_argv argv (args); |
ccefe4c4 | 1556 | |
99e8a4f9 | 1557 | for (i = 0; argv != NULL && argv[i] != NULL; ++i) |
ccefe4c4 | 1558 | { |
34c41c68 DE |
1559 | if (strcmp (argv[i], "-pc") == 0) |
1560 | { | |
1561 | if (argv[i + 1] == NULL) | |
1562 | error (_("Missing pc value")); | |
1563 | address_arg = argv[++i]; | |
1564 | } | |
1565 | else if (strcmp (argv[i], "-source") == 0) | |
1566 | { | |
1567 | if (argv[i + 1] == NULL) | |
1568 | error (_("Missing source file")); | |
1569 | source_arg = argv[++i]; | |
1570 | } | |
1571 | else if (strcmp (argv[i], "-objfile") == 0) | |
1572 | { | |
1573 | if (argv[i + 1] == NULL) | |
1574 | error (_("Missing objfile name")); | |
1575 | objfile_arg = argv[++i]; | |
1576 | } | |
1577 | else if (strcmp (argv[i], "--") == 0) | |
1578 | { | |
1579 | /* End of options. */ | |
1580 | ++i; | |
1581 | break; | |
1582 | } | |
1583 | else if (argv[i][0] == '-') | |
ccefe4c4 | 1584 | { |
34c41c68 DE |
1585 | /* Future proofing: Don't allow OUTFILE to begin with "-". */ |
1586 | error (_("Unknown option: %s"), argv[i]); | |
ccefe4c4 | 1587 | } |
34c41c68 DE |
1588 | else |
1589 | break; | |
ccefe4c4 | 1590 | } |
34c41c68 | 1591 | outfile_idx = i; |
ccefe4c4 | 1592 | |
34c41c68 DE |
1593 | if (address_arg != NULL && source_arg != NULL) |
1594 | error (_("Must specify at most one of -pc and -source")); | |
ccefe4c4 | 1595 | |
d7e74731 PA |
1596 | stdio_file arg_outfile; |
1597 | ||
99e8a4f9 | 1598 | if (argv != NULL && argv[outfile_idx] != NULL) |
34c41c68 | 1599 | { |
34c41c68 DE |
1600 | if (argv[outfile_idx + 1] != NULL) |
1601 | error (_("Junk at end of command")); | |
ee0c3293 TT |
1602 | gdb::unique_xmalloc_ptr<char> outfile_name |
1603 | (tilde_expand (argv[outfile_idx])); | |
1604 | if (!arg_outfile.open (outfile_name.get (), FOPEN_WT)) | |
1605 | perror_with_name (outfile_name.get ()); | |
d7e74731 | 1606 | outfile = &arg_outfile; |
34c41c68 | 1607 | } |
ccefe4c4 | 1608 | |
34c41c68 DE |
1609 | if (address_arg != NULL) |
1610 | { | |
1611 | pc = parse_and_eval_address (address_arg); | |
1612 | /* If we fail to find a section, that's ok, try the lookup anyway. */ | |
1613 | section = find_pc_section (pc); | |
1614 | } | |
372405a5 | 1615 | |
34c41c68 | 1616 | found = 0; |
2030c079 | 1617 | for (objfile *objfile : current_program_space->objfiles ()) |
27618ce4 | 1618 | { |
34c41c68 DE |
1619 | int printed_objfile_header = 0; |
1620 | int print_for_objfile = 1; | |
1621 | ||
27618ce4 | 1622 | QUIT; |
34c41c68 DE |
1623 | if (objfile_arg != NULL) |
1624 | print_for_objfile | |
1625 | = compare_filenames_for_search (objfile_name (objfile), | |
1626 | objfile_arg); | |
1627 | if (!print_for_objfile) | |
1628 | continue; | |
1629 | ||
e1114590 | 1630 | for (const auto &iter : objfile->qf) |
34c41c68 | 1631 | { |
e1114590 TT |
1632 | psymbol_functions *psf |
1633 | = dynamic_cast<psymbol_functions *> (iter.get ()); | |
1634 | if (psf == nullptr) | |
1635 | continue; | |
34c41c68 | 1636 | |
e1114590 TT |
1637 | psymtab_storage *partial_symtabs |
1638 | = psf->get_partial_symtabs ().get (); | |
1639 | ||
1640 | if (address_arg != NULL) | |
34c41c68 | 1641 | { |
e1114590 | 1642 | struct bound_minimal_symbol msymbol = { NULL, NULL }; |
34c41c68 | 1643 | |
e1114590 TT |
1644 | /* We don't assume each pc has a unique objfile (this is for |
1645 | debugging). */ | |
1646 | struct partial_symtab *ps | |
1647 | = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol); | |
1648 | if (ps != NULL) | |
34c41c68 DE |
1649 | { |
1650 | if (!printed_objfile_header) | |
1651 | { | |
d7e74731 PA |
1652 | outfile->printf ("\nPartial symtabs for objfile %s\n", |
1653 | objfile_name (objfile)); | |
34c41c68 DE |
1654 | printed_objfile_header = 1; |
1655 | } | |
1656 | dump_psymtab (objfile, ps, outfile); | |
e1114590 TT |
1657 | dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile); |
1658 | found = 1; | |
1659 | } | |
1660 | } | |
1661 | else | |
1662 | { | |
1663 | for (partial_symtab *ps : psf->require_partial_symbols (objfile)) | |
1664 | { | |
1665 | int print_for_source = 0; | |
1666 | ||
1667 | QUIT; | |
1668 | if (source_arg != NULL) | |
1669 | { | |
1670 | print_for_source | |
1671 | = compare_filenames_for_search (ps->filename, source_arg); | |
1672 | found = 1; | |
1673 | } | |
1674 | if (source_arg == NULL | |
1675 | || print_for_source) | |
1676 | { | |
1677 | if (!printed_objfile_header) | |
1678 | { | |
1679 | outfile->printf ("\nPartial symtabs for objfile %s\n", | |
1680 | objfile_name (objfile)); | |
1681 | printed_objfile_header = 1; | |
1682 | } | |
1683 | dump_psymtab (objfile, ps, outfile); | |
1684 | dump_psymtab_addrmap (objfile, partial_symtabs, ps, | |
1685 | outfile); | |
1686 | } | |
34c41c68 DE |
1687 | } |
1688 | } | |
34c41c68 | 1689 | |
e1114590 | 1690 | /* If we're printing all the objfile's symbols dump the full addrmap. */ |
34c41c68 | 1691 | |
e1114590 TT |
1692 | if (address_arg == NULL |
1693 | && source_arg == NULL | |
1694 | && partial_symtabs->psymtabs_addrmap != NULL) | |
1695 | { | |
1696 | outfile->puts ("\n"); | |
1697 | dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile); | |
1698 | } | |
372405a5 | 1699 | } |
27618ce4 | 1700 | } |
372405a5 | 1701 | |
34c41c68 DE |
1702 | if (!found) |
1703 | { | |
1704 | if (address_arg != NULL) | |
1705 | error (_("No partial symtab for address: %s"), address_arg); | |
1706 | if (source_arg != NULL) | |
1707 | error (_("No partial symtab for source file: %s"), source_arg); | |
1708 | } | |
ccefe4c4 TT |
1709 | } |
1710 | ||
1711 | /* List all the partial symbol tables whose names match REGEXP (optional). */ | |
95cf5869 | 1712 | |
dfc7bb5b | 1713 | static void |
990b9f9f | 1714 | maintenance_info_psymtabs (const char *regexp, int from_tty) |
ccefe4c4 | 1715 | { |
ccefe4c4 TT |
1716 | if (regexp) |
1717 | re_comp (regexp); | |
1718 | ||
94c93c35 | 1719 | for (struct program_space *pspace : program_spaces) |
2030c079 | 1720 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 1721 | { |
08feed99 | 1722 | struct gdbarch *gdbarch = objfile->arch (); |
ccefe4c4 | 1723 | |
99d89cde TT |
1724 | /* We don't want to print anything for this objfile until we |
1725 | actually find a symtab whose name matches. */ | |
1726 | int printed_objfile_start = 0; | |
ccefe4c4 | 1727 | |
e1114590 | 1728 | for (const auto &iter : objfile->qf) |
99d89cde | 1729 | { |
e1114590 TT |
1730 | psymbol_functions *psf |
1731 | = dynamic_cast<psymbol_functions *> (iter.get ()); | |
1732 | if (psf == nullptr) | |
1733 | continue; | |
1734 | for (partial_symtab *psymtab : psf->require_partial_symbols (objfile)) | |
99d89cde | 1735 | { |
e1114590 | 1736 | QUIT; |
99d89cde | 1737 | |
e1114590 TT |
1738 | if (! regexp |
1739 | || re_exec (psymtab->filename)) | |
99d89cde | 1740 | { |
e1114590 TT |
1741 | if (! printed_objfile_start) |
1742 | { | |
1743 | printf_filtered ("{ objfile %s ", objfile_name (objfile)); | |
1744 | wrap_here (" "); | |
1745 | printf_filtered ("((struct objfile *) %s)\n", | |
1746 | host_address_to_string (objfile)); | |
1747 | printed_objfile_start = 1; | |
1748 | } | |
99d89cde | 1749 | |
e1114590 TT |
1750 | printf_filtered (" { psymtab %s ", psymtab->filename); |
1751 | wrap_here (" "); | |
1752 | printf_filtered ("((struct partial_symtab *) %s)\n", | |
1753 | host_address_to_string (psymtab)); | |
1754 | ||
1755 | printf_filtered (" readin %s\n", | |
1756 | psymtab->readin_p (objfile) ? "yes" : "no"); | |
1757 | printf_filtered (" fullname %s\n", | |
1758 | psymtab->fullname | |
1759 | ? psymtab->fullname : "(null)"); | |
1760 | printf_filtered (" text addresses "); | |
1761 | fputs_filtered (paddress (gdbarch, | |
1762 | psymtab->text_low (objfile)), | |
1763 | gdb_stdout); | |
1764 | printf_filtered (" -- "); | |
1765 | fputs_filtered (paddress (gdbarch, | |
1766 | psymtab->text_high (objfile)), | |
1767 | gdb_stdout); | |
1768 | printf_filtered ("\n"); | |
1769 | printf_filtered (" psymtabs_addrmap_supported %s\n", | |
1770 | (psymtab->psymtabs_addrmap_supported | |
1771 | ? "yes" : "no")); | |
1772 | printf_filtered (" globals "); | |
1773 | if (!psymtab->global_psymbols.empty ()) | |
1774 | printf_filtered | |
1775 | ("(* (struct partial_symbol **) %s @ %d)\n", | |
1776 | host_address_to_string (psymtab->global_psymbols.data ()), | |
1777 | (int) psymtab->global_psymbols.size ()); | |
1778 | else | |
1779 | printf_filtered ("(none)\n"); | |
1780 | printf_filtered (" statics "); | |
1781 | if (!psymtab->static_psymbols.empty ()) | |
1782 | printf_filtered | |
1783 | ("(* (struct partial_symbol **) %s @ %d)\n", | |
1784 | host_address_to_string (psymtab->static_psymbols.data ()), | |
1785 | (int) psymtab->static_psymbols.size ()); | |
1786 | else | |
1787 | printf_filtered ("(none)\n"); | |
1788 | if (psymtab->user) | |
1789 | printf_filtered (" user %s " | |
1790 | "((struct partial_symtab *) %s)\n", | |
1791 | psymtab->user->filename, | |
1792 | host_address_to_string (psymtab->user)); | |
1793 | printf_filtered (" dependencies "); | |
1794 | if (psymtab->number_of_dependencies) | |
99d89cde | 1795 | { |
e1114590 TT |
1796 | int i; |
1797 | ||
1798 | printf_filtered ("{\n"); | |
1799 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
1800 | { | |
1801 | struct partial_symtab *dep = psymtab->dependencies[i]; | |
1802 | ||
1803 | /* Note the string concatenation there --- no | |
1804 | comma. */ | |
1805 | printf_filtered (" psymtab %s " | |
1806 | "((struct partial_symtab *) %s)\n", | |
1807 | dep->filename, | |
1808 | host_address_to_string (dep)); | |
1809 | } | |
1810 | printf_filtered (" }\n"); | |
99d89cde | 1811 | } |
e1114590 TT |
1812 | else |
1813 | printf_filtered ("(none)\n"); | |
1814 | printf_filtered (" }\n"); | |
99d89cde | 1815 | } |
99d89cde TT |
1816 | } |
1817 | } | |
ccefe4c4 | 1818 | |
99d89cde TT |
1819 | if (printed_objfile_start) |
1820 | printf_filtered ("}\n"); | |
1821 | } | |
ccefe4c4 TT |
1822 | } |
1823 | ||
7d0c9981 | 1824 | /* Check consistency of currently expanded psymtabs vs symtabs. */ |
ccefe4c4 | 1825 | |
dfc7bb5b | 1826 | static void |
990b9f9f | 1827 | maintenance_check_psymtabs (const char *ignore, int from_tty) |
ccefe4c4 TT |
1828 | { |
1829 | struct symbol *sym; | |
43f3e411 | 1830 | struct compunit_symtab *cust = NULL; |
346d1dfe | 1831 | const struct blockvector *bv; |
582942f4 | 1832 | const struct block *b; |
ccefe4c4 | 1833 | |
2030c079 | 1834 | for (objfile *objfile : current_program_space->objfiles ()) |
3aa31ce7 | 1835 | { |
e1114590 | 1836 | for (const auto &iter : objfile->qf) |
3aa31ce7 | 1837 | { |
e1114590 TT |
1838 | psymbol_functions *psf |
1839 | = dynamic_cast<psymbol_functions *> (iter.get ()); | |
1840 | if (psf == nullptr) | |
1841 | continue; | |
aed57c53 | 1842 | |
e1114590 | 1843 | for (partial_symtab *ps : psf->require_partial_symbols (objfile)) |
3aa31ce7 | 1844 | { |
e1114590 | 1845 | struct gdbarch *gdbarch = objfile->arch (); |
5707e24b | 1846 | |
e1114590 TT |
1847 | /* We don't call psymtab_to_symtab here because that may cause symtab |
1848 | expansion. When debugging a problem it helps if checkers leave | |
1849 | things unchanged. */ | |
1850 | cust = ps->get_compunit_symtab (objfile); | |
3aa31ce7 | 1851 | |
e1114590 TT |
1852 | /* First do some checks that don't require the associated symtab. */ |
1853 | if (ps->text_high (objfile) < ps->text_low (objfile)) | |
3aa31ce7 | 1854 | { |
e1114590 | 1855 | printf_filtered ("Psymtab "); |
3aa31ce7 | 1856 | puts_filtered (ps->filename); |
e1114590 TT |
1857 | printf_filtered (" covers bad range "); |
1858 | fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), | |
1859 | gdb_stdout); | |
1860 | printf_filtered (" - "); | |
1861 | fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), | |
1862 | gdb_stdout); | |
1863 | printf_filtered ("\n"); | |
1864 | continue; | |
3aa31ce7 | 1865 | } |
e1114590 TT |
1866 | |
1867 | /* Now do checks requiring the associated symtab. */ | |
1868 | if (cust == NULL) | |
1869 | continue; | |
1870 | bv = COMPUNIT_BLOCKVECTOR (cust); | |
1871 | b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); | |
1872 | for (partial_symbol *psym : ps->static_psymbols) | |
1873 | { | |
1874 | /* Skip symbols for inlined functions without address. These may | |
1875 | or may not have a match in the full symtab. */ | |
1876 | if (psym->aclass == LOC_BLOCK | |
1877 | && psym->ginfo.value.address == 0) | |
1878 | continue; | |
1879 | ||
1880 | sym = block_lookup_symbol (b, psym->ginfo.search_name (), | |
1881 | symbol_name_match_type::SEARCH_NAME, | |
1882 | psym->domain); | |
1883 | if (!sym) | |
1884 | { | |
1885 | printf_filtered ("Static symbol `"); | |
1886 | puts_filtered (psym->ginfo.linkage_name ()); | |
1887 | printf_filtered ("' only found in "); | |
1888 | puts_filtered (ps->filename); | |
1889 | printf_filtered (" psymtab\n"); | |
1890 | } | |
1891 | } | |
1892 | b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); | |
1893 | for (partial_symbol *psym : ps->global_psymbols) | |
1894 | { | |
1895 | sym = block_lookup_symbol (b, psym->ginfo.search_name (), | |
1896 | symbol_name_match_type::SEARCH_NAME, | |
1897 | psym->domain); | |
1898 | if (!sym) | |
1899 | { | |
1900 | printf_filtered ("Global symbol `"); | |
1901 | puts_filtered (psym->ginfo.linkage_name ()); | |
1902 | printf_filtered ("' only found in "); | |
1903 | puts_filtered (ps->filename); | |
1904 | printf_filtered (" psymtab\n"); | |
1905 | } | |
1906 | } | |
1907 | if (ps->raw_text_high () != 0 | |
1908 | && (ps->text_low (objfile) < BLOCK_START (b) | |
1909 | || ps->text_high (objfile) > BLOCK_END (b))) | |
3aa31ce7 | 1910 | { |
e1114590 | 1911 | printf_filtered ("Psymtab "); |
3aa31ce7 | 1912 | puts_filtered (ps->filename); |
e1114590 TT |
1913 | printf_filtered (" covers "); |
1914 | fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), | |
1915 | gdb_stdout); | |
1916 | printf_filtered (" - "); | |
1917 | fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), | |
1918 | gdb_stdout); | |
1919 | printf_filtered (" but symtab covers only "); | |
1920 | fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); | |
1921 | printf_filtered (" - "); | |
1922 | fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); | |
1923 | printf_filtered ("\n"); | |
3aa31ce7 TT |
1924 | } |
1925 | } | |
3aa31ce7 TT |
1926 | } |
1927 | } | |
ccefe4c4 TT |
1928 | } |
1929 | ||
6c265988 | 1930 | void _initialize_psymtab (); |
dfc7bb5b | 1931 | void |
6c265988 | 1932 | _initialize_psymtab () |
dfc7bb5b YQ |
1933 | { |
1934 | add_cmd ("psymbols", class_maintenance, maintenance_print_psymbols, _("\ | |
1935 | Print dump of current partial symbol definitions.\n\ | |
48c5e7e2 TT |
1936 | Usage: mt print psymbols [-objfile OBJFILE] [-pc ADDRESS] [--] [OUTFILE]\n\ |
1937 | mt print psymbols [-objfile OBJFILE] [-source SOURCE] [--] [OUTFILE]\n\ | |
34c41c68 DE |
1938 | Entries in the partial symbol table are dumped to file OUTFILE,\n\ |
1939 | or the terminal if OUTFILE is unspecified.\n\ | |
1940 | If ADDRESS is provided, dump only the file for that address.\n\ | |
1941 | If SOURCE is provided, dump only that file's symbols.\n\ | |
1942 | If OBJFILE is provided, dump only that file's minimal symbols."), | |
dfc7bb5b YQ |
1943 | &maintenanceprintlist); |
1944 | ||
1945 | add_cmd ("psymtabs", class_maintenance, maintenance_info_psymtabs, _("\ | |
1946 | List the partial symbol tables for all object files.\n\ | |
1947 | This does not include information about individual partial symbols,\n\ | |
1948 | just the symbol table structures themselves."), | |
1949 | &maintenanceinfolist); | |
1950 | ||
7d0c9981 DE |
1951 | add_cmd ("check-psymtabs", class_maintenance, maintenance_check_psymtabs, |
1952 | _("\ | |
1953 | Check consistency of currently expanded psymtabs versus symtabs."), | |
dfc7bb5b YQ |
1954 | &maintenancelist); |
1955 | } |