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 (objfile
->per_bfd
->n_minsyms
> 0)
115 printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
116 objfile
->per_bfd
->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
->per_bfd
->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
->per_bfd
->minimal_symbol_count
== 0)
209 fprintf_filtered (outfile
, "No minimal symbols found.\n");
213 ALL_OBJFILE_MSYMBOLS (objfile
, msymbol
)
215 struct obj_section
*section
= MSYMBOL_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
, MSYMBOL_VALUE_ADDRESS (objfile
,
257 fprintf_filtered (outfile
, " %s", MSYMBOL_LINKAGE_NAME (msymbol
));
260 if (section
->the_bfd_section
!= NULL
)
261 fprintf_filtered (outfile
, " section %s",
262 bfd_section_name (objfile
->obfd
,
263 section
->the_bfd_section
));
265 fprintf_filtered (outfile
, " spurious section %ld",
266 (long) (section
- objfile
->sections
));
268 if (MSYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
270 fprintf_filtered (outfile
, " %s", MSYMBOL_DEMANGLED_NAME (msymbol
));
272 if (msymbol
->filename
)
273 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
274 fputs_filtered ("\n", outfile
);
277 if (objfile
->per_bfd
->minimal_symbol_count
!= index
)
279 warning (_("internal error: minimal symbol count %d != %d"),
280 objfile
->per_bfd
->minimal_symbol_count
, index
);
282 fprintf_filtered (outfile
, "\n");
286 dump_symtab_1 (struct objfile
*objfile
, struct symtab
*symtab
,
287 struct ui_file
*outfile
)
289 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
291 struct dict_iterator iter
;
294 const struct blockvector
*bv
;
299 fprintf_filtered (outfile
, "\nSymtab for file %s\n",
300 symtab_to_filename_for_display (symtab
));
302 fprintf_filtered (outfile
, "Compilation directory is %s\n",
304 fprintf_filtered (outfile
, "Read from object file %s (",
305 objfile_name (objfile
));
306 gdb_print_host_address (objfile
, outfile
);
307 fprintf_filtered (outfile
, ")\n");
308 fprintf_filtered (outfile
, "Language: %s\n",
309 language_str (symtab
->language
));
311 /* First print the line table. */
312 l
= LINETABLE (symtab
);
315 fprintf_filtered (outfile
, "\nLine table:\n\n");
317 for (i
= 0; i
< len
; i
++)
319 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
320 fputs_filtered (paddress (gdbarch
, l
->item
[i
].pc
), outfile
);
321 fprintf_filtered (outfile
, "\n");
324 /* Now print the block info, but only for primary symtabs since we will
325 print lots of duplicate info otherwise. */
328 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
329 bv
= BLOCKVECTOR (symtab
);
330 len
= BLOCKVECTOR_NBLOCKS (bv
);
331 for (i
= 0; i
< len
; i
++)
333 b
= BLOCKVECTOR_BLOCK (bv
, i
);
334 depth
= block_depth (b
) * 2;
335 print_spaces (depth
, outfile
);
336 fprintf_filtered (outfile
, "block #%03d, object at ", i
);
337 gdb_print_host_address (b
, outfile
);
338 if (BLOCK_SUPERBLOCK (b
))
340 fprintf_filtered (outfile
, " under ");
341 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
343 /* drow/2002-07-10: We could save the total symbols count
344 even if we're using a hashtable, but nothing else but this message
346 fprintf_filtered (outfile
, ", %d syms/buckets in ",
347 dict_size (BLOCK_DICT (b
)));
348 fputs_filtered (paddress (gdbarch
, BLOCK_START (b
)), outfile
);
349 fprintf_filtered (outfile
, "..");
350 fputs_filtered (paddress (gdbarch
, BLOCK_END (b
)), outfile
);
351 if (BLOCK_FUNCTION (b
))
353 fprintf_filtered (outfile
, ", function %s",
354 SYMBOL_LINKAGE_NAME (BLOCK_FUNCTION (b
)));
355 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
357 fprintf_filtered (outfile
, ", %s",
358 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
361 fprintf_filtered (outfile
, "\n");
362 /* Now print each symbol in this block (in no particular order, if
363 we're using a hashtable). Note that we only want this
364 block, not any blocks from included symtabs. */
365 ALL_DICT_SYMBOLS (BLOCK_DICT (b
), iter
, sym
)
367 struct print_symbol_args s
;
373 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
377 fprintf_filtered (outfile
, "\n");
381 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
386 dump_symtab (struct objfile
*objfile
, struct symtab
*symtab
,
387 struct ui_file
*outfile
)
389 /* Set the current language to the language of the symtab we're dumping
390 because certain routines used during dump_symtab() use the current
391 language to print an image of the symbol. We'll restore it later.
392 But use only real languages, not placeholders. */
393 if (symtab
->language
!= language_unknown
394 && symtab
->language
!= language_auto
)
396 enum language saved_lang
;
398 saved_lang
= set_language (symtab
->language
);
400 dump_symtab_1 (objfile
, symtab
, outfile
);
402 set_language (saved_lang
);
405 dump_symtab_1 (objfile
, symtab
, outfile
);
409 maintenance_print_symbols (char *args
, int from_tty
)
412 struct ui_file
*outfile
;
413 struct cleanup
*cleanups
;
414 char *symname
= NULL
;
415 char *filename
= DEV_TTY
;
416 struct objfile
*objfile
;
423 error (_("Arguments missing: an output file name "
424 "and an optional symbol file name"));
426 argv
= gdb_buildargv (args
);
427 cleanups
= make_cleanup_freeargv (argv
);
432 /* If a second arg is supplied, it is a source file name to match on. */
439 filename
= tilde_expand (filename
);
440 make_cleanup (xfree
, filename
);
442 outfile
= gdb_fopen (filename
, FOPEN_WT
);
444 perror_with_name (filename
);
445 make_cleanup_ui_file_delete (outfile
);
447 ALL_SYMTABS (objfile
, s
)
451 || filename_cmp (symname
, symtab_to_filename_for_display (s
)) == 0)
452 dump_symtab (objfile
, s
, outfile
);
454 do_cleanups (cleanups
);
457 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
458 far to indent. ARGS is really a struct print_symbol_args *, but is
459 declared as char * to get it past catch_errors. Returns 0 for error,
463 print_symbol (void *args
)
465 struct gdbarch
*gdbarch
= ((struct print_symbol_args
*) args
)->gdbarch
;
466 struct symbol
*symbol
= ((struct print_symbol_args
*) args
)->symbol
;
467 int depth
= ((struct print_symbol_args
*) args
)->depth
;
468 struct ui_file
*outfile
= ((struct print_symbol_args
*) args
)->outfile
;
469 struct obj_section
*section
= SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (symbol
),
472 print_spaces (depth
, outfile
);
473 if (SYMBOL_DOMAIN (symbol
) == LABEL_DOMAIN
)
475 fprintf_filtered (outfile
, "label %s at ", SYMBOL_PRINT_NAME (symbol
));
476 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
479 fprintf_filtered (outfile
, " section %s\n",
480 bfd_section_name (section
->the_bfd_section
->owner
,
481 section
->the_bfd_section
));
483 fprintf_filtered (outfile
, "\n");
486 if (SYMBOL_DOMAIN (symbol
) == STRUCT_DOMAIN
)
488 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
490 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
491 &type_print_raw_options
);
495 fprintf_filtered (outfile
, "%s %s = ",
496 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
498 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
499 ? "struct" : "union")),
500 SYMBOL_LINKAGE_NAME (symbol
));
501 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
502 &type_print_raw_options
);
504 fprintf_filtered (outfile
, ";\n");
508 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
509 fprintf_filtered (outfile
, "typedef ");
510 if (SYMBOL_TYPE (symbol
))
512 /* Print details of types, except for enums where it's clutter. */
513 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_PRINT_NAME (symbol
),
515 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
517 &type_print_raw_options
);
518 fprintf_filtered (outfile
, "; ");
521 fprintf_filtered (outfile
, "%s ", SYMBOL_PRINT_NAME (symbol
));
523 switch (SYMBOL_CLASS (symbol
))
526 fprintf_filtered (outfile
, "const %s (%s)",
527 plongest (SYMBOL_VALUE (symbol
)),
528 hex_string (SYMBOL_VALUE (symbol
)));
531 case LOC_CONST_BYTES
:
534 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
536 fprintf_filtered (outfile
, "const %u hex bytes:",
538 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
539 fprintf_filtered (outfile
, " %02x",
540 (unsigned) SYMBOL_VALUE_BYTES (symbol
)[i
]);
545 fprintf_filtered (outfile
, "static at ");
546 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
549 fprintf_filtered (outfile
, " section %s",
550 bfd_section_name (section
->the_bfd_section
->owner
,
551 section
->the_bfd_section
));
555 if (SYMBOL_IS_ARGUMENT (symbol
))
556 fprintf_filtered (outfile
, "parameter register %s",
557 plongest (SYMBOL_VALUE (symbol
)));
559 fprintf_filtered (outfile
, "register %s",
560 plongest (SYMBOL_VALUE (symbol
)));
564 fprintf_filtered (outfile
, "arg at offset %s",
565 hex_string (SYMBOL_VALUE (symbol
)));
569 fprintf_filtered (outfile
, "reference arg at %s",
570 hex_string (SYMBOL_VALUE (symbol
)));
573 case LOC_REGPARM_ADDR
:
574 fprintf_filtered (outfile
, "address parameter register %s",
575 plongest (SYMBOL_VALUE (symbol
)));
579 fprintf_filtered (outfile
, "local at offset %s",
580 hex_string (SYMBOL_VALUE (symbol
)));
587 fprintf_filtered (outfile
, "label at ");
588 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
591 fprintf_filtered (outfile
, " section %s",
592 bfd_section_name (section
->the_bfd_section
->owner
,
593 section
->the_bfd_section
));
597 fprintf_filtered (outfile
, "block object ");
598 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
599 fprintf_filtered (outfile
, ", ");
600 fputs_filtered (paddress (gdbarch
,
601 BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
))),
603 fprintf_filtered (outfile
, "..");
604 fputs_filtered (paddress (gdbarch
,
605 BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
))),
608 fprintf_filtered (outfile
, " section %s",
609 bfd_section_name (section
->the_bfd_section
->owner
,
610 section
->the_bfd_section
));
614 fprintf_filtered (outfile
, "computed at runtime");
618 fprintf_filtered (outfile
, "unresolved");
621 case LOC_OPTIMIZED_OUT
:
622 fprintf_filtered (outfile
, "optimized out");
626 fprintf_filtered (outfile
, "botched symbol class %x",
627 SYMBOL_CLASS (symbol
));
631 fprintf_filtered (outfile
, "\n");
636 maintenance_print_msymbols (char *args
, int from_tty
)
639 struct ui_file
*outfile
;
640 struct cleanup
*cleanups
;
641 char *filename
= DEV_TTY
;
642 char *symname
= NULL
;
643 struct program_space
*pspace
;
644 struct objfile
*objfile
;
646 struct stat sym_st
, obj_st
;
652 error (_("print-msymbols takes an output file "
653 "name and optional symbol file name"));
655 argv
= gdb_buildargv (args
);
656 cleanups
= make_cleanup_freeargv (argv
);
661 /* If a second arg is supplied, it is a source file name to match on. */
664 symname
= gdb_realpath (argv
[1]);
665 make_cleanup (xfree
, symname
);
666 if (symname
&& stat (symname
, &sym_st
))
667 perror_with_name (symname
);
671 filename
= tilde_expand (filename
);
672 make_cleanup (xfree
, filename
);
674 outfile
= gdb_fopen (filename
, FOPEN_WT
);
676 perror_with_name (filename
);
677 make_cleanup_ui_file_delete (outfile
);
680 ALL_PSPACE_OBJFILES (pspace
, objfile
)
683 if (symname
== NULL
|| (!stat (objfile_name (objfile
), &obj_st
)
684 && sym_st
.st_dev
== obj_st
.st_dev
685 && sym_st
.st_ino
== obj_st
.st_ino
))
686 dump_msymbols (objfile
, outfile
);
688 fprintf_filtered (outfile
, "\n\n");
689 do_cleanups (cleanups
);
693 maintenance_print_objfiles (char *regexp
, int from_tty
)
695 struct program_space
*pspace
;
696 struct objfile
*objfile
;
704 ALL_PSPACE_OBJFILES (pspace
, objfile
)
708 || re_exec (objfile_name (objfile
)))
709 dump_objfile (objfile
);
713 /* List all the symbol tables whose names match REGEXP (optional). */
716 maintenance_info_symtabs (char *regexp
, int from_tty
)
718 struct program_space
*pspace
;
719 struct objfile
*objfile
;
727 ALL_PSPACE_OBJFILES (pspace
, objfile
)
729 struct symtab
*symtab
;
731 /* We don't want to print anything for this objfile until we
732 actually find a symtab whose name matches. */
733 int printed_objfile_start
= 0;
735 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
740 || re_exec (symtab_to_filename_for_display (symtab
)))
742 if (! printed_objfile_start
)
744 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
746 printf_filtered ("((struct objfile *) %s)\n",
747 host_address_to_string (objfile
));
748 printed_objfile_start
= 1;
751 printf_filtered (" { symtab %s ",
752 symtab_to_filename_for_display (symtab
));
754 printf_filtered ("((struct symtab *) %s)\n",
755 host_address_to_string (symtab
));
756 printf_filtered (" dirname %s\n",
757 symtab
->dirname
? symtab
->dirname
: "(null)");
758 printf_filtered (" fullname %s\n",
759 symtab
->fullname
? symtab
->fullname
: "(null)");
761 "blockvector ((struct blockvector *) %s)%s\n",
762 host_address_to_string (symtab
->blockvector
),
763 symtab
->primary
? " (primary)" : "");
765 "linetable ((struct linetable *) %s)\n",
766 host_address_to_string (symtab
->linetable
));
767 printf_filtered (" debugformat %s\n",
768 symtab
->debugformat
);
769 printf_filtered (" }\n");
773 if (printed_objfile_start
)
774 printf_filtered ("}\n");
778 /* Check consistency of symtabs.
779 An example of what this checks for is NULL blockvectors.
780 They can happen if there's a bug during debug info reading.
781 GDB assumes they are always non-NULL.
783 Note: This does not check for psymtab vs symtab consistency.
784 Use "maint check-psymtabs" for that. */
787 maintenance_check_symtabs (char *ignore
, int from_tty
)
789 struct program_space
*pspace
;
790 struct objfile
*objfile
;
793 ALL_PSPACE_OBJFILES (pspace
, objfile
)
795 struct symtab
*symtab
;
797 /* We don't want to print anything for this objfile until we
798 actually find something worth printing. */
799 int printed_objfile_start
= 0;
801 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
803 int found_something
= 0;
807 if (symtab
->blockvector
== NULL
)
809 /* Add more checks here. */
813 if (! printed_objfile_start
)
815 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
817 printf_filtered ("((struct objfile *) %s)\n",
818 host_address_to_string (objfile
));
819 printed_objfile_start
= 1;
821 printf_filtered (" { symtab %s\n",
822 symtab_to_filename_for_display (symtab
));
823 if (symtab
->blockvector
== NULL
)
824 printf_filtered (" NULL blockvector\n");
825 printf_filtered (" }\n");
829 if (printed_objfile_start
)
830 printf_filtered ("}\n");
834 /* Helper function for maintenance_expand_symtabs.
835 This is the name_matcher function for expand_symtabs_matching. */
838 maintenance_expand_name_matcher (const char *symname
, void *data
)
840 /* Since we're not searching on symbols, just return TRUE. */
844 /* Helper function for maintenance_expand_symtabs.
845 This is the file_matcher function for expand_symtabs_matching. */
848 maintenance_expand_file_matcher (const char *filename
, void *data
,
851 const char *regexp
= data
;
855 /* KISS: Only apply the regexp to the complete file name. */
859 if (regexp
== NULL
|| re_exec (filename
))
865 /* Expand all symbol tables whose name matches an optional regexp. */
868 maintenance_expand_symtabs (char *args
, int from_tty
)
870 struct program_space
*pspace
;
871 struct objfile
*objfile
;
872 struct cleanup
*cleanups
;
876 /* We use buildargv here so that we handle spaces in the regexp
877 in a way that allows adding more arguments later. */
878 argv
= gdb_buildargv (args
);
879 cleanups
= make_cleanup_freeargv (argv
);
887 error (_("Extra arguments after regexp."));
895 ALL_PSPACE_OBJFILES (pspace
, objfile
)
899 objfile
->sf
->qf
->expand_symtabs_matching
900 (objfile
, maintenance_expand_file_matcher
,
901 maintenance_expand_name_matcher
, ALL_DOMAIN
, regexp
);
905 do_cleanups (cleanups
);
909 /* Return the nexting depth of a block within other blocks in its symtab. */
912 block_depth (struct block
*block
)
916 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
924 /* Do early runtime initializations. */
927 _initialize_symmisc (void)
933 add_cmd ("symbols", class_maintenance
, maintenance_print_symbols
, _("\
934 Print dump of current symbol definitions.\n\
935 Entries in the full symbol table are dumped to file OUTFILE.\n\
936 If a SOURCE file is specified, dump only that file's symbols."),
937 &maintenanceprintlist
);
939 add_cmd ("msymbols", class_maintenance
, maintenance_print_msymbols
, _("\
940 Print dump of current minimal symbol definitions.\n\
941 Entries in the minimal symbol table are dumped to file OUTFILE.\n\
942 If a SOURCE file is specified, dump only that file's minimal symbols."),
943 &maintenanceprintlist
);
945 add_cmd ("objfiles", class_maintenance
, maintenance_print_objfiles
,
946 _("Print dump of current object file definitions.\n\
947 With an argument REGEXP, list the object files with matching names."),
948 &maintenanceprintlist
);
950 add_cmd ("symtabs", class_maintenance
, maintenance_info_symtabs
, _("\
951 List the full symbol tables for all object files.\n\
952 This does not include information about individual symbols, blocks, or\n\
953 linetables --- just the symbol table structures themselves.\n\
954 With an argument REGEXP, list the symbol tables with matching names."),
955 &maintenanceinfolist
);
957 add_cmd ("check-symtabs", class_maintenance
, maintenance_check_symtabs
,
959 Check consistency of currently expanded symtabs."),
962 add_cmd ("expand-symtabs", class_maintenance
, maintenance_expand_symtabs
,
963 _("Expand symbol tables.\n\
964 With an argument REGEXP, only expand the symbol tables with matching names."),