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