15796c8dcSSimon Schubert /* Do various things to symbol tables (other than lookup), for GDB.
25796c8dcSSimon Schubert
3*ef5ccd6cSJohn Marino Copyright (C) 1986-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert
55796c8dcSSimon Schubert This file is part of GDB.
65796c8dcSSimon Schubert
75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert (at your option) any later version.
115796c8dcSSimon Schubert
125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
155796c8dcSSimon Schubert GNU General Public License for more details.
165796c8dcSSimon Schubert
175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */
195796c8dcSSimon Schubert
205796c8dcSSimon Schubert #include "defs.h"
215796c8dcSSimon Schubert #include "symtab.h"
225796c8dcSSimon Schubert #include "gdbtypes.h"
235796c8dcSSimon Schubert #include "bfd.h"
24c50c785cSJohn Marino #include "filenames.h"
255796c8dcSSimon Schubert #include "symfile.h"
265796c8dcSSimon Schubert #include "objfiles.h"
275796c8dcSSimon Schubert #include "breakpoint.h"
285796c8dcSSimon Schubert #include "command.h"
295796c8dcSSimon Schubert #include "gdb_obstack.h"
305796c8dcSSimon Schubert #include "exceptions.h"
315796c8dcSSimon Schubert #include "language.h"
325796c8dcSSimon Schubert #include "bcache.h"
335796c8dcSSimon Schubert #include "block.h"
345796c8dcSSimon Schubert #include "gdb_regex.h"
355796c8dcSSimon Schubert #include "gdb_stat.h"
365796c8dcSSimon Schubert #include "dictionary.h"
37*ef5ccd6cSJohn Marino #include "typeprint.h"
38*ef5ccd6cSJohn Marino #include "gdbcmd.h"
39*ef5ccd6cSJohn Marino #include "source.h"
405796c8dcSSimon Schubert
415796c8dcSSimon Schubert #include "gdb_string.h"
425796c8dcSSimon Schubert #include "readline/readline.h"
435796c8dcSSimon Schubert
44cf7f2e2dSJohn Marino #include "psymtab.h"
45cf7f2e2dSJohn Marino
465796c8dcSSimon Schubert #ifndef DEV_TTY
475796c8dcSSimon Schubert #define DEV_TTY "/dev/tty"
485796c8dcSSimon Schubert #endif
495796c8dcSSimon Schubert
505796c8dcSSimon Schubert /* Unfortunately for debugging, stderr is usually a macro. This is painful
515796c8dcSSimon Schubert when calling functions that take FILE *'s from the debugger.
525796c8dcSSimon Schubert So we make a variable which has the same value and which is accessible when
535796c8dcSSimon Schubert debugging GDB with itself. Because stdin et al need not be constants,
545796c8dcSSimon Schubert we initialize them in the _initialize_symmisc function at the bottom
555796c8dcSSimon Schubert of the file. */
565796c8dcSSimon Schubert FILE *std_in;
575796c8dcSSimon Schubert FILE *std_out;
585796c8dcSSimon Schubert FILE *std_err;
595796c8dcSSimon Schubert
605796c8dcSSimon Schubert /* Prototypes for local functions */
615796c8dcSSimon Schubert
625796c8dcSSimon Schubert static void dump_symtab (struct objfile *, struct symtab *,
635796c8dcSSimon Schubert struct ui_file *);
645796c8dcSSimon Schubert
655796c8dcSSimon Schubert static void dump_msymbols (struct objfile *, struct ui_file *);
665796c8dcSSimon Schubert
675796c8dcSSimon Schubert static void dump_objfile (struct objfile *);
685796c8dcSSimon Schubert
695796c8dcSSimon Schubert static int block_depth (struct block *);
705796c8dcSSimon Schubert
715796c8dcSSimon Schubert void _initialize_symmisc (void);
725796c8dcSSimon Schubert
735796c8dcSSimon Schubert struct print_symbol_args
745796c8dcSSimon Schubert {
755796c8dcSSimon Schubert struct gdbarch *gdbarch;
765796c8dcSSimon Schubert struct symbol *symbol;
775796c8dcSSimon Schubert int depth;
785796c8dcSSimon Schubert struct ui_file *outfile;
795796c8dcSSimon Schubert };
805796c8dcSSimon Schubert
815796c8dcSSimon Schubert static int print_symbol (void *);
825796c8dcSSimon Schubert
835796c8dcSSimon Schubert
845796c8dcSSimon Schubert void
print_symbol_bcache_statistics(void)855796c8dcSSimon Schubert print_symbol_bcache_statistics (void)
865796c8dcSSimon Schubert {
87cf7f2e2dSJohn Marino struct program_space *pspace;
885796c8dcSSimon Schubert struct objfile *objfile;
895796c8dcSSimon Schubert
90cf7f2e2dSJohn Marino ALL_PSPACES (pspace)
91cf7f2e2dSJohn Marino ALL_PSPACE_OBJFILES (pspace, objfile)
925796c8dcSSimon Schubert {
93*ef5ccd6cSJohn Marino QUIT;
945796c8dcSSimon Schubert printf_filtered (_("Byte cache statistics for '%s':\n"), objfile->name);
95c50c785cSJohn Marino print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
96c50c785cSJohn Marino "partial symbol cache");
97*ef5ccd6cSJohn Marino print_bcache_statistics (objfile->per_bfd->macro_cache,
98*ef5ccd6cSJohn Marino "preprocessor macro cache");
99*ef5ccd6cSJohn Marino print_bcache_statistics (objfile->per_bfd->filename_cache,
100*ef5ccd6cSJohn Marino "file name cache");
1015796c8dcSSimon Schubert }
1025796c8dcSSimon Schubert }
1035796c8dcSSimon Schubert
1045796c8dcSSimon Schubert void
print_objfile_statistics(void)1055796c8dcSSimon Schubert print_objfile_statistics (void)
1065796c8dcSSimon Schubert {
107cf7f2e2dSJohn Marino struct program_space *pspace;
1085796c8dcSSimon Schubert struct objfile *objfile;
1095796c8dcSSimon Schubert struct symtab *s;
1105796c8dcSSimon Schubert int i, linetables, blockvectors;
1115796c8dcSSimon Schubert
112cf7f2e2dSJohn Marino ALL_PSPACES (pspace)
113cf7f2e2dSJohn Marino ALL_PSPACE_OBJFILES (pspace, objfile)
1145796c8dcSSimon Schubert {
115*ef5ccd6cSJohn Marino QUIT;
1165796c8dcSSimon Schubert printf_filtered (_("Statistics for '%s':\n"), objfile->name);
1175796c8dcSSimon Schubert if (OBJSTAT (objfile, n_stabs) > 0)
1185796c8dcSSimon Schubert printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
1195796c8dcSSimon Schubert OBJSTAT (objfile, n_stabs));
1205796c8dcSSimon Schubert if (OBJSTAT (objfile, n_minsyms) > 0)
1215796c8dcSSimon Schubert printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
1225796c8dcSSimon Schubert OBJSTAT (objfile, n_minsyms));
1235796c8dcSSimon Schubert if (OBJSTAT (objfile, n_psyms) > 0)
1245796c8dcSSimon Schubert printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
1255796c8dcSSimon Schubert OBJSTAT (objfile, n_psyms));
1265796c8dcSSimon Schubert if (OBJSTAT (objfile, n_syms) > 0)
1275796c8dcSSimon Schubert printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
1285796c8dcSSimon Schubert OBJSTAT (objfile, n_syms));
1295796c8dcSSimon Schubert if (OBJSTAT (objfile, n_types) > 0)
1305796c8dcSSimon Schubert printf_filtered (_(" Number of \"types\" defined: %d\n"),
1315796c8dcSSimon Schubert OBJSTAT (objfile, n_types));
132cf7f2e2dSJohn Marino if (objfile->sf)
133cf7f2e2dSJohn Marino objfile->sf->qf->print_stats (objfile);
1345796c8dcSSimon Schubert i = linetables = blockvectors = 0;
1355796c8dcSSimon Schubert ALL_OBJFILE_SYMTABS (objfile, s)
1365796c8dcSSimon Schubert {
1375796c8dcSSimon Schubert i++;
1385796c8dcSSimon Schubert if (s->linetable != NULL)
1395796c8dcSSimon Schubert linetables++;
1405796c8dcSSimon Schubert if (s->primary == 1)
1415796c8dcSSimon Schubert blockvectors++;
1425796c8dcSSimon Schubert }
1435796c8dcSSimon Schubert printf_filtered (_(" Number of symbol tables: %d\n"), i);
1445796c8dcSSimon Schubert printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
1455796c8dcSSimon Schubert linetables);
1465796c8dcSSimon Schubert printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
1475796c8dcSSimon Schubert blockvectors);
1485796c8dcSSimon Schubert
1495796c8dcSSimon Schubert if (OBJSTAT (objfile, sz_strtab) > 0)
1505796c8dcSSimon Schubert printf_filtered (_(" Space used by a.out string tables: %d\n"),
1515796c8dcSSimon Schubert OBJSTAT (objfile, sz_strtab));
1525796c8dcSSimon Schubert printf_filtered (_(" Total memory used for objfile obstack: %d\n"),
1535796c8dcSSimon Schubert obstack_memory_used (&objfile->objfile_obstack));
154*ef5ccd6cSJohn Marino printf_filtered (_(" Total memory used for BFD obstack: %d\n"),
155*ef5ccd6cSJohn Marino obstack_memory_used (&objfile->per_bfd->storage_obstack));
1565796c8dcSSimon Schubert printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
157c50c785cSJohn Marino bcache_memory_used (psymbol_bcache_get_bcache
158c50c785cSJohn Marino (objfile->psymbol_cache)));
1595796c8dcSSimon Schubert printf_filtered (_(" Total memory used for macro cache: %d\n"),
160*ef5ccd6cSJohn Marino bcache_memory_used (objfile->per_bfd->macro_cache));
161cf7f2e2dSJohn Marino printf_filtered (_(" Total memory used for file name cache: %d\n"),
162*ef5ccd6cSJohn Marino bcache_memory_used (objfile->per_bfd->filename_cache));
1635796c8dcSSimon Schubert }
1645796c8dcSSimon Schubert }
1655796c8dcSSimon Schubert
1665796c8dcSSimon Schubert static void
dump_objfile(struct objfile * objfile)1675796c8dcSSimon Schubert dump_objfile (struct objfile *objfile)
1685796c8dcSSimon Schubert {
1695796c8dcSSimon Schubert struct symtab *symtab;
1705796c8dcSSimon Schubert
1715796c8dcSSimon Schubert printf_filtered ("\nObject file %s: ", objfile->name);
1725796c8dcSSimon Schubert printf_filtered ("Objfile at ");
1735796c8dcSSimon Schubert gdb_print_host_address (objfile, gdb_stdout);
1745796c8dcSSimon Schubert printf_filtered (", bfd at ");
1755796c8dcSSimon Schubert gdb_print_host_address (objfile->obfd, gdb_stdout);
1765796c8dcSSimon Schubert printf_filtered (", %d minsyms\n\n",
1775796c8dcSSimon Schubert objfile->minimal_symbol_count);
1785796c8dcSSimon Schubert
179cf7f2e2dSJohn Marino if (objfile->sf)
180cf7f2e2dSJohn Marino objfile->sf->qf->dump (objfile);
1815796c8dcSSimon Schubert
1825796c8dcSSimon Schubert if (objfile->symtabs)
1835796c8dcSSimon Schubert {
1845796c8dcSSimon Schubert printf_filtered ("Symtabs:\n");
1855796c8dcSSimon Schubert for (symtab = objfile->symtabs;
1865796c8dcSSimon Schubert symtab != NULL;
1875796c8dcSSimon Schubert symtab = symtab->next)
1885796c8dcSSimon Schubert {
189*ef5ccd6cSJohn Marino printf_filtered ("%s at ", symtab_to_filename_for_display (symtab));
1905796c8dcSSimon Schubert gdb_print_host_address (symtab, gdb_stdout);
1915796c8dcSSimon Schubert printf_filtered (", ");
1925796c8dcSSimon Schubert if (symtab->objfile != objfile)
1935796c8dcSSimon Schubert {
1945796c8dcSSimon Schubert printf_filtered ("NOT ON CHAIN! ");
1955796c8dcSSimon Schubert }
1965796c8dcSSimon Schubert wrap_here (" ");
1975796c8dcSSimon Schubert }
1985796c8dcSSimon Schubert printf_filtered ("\n\n");
1995796c8dcSSimon Schubert }
2005796c8dcSSimon Schubert }
2015796c8dcSSimon Schubert
2025796c8dcSSimon Schubert /* Print minimal symbols from this objfile. */
2035796c8dcSSimon Schubert
2045796c8dcSSimon Schubert static void
dump_msymbols(struct objfile * objfile,struct ui_file * outfile)2055796c8dcSSimon Schubert dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
2065796c8dcSSimon Schubert {
2075796c8dcSSimon Schubert struct gdbarch *gdbarch = get_objfile_arch (objfile);
2085796c8dcSSimon Schubert struct minimal_symbol *msymbol;
2095796c8dcSSimon Schubert int index;
2105796c8dcSSimon Schubert char ms_type;
2115796c8dcSSimon Schubert
2125796c8dcSSimon Schubert fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name);
2135796c8dcSSimon Schubert if (objfile->minimal_symbol_count == 0)
2145796c8dcSSimon Schubert {
2155796c8dcSSimon Schubert fprintf_filtered (outfile, "No minimal symbols found.\n");
2165796c8dcSSimon Schubert return;
2175796c8dcSSimon Schubert }
2185796c8dcSSimon Schubert index = 0;
2195796c8dcSSimon Schubert ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
2205796c8dcSSimon Schubert {
2215796c8dcSSimon Schubert struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol);
2225796c8dcSSimon Schubert
2235796c8dcSSimon Schubert switch (MSYMBOL_TYPE (msymbol))
2245796c8dcSSimon Schubert {
2255796c8dcSSimon Schubert case mst_unknown:
2265796c8dcSSimon Schubert ms_type = 'u';
2275796c8dcSSimon Schubert break;
2285796c8dcSSimon Schubert case mst_text:
2295796c8dcSSimon Schubert ms_type = 'T';
2305796c8dcSSimon Schubert break;
231c50c785cSJohn Marino case mst_text_gnu_ifunc:
232c50c785cSJohn Marino ms_type = 'i';
233c50c785cSJohn Marino break;
2345796c8dcSSimon Schubert case mst_solib_trampoline:
2355796c8dcSSimon Schubert ms_type = 'S';
2365796c8dcSSimon Schubert break;
2375796c8dcSSimon Schubert case mst_data:
2385796c8dcSSimon Schubert ms_type = 'D';
2395796c8dcSSimon Schubert break;
2405796c8dcSSimon Schubert case mst_bss:
2415796c8dcSSimon Schubert ms_type = 'B';
2425796c8dcSSimon Schubert break;
2435796c8dcSSimon Schubert case mst_abs:
2445796c8dcSSimon Schubert ms_type = 'A';
2455796c8dcSSimon Schubert break;
2465796c8dcSSimon Schubert case mst_file_text:
2475796c8dcSSimon Schubert ms_type = 't';
2485796c8dcSSimon Schubert break;
2495796c8dcSSimon Schubert case mst_file_data:
2505796c8dcSSimon Schubert ms_type = 'd';
2515796c8dcSSimon Schubert break;
2525796c8dcSSimon Schubert case mst_file_bss:
2535796c8dcSSimon Schubert ms_type = 'b';
2545796c8dcSSimon Schubert break;
2555796c8dcSSimon Schubert default:
2565796c8dcSSimon Schubert ms_type = '?';
2575796c8dcSSimon Schubert break;
2585796c8dcSSimon Schubert }
2595796c8dcSSimon Schubert fprintf_filtered (outfile, "[%2d] %c ", index, ms_type);
2605796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msymbol)),
2615796c8dcSSimon Schubert outfile);
2625796c8dcSSimon Schubert fprintf_filtered (outfile, " %s", SYMBOL_LINKAGE_NAME (msymbol));
2635796c8dcSSimon Schubert if (section)
2645796c8dcSSimon Schubert fprintf_filtered (outfile, " section %s",
2655796c8dcSSimon Schubert bfd_section_name (objfile->obfd,
2665796c8dcSSimon Schubert section->the_bfd_section));
2675796c8dcSSimon Schubert if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
2685796c8dcSSimon Schubert {
2695796c8dcSSimon Schubert fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
2705796c8dcSSimon Schubert }
2715796c8dcSSimon Schubert if (msymbol->filename)
2725796c8dcSSimon Schubert fprintf_filtered (outfile, " %s", msymbol->filename);
2735796c8dcSSimon Schubert fputs_filtered ("\n", outfile);
2745796c8dcSSimon Schubert index++;
2755796c8dcSSimon Schubert }
2765796c8dcSSimon Schubert if (objfile->minimal_symbol_count != index)
2775796c8dcSSimon Schubert {
2785796c8dcSSimon Schubert warning (_("internal error: minimal symbol count %d != %d"),
2795796c8dcSSimon Schubert objfile->minimal_symbol_count, index);
2805796c8dcSSimon Schubert }
2815796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
2825796c8dcSSimon Schubert }
2835796c8dcSSimon Schubert
2845796c8dcSSimon Schubert static void
dump_symtab_1(struct objfile * objfile,struct symtab * symtab,struct ui_file * outfile)2855796c8dcSSimon Schubert dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
2865796c8dcSSimon Schubert struct ui_file *outfile)
2875796c8dcSSimon Schubert {
2885796c8dcSSimon Schubert struct gdbarch *gdbarch = get_objfile_arch (objfile);
2895796c8dcSSimon Schubert int i;
2905796c8dcSSimon Schubert struct dict_iterator iter;
291cf7f2e2dSJohn Marino int len;
2925796c8dcSSimon Schubert struct linetable *l;
2935796c8dcSSimon Schubert struct blockvector *bv;
2945796c8dcSSimon Schubert struct symbol *sym;
2955796c8dcSSimon Schubert struct block *b;
2965796c8dcSSimon Schubert int depth;
2975796c8dcSSimon Schubert
298*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "\nSymtab for file %s\n",
299*ef5ccd6cSJohn Marino symtab_to_filename_for_display (symtab));
3005796c8dcSSimon Schubert if (symtab->dirname)
3015796c8dcSSimon Schubert fprintf_filtered (outfile, "Compilation directory is %s\n",
3025796c8dcSSimon Schubert symtab->dirname);
3035796c8dcSSimon Schubert fprintf_filtered (outfile, "Read from object file %s (", objfile->name);
3045796c8dcSSimon Schubert gdb_print_host_address (objfile, outfile);
3055796c8dcSSimon Schubert fprintf_filtered (outfile, ")\n");
306c50c785cSJohn Marino fprintf_filtered (outfile, "Language: %s\n",
307c50c785cSJohn Marino language_str (symtab->language));
3085796c8dcSSimon Schubert
3095796c8dcSSimon Schubert /* First print the line table. */
3105796c8dcSSimon Schubert l = LINETABLE (symtab);
3115796c8dcSSimon Schubert if (l)
3125796c8dcSSimon Schubert {
3135796c8dcSSimon Schubert fprintf_filtered (outfile, "\nLine table:\n\n");
3145796c8dcSSimon Schubert len = l->nitems;
3155796c8dcSSimon Schubert for (i = 0; i < len; i++)
3165796c8dcSSimon Schubert {
3175796c8dcSSimon Schubert fprintf_filtered (outfile, " line %d at ", l->item[i].line);
3185796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, l->item[i].pc), outfile);
3195796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
3205796c8dcSSimon Schubert }
3215796c8dcSSimon Schubert }
3225796c8dcSSimon Schubert /* Now print the block info, but only for primary symtabs since we will
3235796c8dcSSimon Schubert print lots of duplicate info otherwise. */
3245796c8dcSSimon Schubert if (symtab->primary)
3255796c8dcSSimon Schubert {
3265796c8dcSSimon Schubert fprintf_filtered (outfile, "\nBlockvector:\n\n");
3275796c8dcSSimon Schubert bv = BLOCKVECTOR (symtab);
3285796c8dcSSimon Schubert len = BLOCKVECTOR_NBLOCKS (bv);
3295796c8dcSSimon Schubert for (i = 0; i < len; i++)
3305796c8dcSSimon Schubert {
3315796c8dcSSimon Schubert b = BLOCKVECTOR_BLOCK (bv, i);
3325796c8dcSSimon Schubert depth = block_depth (b) * 2;
3335796c8dcSSimon Schubert print_spaces (depth, outfile);
3345796c8dcSSimon Schubert fprintf_filtered (outfile, "block #%03d, object at ", i);
3355796c8dcSSimon Schubert gdb_print_host_address (b, outfile);
3365796c8dcSSimon Schubert if (BLOCK_SUPERBLOCK (b))
3375796c8dcSSimon Schubert {
3385796c8dcSSimon Schubert fprintf_filtered (outfile, " under ");
3395796c8dcSSimon Schubert gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
3405796c8dcSSimon Schubert }
3415796c8dcSSimon Schubert /* drow/2002-07-10: We could save the total symbols count
3425796c8dcSSimon Schubert even if we're using a hashtable, but nothing else but this message
3435796c8dcSSimon Schubert wants it. */
3445796c8dcSSimon Schubert fprintf_filtered (outfile, ", %d syms/buckets in ",
3455796c8dcSSimon Schubert dict_size (BLOCK_DICT (b)));
3465796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, BLOCK_START (b)), outfile);
3475796c8dcSSimon Schubert fprintf_filtered (outfile, "..");
3485796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, BLOCK_END (b)), outfile);
3495796c8dcSSimon Schubert if (BLOCK_FUNCTION (b))
3505796c8dcSSimon Schubert {
3515796c8dcSSimon Schubert fprintf_filtered (outfile, ", function %s",
3525796c8dcSSimon Schubert SYMBOL_LINKAGE_NAME (BLOCK_FUNCTION (b)));
3535796c8dcSSimon Schubert if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
3545796c8dcSSimon Schubert {
3555796c8dcSSimon Schubert fprintf_filtered (outfile, ", %s",
3565796c8dcSSimon Schubert SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
3575796c8dcSSimon Schubert }
3585796c8dcSSimon Schubert }
3595796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
3605796c8dcSSimon Schubert /* Now print each symbol in this block (in no particular order, if
361*ef5ccd6cSJohn Marino we're using a hashtable). Note that we only want this
362*ef5ccd6cSJohn Marino block, not any blocks from included symtabs. */
363*ef5ccd6cSJohn Marino ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
3645796c8dcSSimon Schubert {
3655796c8dcSSimon Schubert struct print_symbol_args s;
366cf7f2e2dSJohn Marino
3675796c8dcSSimon Schubert s.gdbarch = gdbarch;
3685796c8dcSSimon Schubert s.symbol = sym;
3695796c8dcSSimon Schubert s.depth = depth + 1;
3705796c8dcSSimon Schubert s.outfile = outfile;
3715796c8dcSSimon Schubert catch_errors (print_symbol, &s, "Error printing symbol:\n",
3725796c8dcSSimon Schubert RETURN_MASK_ERROR);
3735796c8dcSSimon Schubert }
3745796c8dcSSimon Schubert }
3755796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
3765796c8dcSSimon Schubert }
3775796c8dcSSimon Schubert else
3785796c8dcSSimon Schubert {
3795796c8dcSSimon Schubert fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n");
3805796c8dcSSimon Schubert }
3815796c8dcSSimon Schubert }
3825796c8dcSSimon Schubert
3835796c8dcSSimon Schubert static void
dump_symtab(struct objfile * objfile,struct symtab * symtab,struct ui_file * outfile)3845796c8dcSSimon Schubert dump_symtab (struct objfile *objfile, struct symtab *symtab,
3855796c8dcSSimon Schubert struct ui_file *outfile)
3865796c8dcSSimon Schubert {
3875796c8dcSSimon Schubert /* Set the current language to the language of the symtab we're dumping
3885796c8dcSSimon Schubert because certain routines used during dump_symtab() use the current
3895796c8dcSSimon Schubert language to print an image of the symbol. We'll restore it later.
3905796c8dcSSimon Schubert But use only real languages, not placeholders. */
3915796c8dcSSimon Schubert if (symtab->language != language_unknown
3925796c8dcSSimon Schubert && symtab->language != language_auto)
3935796c8dcSSimon Schubert {
3945796c8dcSSimon Schubert enum language saved_lang;
3955796c8dcSSimon Schubert
3965796c8dcSSimon Schubert saved_lang = set_language (symtab->language);
3975796c8dcSSimon Schubert
3985796c8dcSSimon Schubert dump_symtab_1 (objfile, symtab, outfile);
3995796c8dcSSimon Schubert
4005796c8dcSSimon Schubert set_language (saved_lang);
4015796c8dcSSimon Schubert }
4025796c8dcSSimon Schubert else
4035796c8dcSSimon Schubert dump_symtab_1 (objfile, symtab, outfile);
4045796c8dcSSimon Schubert }
4055796c8dcSSimon Schubert
406*ef5ccd6cSJohn Marino static void
maintenance_print_symbols(char * args,int from_tty)4075796c8dcSSimon Schubert maintenance_print_symbols (char *args, int from_tty)
4085796c8dcSSimon Schubert {
4095796c8dcSSimon Schubert char **argv;
4105796c8dcSSimon Schubert struct ui_file *outfile;
4115796c8dcSSimon Schubert struct cleanup *cleanups;
4125796c8dcSSimon Schubert char *symname = NULL;
4135796c8dcSSimon Schubert char *filename = DEV_TTY;
4145796c8dcSSimon Schubert struct objfile *objfile;
4155796c8dcSSimon Schubert struct symtab *s;
4165796c8dcSSimon Schubert
4175796c8dcSSimon Schubert dont_repeat ();
4185796c8dcSSimon Schubert
4195796c8dcSSimon Schubert if (args == NULL)
4205796c8dcSSimon Schubert {
421c50c785cSJohn Marino error (_("Arguments missing: an output file name "
422c50c785cSJohn Marino "and an optional symbol file name"));
4235796c8dcSSimon Schubert }
4245796c8dcSSimon Schubert argv = gdb_buildargv (args);
4255796c8dcSSimon Schubert cleanups = make_cleanup_freeargv (argv);
4265796c8dcSSimon Schubert
4275796c8dcSSimon Schubert if (argv[0] != NULL)
4285796c8dcSSimon Schubert {
4295796c8dcSSimon Schubert filename = argv[0];
430c50c785cSJohn Marino /* If a second arg is supplied, it is a source file name to match on. */
4315796c8dcSSimon Schubert if (argv[1] != NULL)
4325796c8dcSSimon Schubert {
4335796c8dcSSimon Schubert symname = argv[1];
4345796c8dcSSimon Schubert }
4355796c8dcSSimon Schubert }
4365796c8dcSSimon Schubert
4375796c8dcSSimon Schubert filename = tilde_expand (filename);
4385796c8dcSSimon Schubert make_cleanup (xfree, filename);
4395796c8dcSSimon Schubert
4405796c8dcSSimon Schubert outfile = gdb_fopen (filename, FOPEN_WT);
4415796c8dcSSimon Schubert if (outfile == 0)
4425796c8dcSSimon Schubert perror_with_name (filename);
4435796c8dcSSimon Schubert make_cleanup_ui_file_delete (outfile);
4445796c8dcSSimon Schubert
4455796c8dcSSimon Schubert ALL_SYMTABS (objfile, s)
446*ef5ccd6cSJohn Marino {
447*ef5ccd6cSJohn Marino QUIT;
448*ef5ccd6cSJohn Marino if (symname == NULL
449*ef5ccd6cSJohn Marino || filename_cmp (symname, symtab_to_filename_for_display (s)) == 0)
4505796c8dcSSimon Schubert dump_symtab (objfile, s, outfile);
451*ef5ccd6cSJohn Marino }
4525796c8dcSSimon Schubert do_cleanups (cleanups);
4535796c8dcSSimon Schubert }
4545796c8dcSSimon Schubert
4555796c8dcSSimon Schubert /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
4565796c8dcSSimon Schubert far to indent. ARGS is really a struct print_symbol_args *, but is
4575796c8dcSSimon Schubert declared as char * to get it past catch_errors. Returns 0 for error,
4585796c8dcSSimon Schubert 1 for success. */
4595796c8dcSSimon Schubert
4605796c8dcSSimon Schubert static int
print_symbol(void * args)4615796c8dcSSimon Schubert print_symbol (void *args)
4625796c8dcSSimon Schubert {
4635796c8dcSSimon Schubert struct gdbarch *gdbarch = ((struct print_symbol_args *) args)->gdbarch;
4645796c8dcSSimon Schubert struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
4655796c8dcSSimon Schubert int depth = ((struct print_symbol_args *) args)->depth;
4665796c8dcSSimon Schubert struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile;
4675796c8dcSSimon Schubert struct obj_section *section = SYMBOL_OBJ_SECTION (symbol);
4685796c8dcSSimon Schubert
4695796c8dcSSimon Schubert print_spaces (depth, outfile);
4705796c8dcSSimon Schubert if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
4715796c8dcSSimon Schubert {
4725796c8dcSSimon Schubert fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol));
4735796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
4745796c8dcSSimon Schubert outfile);
4755796c8dcSSimon Schubert if (section)
4765796c8dcSSimon Schubert fprintf_filtered (outfile, " section %s\n",
4775796c8dcSSimon Schubert bfd_section_name (section->the_bfd_section->owner,
4785796c8dcSSimon Schubert section->the_bfd_section));
4795796c8dcSSimon Schubert else
4805796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
4815796c8dcSSimon Schubert return 1;
4825796c8dcSSimon Schubert }
4835796c8dcSSimon Schubert if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
4845796c8dcSSimon Schubert {
4855796c8dcSSimon Schubert if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol)))
4865796c8dcSSimon Schubert {
487*ef5ccd6cSJohn Marino LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth,
488*ef5ccd6cSJohn Marino &type_print_raw_options);
4895796c8dcSSimon Schubert }
4905796c8dcSSimon Schubert else
4915796c8dcSSimon Schubert {
4925796c8dcSSimon Schubert fprintf_filtered (outfile, "%s %s = ",
4935796c8dcSSimon Schubert (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
4945796c8dcSSimon Schubert ? "enum"
4955796c8dcSSimon Schubert : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
4965796c8dcSSimon Schubert ? "struct" : "union")),
4975796c8dcSSimon Schubert SYMBOL_LINKAGE_NAME (symbol));
498*ef5ccd6cSJohn Marino LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth,
499*ef5ccd6cSJohn Marino &type_print_raw_options);
5005796c8dcSSimon Schubert }
5015796c8dcSSimon Schubert fprintf_filtered (outfile, ";\n");
5025796c8dcSSimon Schubert }
5035796c8dcSSimon Schubert else
5045796c8dcSSimon Schubert {
5055796c8dcSSimon Schubert if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
5065796c8dcSSimon Schubert fprintf_filtered (outfile, "typedef ");
5075796c8dcSSimon Schubert if (SYMBOL_TYPE (symbol))
5085796c8dcSSimon Schubert {
5095796c8dcSSimon Schubert /* Print details of types, except for enums where it's clutter. */
5105796c8dcSSimon Schubert LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol),
5115796c8dcSSimon Schubert outfile,
5125796c8dcSSimon Schubert TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
513*ef5ccd6cSJohn Marino depth,
514*ef5ccd6cSJohn Marino &type_print_raw_options);
5155796c8dcSSimon Schubert fprintf_filtered (outfile, "; ");
5165796c8dcSSimon Schubert }
5175796c8dcSSimon Schubert else
5185796c8dcSSimon Schubert fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol));
5195796c8dcSSimon Schubert
5205796c8dcSSimon Schubert switch (SYMBOL_CLASS (symbol))
5215796c8dcSSimon Schubert {
5225796c8dcSSimon Schubert case LOC_CONST:
523*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "const %s (%s)",
524*ef5ccd6cSJohn Marino plongest (SYMBOL_VALUE (symbol)),
525*ef5ccd6cSJohn Marino hex_string (SYMBOL_VALUE (symbol)));
5265796c8dcSSimon Schubert break;
5275796c8dcSSimon Schubert
5285796c8dcSSimon Schubert case LOC_CONST_BYTES:
5295796c8dcSSimon Schubert {
5305796c8dcSSimon Schubert unsigned i;
5315796c8dcSSimon Schubert struct type *type = check_typedef (SYMBOL_TYPE (symbol));
532cf7f2e2dSJohn Marino
5335796c8dcSSimon Schubert fprintf_filtered (outfile, "const %u hex bytes:",
5345796c8dcSSimon Schubert TYPE_LENGTH (type));
5355796c8dcSSimon Schubert for (i = 0; i < TYPE_LENGTH (type); i++)
5365796c8dcSSimon Schubert fprintf_filtered (outfile, " %02x",
5375796c8dcSSimon Schubert (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);
5385796c8dcSSimon Schubert }
5395796c8dcSSimon Schubert break;
5405796c8dcSSimon Schubert
5415796c8dcSSimon Schubert case LOC_STATIC:
5425796c8dcSSimon Schubert fprintf_filtered (outfile, "static at ");
5435796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
5445796c8dcSSimon Schubert outfile);
5455796c8dcSSimon Schubert if (section)
5465796c8dcSSimon Schubert fprintf_filtered (outfile, " section %s",
5475796c8dcSSimon Schubert bfd_section_name (section->the_bfd_section->owner,
5485796c8dcSSimon Schubert section->the_bfd_section));
5495796c8dcSSimon Schubert break;
5505796c8dcSSimon Schubert
5515796c8dcSSimon Schubert case LOC_REGISTER:
5525796c8dcSSimon Schubert if (SYMBOL_IS_ARGUMENT (symbol))
553*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "parameter register %s",
554*ef5ccd6cSJohn Marino plongest (SYMBOL_VALUE (symbol)));
5555796c8dcSSimon Schubert else
556*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "register %s",
557*ef5ccd6cSJohn Marino plongest (SYMBOL_VALUE (symbol)));
5585796c8dcSSimon Schubert break;
5595796c8dcSSimon Schubert
5605796c8dcSSimon Schubert case LOC_ARG:
561*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "arg at offset %s",
562*ef5ccd6cSJohn Marino hex_string (SYMBOL_VALUE (symbol)));
5635796c8dcSSimon Schubert break;
5645796c8dcSSimon Schubert
5655796c8dcSSimon Schubert case LOC_REF_ARG:
566*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "reference arg at %s",
567*ef5ccd6cSJohn Marino hex_string (SYMBOL_VALUE (symbol)));
5685796c8dcSSimon Schubert break;
5695796c8dcSSimon Schubert
5705796c8dcSSimon Schubert case LOC_REGPARM_ADDR:
571*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "address parameter register %s",
572*ef5ccd6cSJohn Marino plongest (SYMBOL_VALUE (symbol)));
5735796c8dcSSimon Schubert break;
5745796c8dcSSimon Schubert
5755796c8dcSSimon Schubert case LOC_LOCAL:
576*ef5ccd6cSJohn Marino fprintf_filtered (outfile, "local at offset %s",
577*ef5ccd6cSJohn Marino hex_string (SYMBOL_VALUE (symbol)));
5785796c8dcSSimon Schubert break;
5795796c8dcSSimon Schubert
5805796c8dcSSimon Schubert case LOC_TYPEDEF:
5815796c8dcSSimon Schubert break;
5825796c8dcSSimon Schubert
5835796c8dcSSimon Schubert case LOC_LABEL:
5845796c8dcSSimon Schubert fprintf_filtered (outfile, "label at ");
5855796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
5865796c8dcSSimon Schubert outfile);
5875796c8dcSSimon Schubert if (section)
5885796c8dcSSimon Schubert fprintf_filtered (outfile, " section %s",
5895796c8dcSSimon Schubert bfd_section_name (section->the_bfd_section->owner,
5905796c8dcSSimon Schubert section->the_bfd_section));
5915796c8dcSSimon Schubert break;
5925796c8dcSSimon Schubert
5935796c8dcSSimon Schubert case LOC_BLOCK:
5945796c8dcSSimon Schubert fprintf_filtered (outfile, "block object ");
5955796c8dcSSimon Schubert gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile);
5965796c8dcSSimon Schubert fprintf_filtered (outfile, ", ");
5975796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch,
5985796c8dcSSimon Schubert BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))),
5995796c8dcSSimon Schubert outfile);
6005796c8dcSSimon Schubert fprintf_filtered (outfile, "..");
6015796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch,
6025796c8dcSSimon Schubert BLOCK_END (SYMBOL_BLOCK_VALUE (symbol))),
6035796c8dcSSimon Schubert outfile);
6045796c8dcSSimon Schubert if (section)
6055796c8dcSSimon Schubert fprintf_filtered (outfile, " section %s",
6065796c8dcSSimon Schubert bfd_section_name (section->the_bfd_section->owner,
6075796c8dcSSimon Schubert section->the_bfd_section));
6085796c8dcSSimon Schubert break;
6095796c8dcSSimon Schubert
6105796c8dcSSimon Schubert case LOC_COMPUTED:
6115796c8dcSSimon Schubert fprintf_filtered (outfile, "computed at runtime");
6125796c8dcSSimon Schubert break;
6135796c8dcSSimon Schubert
6145796c8dcSSimon Schubert case LOC_UNRESOLVED:
6155796c8dcSSimon Schubert fprintf_filtered (outfile, "unresolved");
6165796c8dcSSimon Schubert break;
6175796c8dcSSimon Schubert
6185796c8dcSSimon Schubert case LOC_OPTIMIZED_OUT:
6195796c8dcSSimon Schubert fprintf_filtered (outfile, "optimized out");
6205796c8dcSSimon Schubert break;
6215796c8dcSSimon Schubert
6225796c8dcSSimon Schubert default:
6235796c8dcSSimon Schubert fprintf_filtered (outfile, "botched symbol class %x",
6245796c8dcSSimon Schubert SYMBOL_CLASS (symbol));
6255796c8dcSSimon Schubert break;
6265796c8dcSSimon Schubert }
6275796c8dcSSimon Schubert }
6285796c8dcSSimon Schubert fprintf_filtered (outfile, "\n");
6295796c8dcSSimon Schubert return 1;
6305796c8dcSSimon Schubert }
6315796c8dcSSimon Schubert
632*ef5ccd6cSJohn Marino static void
maintenance_print_msymbols(char * args,int from_tty)6335796c8dcSSimon Schubert maintenance_print_msymbols (char *args, int from_tty)
6345796c8dcSSimon Schubert {
6355796c8dcSSimon Schubert char **argv;
6365796c8dcSSimon Schubert struct ui_file *outfile;
6375796c8dcSSimon Schubert struct cleanup *cleanups;
6385796c8dcSSimon Schubert char *filename = DEV_TTY;
6395796c8dcSSimon Schubert char *symname = NULL;
640cf7f2e2dSJohn Marino struct program_space *pspace;
6415796c8dcSSimon Schubert struct objfile *objfile;
6425796c8dcSSimon Schubert
6435796c8dcSSimon Schubert struct stat sym_st, obj_st;
6445796c8dcSSimon Schubert
6455796c8dcSSimon Schubert dont_repeat ();
6465796c8dcSSimon Schubert
6475796c8dcSSimon Schubert if (args == NULL)
6485796c8dcSSimon Schubert {
649c50c785cSJohn Marino error (_("print-msymbols takes an output file "
650c50c785cSJohn Marino "name and optional symbol file name"));
6515796c8dcSSimon Schubert }
6525796c8dcSSimon Schubert argv = gdb_buildargv (args);
6535796c8dcSSimon Schubert cleanups = make_cleanup_freeargv (argv);
6545796c8dcSSimon Schubert
6555796c8dcSSimon Schubert if (argv[0] != NULL)
6565796c8dcSSimon Schubert {
6575796c8dcSSimon Schubert filename = argv[0];
658c50c785cSJohn Marino /* If a second arg is supplied, it is a source file name to match on. */
6595796c8dcSSimon Schubert if (argv[1] != NULL)
6605796c8dcSSimon Schubert {
661*ef5ccd6cSJohn Marino symname = gdb_realpath (argv[1]);
6625796c8dcSSimon Schubert make_cleanup (xfree, symname);
6635796c8dcSSimon Schubert if (symname && stat (symname, &sym_st))
6645796c8dcSSimon Schubert perror_with_name (symname);
6655796c8dcSSimon Schubert }
6665796c8dcSSimon Schubert }
6675796c8dcSSimon Schubert
6685796c8dcSSimon Schubert filename = tilde_expand (filename);
6695796c8dcSSimon Schubert make_cleanup (xfree, filename);
6705796c8dcSSimon Schubert
6715796c8dcSSimon Schubert outfile = gdb_fopen (filename, FOPEN_WT);
6725796c8dcSSimon Schubert if (outfile == 0)
6735796c8dcSSimon Schubert perror_with_name (filename);
6745796c8dcSSimon Schubert make_cleanup_ui_file_delete (outfile);
6755796c8dcSSimon Schubert
676cf7f2e2dSJohn Marino ALL_PSPACES (pspace)
677cf7f2e2dSJohn Marino ALL_PSPACE_OBJFILES (pspace, objfile)
678*ef5ccd6cSJohn Marino {
679*ef5ccd6cSJohn Marino QUIT;
680c50c785cSJohn Marino if (symname == NULL || (!stat (objfile->name, &obj_st)
681*ef5ccd6cSJohn Marino && sym_st.st_dev == obj_st.st_dev
682c50c785cSJohn Marino && sym_st.st_ino == obj_st.st_ino))
6835796c8dcSSimon Schubert dump_msymbols (objfile, outfile);
684*ef5ccd6cSJohn Marino }
6855796c8dcSSimon Schubert fprintf_filtered (outfile, "\n\n");
6865796c8dcSSimon Schubert do_cleanups (cleanups);
6875796c8dcSSimon Schubert }
6885796c8dcSSimon Schubert
689*ef5ccd6cSJohn Marino static void
maintenance_print_objfiles(char * ignore,int from_tty)6905796c8dcSSimon Schubert maintenance_print_objfiles (char *ignore, int from_tty)
6915796c8dcSSimon Schubert {
692cf7f2e2dSJohn Marino struct program_space *pspace;
6935796c8dcSSimon Schubert struct objfile *objfile;
6945796c8dcSSimon Schubert
6955796c8dcSSimon Schubert dont_repeat ();
6965796c8dcSSimon Schubert
697cf7f2e2dSJohn Marino ALL_PSPACES (pspace)
698cf7f2e2dSJohn Marino ALL_PSPACE_OBJFILES (pspace, objfile)
699*ef5ccd6cSJohn Marino {
700*ef5ccd6cSJohn Marino QUIT;
7015796c8dcSSimon Schubert dump_objfile (objfile);
702*ef5ccd6cSJohn Marino }
7035796c8dcSSimon Schubert }
7045796c8dcSSimon Schubert
7055796c8dcSSimon Schubert /* List all the symbol tables whose names match REGEXP (optional). */
706*ef5ccd6cSJohn Marino
707*ef5ccd6cSJohn Marino static void
maintenance_info_symtabs(char * regexp,int from_tty)7085796c8dcSSimon Schubert maintenance_info_symtabs (char *regexp, int from_tty)
7095796c8dcSSimon Schubert {
710cf7f2e2dSJohn Marino struct program_space *pspace;
7115796c8dcSSimon Schubert struct objfile *objfile;
7125796c8dcSSimon Schubert
7135796c8dcSSimon Schubert if (regexp)
7145796c8dcSSimon Schubert re_comp (regexp);
7155796c8dcSSimon Schubert
716cf7f2e2dSJohn Marino ALL_PSPACES (pspace)
717cf7f2e2dSJohn Marino ALL_PSPACE_OBJFILES (pspace, objfile)
7185796c8dcSSimon Schubert {
7195796c8dcSSimon Schubert struct symtab *symtab;
7205796c8dcSSimon Schubert
7215796c8dcSSimon Schubert /* We don't want to print anything for this objfile until we
7225796c8dcSSimon Schubert actually find a symtab whose name matches. */
7235796c8dcSSimon Schubert int printed_objfile_start = 0;
7245796c8dcSSimon Schubert
7255796c8dcSSimon Schubert ALL_OBJFILE_SYMTABS (objfile, symtab)
7265796c8dcSSimon Schubert {
7275796c8dcSSimon Schubert QUIT;
7285796c8dcSSimon Schubert
7295796c8dcSSimon Schubert if (! regexp
730*ef5ccd6cSJohn Marino || re_exec (symtab_to_filename_for_display (symtab)))
7315796c8dcSSimon Schubert {
7325796c8dcSSimon Schubert if (! printed_objfile_start)
7335796c8dcSSimon Schubert {
7345796c8dcSSimon Schubert printf_filtered ("{ objfile %s ", objfile->name);
7355796c8dcSSimon Schubert wrap_here (" ");
7365796c8dcSSimon Schubert printf_filtered ("((struct objfile *) %s)\n",
7375796c8dcSSimon Schubert host_address_to_string (objfile));
7385796c8dcSSimon Schubert printed_objfile_start = 1;
7395796c8dcSSimon Schubert }
7405796c8dcSSimon Schubert
741*ef5ccd6cSJohn Marino printf_filtered (" { symtab %s ",
742*ef5ccd6cSJohn Marino symtab_to_filename_for_display (symtab));
7435796c8dcSSimon Schubert wrap_here (" ");
7445796c8dcSSimon Schubert printf_filtered ("((struct symtab *) %s)\n",
7455796c8dcSSimon Schubert host_address_to_string (symtab));
7465796c8dcSSimon Schubert printf_filtered (" dirname %s\n",
7475796c8dcSSimon Schubert symtab->dirname ? symtab->dirname : "(null)");
7485796c8dcSSimon Schubert printf_filtered (" fullname %s\n",
7495796c8dcSSimon Schubert symtab->fullname ? symtab->fullname : "(null)");
750c50c785cSJohn Marino printf_filtered (" "
751c50c785cSJohn Marino "blockvector ((struct blockvector *) %s)%s\n",
7525796c8dcSSimon Schubert host_address_to_string (symtab->blockvector),
7535796c8dcSSimon Schubert symtab->primary ? " (primary)" : "");
754c50c785cSJohn Marino printf_filtered (" "
755c50c785cSJohn Marino "linetable ((struct linetable *) %s)\n",
7565796c8dcSSimon Schubert host_address_to_string (symtab->linetable));
757c50c785cSJohn Marino printf_filtered (" debugformat %s\n",
758c50c785cSJohn Marino symtab->debugformat);
7595796c8dcSSimon Schubert printf_filtered (" }\n");
7605796c8dcSSimon Schubert }
7615796c8dcSSimon Schubert }
7625796c8dcSSimon Schubert
7635796c8dcSSimon Schubert if (printed_objfile_start)
7645796c8dcSSimon Schubert printf_filtered ("}\n");
7655796c8dcSSimon Schubert }
7665796c8dcSSimon Schubert }
7675796c8dcSSimon Schubert
7685796c8dcSSimon Schubert
7695796c8dcSSimon Schubert /* Return the nexting depth of a block within other blocks in its symtab. */
7705796c8dcSSimon Schubert
7715796c8dcSSimon Schubert static int
block_depth(struct block * block)7725796c8dcSSimon Schubert block_depth (struct block *block)
7735796c8dcSSimon Schubert {
7745796c8dcSSimon Schubert int i = 0;
775cf7f2e2dSJohn Marino
7765796c8dcSSimon Schubert while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
7775796c8dcSSimon Schubert {
7785796c8dcSSimon Schubert i++;
7795796c8dcSSimon Schubert }
7805796c8dcSSimon Schubert return i;
7815796c8dcSSimon Schubert }
7825796c8dcSSimon Schubert
7835796c8dcSSimon Schubert
7845796c8dcSSimon Schubert /* Do early runtime initializations. */
785*ef5ccd6cSJohn Marino
7865796c8dcSSimon Schubert void
_initialize_symmisc(void)7875796c8dcSSimon Schubert _initialize_symmisc (void)
7885796c8dcSSimon Schubert {
7895796c8dcSSimon Schubert std_in = stdin;
7905796c8dcSSimon Schubert std_out = stdout;
7915796c8dcSSimon Schubert std_err = stderr;
792*ef5ccd6cSJohn Marino
793*ef5ccd6cSJohn Marino add_cmd ("symbols", class_maintenance, maintenance_print_symbols, _("\
794*ef5ccd6cSJohn Marino Print dump of current symbol definitions.\n\
795*ef5ccd6cSJohn Marino Entries in the full symbol table are dumped to file OUTFILE.\n\
796*ef5ccd6cSJohn Marino If a SOURCE file is specified, dump only that file's symbols."),
797*ef5ccd6cSJohn Marino &maintenanceprintlist);
798*ef5ccd6cSJohn Marino
799*ef5ccd6cSJohn Marino add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols, _("\
800*ef5ccd6cSJohn Marino Print dump of current minimal symbol definitions.\n\
801*ef5ccd6cSJohn Marino Entries in the minimal symbol table are dumped to file OUTFILE.\n\
802*ef5ccd6cSJohn Marino If a SOURCE file is specified, dump only that file's minimal symbols."),
803*ef5ccd6cSJohn Marino &maintenanceprintlist);
804*ef5ccd6cSJohn Marino
805*ef5ccd6cSJohn Marino add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles,
806*ef5ccd6cSJohn Marino _("Print dump of current object file definitions."),
807*ef5ccd6cSJohn Marino &maintenanceprintlist);
808*ef5ccd6cSJohn Marino
809*ef5ccd6cSJohn Marino add_cmd ("symtabs", class_maintenance, maintenance_info_symtabs, _("\
810*ef5ccd6cSJohn Marino List the full symbol tables for all object files.\n\
811*ef5ccd6cSJohn Marino This does not include information about individual symbols, blocks, or\n\
812*ef5ccd6cSJohn Marino linetables --- just the symbol table structures themselves.\n\
813*ef5ccd6cSJohn Marino With an argument REGEXP, list the symbol tables whose names that match that."),
814*ef5ccd6cSJohn Marino &maintenanceinfolist);
8155796c8dcSSimon Schubert }
816