* dwarf2read.c (macro_start_file): Update.
[deliverable/binutils-gdb.git] / gdb / symmisc.c
1 /* Do various things to symbol tables (other than lookup), for GDB.
2
3 Copyright (C) 1986-2000, 2002-2004, 2007-2012 Free Software
4 Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 #include "defs.h"
22 #include "symtab.h"
23 #include "gdbtypes.h"
24 #include "bfd.h"
25 #include "filenames.h"
26 #include "symfile.h"
27 #include "objfiles.h"
28 #include "breakpoint.h"
29 #include "command.h"
30 #include "gdb_obstack.h"
31 #include "exceptions.h"
32 #include "language.h"
33 #include "bcache.h"
34 #include "block.h"
35 #include "gdb_regex.h"
36 #include "gdb_stat.h"
37 #include "dictionary.h"
38
39 #include "gdb_string.h"
40 #include "readline/readline.h"
41
42 #include "psymtab.h"
43
44 #ifndef DEV_TTY
45 #define DEV_TTY "/dev/tty"
46 #endif
47
48 /* Unfortunately for debugging, stderr is usually a macro. This is painful
49 when calling functions that take FILE *'s from the debugger.
50 So we make a variable which has the same value and which is accessible when
51 debugging GDB with itself. Because stdin et al need not be constants,
52 we initialize them in the _initialize_symmisc function at the bottom
53 of the file. */
54 FILE *std_in;
55 FILE *std_out;
56 FILE *std_err;
57
58 /* Prototypes for local functions */
59
60 static void dump_symtab (struct objfile *, struct symtab *,
61 struct ui_file *);
62
63 static void dump_msymbols (struct objfile *, struct ui_file *);
64
65 static void dump_objfile (struct objfile *);
66
67 static int block_depth (struct block *);
68
69 void _initialize_symmisc (void);
70
71 struct print_symbol_args
72 {
73 struct gdbarch *gdbarch;
74 struct symbol *symbol;
75 int depth;
76 struct ui_file *outfile;
77 };
78
79 static int print_symbol (void *);
80 \f
81
82 void
83 print_symbol_bcache_statistics (void)
84 {
85 struct program_space *pspace;
86 struct objfile *objfile;
87
88 ALL_PSPACES (pspace)
89 ALL_PSPACE_OBJFILES (pspace, objfile)
90 {
91 QUIT;
92 printf_filtered (_("Byte cache statistics for '%s':\n"), objfile->name);
93 print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
94 "partial symbol cache");
95 print_bcache_statistics (objfile->per_bfd->macro_cache,
96 "preprocessor macro cache");
97 print_bcache_statistics (objfile->per_bfd->filename_cache,
98 "file name cache");
99 }
100 }
101
102 void
103 print_objfile_statistics (void)
104 {
105 struct program_space *pspace;
106 struct objfile *objfile;
107 struct symtab *s;
108 int i, linetables, blockvectors;
109
110 ALL_PSPACES (pspace)
111 ALL_PSPACE_OBJFILES (pspace, objfile)
112 {
113 QUIT;
114 printf_filtered (_("Statistics for '%s':\n"), objfile->name);
115 if (OBJSTAT (objfile, n_stabs) > 0)
116 printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
117 OBJSTAT (objfile, n_stabs));
118 if (OBJSTAT (objfile, n_minsyms) > 0)
119 printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
120 OBJSTAT (objfile, n_minsyms));
121 if (OBJSTAT (objfile, n_psyms) > 0)
122 printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
123 OBJSTAT (objfile, n_psyms));
124 if (OBJSTAT (objfile, n_syms) > 0)
125 printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
126 OBJSTAT (objfile, n_syms));
127 if (OBJSTAT (objfile, n_types) > 0)
128 printf_filtered (_(" Number of \"types\" defined: %d\n"),
129 OBJSTAT (objfile, n_types));
130 if (objfile->sf)
131 objfile->sf->qf->print_stats (objfile);
132 i = linetables = blockvectors = 0;
133 ALL_OBJFILE_SYMTABS (objfile, s)
134 {
135 i++;
136 if (s->linetable != NULL)
137 linetables++;
138 if (s->primary == 1)
139 blockvectors++;
140 }
141 printf_filtered (_(" Number of symbol tables: %d\n"), i);
142 printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
143 linetables);
144 printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
145 blockvectors);
146
147 if (OBJSTAT (objfile, sz_strtab) > 0)
148 printf_filtered (_(" Space used by a.out string tables: %d\n"),
149 OBJSTAT (objfile, sz_strtab));
150 printf_filtered (_(" Total memory used for objfile obstack: %d\n"),
151 obstack_memory_used (&objfile->objfile_obstack));
152 printf_filtered (_(" Total memory used for BFD obstack: %d\n"),
153 obstack_memory_used (&objfile->per_bfd->storage_obstack));
154 printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
155 bcache_memory_used (psymbol_bcache_get_bcache
156 (objfile->psymbol_cache)));
157 printf_filtered (_(" Total memory used for macro cache: %d\n"),
158 bcache_memory_used (objfile->per_bfd->macro_cache));
159 printf_filtered (_(" Total memory used for file name cache: %d\n"),
160 bcache_memory_used (objfile->per_bfd->filename_cache));
161 }
162 }
163
164 static void
165 dump_objfile (struct objfile *objfile)
166 {
167 struct symtab *symtab;
168
169 printf_filtered ("\nObject file %s: ", objfile->name);
170 printf_filtered ("Objfile at ");
171 gdb_print_host_address (objfile, gdb_stdout);
172 printf_filtered (", bfd at ");
173 gdb_print_host_address (objfile->obfd, gdb_stdout);
174 printf_filtered (", %d minsyms\n\n",
175 objfile->minimal_symbol_count);
176
177 if (objfile->sf)
178 objfile->sf->qf->dump (objfile);
179
180 if (objfile->symtabs)
181 {
182 printf_filtered ("Symtabs:\n");
183 for (symtab = objfile->symtabs;
184 symtab != NULL;
185 symtab = symtab->next)
186 {
187 printf_filtered ("%s at ", symtab->filename);
188 gdb_print_host_address (symtab, gdb_stdout);
189 printf_filtered (", ");
190 if (symtab->objfile != objfile)
191 {
192 printf_filtered ("NOT ON CHAIN! ");
193 }
194 wrap_here (" ");
195 }
196 printf_filtered ("\n\n");
197 }
198 }
199
200 /* Print minimal symbols from this objfile. */
201
202 static void
203 dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
204 {
205 struct gdbarch *gdbarch = get_objfile_arch (objfile);
206 struct minimal_symbol *msymbol;
207 int index;
208 char ms_type;
209
210 fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name);
211 if (objfile->minimal_symbol_count == 0)
212 {
213 fprintf_filtered (outfile, "No minimal symbols found.\n");
214 return;
215 }
216 index = 0;
217 ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
218 {
219 struct obj_section *section = SYMBOL_OBJ_SECTION (msymbol);
220
221 switch (MSYMBOL_TYPE (msymbol))
222 {
223 case mst_unknown:
224 ms_type = 'u';
225 break;
226 case mst_text:
227 ms_type = 'T';
228 break;
229 case mst_text_gnu_ifunc:
230 ms_type = 'i';
231 break;
232 case mst_solib_trampoline:
233 ms_type = 'S';
234 break;
235 case mst_data:
236 ms_type = 'D';
237 break;
238 case mst_bss:
239 ms_type = 'B';
240 break;
241 case mst_abs:
242 ms_type = 'A';
243 break;
244 case mst_file_text:
245 ms_type = 't';
246 break;
247 case mst_file_data:
248 ms_type = 'd';
249 break;
250 case mst_file_bss:
251 ms_type = 'b';
252 break;
253 default:
254 ms_type = '?';
255 break;
256 }
257 fprintf_filtered (outfile, "[%2d] %c ", index, ms_type);
258 fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msymbol)),
259 outfile);
260 fprintf_filtered (outfile, " %s", SYMBOL_LINKAGE_NAME (msymbol));
261 if (section)
262 fprintf_filtered (outfile, " section %s",
263 bfd_section_name (objfile->obfd,
264 section->the_bfd_section));
265 if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
266 {
267 fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
268 }
269 if (msymbol->filename)
270 fprintf_filtered (outfile, " %s", msymbol->filename);
271 fputs_filtered ("\n", outfile);
272 index++;
273 }
274 if (objfile->minimal_symbol_count != index)
275 {
276 warning (_("internal error: minimal symbol count %d != %d"),
277 objfile->minimal_symbol_count, index);
278 }
279 fprintf_filtered (outfile, "\n");
280 }
281
282 static void
283 dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
284 struct ui_file *outfile)
285 {
286 struct gdbarch *gdbarch = get_objfile_arch (objfile);
287 int i;
288 struct dict_iterator iter;
289 int len;
290 struct linetable *l;
291 struct blockvector *bv;
292 struct symbol *sym;
293 struct block *b;
294 int depth;
295
296 fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
297 if (symtab->dirname)
298 fprintf_filtered (outfile, "Compilation directory is %s\n",
299 symtab->dirname);
300 fprintf_filtered (outfile, "Read from object file %s (", objfile->name);
301 gdb_print_host_address (objfile, outfile);
302 fprintf_filtered (outfile, ")\n");
303 fprintf_filtered (outfile, "Language: %s\n",
304 language_str (symtab->language));
305
306 /* First print the line table. */
307 l = LINETABLE (symtab);
308 if (l)
309 {
310 fprintf_filtered (outfile, "\nLine table:\n\n");
311 len = l->nitems;
312 for (i = 0; i < len; i++)
313 {
314 fprintf_filtered (outfile, " line %d at ", l->item[i].line);
315 fputs_filtered (paddress (gdbarch, l->item[i].pc), outfile);
316 fprintf_filtered (outfile, "\n");
317 }
318 }
319 /* Now print the block info, but only for primary symtabs since we will
320 print lots of duplicate info otherwise. */
321 if (symtab->primary)
322 {
323 fprintf_filtered (outfile, "\nBlockvector:\n\n");
324 bv = BLOCKVECTOR (symtab);
325 len = BLOCKVECTOR_NBLOCKS (bv);
326 for (i = 0; i < len; i++)
327 {
328 b = BLOCKVECTOR_BLOCK (bv, i);
329 depth = block_depth (b) * 2;
330 print_spaces (depth, outfile);
331 fprintf_filtered (outfile, "block #%03d, object at ", i);
332 gdb_print_host_address (b, outfile);
333 if (BLOCK_SUPERBLOCK (b))
334 {
335 fprintf_filtered (outfile, " under ");
336 gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
337 }
338 /* drow/2002-07-10: We could save the total symbols count
339 even if we're using a hashtable, but nothing else but this message
340 wants it. */
341 fprintf_filtered (outfile, ", %d syms/buckets in ",
342 dict_size (BLOCK_DICT (b)));
343 fputs_filtered (paddress (gdbarch, BLOCK_START (b)), outfile);
344 fprintf_filtered (outfile, "..");
345 fputs_filtered (paddress (gdbarch, BLOCK_END (b)), outfile);
346 if (BLOCK_FUNCTION (b))
347 {
348 fprintf_filtered (outfile, ", function %s",
349 SYMBOL_LINKAGE_NAME (BLOCK_FUNCTION (b)));
350 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
351 {
352 fprintf_filtered (outfile, ", %s",
353 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
354 }
355 }
356 fprintf_filtered (outfile, "\n");
357 /* Now print each symbol in this block (in no particular order, if
358 we're using a hashtable). Note that we only want this
359 block, not any blocks from included symtabs. */
360 ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
361 {
362 struct print_symbol_args s;
363
364 s.gdbarch = gdbarch;
365 s.symbol = sym;
366 s.depth = depth + 1;
367 s.outfile = outfile;
368 catch_errors (print_symbol, &s, "Error printing symbol:\n",
369 RETURN_MASK_ERROR);
370 }
371 }
372 fprintf_filtered (outfile, "\n");
373 }
374 else
375 {
376 fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n");
377 }
378 }
379
380 static void
381 dump_symtab (struct objfile *objfile, struct symtab *symtab,
382 struct ui_file *outfile)
383 {
384 /* Set the current language to the language of the symtab we're dumping
385 because certain routines used during dump_symtab() use the current
386 language to print an image of the symbol. We'll restore it later.
387 But use only real languages, not placeholders. */
388 if (symtab->language != language_unknown
389 && symtab->language != language_auto)
390 {
391 enum language saved_lang;
392
393 saved_lang = set_language (symtab->language);
394
395 dump_symtab_1 (objfile, symtab, outfile);
396
397 set_language (saved_lang);
398 }
399 else
400 dump_symtab_1 (objfile, symtab, outfile);
401 }
402
403 void
404 maintenance_print_symbols (char *args, int from_tty)
405 {
406 char **argv;
407 struct ui_file *outfile;
408 struct cleanup *cleanups;
409 char *symname = NULL;
410 char *filename = DEV_TTY;
411 struct objfile *objfile;
412 struct symtab *s;
413
414 dont_repeat ();
415
416 if (args == NULL)
417 {
418 error (_("Arguments missing: an output file name "
419 "and an optional symbol file name"));
420 }
421 argv = gdb_buildargv (args);
422 cleanups = make_cleanup_freeargv (argv);
423
424 if (argv[0] != NULL)
425 {
426 filename = argv[0];
427 /* If a second arg is supplied, it is a source file name to match on. */
428 if (argv[1] != NULL)
429 {
430 symname = argv[1];
431 }
432 }
433
434 filename = tilde_expand (filename);
435 make_cleanup (xfree, filename);
436
437 outfile = gdb_fopen (filename, FOPEN_WT);
438 if (outfile == 0)
439 perror_with_name (filename);
440 make_cleanup_ui_file_delete (outfile);
441
442 ALL_SYMTABS (objfile, s)
443 {
444 QUIT;
445 if (symname == NULL || filename_cmp (symname, s->filename) == 0)
446 dump_symtab (objfile, s, outfile);
447 }
448 do_cleanups (cleanups);
449 }
450
451 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
452 far to indent. ARGS is really a struct print_symbol_args *, but is
453 declared as char * to get it past catch_errors. Returns 0 for error,
454 1 for success. */
455
456 static int
457 print_symbol (void *args)
458 {
459 struct gdbarch *gdbarch = ((struct print_symbol_args *) args)->gdbarch;
460 struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
461 int depth = ((struct print_symbol_args *) args)->depth;
462 struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile;
463 struct obj_section *section = SYMBOL_OBJ_SECTION (symbol);
464
465 print_spaces (depth, outfile);
466 if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
467 {
468 fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol));
469 fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
470 outfile);
471 if (section)
472 fprintf_filtered (outfile, " section %s\n",
473 bfd_section_name (section->the_bfd_section->owner,
474 section->the_bfd_section));
475 else
476 fprintf_filtered (outfile, "\n");
477 return 1;
478 }
479 if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
480 {
481 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol)))
482 {
483 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
484 }
485 else
486 {
487 fprintf_filtered (outfile, "%s %s = ",
488 (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
489 ? "enum"
490 : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
491 ? "struct" : "union")),
492 SYMBOL_LINKAGE_NAME (symbol));
493 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
494 }
495 fprintf_filtered (outfile, ";\n");
496 }
497 else
498 {
499 if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
500 fprintf_filtered (outfile, "typedef ");
501 if (SYMBOL_TYPE (symbol))
502 {
503 /* Print details of types, except for enums where it's clutter. */
504 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol),
505 outfile,
506 TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
507 depth);
508 fprintf_filtered (outfile, "; ");
509 }
510 else
511 fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol));
512
513 switch (SYMBOL_CLASS (symbol))
514 {
515 case LOC_CONST:
516 fprintf_filtered (outfile, "const %s (%s)",
517 plongest (SYMBOL_VALUE (symbol)),
518 hex_string (SYMBOL_VALUE (symbol)));
519 break;
520
521 case LOC_CONST_BYTES:
522 {
523 unsigned i;
524 struct type *type = check_typedef (SYMBOL_TYPE (symbol));
525
526 fprintf_filtered (outfile, "const %u hex bytes:",
527 TYPE_LENGTH (type));
528 for (i = 0; i < TYPE_LENGTH (type); i++)
529 fprintf_filtered (outfile, " %02x",
530 (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);
531 }
532 break;
533
534 case LOC_STATIC:
535 fprintf_filtered (outfile, "static at ");
536 fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
537 outfile);
538 if (section)
539 fprintf_filtered (outfile, " section %s",
540 bfd_section_name (section->the_bfd_section->owner,
541 section->the_bfd_section));
542 break;
543
544 case LOC_REGISTER:
545 if (SYMBOL_IS_ARGUMENT (symbol))
546 fprintf_filtered (outfile, "parameter register %s",
547 plongest (SYMBOL_VALUE (symbol)));
548 else
549 fprintf_filtered (outfile, "register %s",
550 plongest (SYMBOL_VALUE (symbol)));
551 break;
552
553 case LOC_ARG:
554 fprintf_filtered (outfile, "arg at offset %s",
555 hex_string (SYMBOL_VALUE (symbol)));
556 break;
557
558 case LOC_REF_ARG:
559 fprintf_filtered (outfile, "reference arg at %s",
560 hex_string (SYMBOL_VALUE (symbol)));
561 break;
562
563 case LOC_REGPARM_ADDR:
564 fprintf_filtered (outfile, "address parameter register %s",
565 plongest (SYMBOL_VALUE (symbol)));
566 break;
567
568 case LOC_LOCAL:
569 fprintf_filtered (outfile, "local at offset %s",
570 hex_string (SYMBOL_VALUE (symbol)));
571 break;
572
573 case LOC_TYPEDEF:
574 break;
575
576 case LOC_LABEL:
577 fprintf_filtered (outfile, "label at ");
578 fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
579 outfile);
580 if (section)
581 fprintf_filtered (outfile, " section %s",
582 bfd_section_name (section->the_bfd_section->owner,
583 section->the_bfd_section));
584 break;
585
586 case LOC_BLOCK:
587 fprintf_filtered (outfile, "block object ");
588 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile);
589 fprintf_filtered (outfile, ", ");
590 fputs_filtered (paddress (gdbarch,
591 BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))),
592 outfile);
593 fprintf_filtered (outfile, "..");
594 fputs_filtered (paddress (gdbarch,
595 BLOCK_END (SYMBOL_BLOCK_VALUE (symbol))),
596 outfile);
597 if (section)
598 fprintf_filtered (outfile, " section %s",
599 bfd_section_name (section->the_bfd_section->owner,
600 section->the_bfd_section));
601 break;
602
603 case LOC_COMPUTED:
604 fprintf_filtered (outfile, "computed at runtime");
605 break;
606
607 case LOC_UNRESOLVED:
608 fprintf_filtered (outfile, "unresolved");
609 break;
610
611 case LOC_OPTIMIZED_OUT:
612 fprintf_filtered (outfile, "optimized out");
613 break;
614
615 default:
616 fprintf_filtered (outfile, "botched symbol class %x",
617 SYMBOL_CLASS (symbol));
618 break;
619 }
620 }
621 fprintf_filtered (outfile, "\n");
622 return 1;
623 }
624
625 void
626 maintenance_print_msymbols (char *args, int from_tty)
627 {
628 char **argv;
629 struct ui_file *outfile;
630 struct cleanup *cleanups;
631 char *filename = DEV_TTY;
632 char *symname = NULL;
633 struct program_space *pspace;
634 struct objfile *objfile;
635
636 struct stat sym_st, obj_st;
637
638 dont_repeat ();
639
640 if (args == NULL)
641 {
642 error (_("print-msymbols takes an output file "
643 "name and optional symbol file name"));
644 }
645 argv = gdb_buildargv (args);
646 cleanups = make_cleanup_freeargv (argv);
647
648 if (argv[0] != NULL)
649 {
650 filename = argv[0];
651 /* If a second arg is supplied, it is a source file name to match on. */
652 if (argv[1] != NULL)
653 {
654 symname = xfullpath (argv[1]);
655 make_cleanup (xfree, symname);
656 if (symname && stat (symname, &sym_st))
657 perror_with_name (symname);
658 }
659 }
660
661 filename = tilde_expand (filename);
662 make_cleanup (xfree, filename);
663
664 outfile = gdb_fopen (filename, FOPEN_WT);
665 if (outfile == 0)
666 perror_with_name (filename);
667 make_cleanup_ui_file_delete (outfile);
668
669 ALL_PSPACES (pspace)
670 ALL_PSPACE_OBJFILES (pspace, objfile)
671 {
672 QUIT;
673 if (symname == NULL || (!stat (objfile->name, &obj_st)
674 && sym_st.st_ino == obj_st.st_ino))
675 dump_msymbols (objfile, outfile);
676 }
677 fprintf_filtered (outfile, "\n\n");
678 do_cleanups (cleanups);
679 }
680
681 void
682 maintenance_print_objfiles (char *ignore, int from_tty)
683 {
684 struct program_space *pspace;
685 struct objfile *objfile;
686
687 dont_repeat ();
688
689 ALL_PSPACES (pspace)
690 ALL_PSPACE_OBJFILES (pspace, objfile)
691 {
692 QUIT;
693 dump_objfile (objfile);
694 }
695 }
696
697
698 /* List all the symbol tables whose names match REGEXP (optional). */
699 void
700 maintenance_info_symtabs (char *regexp, int from_tty)
701 {
702 struct program_space *pspace;
703 struct objfile *objfile;
704
705 if (regexp)
706 re_comp (regexp);
707
708 ALL_PSPACES (pspace)
709 ALL_PSPACE_OBJFILES (pspace, objfile)
710 {
711 struct symtab *symtab;
712
713 /* We don't want to print anything for this objfile until we
714 actually find a symtab whose name matches. */
715 int printed_objfile_start = 0;
716
717 ALL_OBJFILE_SYMTABS (objfile, symtab)
718 {
719 QUIT;
720
721 if (! regexp
722 || re_exec (symtab->filename))
723 {
724 if (! printed_objfile_start)
725 {
726 printf_filtered ("{ objfile %s ", objfile->name);
727 wrap_here (" ");
728 printf_filtered ("((struct objfile *) %s)\n",
729 host_address_to_string (objfile));
730 printed_objfile_start = 1;
731 }
732
733 printf_filtered (" { symtab %s ", symtab->filename);
734 wrap_here (" ");
735 printf_filtered ("((struct symtab *) %s)\n",
736 host_address_to_string (symtab));
737 printf_filtered (" dirname %s\n",
738 symtab->dirname ? symtab->dirname : "(null)");
739 printf_filtered (" fullname %s\n",
740 symtab->fullname ? symtab->fullname : "(null)");
741 printf_filtered (" "
742 "blockvector ((struct blockvector *) %s)%s\n",
743 host_address_to_string (symtab->blockvector),
744 symtab->primary ? " (primary)" : "");
745 printf_filtered (" "
746 "linetable ((struct linetable *) %s)\n",
747 host_address_to_string (symtab->linetable));
748 printf_filtered (" debugformat %s\n",
749 symtab->debugformat);
750 printf_filtered (" }\n");
751 }
752 }
753
754 if (printed_objfile_start)
755 printf_filtered ("}\n");
756 }
757 }
758 \f
759
760 /* Return the nexting depth of a block within other blocks in its symtab. */
761
762 static int
763 block_depth (struct block *block)
764 {
765 int i = 0;
766
767 while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
768 {
769 i++;
770 }
771 return i;
772 }
773 \f
774
775 /* Do early runtime initializations. */
776 void
777 _initialize_symmisc (void)
778 {
779 std_in = stdin;
780 std_out = stdout;
781 std_err = stderr;
782 }
This page took 0.050228 seconds and 5 git commands to generate.