1 /* Do various things to symbol tables (other than lookup), for GDB.
3 Copyright (C) 1986-2014 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 "filenames.h"
27 #include "breakpoint.h"
29 #include "gdb_obstack.h"
30 #include "exceptions.h"
34 #include "gdb_regex.h"
36 #include "dictionary.h"
37 #include "typeprint.h"
42 #include "readline/readline.h"
47 #define DEV_TTY "/dev/tty"
50 /* Unfortunately for debugging, stderr is usually a macro. This is painful
51 when calling functions that take FILE *'s from the debugger.
52 So we make a variable which has the same value and which is accessible when
53 debugging GDB with itself. Because stdin et al need not be constants,
54 we initialize them in the _initialize_symmisc function at the bottom
60 /* Prototypes for local functions */
62 static int block_depth (struct block
*);
64 void _initialize_symmisc (void);
66 struct print_symbol_args
68 struct gdbarch
*gdbarch
;
69 struct symbol
*symbol
;
71 struct ui_file
*outfile
;
74 static int print_symbol (void *);
78 print_symbol_bcache_statistics (void)
80 struct program_space
*pspace
;
81 struct objfile
*objfile
;
84 ALL_PSPACE_OBJFILES (pspace
, objfile
)
87 printf_filtered (_("Byte cache statistics for '%s':\n"),
88 objfile_name (objfile
));
89 print_bcache_statistics (psymbol_bcache_get_bcache (objfile
->psymbol_cache
),
90 "partial symbol cache");
91 print_bcache_statistics (objfile
->per_bfd
->macro_cache
,
92 "preprocessor macro cache");
93 print_bcache_statistics (objfile
->per_bfd
->filename_cache
,
99 print_objfile_statistics (void)
101 struct program_space
*pspace
;
102 struct objfile
*objfile
;
104 int i
, linetables
, blockvectors
;
107 ALL_PSPACE_OBJFILES (pspace
, objfile
)
110 printf_filtered (_("Statistics for '%s':\n"), objfile_name (objfile
));
111 if (OBJSTAT (objfile
, n_stabs
) > 0)
112 printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
113 OBJSTAT (objfile
, n_stabs
));
114 if (OBJSTAT (objfile
, n_minsyms
) > 0)
115 printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
116 OBJSTAT (objfile
, n_minsyms
));
117 if (OBJSTAT (objfile
, n_psyms
) > 0)
118 printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
119 OBJSTAT (objfile
, n_psyms
));
120 if (OBJSTAT (objfile
, n_syms
) > 0)
121 printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
122 OBJSTAT (objfile
, n_syms
));
123 if (OBJSTAT (objfile
, n_types
) > 0)
124 printf_filtered (_(" Number of \"types\" defined: %d\n"),
125 OBJSTAT (objfile
, n_types
));
127 objfile
->sf
->qf
->print_stats (objfile
);
128 i
= linetables
= blockvectors
= 0;
129 ALL_OBJFILE_SYMTABS (objfile
, s
)
132 if (s
->linetable
!= NULL
)
137 printf_filtered (_(" Number of symbol tables: %d\n"), i
);
138 printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
140 printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
143 if (OBJSTAT (objfile
, sz_strtab
) > 0)
144 printf_filtered (_(" Space used by a.out string tables: %d\n"),
145 OBJSTAT (objfile
, sz_strtab
));
146 printf_filtered (_(" Total memory used for objfile obstack: %d\n"),
147 obstack_memory_used (&objfile
->objfile_obstack
));
148 printf_filtered (_(" Total memory used for BFD obstack: %d\n"),
149 obstack_memory_used (&objfile
->per_bfd
->storage_obstack
));
150 printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
151 bcache_memory_used (psymbol_bcache_get_bcache
152 (objfile
->psymbol_cache
)));
153 printf_filtered (_(" Total memory used for macro cache: %d\n"),
154 bcache_memory_used (objfile
->per_bfd
->macro_cache
));
155 printf_filtered (_(" Total memory used for file name cache: %d\n"),
156 bcache_memory_used (objfile
->per_bfd
->filename_cache
));
161 dump_objfile (struct objfile
*objfile
)
163 struct symtab
*symtab
;
165 printf_filtered ("\nObject file %s: ", objfile_name (objfile
));
166 printf_filtered ("Objfile at ");
167 gdb_print_host_address (objfile
, gdb_stdout
);
168 printf_filtered (", bfd at ");
169 gdb_print_host_address (objfile
->obfd
, gdb_stdout
);
170 printf_filtered (", %d minsyms\n\n",
171 objfile
->minimal_symbol_count
);
174 objfile
->sf
->qf
->dump (objfile
);
176 if (objfile
->symtabs
)
178 printf_filtered ("Symtabs:\n");
179 for (symtab
= objfile
->symtabs
;
181 symtab
= symtab
->next
)
183 printf_filtered ("%s at ", symtab_to_filename_for_display (symtab
));
184 gdb_print_host_address (symtab
, gdb_stdout
);
185 printf_filtered (", ");
186 if (symtab
->objfile
!= objfile
)
188 printf_filtered ("NOT ON CHAIN! ");
192 printf_filtered ("\n\n");
196 /* Print minimal symbols from this objfile. */
199 dump_msymbols (struct objfile
*objfile
, struct ui_file
*outfile
)
201 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
202 struct minimal_symbol
*msymbol
;
206 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile_name (objfile
));
207 if (objfile
->minimal_symbol_count
== 0)
209 fprintf_filtered (outfile
, "No minimal symbols found.\n");
213 ALL_OBJFILE_MSYMBOLS (objfile
, msymbol
)
215 struct obj_section
*section
= SYMBOL_OBJ_SECTION (objfile
, msymbol
);
217 switch (MSYMBOL_TYPE (msymbol
))
225 case mst_text_gnu_ifunc
:
228 case mst_solib_trampoline
:
253 fprintf_filtered (outfile
, "[%2d] %c ", index
, ms_type
);
254 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (msymbol
)),
256 fprintf_filtered (outfile
, " %s", SYMBOL_LINKAGE_NAME (msymbol
));
259 if (section
->the_bfd_section
!= NULL
)
260 fprintf_filtered (outfile
, " section %s",
261 bfd_section_name (objfile
->obfd
,
262 section
->the_bfd_section
));
264 fprintf_filtered (outfile
, " spurious section %ld",
265 (long) (section
- objfile
->sections
));
267 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
269 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
271 if (msymbol
->filename
)
272 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
273 fputs_filtered ("\n", outfile
);
276 if (objfile
->minimal_symbol_count
!= index
)
278 warning (_("internal error: minimal symbol count %d != %d"),
279 objfile
->minimal_symbol_count
, index
);
281 fprintf_filtered (outfile
, "\n");
285 dump_symtab_1 (struct objfile
*objfile
, struct symtab
*symtab
,
286 struct ui_file
*outfile
)
288 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
290 struct dict_iterator iter
;
293 struct blockvector
*bv
;
298 fprintf_filtered (outfile
, "\nSymtab for file %s\n",
299 symtab_to_filename_for_display (symtab
));
301 fprintf_filtered (outfile
, "Compilation directory is %s\n",
303 fprintf_filtered (outfile
, "Read from object file %s (",
304 objfile_name (objfile
));
305 gdb_print_host_address (objfile
, outfile
);
306 fprintf_filtered (outfile
, ")\n");
307 fprintf_filtered (outfile
, "Language: %s\n",
308 language_str (symtab
->language
));
310 /* First print the line table. */
311 l
= LINETABLE (symtab
);
314 fprintf_filtered (outfile
, "\nLine table:\n\n");
316 for (i
= 0; i
< len
; i
++)
318 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
319 fputs_filtered (paddress (gdbarch
, l
->item
[i
].pc
), outfile
);
320 fprintf_filtered (outfile
, "\n");
323 /* Now print the block info, but only for primary symtabs since we will
324 print lots of duplicate info otherwise. */
327 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
328 bv
= BLOCKVECTOR (symtab
);
329 len
= BLOCKVECTOR_NBLOCKS (bv
);
330 for (i
= 0; i
< len
; i
++)
332 b
= BLOCKVECTOR_BLOCK (bv
, i
);
333 depth
= block_depth (b
) * 2;
334 print_spaces (depth
, outfile
);
335 fprintf_filtered (outfile
, "block #%03d, object at ", i
);
336 gdb_print_host_address (b
, outfile
);
337 if (BLOCK_SUPERBLOCK (b
))
339 fprintf_filtered (outfile
, " under ");
340 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
342 /* drow/2002-07-10: We could save the total symbols count
343 even if we're using a hashtable, but nothing else but this message
345 fprintf_filtered (outfile
, ", %d syms/buckets in ",
346 dict_size (BLOCK_DICT (b
)));
347 fputs_filtered (paddress (gdbarch
, BLOCK_START (b
)), outfile
);
348 fprintf_filtered (outfile
, "..");
349 fputs_filtered (paddress (gdbarch
, BLOCK_END (b
)), outfile
);
350 if (BLOCK_FUNCTION (b
))
352 fprintf_filtered (outfile
, ", function %s",
353 SYMBOL_LINKAGE_NAME (BLOCK_FUNCTION (b
)));
354 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
356 fprintf_filtered (outfile
, ", %s",
357 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
360 fprintf_filtered (outfile
, "\n");
361 /* Now print each symbol in this block (in no particular order, if
362 we're using a hashtable). Note that we only want this
363 block, not any blocks from included symtabs. */
364 ALL_DICT_SYMBOLS (BLOCK_DICT (b
), iter
, sym
)
366 struct print_symbol_args s
;
372 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
376 fprintf_filtered (outfile
, "\n");
380 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
385 dump_symtab (struct objfile
*objfile
, struct symtab
*symtab
,
386 struct ui_file
*outfile
)
388 /* Set the current language to the language of the symtab we're dumping
389 because certain routines used during dump_symtab() use the current
390 language to print an image of the symbol. We'll restore it later.
391 But use only real languages, not placeholders. */
392 if (symtab
->language
!= language_unknown
393 && symtab
->language
!= language_auto
)
395 enum language saved_lang
;
397 saved_lang
= set_language (symtab
->language
);
399 dump_symtab_1 (objfile
, symtab
, outfile
);
401 set_language (saved_lang
);
404 dump_symtab_1 (objfile
, symtab
, outfile
);
408 maintenance_print_symbols (char *args
, int from_tty
)
411 struct ui_file
*outfile
;
412 struct cleanup
*cleanups
;
413 char *symname
= NULL
;
414 char *filename
= DEV_TTY
;
415 struct objfile
*objfile
;
422 error (_("Arguments missing: an output file name "
423 "and an optional symbol file name"));
425 argv
= gdb_buildargv (args
);
426 cleanups
= make_cleanup_freeargv (argv
);
431 /* If a second arg is supplied, it is a source file name to match on. */
438 filename
= tilde_expand (filename
);
439 make_cleanup (xfree
, filename
);
441 outfile
= gdb_fopen (filename
, FOPEN_WT
);
443 perror_with_name (filename
);
444 make_cleanup_ui_file_delete (outfile
);
446 ALL_SYMTABS (objfile
, s
)
450 || filename_cmp (symname
, symtab_to_filename_for_display (s
)) == 0)
451 dump_symtab (objfile
, s
, outfile
);
453 do_cleanups (cleanups
);
456 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
457 far to indent. ARGS is really a struct print_symbol_args *, but is
458 declared as char * to get it past catch_errors. Returns 0 for error,
462 print_symbol (void *args
)
464 struct gdbarch
*gdbarch
= ((struct print_symbol_args
*) args
)->gdbarch
;
465 struct symbol
*symbol
= ((struct print_symbol_args
*) args
)->symbol
;
466 int depth
= ((struct print_symbol_args
*) args
)->depth
;
467 struct ui_file
*outfile
= ((struct print_symbol_args
*) args
)->outfile
;
468 struct obj_section
*section
= SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (symbol
),
471 print_spaces (depth
, outfile
);
472 if (SYMBOL_DOMAIN (symbol
) == LABEL_DOMAIN
)
474 fprintf_filtered (outfile
, "label %s at ", SYMBOL_PRINT_NAME (symbol
));
475 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
478 fprintf_filtered (outfile
, " section %s\n",
479 bfd_section_name (section
->the_bfd_section
->owner
,
480 section
->the_bfd_section
));
482 fprintf_filtered (outfile
, "\n");
485 if (SYMBOL_DOMAIN (symbol
) == STRUCT_DOMAIN
)
487 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
489 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
490 &type_print_raw_options
);
494 fprintf_filtered (outfile
, "%s %s = ",
495 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
497 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
498 ? "struct" : "union")),
499 SYMBOL_LINKAGE_NAME (symbol
));
500 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
501 &type_print_raw_options
);
503 fprintf_filtered (outfile
, ";\n");
507 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
508 fprintf_filtered (outfile
, "typedef ");
509 if (SYMBOL_TYPE (symbol
))
511 /* Print details of types, except for enums where it's clutter. */
512 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_PRINT_NAME (symbol
),
514 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
516 &type_print_raw_options
);
517 fprintf_filtered (outfile
, "; ");
520 fprintf_filtered (outfile
, "%s ", SYMBOL_PRINT_NAME (symbol
));
522 switch (SYMBOL_CLASS (symbol
))
525 fprintf_filtered (outfile
, "const %s (%s)",
526 plongest (SYMBOL_VALUE (symbol
)),
527 hex_string (SYMBOL_VALUE (symbol
)));
530 case LOC_CONST_BYTES
:
533 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
535 fprintf_filtered (outfile
, "const %u hex bytes:",
537 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
538 fprintf_filtered (outfile
, " %02x",
539 (unsigned) SYMBOL_VALUE_BYTES (symbol
)[i
]);
544 fprintf_filtered (outfile
, "static at ");
545 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
548 fprintf_filtered (outfile
, " section %s",
549 bfd_section_name (section
->the_bfd_section
->owner
,
550 section
->the_bfd_section
));
554 if (SYMBOL_IS_ARGUMENT (symbol
))
555 fprintf_filtered (outfile
, "parameter register %s",
556 plongest (SYMBOL_VALUE (symbol
)));
558 fprintf_filtered (outfile
, "register %s",
559 plongest (SYMBOL_VALUE (symbol
)));
563 fprintf_filtered (outfile
, "arg at offset %s",
564 hex_string (SYMBOL_VALUE (symbol
)));
568 fprintf_filtered (outfile
, "reference arg at %s",
569 hex_string (SYMBOL_VALUE (symbol
)));
572 case LOC_REGPARM_ADDR
:
573 fprintf_filtered (outfile
, "address parameter register %s",
574 plongest (SYMBOL_VALUE (symbol
)));
578 fprintf_filtered (outfile
, "local at offset %s",
579 hex_string (SYMBOL_VALUE (symbol
)));
586 fprintf_filtered (outfile
, "label at ");
587 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
590 fprintf_filtered (outfile
, " section %s",
591 bfd_section_name (section
->the_bfd_section
->owner
,
592 section
->the_bfd_section
));
596 fprintf_filtered (outfile
, "block object ");
597 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
598 fprintf_filtered (outfile
, ", ");
599 fputs_filtered (paddress (gdbarch
,
600 BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
))),
602 fprintf_filtered (outfile
, "..");
603 fputs_filtered (paddress (gdbarch
,
604 BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
))),
607 fprintf_filtered (outfile
, " section %s",
608 bfd_section_name (section
->the_bfd_section
->owner
,
609 section
->the_bfd_section
));
613 fprintf_filtered (outfile
, "computed at runtime");
617 fprintf_filtered (outfile
, "unresolved");
620 case LOC_OPTIMIZED_OUT
:
621 fprintf_filtered (outfile
, "optimized out");
625 fprintf_filtered (outfile
, "botched symbol class %x",
626 SYMBOL_CLASS (symbol
));
630 fprintf_filtered (outfile
, "\n");
635 maintenance_print_msymbols (char *args
, int from_tty
)
638 struct ui_file
*outfile
;
639 struct cleanup
*cleanups
;
640 char *filename
= DEV_TTY
;
641 char *symname
= NULL
;
642 struct program_space
*pspace
;
643 struct objfile
*objfile
;
645 struct stat sym_st
, obj_st
;
651 error (_("print-msymbols takes an output file "
652 "name and optional symbol file name"));
654 argv
= gdb_buildargv (args
);
655 cleanups
= make_cleanup_freeargv (argv
);
660 /* If a second arg is supplied, it is a source file name to match on. */
663 symname
= gdb_realpath (argv
[1]);
664 make_cleanup (xfree
, symname
);
665 if (symname
&& stat (symname
, &sym_st
))
666 perror_with_name (symname
);
670 filename
= tilde_expand (filename
);
671 make_cleanup (xfree
, filename
);
673 outfile
= gdb_fopen (filename
, FOPEN_WT
);
675 perror_with_name (filename
);
676 make_cleanup_ui_file_delete (outfile
);
679 ALL_PSPACE_OBJFILES (pspace
, objfile
)
682 if (symname
== NULL
|| (!stat (objfile_name (objfile
), &obj_st
)
683 && sym_st
.st_dev
== obj_st
.st_dev
684 && sym_st
.st_ino
== obj_st
.st_ino
))
685 dump_msymbols (objfile
, outfile
);
687 fprintf_filtered (outfile
, "\n\n");
688 do_cleanups (cleanups
);
692 maintenance_print_objfiles (char *regexp
, int from_tty
)
694 struct program_space
*pspace
;
695 struct objfile
*objfile
;
703 ALL_PSPACE_OBJFILES (pspace
, objfile
)
707 || re_exec (objfile_name (objfile
)))
708 dump_objfile (objfile
);
712 /* List all the symbol tables whose names match REGEXP (optional). */
715 maintenance_info_symtabs (char *regexp
, int from_tty
)
717 struct program_space
*pspace
;
718 struct objfile
*objfile
;
726 ALL_PSPACE_OBJFILES (pspace
, objfile
)
728 struct symtab
*symtab
;
730 /* We don't want to print anything for this objfile until we
731 actually find a symtab whose name matches. */
732 int printed_objfile_start
= 0;
734 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
739 || re_exec (symtab_to_filename_for_display (symtab
)))
741 if (! printed_objfile_start
)
743 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
745 printf_filtered ("((struct objfile *) %s)\n",
746 host_address_to_string (objfile
));
747 printed_objfile_start
= 1;
750 printf_filtered (" { symtab %s ",
751 symtab_to_filename_for_display (symtab
));
753 printf_filtered ("((struct symtab *) %s)\n",
754 host_address_to_string (symtab
));
755 printf_filtered (" dirname %s\n",
756 symtab
->dirname
? symtab
->dirname
: "(null)");
757 printf_filtered (" fullname %s\n",
758 symtab
->fullname
? symtab
->fullname
: "(null)");
760 "blockvector ((struct blockvector *) %s)%s\n",
761 host_address_to_string (symtab
->blockvector
),
762 symtab
->primary
? " (primary)" : "");
764 "linetable ((struct linetable *) %s)\n",
765 host_address_to_string (symtab
->linetable
));
766 printf_filtered (" debugformat %s\n",
767 symtab
->debugformat
);
768 printf_filtered (" }\n");
772 if (printed_objfile_start
)
773 printf_filtered ("}\n");
777 /* Check consistency of symtabs.
778 An example of what this checks for is NULL blockvectors.
779 They can happen if there's a bug during debug info reading.
780 GDB assumes they are always non-NULL.
782 Note: This does not check for psymtab vs symtab consistency.
783 Use "maint check-psymtabs" for that. */
786 maintenance_check_symtabs (char *ignore
, int from_tty
)
788 struct program_space
*pspace
;
789 struct objfile
*objfile
;
792 ALL_PSPACE_OBJFILES (pspace
, objfile
)
794 struct symtab
*symtab
;
796 /* We don't want to print anything for this objfile until we
797 actually find something worth printing. */
798 int printed_objfile_start
= 0;
800 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
802 int found_something
= 0;
806 if (symtab
->blockvector
== NULL
)
808 /* Add more checks here. */
812 if (! printed_objfile_start
)
814 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
816 printf_filtered ("((struct objfile *) %s)\n",
817 host_address_to_string (objfile
));
818 printed_objfile_start
= 1;
820 printf_filtered (" { symtab %s\n",
821 symtab_to_filename_for_display (symtab
));
822 if (symtab
->blockvector
== NULL
)
823 printf_filtered (" NULL blockvector\n");
824 printf_filtered (" }\n");
828 if (printed_objfile_start
)
829 printf_filtered ("}\n");
833 /* Helper function for maintenance_expand_symtabs.
834 This is the name_matcher function for expand_symtabs_matching. */
837 maintenance_expand_name_matcher (const char *symname
, void *data
)
839 /* Since we're not searching on symbols, just return TRUE. */
843 /* Helper function for maintenance_expand_symtabs.
844 This is the file_matcher function for expand_symtabs_matching. */
847 maintenance_expand_file_matcher (const char *filename
, void *data
,
850 const char *regexp
= data
;
854 /* KISS: Only apply the regexp to the complete file name. */
858 if (regexp
== NULL
|| re_exec (filename
))
864 /* Expand all symbol tables whose name matches an optional regexp. */
867 maintenance_expand_symtabs (char *args
, int from_tty
)
869 struct program_space
*pspace
;
870 struct objfile
*objfile
;
871 struct cleanup
*cleanups
;
875 /* We use buildargv here so that we handle spaces in the regexp
876 in a way that allows adding more arguments later. */
877 argv
= gdb_buildargv (args
);
878 cleanups
= make_cleanup_freeargv (argv
);
886 error (_("Extra arguments after regexp."));
894 ALL_PSPACE_OBJFILES (pspace
, objfile
)
898 objfile
->sf
->qf
->expand_symtabs_matching
899 (objfile
, maintenance_expand_file_matcher
,
900 maintenance_expand_name_matcher
, ALL_DOMAIN
, regexp
);
904 do_cleanups (cleanups
);
908 /* Return the nexting depth of a block within other blocks in its symtab. */
911 block_depth (struct block
*block
)
915 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
923 /* Do early runtime initializations. */
926 _initialize_symmisc (void)
932 add_cmd ("symbols", class_maintenance
, maintenance_print_symbols
, _("\
933 Print dump of current symbol definitions.\n\
934 Entries in the full symbol table are dumped to file OUTFILE.\n\
935 If a SOURCE file is specified, dump only that file's symbols."),
936 &maintenanceprintlist
);
938 add_cmd ("msymbols", class_maintenance
, maintenance_print_msymbols
, _("\
939 Print dump of current minimal symbol definitions.\n\
940 Entries in the minimal symbol table are dumped to file OUTFILE.\n\
941 If a SOURCE file is specified, dump only that file's minimal symbols."),
942 &maintenanceprintlist
);
944 add_cmd ("objfiles", class_maintenance
, maintenance_print_objfiles
,
945 _("Print dump of current object file definitions.\n\
946 With an argument REGEXP, list the object files with matching names."),
947 &maintenanceprintlist
);
949 add_cmd ("symtabs", class_maintenance
, maintenance_info_symtabs
, _("\
950 List the full symbol tables for all object files.\n\
951 This does not include information about individual symbols, blocks, or\n\
952 linetables --- just the symbol table structures themselves.\n\
953 With an argument REGEXP, list the symbol tables with matching names."),
954 &maintenanceinfolist
);
956 add_cmd ("check-symtabs", class_maintenance
, maintenance_check_symtabs
,
958 Check consistency of currently expanded symtabs."),
961 add_cmd ("expand-symtabs", class_maintenance
, maintenance_expand_symtabs
,
962 _("Expand symbol tables.\n\
963 With an argument REGEXP, only expand the symbol tables with matching names."),