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: %s\n"),
147 pulongest (obstack_memory_used (&objfile
148 ->objfile_obstack
)));
149 printf_filtered (_(" Total memory used for BFD obstack: %s\n"),
150 pulongest (obstack_memory_used (&objfile
->per_bfd
151 ->storage_obstack
)));
152 printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
153 bcache_memory_used (psymbol_bcache_get_bcache
154 (objfile
->psymbol_cache
)));
155 printf_filtered (_(" Total memory used for macro cache: %d\n"),
156 bcache_memory_used (objfile
->per_bfd
->macro_cache
));
157 printf_filtered (_(" Total memory used for file name cache: %d\n"),
158 bcache_memory_used (objfile
->per_bfd
->filename_cache
));
163 dump_objfile (struct objfile
*objfile
)
165 struct symtab
*symtab
;
167 printf_filtered ("\nObject file %s: ", objfile_name (objfile
));
168 printf_filtered ("Objfile at ");
169 gdb_print_host_address (objfile
, gdb_stdout
);
170 printf_filtered (", bfd at ");
171 gdb_print_host_address (objfile
->obfd
, gdb_stdout
);
172 printf_filtered (", %d minsyms\n\n",
173 objfile
->per_bfd
->minimal_symbol_count
);
176 objfile
->sf
->qf
->dump (objfile
);
178 if (objfile
->symtabs
)
180 printf_filtered ("Symtabs:\n");
181 for (symtab
= objfile
->symtabs
;
183 symtab
= symtab
->next
)
185 printf_filtered ("%s at ", symtab_to_filename_for_display (symtab
));
186 gdb_print_host_address (symtab
, gdb_stdout
);
187 printf_filtered (", ");
188 if (symtab
->objfile
!= objfile
)
190 printf_filtered ("NOT ON CHAIN! ");
194 printf_filtered ("\n\n");
198 /* Print minimal symbols from this objfile. */
201 dump_msymbols (struct objfile
*objfile
, struct ui_file
*outfile
)
203 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
204 struct minimal_symbol
*msymbol
;
208 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile_name (objfile
));
209 if (objfile
->per_bfd
->minimal_symbol_count
== 0)
211 fprintf_filtered (outfile
, "No minimal symbols found.\n");
215 ALL_OBJFILE_MSYMBOLS (objfile
, msymbol
)
217 struct obj_section
*section
= MSYMBOL_OBJ_SECTION (objfile
, msymbol
);
219 switch (MSYMBOL_TYPE (msymbol
))
227 case mst_text_gnu_ifunc
:
230 case mst_solib_trampoline
:
255 fprintf_filtered (outfile
, "[%2d] %c ", index
, ms_type
);
256 fputs_filtered (paddress (gdbarch
, MSYMBOL_VALUE_ADDRESS (objfile
,
259 fprintf_filtered (outfile
, " %s", MSYMBOL_LINKAGE_NAME (msymbol
));
262 if (section
->the_bfd_section
!= NULL
)
263 fprintf_filtered (outfile
, " section %s",
264 bfd_section_name (objfile
->obfd
,
265 section
->the_bfd_section
));
267 fprintf_filtered (outfile
, " spurious section %ld",
268 (long) (section
- objfile
->sections
));
270 if (MSYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
272 fprintf_filtered (outfile
, " %s", MSYMBOL_DEMANGLED_NAME (msymbol
));
274 if (msymbol
->filename
)
275 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
276 fputs_filtered ("\n", outfile
);
279 if (objfile
->per_bfd
->minimal_symbol_count
!= index
)
281 warning (_("internal error: minimal symbol count %d != %d"),
282 objfile
->per_bfd
->minimal_symbol_count
, index
);
284 fprintf_filtered (outfile
, "\n");
288 dump_symtab_1 (struct objfile
*objfile
, struct symtab
*symtab
,
289 struct ui_file
*outfile
)
291 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
293 struct dict_iterator iter
;
296 const struct blockvector
*bv
;
301 fprintf_filtered (outfile
, "\nSymtab for file %s\n",
302 symtab_to_filename_for_display (symtab
));
304 fprintf_filtered (outfile
, "Compilation directory is %s\n",
306 fprintf_filtered (outfile
, "Read from object file %s (",
307 objfile_name (objfile
));
308 gdb_print_host_address (objfile
, outfile
);
309 fprintf_filtered (outfile
, ")\n");
310 fprintf_filtered (outfile
, "Language: %s\n",
311 language_str (symtab
->language
));
313 /* First print the line table. */
314 l
= LINETABLE (symtab
);
317 fprintf_filtered (outfile
, "\nLine table:\n\n");
319 for (i
= 0; i
< len
; i
++)
321 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
322 fputs_filtered (paddress (gdbarch
, l
->item
[i
].pc
), outfile
);
323 fprintf_filtered (outfile
, "\n");
326 /* Now print the block info, but only for primary symtabs since we will
327 print lots of duplicate info otherwise. */
330 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
331 bv
= BLOCKVECTOR (symtab
);
332 len
= BLOCKVECTOR_NBLOCKS (bv
);
333 for (i
= 0; i
< len
; i
++)
335 b
= BLOCKVECTOR_BLOCK (bv
, i
);
336 depth
= block_depth (b
) * 2;
337 print_spaces (depth
, outfile
);
338 fprintf_filtered (outfile
, "block #%03d, object at ", i
);
339 gdb_print_host_address (b
, outfile
);
340 if (BLOCK_SUPERBLOCK (b
))
342 fprintf_filtered (outfile
, " under ");
343 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
345 /* drow/2002-07-10: We could save the total symbols count
346 even if we're using a hashtable, but nothing else but this message
348 fprintf_filtered (outfile
, ", %d syms/buckets in ",
349 dict_size (BLOCK_DICT (b
)));
350 fputs_filtered (paddress (gdbarch
, BLOCK_START (b
)), outfile
);
351 fprintf_filtered (outfile
, "..");
352 fputs_filtered (paddress (gdbarch
, BLOCK_END (b
)), outfile
);
353 if (BLOCK_FUNCTION (b
))
355 fprintf_filtered (outfile
, ", function %s",
356 SYMBOL_LINKAGE_NAME (BLOCK_FUNCTION (b
)));
357 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
359 fprintf_filtered (outfile
, ", %s",
360 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
363 fprintf_filtered (outfile
, "\n");
364 /* Now print each symbol in this block (in no particular order, if
365 we're using a hashtable). Note that we only want this
366 block, not any blocks from included symtabs. */
367 ALL_DICT_SYMBOLS (BLOCK_DICT (b
), iter
, sym
)
369 struct print_symbol_args s
;
375 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
379 fprintf_filtered (outfile
, "\n");
383 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
388 dump_symtab (struct objfile
*objfile
, struct symtab
*symtab
,
389 struct ui_file
*outfile
)
391 /* Set the current language to the language of the symtab we're dumping
392 because certain routines used during dump_symtab() use the current
393 language to print an image of the symbol. We'll restore it later.
394 But use only real languages, not placeholders. */
395 if (symtab
->language
!= language_unknown
396 && symtab
->language
!= language_auto
)
398 enum language saved_lang
;
400 saved_lang
= set_language (symtab
->language
);
402 dump_symtab_1 (objfile
, symtab
, outfile
);
404 set_language (saved_lang
);
407 dump_symtab_1 (objfile
, symtab
, outfile
);
411 maintenance_print_symbols (char *args
, int from_tty
)
414 struct ui_file
*outfile
;
415 struct cleanup
*cleanups
;
416 char *symname
= NULL
;
417 char *filename
= DEV_TTY
;
418 struct objfile
*objfile
;
425 error (_("Arguments missing: an output file name "
426 "and an optional symbol file name"));
428 argv
= gdb_buildargv (args
);
429 cleanups
= make_cleanup_freeargv (argv
);
434 /* If a second arg is supplied, it is a source file name to match on. */
441 filename
= tilde_expand (filename
);
442 make_cleanup (xfree
, filename
);
444 outfile
= gdb_fopen (filename
, FOPEN_WT
);
446 perror_with_name (filename
);
447 make_cleanup_ui_file_delete (outfile
);
449 ALL_SYMTABS (objfile
, s
)
453 || filename_cmp (symname
, symtab_to_filename_for_display (s
)) == 0)
454 dump_symtab (objfile
, s
, outfile
);
456 do_cleanups (cleanups
);
459 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
460 far to indent. ARGS is really a struct print_symbol_args *, but is
461 declared as char * to get it past catch_errors. Returns 0 for error,
465 print_symbol (void *args
)
467 struct gdbarch
*gdbarch
= ((struct print_symbol_args
*) args
)->gdbarch
;
468 struct symbol
*symbol
= ((struct print_symbol_args
*) args
)->symbol
;
469 int depth
= ((struct print_symbol_args
*) args
)->depth
;
470 struct ui_file
*outfile
= ((struct print_symbol_args
*) args
)->outfile
;
471 struct obj_section
*section
= SYMBOL_OBJ_SECTION (SYMBOL_OBJFILE (symbol
),
474 print_spaces (depth
, outfile
);
475 if (SYMBOL_DOMAIN (symbol
) == LABEL_DOMAIN
)
477 fprintf_filtered (outfile
, "label %s at ", SYMBOL_PRINT_NAME (symbol
));
478 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
481 fprintf_filtered (outfile
, " section %s\n",
482 bfd_section_name (section
->the_bfd_section
->owner
,
483 section
->the_bfd_section
));
485 fprintf_filtered (outfile
, "\n");
488 if (SYMBOL_DOMAIN (symbol
) == STRUCT_DOMAIN
)
490 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
492 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
493 &type_print_raw_options
);
497 fprintf_filtered (outfile
, "%s %s = ",
498 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
500 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
501 ? "struct" : "union")),
502 SYMBOL_LINKAGE_NAME (symbol
));
503 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
,
504 &type_print_raw_options
);
506 fprintf_filtered (outfile
, ";\n");
510 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
511 fprintf_filtered (outfile
, "typedef ");
512 if (SYMBOL_TYPE (symbol
))
514 /* Print details of types, except for enums where it's clutter. */
515 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_PRINT_NAME (symbol
),
517 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
519 &type_print_raw_options
);
520 fprintf_filtered (outfile
, "; ");
523 fprintf_filtered (outfile
, "%s ", SYMBOL_PRINT_NAME (symbol
));
525 switch (SYMBOL_CLASS (symbol
))
528 fprintf_filtered (outfile
, "const %s (%s)",
529 plongest (SYMBOL_VALUE (symbol
)),
530 hex_string (SYMBOL_VALUE (symbol
)));
533 case LOC_CONST_BYTES
:
536 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
538 fprintf_filtered (outfile
, "const %u hex bytes:",
540 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
541 fprintf_filtered (outfile
, " %02x",
542 (unsigned) SYMBOL_VALUE_BYTES (symbol
)[i
]);
547 fprintf_filtered (outfile
, "static at ");
548 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
551 fprintf_filtered (outfile
, " section %s",
552 bfd_section_name (section
->the_bfd_section
->owner
,
553 section
->the_bfd_section
));
557 if (SYMBOL_IS_ARGUMENT (symbol
))
558 fprintf_filtered (outfile
, "parameter register %s",
559 plongest (SYMBOL_VALUE (symbol
)));
561 fprintf_filtered (outfile
, "register %s",
562 plongest (SYMBOL_VALUE (symbol
)));
566 fprintf_filtered (outfile
, "arg at offset %s",
567 hex_string (SYMBOL_VALUE (symbol
)));
571 fprintf_filtered (outfile
, "reference arg at %s",
572 hex_string (SYMBOL_VALUE (symbol
)));
575 case LOC_REGPARM_ADDR
:
576 fprintf_filtered (outfile
, "address parameter register %s",
577 plongest (SYMBOL_VALUE (symbol
)));
581 fprintf_filtered (outfile
, "local at offset %s",
582 hex_string (SYMBOL_VALUE (symbol
)));
589 fprintf_filtered (outfile
, "label at ");
590 fputs_filtered (paddress (gdbarch
, SYMBOL_VALUE_ADDRESS (symbol
)),
593 fprintf_filtered (outfile
, " section %s",
594 bfd_section_name (section
->the_bfd_section
->owner
,
595 section
->the_bfd_section
));
599 fprintf_filtered (outfile
, "block object ");
600 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
601 fprintf_filtered (outfile
, ", ");
602 fputs_filtered (paddress (gdbarch
,
603 BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
))),
605 fprintf_filtered (outfile
, "..");
606 fputs_filtered (paddress (gdbarch
,
607 BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
))),
610 fprintf_filtered (outfile
, " section %s",
611 bfd_section_name (section
->the_bfd_section
->owner
,
612 section
->the_bfd_section
));
616 fprintf_filtered (outfile
, "computed at runtime");
620 fprintf_filtered (outfile
, "unresolved");
623 case LOC_OPTIMIZED_OUT
:
624 fprintf_filtered (outfile
, "optimized out");
628 fprintf_filtered (outfile
, "botched symbol class %x",
629 SYMBOL_CLASS (symbol
));
633 fprintf_filtered (outfile
, "\n");
638 maintenance_print_msymbols (char *args
, int from_tty
)
641 struct ui_file
*outfile
;
642 struct cleanup
*cleanups
;
643 char *filename
= DEV_TTY
;
644 char *symname
= NULL
;
645 struct program_space
*pspace
;
646 struct objfile
*objfile
;
648 struct stat sym_st
, obj_st
;
654 error (_("print-msymbols takes an output file "
655 "name and optional symbol file name"));
657 argv
= gdb_buildargv (args
);
658 cleanups
= make_cleanup_freeargv (argv
);
663 /* If a second arg is supplied, it is a source file name to match on. */
666 symname
= gdb_realpath (argv
[1]);
667 make_cleanup (xfree
, symname
);
668 if (symname
&& stat (symname
, &sym_st
))
669 perror_with_name (symname
);
673 filename
= tilde_expand (filename
);
674 make_cleanup (xfree
, filename
);
676 outfile
= gdb_fopen (filename
, FOPEN_WT
);
678 perror_with_name (filename
);
679 make_cleanup_ui_file_delete (outfile
);
682 ALL_PSPACE_OBJFILES (pspace
, objfile
)
685 if (symname
== NULL
|| (!stat (objfile_name (objfile
), &obj_st
)
686 && sym_st
.st_dev
== obj_st
.st_dev
687 && sym_st
.st_ino
== obj_st
.st_ino
))
688 dump_msymbols (objfile
, outfile
);
690 fprintf_filtered (outfile
, "\n\n");
691 do_cleanups (cleanups
);
695 maintenance_print_objfiles (char *regexp
, int from_tty
)
697 struct program_space
*pspace
;
698 struct objfile
*objfile
;
706 ALL_PSPACE_OBJFILES (pspace
, objfile
)
710 || re_exec (objfile_name (objfile
)))
711 dump_objfile (objfile
);
715 /* List all the symbol tables whose names match REGEXP (optional). */
718 maintenance_info_symtabs (char *regexp
, int from_tty
)
720 struct program_space
*pspace
;
721 struct objfile
*objfile
;
729 ALL_PSPACE_OBJFILES (pspace
, objfile
)
731 struct symtab
*symtab
;
733 /* We don't want to print anything for this objfile until we
734 actually find a symtab whose name matches. */
735 int printed_objfile_start
= 0;
737 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
742 || re_exec (symtab_to_filename_for_display (symtab
)))
744 if (! printed_objfile_start
)
746 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
748 printf_filtered ("((struct objfile *) %s)\n",
749 host_address_to_string (objfile
));
750 printed_objfile_start
= 1;
753 printf_filtered (" { symtab %s ",
754 symtab_to_filename_for_display (symtab
));
756 printf_filtered ("((struct symtab *) %s)\n",
757 host_address_to_string (symtab
));
758 printf_filtered (" dirname %s\n",
759 symtab
->dirname
? symtab
->dirname
: "(null)");
760 printf_filtered (" fullname %s\n",
761 symtab
->fullname
? symtab
->fullname
: "(null)");
763 "blockvector ((struct blockvector *) %s)%s\n",
764 host_address_to_string (symtab
->blockvector
),
765 symtab
->primary
? " (primary)" : "");
767 "linetable ((struct linetable *) %s)\n",
768 host_address_to_string (symtab
->linetable
));
769 printf_filtered (" debugformat %s\n",
770 symtab
->debugformat
);
771 printf_filtered (" }\n");
775 if (printed_objfile_start
)
776 printf_filtered ("}\n");
780 /* Check consistency of symtabs.
781 An example of what this checks for is NULL blockvectors.
782 They can happen if there's a bug during debug info reading.
783 GDB assumes they are always non-NULL.
785 Note: This does not check for psymtab vs symtab consistency.
786 Use "maint check-psymtabs" for that. */
789 maintenance_check_symtabs (char *ignore
, int from_tty
)
791 struct program_space
*pspace
;
792 struct objfile
*objfile
;
795 ALL_PSPACE_OBJFILES (pspace
, objfile
)
797 struct symtab
*symtab
;
799 /* We don't want to print anything for this objfile until we
800 actually find something worth printing. */
801 int printed_objfile_start
= 0;
803 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
805 int found_something
= 0;
809 if (symtab
->blockvector
== NULL
)
811 /* Add more checks here. */
815 if (! printed_objfile_start
)
817 printf_filtered ("{ objfile %s ", objfile_name (objfile
));
819 printf_filtered ("((struct objfile *) %s)\n",
820 host_address_to_string (objfile
));
821 printed_objfile_start
= 1;
823 printf_filtered (" { symtab %s\n",
824 symtab_to_filename_for_display (symtab
));
825 if (symtab
->blockvector
== NULL
)
826 printf_filtered (" NULL blockvector\n");
827 printf_filtered (" }\n");
831 if (printed_objfile_start
)
832 printf_filtered ("}\n");
836 /* Helper function for maintenance_expand_symtabs.
837 This is the name_matcher function for expand_symtabs_matching. */
840 maintenance_expand_name_matcher (const char *symname
, void *data
)
842 /* Since we're not searching on symbols, just return TRUE. */
846 /* Helper function for maintenance_expand_symtabs.
847 This is the file_matcher function for expand_symtabs_matching. */
850 maintenance_expand_file_matcher (const char *filename
, void *data
,
853 const char *regexp
= data
;
857 /* KISS: Only apply the regexp to the complete file name. */
861 if (regexp
== NULL
|| re_exec (filename
))
867 /* Expand all symbol tables whose name matches an optional regexp. */
870 maintenance_expand_symtabs (char *args
, int from_tty
)
872 struct program_space
*pspace
;
873 struct objfile
*objfile
;
874 struct cleanup
*cleanups
;
878 /* We use buildargv here so that we handle spaces in the regexp
879 in a way that allows adding more arguments later. */
880 argv
= gdb_buildargv (args
);
881 cleanups
= make_cleanup_freeargv (argv
);
889 error (_("Extra arguments after regexp."));
897 ALL_PSPACE_OBJFILES (pspace
, objfile
)
901 objfile
->sf
->qf
->expand_symtabs_matching
902 (objfile
, maintenance_expand_file_matcher
,
903 maintenance_expand_name_matcher
, ALL_DOMAIN
, regexp
);
907 do_cleanups (cleanups
);
911 /* Return the nexting depth of a block within other blocks in its symtab. */
914 block_depth (struct block
*block
)
918 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
926 /* Do early runtime initializations. */
929 _initialize_symmisc (void)
935 add_cmd ("symbols", class_maintenance
, maintenance_print_symbols
, _("\
936 Print dump of current symbol definitions.\n\
937 Entries in the full symbol table are dumped to file OUTFILE.\n\
938 If a SOURCE file is specified, dump only that file's symbols."),
939 &maintenanceprintlist
);
941 add_cmd ("msymbols", class_maintenance
, maintenance_print_msymbols
, _("\
942 Print dump of current minimal symbol definitions.\n\
943 Entries in the minimal symbol table are dumped to file OUTFILE.\n\
944 If a SOURCE file is specified, dump only that file's minimal symbols."),
945 &maintenanceprintlist
);
947 add_cmd ("objfiles", class_maintenance
, maintenance_print_objfiles
,
948 _("Print dump of current object file definitions.\n\
949 With an argument REGEXP, list the object files with matching names."),
950 &maintenanceprintlist
);
952 add_cmd ("symtabs", class_maintenance
, maintenance_info_symtabs
, _("\
953 List the full symbol tables for all object files.\n\
954 This does not include information about individual symbols, blocks, or\n\
955 linetables --- just the symbol table structures themselves.\n\
956 With an argument REGEXP, list the symbol tables with matching names."),
957 &maintenanceinfolist
);
959 add_cmd ("check-symtabs", class_maintenance
, maintenance_check_symtabs
,
961 Check consistency of currently expanded symtabs."),
964 add_cmd ("expand-symtabs", class_maintenance
, maintenance_expand_symtabs
,
965 _("Expand symbol tables.\n\
966 With an argument REGEXP, only expand the symbol tables with matching names."),