1 /* Partial symbol tables.
3 Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
24 #include "gdb_assert.h"
26 #include "filenames.h"
33 #include "readline/readline.h"
34 #include "gdb_regex.h"
35 #include "dictionary.h"
38 #define DEV_TTY "/dev/tty"
43 struct bcache *bcache;
46 /* A fast way to get from a psymtab to its symtab (after the first time). */
47 #define PSYMTAB_TO_SYMTAB(pst) \
48 ((pst) -> symtab != NULL ? (pst) -> symtab : psymtab_to_symtab (pst))
50 static struct partial_symbol *match_partial_symbol (struct partial_symtab *,
52 const char *, domain_enum,
53 symbol_compare_ftype *,
54 symbol_compare_ftype *);
56 static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
60 static char *psymtab_to_fullname (struct partial_symtab *ps);
62 static struct partial_symbol *find_pc_sect_psymbol (struct partial_symtab *,
64 struct obj_section *);
66 static struct partial_symbol *fixup_psymbol_section (struct partial_symbol
68 struct objfile *objfile);
70 static struct symtab *psymtab_to_symtab (struct partial_symtab *pst);
72 /* Lookup the partial symbol table of a source file named NAME.
73 *If* there is no '/' in the name, a match after a '/'
74 in the psymtab filename will also work. */
76 static struct partial_symtab *
77 lookup_partial_symtab (struct objfile *objfile, const char *name,
78 const char *full_path, const char *real_path)
80 struct partial_symtab *pst;
82 ALL_OBJFILE_PSYMTABS (objfile, pst)
84 if (FILENAME_CMP (name, pst->filename) == 0)
89 /* If the user gave us an absolute path, try to find the file in
90 this symtab and use its absolute path. */
91 if (full_path != NULL)
93 psymtab_to_fullname (pst);
94 if (pst->fullname != NULL
95 && FILENAME_CMP (full_path, pst->fullname) == 0)
101 if (real_path != NULL)
104 psymtab_to_fullname (pst);
105 if (pst->fullname != NULL)
107 rp = gdb_realpath (pst->fullname);
108 make_cleanup (xfree, rp);
110 if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
117 /* Now, search for a matching tail (only if name doesn't have any dirs). */
119 if (lbasename (name) == name)
120 ALL_OBJFILE_PSYMTABS (objfile, pst)
122 if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
130 lookup_symtab_via_partial_symtab (struct objfile *objfile, const char *name,
131 const char *full_path, const char *real_path,
132 struct symtab **result)
134 struct partial_symtab *ps;
136 ps = lookup_partial_symtab (objfile, name, full_path, real_path);
141 error (_("Internal: readin %s pst for `%s' found when no symtab found."),
144 *result = PSYMTAB_TO_SYMTAB (ps);
148 /* Find which partial symtab contains PC and SECTION starting at psymtab PST.
149 We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */
151 static struct partial_symtab *
152 find_pc_sect_psymtab_closer (CORE_ADDR pc, struct obj_section *section,
153 struct partial_symtab *pst,
154 struct minimal_symbol *msymbol)
156 struct objfile *objfile = pst->objfile;
157 struct partial_symtab *tpst;
158 struct partial_symtab *best_pst = pst;
159 CORE_ADDR best_addr = pst->textlow;
161 /* An objfile that has its functions reordered might have
162 many partial symbol tables containing the PC, but
163 we want the partial symbol table that contains the
164 function containing the PC. */
165 if (!(objfile->flags & OBJF_REORDERED) &&
166 section == 0) /* Can't validate section this way. */
172 /* The code range of partial symtabs sometimes overlap, so, in
173 the loop below, we need to check all partial symtabs and
174 find the one that fits better for the given PC address. We
175 select the partial symtab that contains a symbol whose
176 address is closest to the PC address. By closest we mean
177 that find_pc_sect_symbol returns the symbol with address
178 that is closest and still less than the given PC. */
179 for (tpst = pst; tpst != NULL; tpst = tpst->next)
181 if (pc >= tpst->textlow && pc < tpst->texthigh)
183 struct partial_symbol *p;
186 /* NOTE: This assumes that every psymbol has a
187 corresponding msymbol, which is not necessarily
188 true; the debug info might be much richer than the
189 object's symbol table. */
190 p = find_pc_sect_psymbol (tpst, pc, section);
192 && SYMBOL_VALUE_ADDRESS (p)
193 == SYMBOL_VALUE_ADDRESS (msymbol))
196 /* Also accept the textlow value of a psymtab as a
197 "symbol", to provide some support for partial
198 symbol tables with line information but no debug
199 symbols (e.g. those produced by an assembler). */
201 this_addr = SYMBOL_VALUE_ADDRESS (p);
203 this_addr = tpst->textlow;
205 /* Check whether it is closer than our current
206 BEST_ADDR. Since this symbol address is
207 necessarily lower or equal to PC, the symbol closer
208 to PC is the symbol which address is the highest.
209 This way we return the psymtab which contains such
210 best match symbol. This can help in cases where the
211 symbol information/debuginfo is not complete, like
212 for instance on IRIX6 with gcc, where no debug info
213 is emitted for statics. (See also the nodebug.exp
215 if (this_addr > best_addr)
217 best_addr = this_addr;
225 /* Find which partial symtab contains PC and SECTION. Return 0 if
226 none. We return the psymtab that contains a symbol whose address
227 exactly matches PC, or, if we cannot find an exact match, the
228 psymtab that contains a symbol whose address is closest to PC. */
229 static struct partial_symtab *
230 find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
231 struct obj_section *section,
232 struct minimal_symbol *msymbol)
234 struct partial_symtab *pst;
236 /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
237 than the later used TEXTLOW/TEXTHIGH one. */
239 if (objfile->psymtabs_addrmap != NULL)
241 pst = addrmap_find (objfile->psymtabs_addrmap, pc);
244 /* FIXME: addrmaps currently do not handle overlayed sections,
245 so fall back to the non-addrmap case if we're debugging
246 overlays and the addrmap returned the wrong section. */
247 if (overlay_debugging && msymbol && section)
249 struct partial_symbol *p;
251 /* NOTE: This assumes that every psymbol has a
252 corresponding msymbol, which is not necessarily
253 true; the debug info might be much richer than the
254 object's symbol table. */
255 p = find_pc_sect_psymbol (pst, pc, section);
257 || SYMBOL_VALUE_ADDRESS (p)
258 != SYMBOL_VALUE_ADDRESS (msymbol))
262 /* We do not try to call FIND_PC_SECT_PSYMTAB_CLOSER as
263 PSYMTABS_ADDRMAP we used has already the best 1-byte
264 granularity and FIND_PC_SECT_PSYMTAB_CLOSER may mislead us into
265 a worse chosen section due to the TEXTLOW/TEXTHIGH ranges
274 /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs
275 which still have no corresponding full SYMTABs read. But it is not
276 present for non-DWARF2 debug infos not supporting PSYMTABS_ADDRMAP in GDB
279 /* Check even OBJFILE with non-zero PSYMTABS_ADDRMAP as only several of
280 its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying
281 debug info type in single OBJFILE. */
283 ALL_OBJFILE_PSYMTABS (objfile, pst)
284 if (pc >= pst->textlow && pc < pst->texthigh)
286 struct partial_symtab *best_pst;
288 best_pst = find_pc_sect_psymtab_closer (pc, section, pst, msymbol);
289 if (best_pst != NULL)
296 static struct symtab *
297 find_pc_sect_symtab_from_partial (struct objfile *objfile,
298 struct minimal_symbol *msymbol,
299 CORE_ADDR pc, struct obj_section *section,
302 struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc, section,
306 if (warn_if_readin && ps->readin)
307 /* Might want to error() here (in case symtab is corrupt and
308 will cause a core dump), but maybe we can successfully
309 continue, so let's not. */
311 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
312 paddress (get_objfile_arch (ps->objfile), pc));
313 return PSYMTAB_TO_SYMTAB (ps);
318 /* Find which partial symbol within a psymtab matches PC and SECTION.
321 static struct partial_symbol *
322 find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc,
323 struct obj_section *section)
325 struct partial_symbol *best = NULL, *p, **pp;
328 gdb_assert (psymtab != NULL);
330 /* Cope with programs that start at address 0. */
331 best_pc = (psymtab->textlow != 0) ? psymtab->textlow - 1 : 0;
333 /* Search the global symbols as well as the static symbols, so that
334 find_pc_partial_function doesn't use a minimal symbol and thus
335 cache a bad endaddr. */
336 for (pp = psymtab->objfile->global_psymbols.list + psymtab->globals_offset;
337 (pp - (psymtab->objfile->global_psymbols.list + psymtab->globals_offset)
338 < psymtab->n_global_syms);
342 if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
343 && SYMBOL_CLASS (p) == LOC_BLOCK
344 && pc >= SYMBOL_VALUE_ADDRESS (p)
345 && (SYMBOL_VALUE_ADDRESS (p) > best_pc
346 || (psymtab->textlow == 0
347 && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
349 if (section) /* Match on a specific section. */
351 fixup_psymbol_section (p, psymtab->objfile);
352 if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section))
355 best_pc = SYMBOL_VALUE_ADDRESS (p);
360 for (pp = psymtab->objfile->static_psymbols.list + psymtab->statics_offset;
361 (pp - (psymtab->objfile->static_psymbols.list + psymtab->statics_offset)
362 < psymtab->n_static_syms);
366 if (SYMBOL_DOMAIN (p) == VAR_DOMAIN
367 && SYMBOL_CLASS (p) == LOC_BLOCK
368 && pc >= SYMBOL_VALUE_ADDRESS (p)
369 && (SYMBOL_VALUE_ADDRESS (p) > best_pc
370 || (psymtab->textlow == 0
371 && best_pc == 0 && SYMBOL_VALUE_ADDRESS (p) == 0)))
373 if (section) /* Match on a specific section. */
375 fixup_psymbol_section (p, psymtab->objfile);
376 if (!matching_obj_sections (SYMBOL_OBJ_SECTION (p), section))
379 best_pc = SYMBOL_VALUE_ADDRESS (p);
387 static struct partial_symbol *
388 fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
395 if (SYMBOL_OBJ_SECTION (psym))
398 gdb_assert (objfile);
400 switch (SYMBOL_CLASS (psym))
405 addr = SYMBOL_VALUE_ADDRESS (psym);
408 /* Nothing else will be listed in the minsyms -- no use looking
413 fixup_section (&psym->ginfo, addr, objfile);
418 static struct symtab *
419 lookup_symbol_aux_psymtabs (struct objfile *objfile,
420 int block_index, const char *name,
421 const domain_enum domain)
423 struct partial_symtab *ps;
424 const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
426 ALL_OBJFILE_PSYMTABS (objfile, ps)
428 if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
429 return PSYMTAB_TO_SYMTAB (ps);
435 /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search
436 the global block of PST if GLOBAL, and otherwise the static block.
437 MATCH is the comparison operation that returns true iff MATCH (s,
438 NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is
439 non-null, the symbols in the block are assumed to be ordered
440 according to it (allowing binary search). It must be compatible
441 with MATCH. Returns the symbol, if found, and otherwise NULL. */
443 static struct partial_symbol *
444 match_partial_symbol (struct partial_symtab *pst, int global,
445 const char *name, domain_enum domain,
446 symbol_compare_ftype *match,
447 symbol_compare_ftype *ordered_compare)
449 struct partial_symbol **start, **psym;
450 struct partial_symbol **top, **real_top, **bottom, **center;
451 int length = (global ? pst->n_global_syms : pst->n_static_syms);
452 int do_linear_search = 1;
457 pst->objfile->global_psymbols.list + pst->globals_offset :
458 pst->objfile->static_psymbols.list + pst->statics_offset);
460 if (global && ordered_compare) /* Can use a binary search. */
462 do_linear_search = 0;
464 /* Binary search. This search is guaranteed to end with center
465 pointing at the earliest partial symbol whose name might be
466 correct. At that point *all* partial symbols with an
467 appropriate name will be checked against the correct
471 top = start + length - 1;
475 center = bottom + (top - bottom) / 2;
476 gdb_assert (center < top);
477 if (!do_linear_search
478 && (SYMBOL_LANGUAGE (*center) == language_java))
479 do_linear_search = 1;
480 if (ordered_compare (SYMBOL_SEARCH_NAME (*center), name) >= 0)
485 gdb_assert (top == bottom);
487 while (top <= real_top
488 && match (SYMBOL_SEARCH_NAME (*top), name) == 0)
490 if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
491 SYMBOL_DOMAIN (*top), domain))
497 /* Can't use a binary search or else we found during the binary search that
498 we should also do a linear search. */
500 if (do_linear_search)
502 for (psym = start; psym < start + length; psym++)
504 if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
505 SYMBOL_DOMAIN (*psym), domain)
506 && match (SYMBOL_SEARCH_NAME (*psym), name) == 0)
515 pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
516 int kind, const char *name,
522 /* Look, in partial_symtab PST, for symbol whose natural name is NAME.
523 Check the global symbols if GLOBAL, the static symbols if not. */
525 static struct partial_symbol *
526 lookup_partial_symbol (struct partial_symtab *pst, const char *name,
527 int global, domain_enum domain)
529 struct partial_symbol **start, **psym;
530 struct partial_symbol **top, **real_top, **bottom, **center;
531 int length = (global ? pst->n_global_syms : pst->n_static_syms);
532 int do_linear_search = 1;
539 pst->objfile->global_psymbols.list + pst->globals_offset :
540 pst->objfile->static_psymbols.list + pst->statics_offset);
542 if (global) /* This means we can use a binary search. */
544 do_linear_search = 0;
546 /* Binary search. This search is guaranteed to end with center
547 pointing at the earliest partial symbol whose name might be
548 correct. At that point *all* partial symbols with an
549 appropriate name will be checked against the correct
553 top = start + length - 1;
557 center = bottom + (top - bottom) / 2;
559 internal_error (__FILE__, __LINE__,
560 _("failed internal consistency check"));
561 if (!do_linear_search
562 && SYMBOL_LANGUAGE (*center) == language_java)
564 do_linear_search = 1;
566 if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), name) >= 0)
575 if (!(top == bottom))
576 internal_error (__FILE__, __LINE__,
577 _("failed internal consistency check"));
579 while (top <= real_top
580 && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
582 if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
583 SYMBOL_DOMAIN (*top), domain))
589 /* Can't use a binary search or else we found during the binary search that
590 we should also do a linear search. */
592 if (do_linear_search)
594 for (psym = start; psym < start + length; psym++)
596 if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
597 SYMBOL_DOMAIN (*psym), domain)
598 && SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
606 /* Get the symbol table that corresponds to a partial_symtab.
607 This is fast after the first time you do it. In fact, there
608 is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
611 static struct symtab *
612 psymtab_to_symtab (struct partial_symtab *pst)
614 /* If it's been looked up before, return it. */
618 /* If it has not yet been read in, read it. */
621 struct cleanup *back_to = increment_reading_symtab ();
623 (*pst->read_symtab) (pst);
624 do_cleanups (back_to);
631 relocate_psymtabs (struct objfile *objfile,
632 struct section_offsets *new_offsets,
633 struct section_offsets *delta)
635 struct partial_symbol **psym;
636 struct partial_symtab *p;
638 ALL_OBJFILE_PSYMTABS (objfile, p)
640 p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
641 p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
644 for (psym = objfile->global_psymbols.list;
645 psym < objfile->global_psymbols.next;
648 fixup_psymbol_section (*psym, objfile);
649 if (SYMBOL_SECTION (*psym) >= 0)
650 SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
651 SYMBOL_SECTION (*psym));
653 for (psym = objfile->static_psymbols.list;
654 psym < objfile->static_psymbols.next;
657 fixup_psymbol_section (*psym, objfile);
658 if (SYMBOL_SECTION (*psym) >= 0)
659 SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
660 SYMBOL_SECTION (*psym));
664 static struct symtab *
665 find_last_source_symtab_from_partial (struct objfile *ofp)
667 struct partial_symtab *ps;
668 struct partial_symtab *cs_pst = 0;
670 ALL_OBJFILE_PSYMTABS (ofp, ps)
672 const char *name = ps->filename;
673 int len = strlen (name);
675 if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
676 || strcmp (name, "<<C++-namespaces>>") == 0)))
684 internal_error (__FILE__, __LINE__,
685 _("select_source_symtab: "
686 "readin pst found and no symtabs."));
689 return PSYMTAB_TO_SYMTAB (cs_pst);
695 forget_cached_source_info_partial (struct objfile *objfile)
697 struct partial_symtab *pst;
699 ALL_OBJFILE_PSYMTABS (objfile, pst)
701 if (pst->fullname != NULL)
703 xfree (pst->fullname);
704 pst->fullname = NULL;
710 print_partial_symbols (struct gdbarch *gdbarch,
711 struct partial_symbol **p, int count, char *what,
712 struct ui_file *outfile)
714 fprintf_filtered (outfile, " %s partial symbols:\n", what);
717 fprintf_filtered (outfile, " `%s'", SYMBOL_LINKAGE_NAME (*p));
718 if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
720 fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p));
722 fputs_filtered (", ", outfile);
723 switch (SYMBOL_DOMAIN (*p))
726 fputs_filtered ("undefined domain, ", outfile);
729 /* This is the usual thing -- don't print it. */
732 fputs_filtered ("struct domain, ", outfile);
735 fputs_filtered ("label domain, ", outfile);
738 fputs_filtered ("<invalid domain>, ", outfile);
741 switch (SYMBOL_CLASS (*p))
744 fputs_filtered ("undefined", outfile);
747 fputs_filtered ("constant int", outfile);
750 fputs_filtered ("static", outfile);
753 fputs_filtered ("register", outfile);
756 fputs_filtered ("pass by value", outfile);
759 fputs_filtered ("pass by reference", outfile);
761 case LOC_REGPARM_ADDR:
762 fputs_filtered ("register address parameter", outfile);
765 fputs_filtered ("stack parameter", outfile);
768 fputs_filtered ("type", outfile);
771 fputs_filtered ("label", outfile);
774 fputs_filtered ("function", outfile);
776 case LOC_CONST_BYTES:
777 fputs_filtered ("constant bytes", outfile);
780 fputs_filtered ("unresolved", outfile);
782 case LOC_OPTIMIZED_OUT:
783 fputs_filtered ("optimized out", outfile);
786 fputs_filtered ("computed at runtime", outfile);
789 fputs_filtered ("<invalid location>", outfile);
792 fputs_filtered (", ", outfile);
793 fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (*p)), outfile);
794 fprintf_filtered (outfile, "\n");
800 dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
801 struct ui_file *outfile)
803 struct gdbarch *gdbarch = get_objfile_arch (objfile);
806 fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
808 fprintf_filtered (outfile, "(object ");
809 gdb_print_host_address (psymtab, outfile);
810 fprintf_filtered (outfile, ")\n\n");
811 fprintf_unfiltered (outfile, " Read from object file %s (",
813 gdb_print_host_address (objfile, outfile);
814 fprintf_unfiltered (outfile, ")\n");
818 fprintf_filtered (outfile,
819 " Full symtab was read (at ");
820 gdb_print_host_address (psymtab->symtab, outfile);
821 fprintf_filtered (outfile, " by function at ");
822 gdb_print_host_address (psymtab->read_symtab, outfile);
823 fprintf_filtered (outfile, ")\n");
826 fprintf_filtered (outfile, " Relocate symbols by ");
827 for (i = 0; i < psymtab->objfile->num_sections; ++i)
830 fprintf_filtered (outfile, ", ");
832 fputs_filtered (paddress (gdbarch,
833 ANOFFSET (psymtab->section_offsets, i)),
836 fprintf_filtered (outfile, "\n");
838 fprintf_filtered (outfile, " Symbols cover text addresses ");
839 fputs_filtered (paddress (gdbarch, psymtab->textlow), outfile);
840 fprintf_filtered (outfile, "-");
841 fputs_filtered (paddress (gdbarch, psymtab->texthigh), outfile);
842 fprintf_filtered (outfile, "\n");
843 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
844 psymtab->number_of_dependencies);
845 for (i = 0; i < psymtab->number_of_dependencies; i++)
847 fprintf_filtered (outfile, " %d ", i);
848 gdb_print_host_address (psymtab->dependencies[i], outfile);
849 fprintf_filtered (outfile, " %s\n",
850 psymtab->dependencies[i]->filename);
852 if (psymtab->n_global_syms > 0)
854 print_partial_symbols (gdbarch,
855 objfile->global_psymbols.list
856 + psymtab->globals_offset,
857 psymtab->n_global_syms, "Global", outfile);
859 if (psymtab->n_static_syms > 0)
861 print_partial_symbols (gdbarch,
862 objfile->static_psymbols.list
863 + psymtab->statics_offset,
864 psymtab->n_static_syms, "Static", outfile);
866 fprintf_filtered (outfile, "\n");
870 print_psymtab_stats_for_objfile (struct objfile *objfile)
873 struct partial_symtab *ps;
876 ALL_OBJFILE_PSYMTABS (objfile, ps)
881 printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i);
885 dump_psymtabs_for_objfile (struct objfile *objfile)
887 struct partial_symtab *psymtab;
889 if (objfile->psymtabs)
891 printf_filtered ("Psymtabs:\n");
892 for (psymtab = objfile->psymtabs;
894 psymtab = psymtab->next)
896 printf_filtered ("%s at ",
898 gdb_print_host_address (psymtab, gdb_stdout);
899 printf_filtered (", ");
900 if (psymtab->objfile != objfile)
902 printf_filtered ("NOT ON CHAIN! ");
906 printf_filtered ("\n\n");
910 /* Look through the partial symtabs for all symbols which begin
911 by matching FUNC_NAME. Make sure we read that symbol table in. */
914 read_symtabs_for_function (struct objfile *objfile, const char *func_name)
916 struct partial_symtab *ps;
918 ALL_OBJFILE_PSYMTABS (objfile, ps)
923 if ((lookup_partial_symbol (ps, func_name, 1, VAR_DOMAIN)
925 || (lookup_partial_symbol (ps, func_name, 0, VAR_DOMAIN)
927 psymtab_to_symtab (ps);
932 expand_partial_symbol_tables (struct objfile *objfile)
934 struct partial_symtab *psymtab;
936 ALL_OBJFILE_PSYMTABS (objfile, psymtab)
938 psymtab_to_symtab (psymtab);
943 read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
945 struct partial_symtab *p;
947 ALL_OBJFILE_PSYMTABS (objfile, p)
949 if (strcmp (filename, p->filename) == 0)
950 PSYMTAB_TO_SYMTAB (p);
955 map_symbol_names_psymtab (struct objfile *objfile,
956 void (*fun) (const char *, void *), void *data)
958 struct partial_symtab *ps;
960 ALL_OBJFILE_PSYMTABS (objfile, ps)
962 struct partial_symbol **psym;
964 /* If the psymtab's been read in we'll get it when we search
965 through the blockvector. */
969 for (psym = objfile->global_psymbols.list + ps->globals_offset;
970 psym < (objfile->global_psymbols.list + ps->globals_offset
971 + ps->n_global_syms);
974 /* If interrupted, then quit. */
976 (*fun) (SYMBOL_NATURAL_NAME (*psym), data);
979 for (psym = objfile->static_psymbols.list + ps->statics_offset;
980 psym < (objfile->static_psymbols.list + ps->statics_offset
981 + ps->n_static_syms);
985 (*fun) (SYMBOL_NATURAL_NAME (*psym), data);
991 map_symbol_filenames_psymtab (struct objfile *objfile,
992 void (*fun) (const char *, const char *,
996 struct partial_symtab *ps;
998 ALL_OBJFILE_PSYMTABS (objfile, ps)
1000 const char *fullname;
1005 fullname = psymtab_to_fullname (ps);
1006 (*fun) (ps->filename, fullname, data);
1010 int find_and_open_source (const char *filename,
1011 const char *dirname,
1014 /* Finds the fullname that a partial_symtab represents.
1016 If this functions finds the fullname, it will save it in ps->fullname
1017 and it will also return the value.
1019 If this function fails to find the file that this partial_symtab represents,
1020 NULL will be returned and ps->fullname will be set to NULL. */
1022 psymtab_to_fullname (struct partial_symtab *ps)
1029 /* Don't check ps->fullname here, the file could have been
1030 deleted/moved/..., look for it again. */
1031 r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
1036 return ps->fullname;
1043 find_symbol_file_from_partial (struct objfile *objfile, const char *name)
1045 struct partial_symtab *pst;
1047 ALL_OBJFILE_PSYMTABS (objfile, pst)
1049 if (lookup_partial_symbol (pst, name, 1, VAR_DOMAIN))
1050 return pst->filename;
1055 /* For all symbols, s, in BLOCK that are in NAMESPACE and match NAME
1056 according to the function MATCH, call CALLBACK(BLOCK, s, DATA).
1057 BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK
1058 ever returns non-zero, and otherwise returns 0. */
1061 map_block (const char *name, domain_enum namespace, struct objfile *objfile,
1062 struct block *block,
1063 int (*callback) (struct block *, struct symbol *, void *),
1064 void *data, symbol_compare_ftype *match)
1066 struct dict_iterator iter;
1069 for (sym = dict_iter_match_first (BLOCK_DICT (block), name, match, &iter);
1070 sym != NULL; sym = dict_iter_match_next (name, match, &iter))
1072 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
1073 SYMBOL_DOMAIN (sym), namespace))
1075 if (callback (block, sym, data))
1083 /* Psymtab version of map_matching_symbols. See its definition in
1084 the definition of quick_symbol_functions in symfile.h. */
1087 map_matching_symbols_psymtab (const char *name, domain_enum namespace,
1088 struct objfile *objfile, int global,
1089 int (*callback) (struct block *,
1090 struct symbol *, void *),
1092 symbol_compare_ftype *match,
1093 symbol_compare_ftype *ordered_compare)
1095 const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
1096 struct partial_symtab *ps;
1098 ALL_OBJFILE_PSYMTABS (objfile, ps)
1102 || match_partial_symbol (ps, global, name, namespace, match,
1105 struct symtab *s = PSYMTAB_TO_SYMTAB (ps);
1106 struct block *block;
1108 if (s == NULL || !s->primary)
1110 block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), block_kind);
1111 if (map_block (name, namespace, objfile, block,
1112 callback, data, match))
1114 if (callback (block, NULL, data))
1121 expand_symtabs_matching_via_partial (struct objfile *objfile,
1122 int (*file_matcher) (const char *,
1124 int (*name_matcher) (const char *,
1129 struct partial_symtab *ps;
1131 ALL_OBJFILE_PSYMTABS (objfile, ps)
1133 struct partial_symbol **psym;
1134 struct partial_symbol **bound, **gbound, **sbound;
1140 if (! (*file_matcher) (ps->filename, data))
1143 gbound = objfile->global_psymbols.list
1144 + ps->globals_offset + ps->n_global_syms;
1145 sbound = objfile->static_psymbols.list
1146 + ps->statics_offset + ps->n_static_syms;
1149 /* Go through all of the symbols stored in a partial
1150 symtab in one loop. */
1151 psym = objfile->global_psymbols.list + ps->globals_offset;
1156 if (bound == gbound && ps->n_static_syms != 0)
1158 psym = objfile->static_psymbols.list + ps->statics_offset;
1169 if ((*name_matcher) (SYMBOL_NATURAL_NAME (*psym), data)
1170 && ((kind == VARIABLES_DOMAIN
1171 && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
1172 && SYMBOL_CLASS (*psym) != LOC_BLOCK)
1173 || (kind == FUNCTIONS_DOMAIN
1174 && SYMBOL_CLASS (*psym) == LOC_BLOCK)
1175 || (kind == TYPES_DOMAIN
1176 && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)))
1178 PSYMTAB_TO_SYMTAB (ps);
1188 objfile_has_psyms (struct objfile *objfile)
1190 return objfile->psymtabs != NULL;
1193 const struct quick_symbol_functions psym_functions =
1196 find_last_source_symtab_from_partial,
1197 forget_cached_source_info_partial,
1198 lookup_symtab_via_partial_symtab,
1199 lookup_symbol_aux_psymtabs,
1200 pre_expand_symtabs_matching_psymtabs,
1201 print_psymtab_stats_for_objfile,
1202 dump_psymtabs_for_objfile,
1204 read_symtabs_for_function,
1205 expand_partial_symbol_tables,
1206 read_psymtabs_with_filename,
1207 find_symbol_file_from_partial,
1208 map_matching_symbols_psymtab,
1209 expand_symtabs_matching_via_partial,
1210 find_pc_sect_symtab_from_partial,
1211 map_symbol_names_psymtab,
1212 map_symbol_filenames_psymtab
1217 /* This compares two partial symbols by names, using strcmp_iw_ordered
1218 for the comparison. */
1221 compare_psymbols (const void *s1p, const void *s2p)
1223 struct partial_symbol *const *s1 = s1p;
1224 struct partial_symbol *const *s2 = s2p;
1226 return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*s1),
1227 SYMBOL_SEARCH_NAME (*s2));
1231 sort_pst_symbols (struct partial_symtab *pst)
1233 /* Sort the global list; don't sort the static list. */
1235 qsort (pst->objfile->global_psymbols.list + pst->globals_offset,
1236 pst->n_global_syms, sizeof (struct partial_symbol *),
1240 /* Allocate and partially fill a partial symtab. It will be
1241 completely filled at the end of the symbol list.
1243 FILENAME is the name of the symbol-file we are reading from. */
1245 struct partial_symtab *
1246 start_psymtab_common (struct objfile *objfile,
1247 struct section_offsets *section_offsets,
1248 const char *filename,
1249 CORE_ADDR textlow, struct partial_symbol **global_syms,
1250 struct partial_symbol **static_syms)
1252 struct partial_symtab *psymtab;
1254 psymtab = allocate_psymtab (filename, objfile);
1255 psymtab->section_offsets = section_offsets;
1256 psymtab->textlow = textlow;
1257 psymtab->texthigh = psymtab->textlow; /* default */
1258 psymtab->globals_offset = global_syms - objfile->global_psymbols.list;
1259 psymtab->statics_offset = static_syms - objfile->static_psymbols.list;
1263 /* Calculate a hash code for the given partial symbol. The hash is
1264 calculated using the symbol's value, language, domain, class
1265 and name. These are the values which are set by
1266 add_psymbol_to_bcache. */
1268 static unsigned long
1269 psymbol_hash (const void *addr, int length)
1271 unsigned long h = 0;
1272 struct partial_symbol *psymbol = (struct partial_symbol *) addr;
1273 unsigned int lang = psymbol->ginfo.language;
1274 unsigned int domain = PSYMBOL_DOMAIN (psymbol);
1275 unsigned int class = PSYMBOL_CLASS (psymbol);
1277 h = hash_continue (&psymbol->ginfo.value, sizeof (psymbol->ginfo.value), h);
1278 h = hash_continue (&lang, sizeof (unsigned int), h);
1279 h = hash_continue (&domain, sizeof (unsigned int), h);
1280 h = hash_continue (&class, sizeof (unsigned int), h);
1281 h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h);
1286 /* Returns true if the symbol at addr1 equals the symbol at addr2.
1287 For the comparison this function uses a symbols value,
1288 language, domain, class and name. */
1291 psymbol_compare (const void *addr1, const void *addr2, int length)
1293 struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
1294 struct partial_symbol *sym2 = (struct partial_symbol *) addr2;
1296 return (memcmp (&sym1->ginfo.value, &sym1->ginfo.value,
1297 sizeof (sym1->ginfo.value)) == 0
1298 && sym1->ginfo.language == sym2->ginfo.language
1299 && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
1300 && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
1301 && sym1->ginfo.name == sym2->ginfo.name);
1304 /* Initialize a partial symbol bcache. */
1306 struct psymbol_bcache *
1307 psymbol_bcache_init (void)
1309 struct psymbol_bcache *bcache = XCALLOC (1, struct psymbol_bcache);
1310 bcache->bcache = bcache_xmalloc (psymbol_hash, psymbol_compare);
1314 /* Free a partial symbol bcache. */
1316 psymbol_bcache_free (struct psymbol_bcache *bcache)
1321 bcache_xfree (bcache->bcache);
1325 /* Return the internal bcache of the psymbol_bcache BCACHE. */
1328 psymbol_bcache_get_bcache (struct psymbol_bcache *bcache)
1330 return bcache->bcache;
1333 /* Find a copy of the SYM in BCACHE. If BCACHE has never seen this
1334 symbol before, add a copy to BCACHE. In either case, return a pointer
1335 to BCACHE's copy of the symbol. If optional ADDED is not NULL, return
1336 1 in case of new entry or 0 if returning an old entry. */
1338 static const struct partial_symbol *
1339 psymbol_bcache_full (struct partial_symbol *sym,
1340 struct psymbol_bcache *bcache,
1343 return bcache_full (sym,
1344 sizeof (struct partial_symbol),
1349 /* Helper function, initialises partial symbol structure and stashes
1350 it into objfile's bcache. Note that our caching mechanism will
1351 use all fields of struct partial_symbol to determine hash value of the
1352 structure. In other words, having two symbols with the same name but
1353 different domain (or address) is possible and correct. */
1355 static const struct partial_symbol *
1356 add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
1358 enum address_class class,
1359 long val, /* Value as a long */
1360 CORE_ADDR coreaddr, /* Value as a CORE_ADDR */
1361 enum language language, struct objfile *objfile,
1364 struct partial_symbol psymbol;
1366 /* We must ensure that the entire 'value' field has been zeroed
1367 before assigning to it, because an assignment may not write the
1369 memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value));
1371 /* val and coreaddr are mutually exclusive, one of them *will* be zero. */
1374 SYMBOL_VALUE (&psymbol) = val;
1378 SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
1380 SYMBOL_SECTION (&psymbol) = 0;
1381 SYMBOL_OBJ_SECTION (&psymbol) = NULL;
1382 SYMBOL_SET_LANGUAGE (&psymbol, language);
1383 PSYMBOL_DOMAIN (&psymbol) = domain;
1384 PSYMBOL_CLASS (&psymbol) = class;
1386 SYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
1388 /* Stash the partial symbol away in the cache. */
1389 return psymbol_bcache_full (&psymbol,
1390 objfile->psymbol_cache,
1394 /* Increase the space allocated for LISTP, which is probably
1395 global_psymbols or static_psymbols. This space will eventually
1396 be freed in free_objfile(). */
1399 extend_psymbol_list (struct psymbol_allocation_list *listp,
1400 struct objfile *objfile)
1404 if (listp->size == 0)
1407 listp->list = (struct partial_symbol **)
1408 xmalloc (new_size * sizeof (struct partial_symbol *));
1412 new_size = listp->size * 2;
1413 listp->list = (struct partial_symbol **)
1414 xrealloc ((char *) listp->list,
1415 new_size * sizeof (struct partial_symbol *));
1417 /* Next assumes we only went one over. Should be good if
1418 program works correctly. */
1419 listp->next = listp->list + listp->size;
1420 listp->size = new_size;
1423 /* Helper function, adds partial symbol to the given partial symbol
1427 append_psymbol_to_list (struct psymbol_allocation_list *list,
1428 const struct partial_symbol *psym,
1429 struct objfile *objfile)
1431 if (list->next >= list->list + list->size)
1432 extend_psymbol_list (list, objfile);
1433 *list->next++ = (struct partial_symbol *) psym;
1434 OBJSTAT (objfile, n_psyms++);
1437 /* Add a symbol with a long value to a psymtab.
1438 Since one arg is a struct, we pass in a ptr and deref it (sigh).
1439 Return the partial symbol that has been added. */
1441 /* NOTE: carlton/2003-09-11: The reason why we return the partial
1442 symbol is so that callers can get access to the symbol's demangled
1443 name, which they don't have any cheap way to determine otherwise.
1444 (Currenly, dwarf2read.c is the only file who uses that information,
1445 though it's possible that other readers might in the future.)
1446 Elena wasn't thrilled about that, and I don't blame her, but we
1447 couldn't come up with a better way to get that information. If
1448 it's needed in other situations, we could consider breaking up
1449 SYMBOL_SET_NAMES to provide access to the demangled name lookup
1452 const struct partial_symbol *
1453 add_psymbol_to_list (const char *name, int namelength, int copy_name,
1455 enum address_class class,
1456 struct psymbol_allocation_list *list,
1457 long val, /* Value as a long */
1458 CORE_ADDR coreaddr, /* Value as a CORE_ADDR */
1459 enum language language, struct objfile *objfile)
1461 const struct partial_symbol *psym;
1465 /* Stash the partial symbol away in the cache. */
1466 psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, class,
1467 val, coreaddr, language, objfile, &added);
1469 /* Do not duplicate global partial symbols. */
1470 if (list == &objfile->global_psymbols
1474 /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
1475 append_psymbol_to_list (list, psym, objfile);
1479 /* Initialize storage for partial symbols. */
1482 init_psymbol_list (struct objfile *objfile, int total_symbols)
1484 /* Free any previously allocated psymbol lists. */
1486 if (objfile->global_psymbols.list)
1488 xfree (objfile->global_psymbols.list);
1490 if (objfile->static_psymbols.list)
1492 xfree (objfile->static_psymbols.list);
1495 /* Current best guess is that approximately a twentieth
1496 of the total symbols (in a debugging file) are global or static
1497 oriented symbols. */
1499 objfile->global_psymbols.size = total_symbols / 10;
1500 objfile->static_psymbols.size = total_symbols / 10;
1502 if (objfile->global_psymbols.size > 0)
1504 objfile->global_psymbols.next =
1505 objfile->global_psymbols.list = (struct partial_symbol **)
1506 xmalloc ((objfile->global_psymbols.size
1507 * sizeof (struct partial_symbol *)));
1509 if (objfile->static_psymbols.size > 0)
1511 objfile->static_psymbols.next =
1512 objfile->static_psymbols.list = (struct partial_symbol **)
1513 xmalloc ((objfile->static_psymbols.size
1514 * sizeof (struct partial_symbol *)));
1518 struct partial_symtab *
1519 allocate_psymtab (const char *filename, struct objfile *objfile)
1521 struct partial_symtab *psymtab;
1523 if (objfile->free_psymtabs)
1525 psymtab = objfile->free_psymtabs;
1526 objfile->free_psymtabs = psymtab->next;
1529 psymtab = (struct partial_symtab *)
1530 obstack_alloc (&objfile->objfile_obstack,
1531 sizeof (struct partial_symtab));
1533 memset (psymtab, 0, sizeof (struct partial_symtab));
1534 psymtab->filename = obsavestring (filename, strlen (filename),
1535 &objfile->objfile_obstack);
1536 psymtab->symtab = NULL;
1538 /* Prepend it to the psymtab list for the objfile it belongs to.
1539 Psymtabs are searched in most recent inserted -> least recent
1542 psymtab->objfile = objfile;
1543 psymtab->next = objfile->psymtabs;
1544 objfile->psymtabs = psymtab;
1550 discard_psymtab (struct partial_symtab *pst)
1552 struct partial_symtab **prev_pst;
1555 Empty psymtabs happen as a result of header files which don't
1556 have any symbols in them. There can be a lot of them. But this
1557 check is wrong, in that a psymtab with N_SLINE entries but
1558 nothing else is not empty, but we don't realize that. Fixing
1559 that without slowing things down might be tricky. */
1561 /* First, snip it out of the psymtab chain. */
1563 prev_pst = &(pst->objfile->psymtabs);
1564 while ((*prev_pst) != pst)
1565 prev_pst = &((*prev_pst)->next);
1566 (*prev_pst) = pst->next;
1568 /* Next, put it on a free list for recycling. */
1570 pst->next = pst->objfile->free_psymtabs;
1571 pst->objfile->free_psymtabs = pst;
1577 maintenance_print_psymbols (char *args, int from_tty)
1580 struct ui_file *outfile;
1581 struct cleanup *cleanups;
1582 char *symname = NULL;
1583 char *filename = DEV_TTY;
1584 struct objfile *objfile;
1585 struct partial_symtab *ps;
1592 print-psymbols takes an output file name and optional symbol file name"));
1594 argv = gdb_buildargv (args);
1595 cleanups = make_cleanup_freeargv (argv);
1597 if (argv[0] != NULL)
1600 /* If a second arg is supplied, it is a source file name to match on. */
1601 if (argv[1] != NULL)
1607 filename = tilde_expand (filename);
1608 make_cleanup (xfree, filename);
1610 outfile = gdb_fopen (filename, FOPEN_WT);
1612 perror_with_name (filename);
1613 make_cleanup_ui_file_delete (outfile);
1616 ALL_PSYMTABS (objfile, ps)
1617 if (symname == NULL || strcmp (symname, ps->filename) == 0)
1618 dump_psymtab (objfile, ps, outfile);
1620 do_cleanups (cleanups);
1623 /* List all the partial symbol tables whose names match REGEXP (optional). */
1625 maintenance_info_psymtabs (char *regexp, int from_tty)
1627 struct program_space *pspace;
1628 struct objfile *objfile;
1633 ALL_PSPACES (pspace)
1634 ALL_PSPACE_OBJFILES (pspace, objfile)
1636 struct gdbarch *gdbarch = get_objfile_arch (objfile);
1637 struct partial_symtab *psymtab;
1639 /* We don't want to print anything for this objfile until we
1640 actually find a symtab whose name matches. */
1641 int printed_objfile_start = 0;
1643 ALL_OBJFILE_PSYMTABS (objfile, psymtab)
1648 || re_exec (psymtab->filename))
1650 if (! printed_objfile_start)
1652 printf_filtered ("{ objfile %s ", objfile->name);
1654 printf_filtered ("((struct objfile *) %s)\n",
1655 host_address_to_string (objfile));
1656 printed_objfile_start = 1;
1659 printf_filtered (" { psymtab %s ", psymtab->filename);
1661 printf_filtered ("((struct partial_symtab *) %s)\n",
1662 host_address_to_string (psymtab));
1664 printf_filtered (" readin %s\n",
1665 psymtab->readin ? "yes" : "no");
1666 printf_filtered (" fullname %s\n",
1668 ? psymtab->fullname : "(null)");
1669 printf_filtered (" text addresses ");
1670 fputs_filtered (paddress (gdbarch, psymtab->textlow),
1672 printf_filtered (" -- ");
1673 fputs_filtered (paddress (gdbarch, psymtab->texthigh),
1675 printf_filtered ("\n");
1676 printf_filtered (" globals ");
1677 if (psymtab->n_global_syms)
1679 printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n",
1680 host_address_to_string (psymtab->objfile->global_psymbols.list
1681 + psymtab->globals_offset),
1682 psymtab->n_global_syms);
1685 printf_filtered ("(none)\n");
1686 printf_filtered (" statics ");
1687 if (psymtab->n_static_syms)
1689 printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n",
1690 host_address_to_string (psymtab->objfile->static_psymbols.list
1691 + psymtab->statics_offset),
1692 psymtab->n_static_syms);
1695 printf_filtered ("(none)\n");
1696 printf_filtered (" dependencies ");
1697 if (psymtab->number_of_dependencies)
1701 printf_filtered ("{\n");
1702 for (i = 0; i < psymtab->number_of_dependencies; i++)
1704 struct partial_symtab *dep = psymtab->dependencies[i];
1706 /* Note the string concatenation there --- no comma. */
1707 printf_filtered (" psymtab %s "
1708 "((struct partial_symtab *) %s)\n",
1710 host_address_to_string (dep));
1712 printf_filtered (" }\n");
1715 printf_filtered ("(none)\n");
1716 printf_filtered (" }\n");
1720 if (printed_objfile_start)
1721 printf_filtered ("}\n");
1725 /* Check consistency of psymtabs and symtabs. */
1728 maintenance_check_symtabs (char *ignore, int from_tty)
1731 struct partial_symbol **psym;
1732 struct symtab *s = NULL;
1733 struct partial_symtab *ps;
1734 struct blockvector *bv;
1735 struct objfile *objfile;
1739 ALL_PSYMTABS (objfile, ps)
1741 struct gdbarch *gdbarch = get_objfile_arch (objfile);
1743 s = PSYMTAB_TO_SYMTAB (ps);
1746 bv = BLOCKVECTOR (s);
1747 b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
1748 psym = ps->objfile->static_psymbols.list + ps->statics_offset;
1749 length = ps->n_static_syms;
1752 sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
1753 SYMBOL_DOMAIN (*psym));
1756 printf_filtered ("Static symbol `");
1757 puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
1758 printf_filtered ("' only found in ");
1759 puts_filtered (ps->filename);
1760 printf_filtered (" psymtab\n");
1764 b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
1765 psym = ps->objfile->global_psymbols.list + ps->globals_offset;
1766 length = ps->n_global_syms;
1769 sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
1770 SYMBOL_DOMAIN (*psym));
1773 printf_filtered ("Global symbol `");
1774 puts_filtered (SYMBOL_LINKAGE_NAME (*psym));
1775 printf_filtered ("' only found in ");
1776 puts_filtered (ps->filename);
1777 printf_filtered (" psymtab\n");
1781 if (ps->texthigh < ps->textlow)
1783 printf_filtered ("Psymtab ");
1784 puts_filtered (ps->filename);
1785 printf_filtered (" covers bad range ");
1786 fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
1787 printf_filtered (" - ");
1788 fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
1789 printf_filtered ("\n");
1792 if (ps->texthigh == 0)
1794 if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
1796 printf_filtered ("Psymtab ");
1797 puts_filtered (ps->filename);
1798 printf_filtered (" covers ");
1799 fputs_filtered (paddress (gdbarch, ps->textlow), gdb_stdout);
1800 printf_filtered (" - ");
1801 fputs_filtered (paddress (gdbarch, ps->texthigh), gdb_stdout);
1802 printf_filtered (" but symtab covers only ");
1803 fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout);
1804 printf_filtered (" - ");
1805 fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout);
1806 printf_filtered ("\n");
1814 map_partial_symbol_names (void (*fun) (const char *, void *), void *data)
1816 struct objfile *objfile;
1818 ALL_OBJFILES (objfile)
1821 objfile->sf->qf->map_symbol_names (objfile, fun, data);
1826 map_partial_symbol_filenames (void (*fun) (const char *, const char *,
1830 struct objfile *objfile;
1832 ALL_OBJFILES (objfile)
1835 objfile->sf->qf->map_symbol_filenames (objfile, fun, data);