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