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