1 /* Do various things to symbol tables (other than lookup), for GDB.
2 Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 1998
3 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 #include "breakpoint.h"
34 #include "gdb_string.h"
37 #define DEV_TTY "/dev/tty"
40 /* Unfortunately for debugging, stderr is usually a macro. This is painful
41 when calling functions that take FILE *'s from the debugger.
42 So we make a variable which has the same value and which is accessible when
43 debugging GDB with itself. Because stdin et al need not be constants,
44 we initialize them in the _initialize_symmisc function at the bottom
50 /* Prototypes for local functions */
52 static void dump_symtab PARAMS ((struct objfile *, struct symtab *,
55 static void dump_psymtab PARAMS ((struct objfile *, struct partial_symtab *,
58 static void dump_msymbols PARAMS ((struct objfile *, GDB_FILE *));
60 static void dump_objfile PARAMS ((struct objfile *));
62 static int block_depth PARAMS ((struct block *));
64 static void print_partial_symbols PARAMS ((struct partial_symbol **, int,
67 static void free_symtab_block PARAMS ((struct objfile *, struct block *));
69 void _initialize_symmisc PARAMS ((void));
71 struct print_symbol_args
73 struct symbol *symbol;
78 static int print_symbol PARAMS ((PTR));
81 free_symtab_block PARAMS ((struct objfile *, struct block *));
84 /* Free a struct block <- B and all the symbols defined in that block. */
87 free_symtab_block (objfile, b)
88 struct objfile *objfile;
93 for (i = 0; i < n; i++)
95 mfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
96 mfree (objfile->md, (PTR) BLOCK_SYM (b, i));
98 mfree (objfile->md, (PTR) b);
101 /* Free all the storage associated with the struct symtab <- S.
102 Note that some symtabs have contents malloc'ed structure by structure,
103 while some have contents that all live inside one big block of memory,
104 and some share the contents of another symbol table and so you should
105 not free the contents on their behalf (except sometimes the linetable,
106 which maybe per symtab even when the rest is not).
107 It is s->free_code that says which alternative to use. */
111 register struct symtab *s;
114 register struct blockvector *bv;
116 switch (s->free_code)
119 /* All the contents are part of a big block of memory (an obstack),
120 and some other symtab is in charge of freeing that block.
121 Therefore, do nothing. */
125 /* Here all the contents were malloc'ed structure by structure
126 and must be freed that way. */
127 /* First free the blocks (and their symbols. */
128 bv = BLOCKVECTOR (s);
129 n = BLOCKVECTOR_NBLOCKS (bv);
130 for (i = 0; i < n; i++)
131 free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i));
132 /* Free the blockvector itself. */
133 mfree (s->objfile->md, (PTR) bv);
134 /* Also free the linetable. */
137 /* Everything will be freed either by our `free_ptr'
138 or by some other symtab, except for our linetable.
141 mfree (s->objfile->md, (PTR) LINETABLE (s));
145 /* If there is a single block of memory to free, free it. */
146 if (s->free_ptr != NULL)
147 mfree (s->objfile->md, s->free_ptr);
149 /* Free source-related stuff */
150 if (s->line_charpos != NULL)
151 mfree (s->objfile->md, (PTR) s->line_charpos);
152 if (s->fullname != NULL)
153 mfree (s->objfile->md, s->fullname);
154 if (s->debugformat != NULL)
155 mfree (s->objfile->md, s->debugformat);
156 mfree (s->objfile->md, (PTR) s);
160 print_symbol_bcache_statistics ()
162 struct objfile *objfile;
165 ALL_OBJFILES (objfile)
167 printf_filtered ("Byte cache statistics for '%s':\n", objfile->name);
168 print_bcache_statistics (&objfile->psymbol_cache, "partial symbol cache");
174 print_objfile_statistics ()
176 struct objfile *objfile;
179 ALL_OBJFILES (objfile)
181 printf_filtered ("Statistics for '%s':\n", objfile->name);
182 if (OBJSTAT (objfile, n_stabs) > 0)
183 printf_filtered (" Number of \"stab\" symbols read: %d\n",
184 OBJSTAT (objfile, n_stabs));
185 if (OBJSTAT (objfile, n_minsyms) > 0)
186 printf_filtered (" Number of \"minimal\" symbols read: %d\n",
187 OBJSTAT (objfile, n_minsyms));
188 if (OBJSTAT (objfile, n_psyms) > 0)
189 printf_filtered (" Number of \"partial\" symbols read: %d\n",
190 OBJSTAT (objfile, n_psyms));
191 if (OBJSTAT (objfile, n_syms) > 0)
192 printf_filtered (" Number of \"full\" symbols read: %d\n",
193 OBJSTAT (objfile, n_syms));
194 if (OBJSTAT (objfile, n_types) > 0)
195 printf_filtered (" Number of \"types\" defined: %d\n",
196 OBJSTAT (objfile, n_types));
197 if (OBJSTAT (objfile, sz_strtab) > 0)
198 printf_filtered (" Space used by a.out string tables: %d\n",
199 OBJSTAT (objfile, sz_strtab));
200 printf_filtered (" Total memory used for psymbol obstack: %d\n",
201 obstack_memory_used (&objfile->psymbol_obstack));
202 printf_filtered (" Total memory used for psymbol cache: %d\n",
203 obstack_memory_used (&objfile->psymbol_cache.cache));
204 printf_filtered (" Total memory used for symbol obstack: %d\n",
205 obstack_memory_used (&objfile->symbol_obstack));
206 printf_filtered (" Total memory used for type obstack: %d\n",
207 obstack_memory_used (&objfile->type_obstack));
213 dump_objfile (objfile)
214 struct objfile *objfile;
216 struct symtab *symtab;
217 struct partial_symtab *psymtab;
219 printf_filtered ("\nObject file %s: ", objfile->name);
220 printf_filtered ("Objfile at ");
221 gdb_print_host_address (objfile, gdb_stdout);
222 printf_filtered (", bfd at ");
223 gdb_print_host_address (objfile->obfd, gdb_stdout);
224 printf_filtered (", %d minsyms\n\n",
225 objfile->minimal_symbol_count);
227 if (objfile->psymtabs)
229 printf_filtered ("Psymtabs:\n");
230 for (psymtab = objfile->psymtabs;
232 psymtab = psymtab->next)
234 printf_filtered ("%s at ",
236 gdb_print_host_address (psymtab, gdb_stdout);
237 printf_filtered (", ");
238 if (psymtab->objfile != objfile)
240 printf_filtered ("NOT ON CHAIN! ");
244 printf_filtered ("\n\n");
247 if (objfile->symtabs)
249 printf_filtered ("Symtabs:\n");
250 for (symtab = objfile->symtabs;
252 symtab = symtab->next)
254 printf_filtered ("%s at ", symtab->filename);
255 gdb_print_host_address (symtab, gdb_stdout);
256 printf_filtered (", ");
257 if (symtab->objfile != objfile)
259 printf_filtered ("NOT ON CHAIN! ");
263 printf_filtered ("\n\n");
267 /* Print minimal symbols from this objfile. */
270 dump_msymbols (objfile, outfile)
271 struct objfile *objfile;
274 struct minimal_symbol *msymbol;
278 fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name);
279 if (objfile->minimal_symbol_count == 0)
281 fprintf_filtered (outfile, "No minimal symbols found.\n");
284 for (index = 0, msymbol = objfile->msymbols;
285 SYMBOL_NAME (msymbol) != NULL; msymbol++, index++)
287 switch (msymbol->type)
295 case mst_solib_trampoline:
320 fprintf_filtered (outfile, "[%2d] %c ", index, ms_type);
321 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1, outfile);
322 fprintf_filtered (outfile, " %s", SYMBOL_NAME (msymbol));
323 if (SYMBOL_BFD_SECTION (msymbol))
324 fprintf_filtered (outfile, " section %s",
325 bfd_section_name (objfile->obfd,
326 SYMBOL_BFD_SECTION (msymbol)));
327 if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
329 fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
331 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
332 if (msymbol->filename)
333 fprintf_filtered (outfile, " %s", msymbol->filename);
335 fputs_filtered ("\n", outfile);
337 if (objfile->minimal_symbol_count != index)
339 warning ("internal error: minimal symbol count %d != %d",
340 objfile->minimal_symbol_count, index);
342 fprintf_filtered (outfile, "\n");
346 dump_psymtab (objfile, psymtab, outfile)
347 struct objfile *objfile;
348 struct partial_symtab *psymtab;
353 fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
355 fprintf_filtered (outfile, "(object ");
356 gdb_print_host_address (psymtab, outfile);
357 fprintf_filtered (outfile, ")\n\n");
358 fprintf_unfiltered (outfile, " Read from object file %s (",
360 gdb_print_host_address (objfile, outfile);
361 fprintf_unfiltered (outfile, ")\n");
365 fprintf_filtered (outfile,
366 " Full symtab was read (at ");
367 gdb_print_host_address (psymtab->symtab, outfile);
368 fprintf_filtered (outfile, " by function at ");
369 gdb_print_host_address ((PTR) psymtab->read_symtab, outfile);
370 fprintf_filtered (outfile, ")\n");
373 fprintf_filtered (outfile, " Relocate symbols by ");
374 for (i = 0; i < psymtab->objfile->num_sections; ++i)
377 fprintf_filtered (outfile, ", ");
379 print_address_numeric (ANOFFSET (psymtab->section_offsets, i),
383 fprintf_filtered (outfile, "\n");
385 fprintf_filtered (outfile, " Symbols cover text addresses ");
386 print_address_numeric (psymtab->textlow, 1, outfile);
387 fprintf_filtered (outfile, "-");
388 print_address_numeric (psymtab->texthigh, 1, outfile);
389 fprintf_filtered (outfile, "\n");
390 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
391 psymtab->number_of_dependencies);
392 for (i = 0; i < psymtab->number_of_dependencies; i++)
394 fprintf_filtered (outfile, " %d ", i);
395 gdb_print_host_address (psymtab->dependencies[i], outfile);
396 fprintf_filtered (outfile, " %s\n",
397 psymtab->dependencies[i]->filename);
399 if (psymtab->n_global_syms > 0)
401 print_partial_symbols (objfile->global_psymbols.list
402 + psymtab->globals_offset,
403 psymtab->n_global_syms, "Global", outfile);
405 if (psymtab->n_static_syms > 0)
407 print_partial_symbols (objfile->static_psymbols.list
408 + psymtab->statics_offset,
409 psymtab->n_static_syms, "Static", outfile);
411 fprintf_filtered (outfile, "\n");
415 dump_symtab (objfile, symtab, outfile)
416 struct objfile *objfile;
417 struct symtab *symtab;
422 register struct linetable *l;
423 struct blockvector *bv;
424 register struct block *b;
427 fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
429 fprintf_filtered (outfile, "Compilation directory is %s\n",
431 fprintf_filtered (outfile, "Read from object file %s (", objfile->name);
432 gdb_print_host_address (objfile, outfile);
433 fprintf_filtered (outfile, ")\n");
434 fprintf_filtered (outfile, "Language: %s\n", language_str (symtab->language));
436 /* First print the line table. */
437 l = LINETABLE (symtab);
440 fprintf_filtered (outfile, "\nLine table:\n\n");
442 for (i = 0; i < len; i++)
444 fprintf_filtered (outfile, " line %d at ", l->item[i].line);
445 print_address_numeric (l->item[i].pc, 1, outfile);
446 fprintf_filtered (outfile, "\n");
449 /* Now print the block info, but only for primary symtabs since we will
450 print lots of duplicate info otherwise. */
453 fprintf_filtered (outfile, "\nBlockvector:\n\n");
454 bv = BLOCKVECTOR (symtab);
455 len = BLOCKVECTOR_NBLOCKS (bv);
456 for (i = 0; i < len; i++)
458 b = BLOCKVECTOR_BLOCK (bv, i);
459 depth = block_depth (b) * 2;
460 print_spaces (depth, outfile);
461 fprintf_filtered (outfile, "block #%03d, object at ", i);
462 gdb_print_host_address (b, outfile);
463 if (BLOCK_SUPERBLOCK (b))
465 fprintf_filtered (outfile, " under ");
466 gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
468 blen = BLOCK_NSYMS (b);
469 fprintf_filtered (outfile, ", %d syms in ", blen);
470 print_address_numeric (BLOCK_START (b), 1, outfile);
471 fprintf_filtered (outfile, "..");
472 print_address_numeric (BLOCK_END (b), 1, outfile);
473 if (BLOCK_FUNCTION (b))
475 fprintf_filtered (outfile, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
476 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
478 fprintf_filtered (outfile, ", %s",
479 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)));
482 if (BLOCK_GCC_COMPILED (b))
483 fprintf_filtered (outfile, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b));
484 fprintf_filtered (outfile, "\n");
485 /* Now print each symbol in this block */
486 for (j = 0; j < blen; j++)
488 struct print_symbol_args s;
489 s.symbol = BLOCK_SYM (b, j);
492 catch_errors (print_symbol, &s, "Error printing symbol:\n",
496 fprintf_filtered (outfile, "\n");
500 fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n");
505 maintenance_print_symbols (args, from_tty)
511 struct cleanup *cleanups;
512 char *symname = NULL;
513 char *filename = DEV_TTY;
514 struct objfile *objfile;
522 Arguments missing: an output file name and an optional symbol file name");
524 else if ((argv = buildargv (args)) == NULL)
528 cleanups = make_cleanup_freeargv (argv);
533 /* If a second arg is supplied, it is a source file name to match on */
540 filename = tilde_expand (filename);
541 make_cleanup (free, filename);
543 outfile = gdb_fopen (filename, FOPEN_WT);
545 perror_with_name (filename);
546 make_cleanup ((make_cleanup_func) gdb_fclose, (char *) &outfile);
549 ALL_SYMTABS (objfile, s)
550 if (symname == NULL || (STREQ (symname, s->filename)))
551 dump_symtab (objfile, s, outfile);
553 do_cleanups (cleanups);
556 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
557 far to indent. ARGS is really a struct print_symbol_args *, but is
558 declared as char * to get it past catch_errors. Returns 0 for error,
565 struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
566 int depth = ((struct print_symbol_args *) args)->depth;
567 GDB_FILE *outfile = ((struct print_symbol_args *) args)->outfile;
569 print_spaces (depth, outfile);
570 if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
572 fprintf_filtered (outfile, "label %s at ", SYMBOL_SOURCE_NAME (symbol));
573 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
574 if (SYMBOL_BFD_SECTION (symbol))
575 fprintf_filtered (outfile, " section %s\n",
576 bfd_section_name (SYMBOL_BFD_SECTION (symbol)->owner,
577 SYMBOL_BFD_SECTION (symbol)));
579 fprintf_filtered (outfile, "\n");
582 if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE)
584 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol)))
586 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
590 fprintf_filtered (outfile, "%s %s = ",
591 (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM
593 : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
594 ? "struct" : "union")),
595 SYMBOL_NAME (symbol));
596 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
598 fprintf_filtered (outfile, ";\n");
602 if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
603 fprintf_filtered (outfile, "typedef ");
604 if (SYMBOL_TYPE (symbol))
606 /* Print details of types, except for enums where it's clutter. */
607 LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_SOURCE_NAME (symbol),
609 TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
611 fprintf_filtered (outfile, "; ");
614 fprintf_filtered (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol));
616 switch (SYMBOL_CLASS (symbol))
619 fprintf_filtered (outfile, "const %ld (0x%lx)",
620 SYMBOL_VALUE (symbol),
621 SYMBOL_VALUE (symbol));
624 case LOC_CONST_BYTES:
627 struct type *type = check_typedef (SYMBOL_TYPE (symbol));
628 fprintf_filtered (outfile, "const %u hex bytes:",
630 for (i = 0; i < TYPE_LENGTH (type); i++)
631 fprintf_filtered (outfile, " %02x",
632 (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);
637 fprintf_filtered (outfile, "static at ");
638 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
639 if (SYMBOL_BFD_SECTION (symbol))
640 fprintf_filtered (outfile, " section %s",
642 (SYMBOL_BFD_SECTION (symbol)->owner,
643 SYMBOL_BFD_SECTION (symbol)));
647 fprintf_filtered (outfile, "extern global at *(");
648 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
649 fprintf_filtered (outfile, "),");
653 fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol));
657 fprintf_filtered (outfile, "arg at offset 0x%lx",
658 SYMBOL_VALUE (symbol));
662 fprintf_filtered (outfile, "arg at offset 0x%lx from fp",
663 SYMBOL_VALUE (symbol));
667 fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol));
671 fprintf_filtered (outfile, "parameter register %ld", SYMBOL_VALUE (symbol));
674 case LOC_REGPARM_ADDR:
675 fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol));
679 fprintf_filtered (outfile, "local at offset 0x%lx",
680 SYMBOL_VALUE (symbol));
684 fprintf_filtered (outfile, "local at 0x%lx from register %d",
685 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
688 case LOC_BASEREG_ARG:
689 fprintf_filtered (outfile, "arg at 0x%lx from register %d",
690 SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol));
697 fprintf_filtered (outfile, "label at ");
698 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
699 if (SYMBOL_BFD_SECTION (symbol))
700 fprintf_filtered (outfile, " section %s",
702 (SYMBOL_BFD_SECTION (symbol)->owner,
703 SYMBOL_BFD_SECTION (symbol)));
707 fprintf_filtered (outfile, "block object ");
708 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile);
709 fprintf_filtered (outfile, ", ");
710 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)),
713 fprintf_filtered (outfile, "..");
714 print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol)),
717 if (SYMBOL_BFD_SECTION (symbol))
718 fprintf_filtered (outfile, " section %s",
720 (SYMBOL_BFD_SECTION (symbol)->owner,
721 SYMBOL_BFD_SECTION (symbol)));
725 fprintf_filtered (outfile, "unresolved");
728 case LOC_OPTIMIZED_OUT:
729 fprintf_filtered (outfile, "optimized out");
733 fprintf_filtered (outfile, "botched symbol class %x",
734 SYMBOL_CLASS (symbol));
738 fprintf_filtered (outfile, "\n");
743 maintenance_print_psymbols (args, from_tty)
749 struct cleanup *cleanups;
750 char *symname = NULL;
751 char *filename = DEV_TTY;
752 struct objfile *objfile;
753 struct partial_symtab *ps;
759 error ("print-psymbols takes an output file name and optional symbol file name");
761 else if ((argv = buildargv (args)) == NULL)
765 cleanups = make_cleanup_freeargv (argv);
770 /* If a second arg is supplied, it is a source file name to match on */
777 filename = tilde_expand (filename);
778 make_cleanup (free, filename);
780 outfile = gdb_fopen (filename, FOPEN_WT);
782 perror_with_name (filename);
783 make_cleanup ((make_cleanup_func) gdb_fclose, &outfile);
786 ALL_PSYMTABS (objfile, ps)
787 if (symname == NULL || (STREQ (symname, ps->filename)))
788 dump_psymtab (objfile, ps, outfile);
790 do_cleanups (cleanups);
794 print_partial_symbols (p, count, what, outfile)
795 struct partial_symbol **p;
800 fprintf_filtered (outfile, " %s partial symbols:\n", what);
803 fprintf_filtered (outfile, " `%s'", SYMBOL_NAME (*p));
804 if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
806 fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p));
808 fputs_filtered (", ", outfile);
809 switch (SYMBOL_NAMESPACE (*p))
811 case UNDEF_NAMESPACE:
812 fputs_filtered ("undefined namespace, ", outfile);
815 /* This is the usual thing -- don't print it */
817 case STRUCT_NAMESPACE:
818 fputs_filtered ("struct namespace, ", outfile);
820 case LABEL_NAMESPACE:
821 fputs_filtered ("label namespace, ", outfile);
824 fputs_filtered ("<invalid namespace>, ", outfile);
827 switch (SYMBOL_CLASS (*p))
830 fputs_filtered ("undefined", outfile);
833 fputs_filtered ("constant int", outfile);
836 fputs_filtered ("static", outfile);
839 fputs_filtered ("extern global", outfile);
842 fputs_filtered ("register", outfile);
845 fputs_filtered ("pass by value", outfile);
848 fputs_filtered ("pass by reference", outfile);
851 fputs_filtered ("register parameter", outfile);
853 case LOC_REGPARM_ADDR:
854 fputs_filtered ("register address parameter", outfile);
857 fputs_filtered ("stack parameter", outfile);
860 fputs_filtered ("type", outfile);
863 fputs_filtered ("label", outfile);
866 fputs_filtered ("function", outfile);
868 case LOC_CONST_BYTES:
869 fputs_filtered ("constant bytes", outfile);
872 fputs_filtered ("shuffled arg", outfile);
875 fputs_filtered ("unresolved", outfile);
877 case LOC_OPTIMIZED_OUT:
878 fputs_filtered ("optimized out", outfile);
881 fputs_filtered ("<invalid location>", outfile);
884 fputs_filtered (", ", outfile);
885 print_address_numeric (SYMBOL_VALUE_ADDRESS (*p), 1, outfile);
886 fprintf_filtered (outfile, "\n");
892 maintenance_print_msymbols (args, from_tty)
898 struct cleanup *cleanups;
899 char *filename = DEV_TTY;
900 char *symname = NULL;
901 struct objfile *objfile;
907 error ("print-msymbols takes an output file name and optional symbol file name");
909 else if ((argv = buildargv (args)) == NULL)
913 cleanups = make_cleanup_freeargv (argv);
918 /* If a second arg is supplied, it is a source file name to match on */
925 filename = tilde_expand (filename);
926 make_cleanup (free, filename);
928 outfile = gdb_fopen (filename, FOPEN_WT);
930 perror_with_name (filename);
931 make_cleanup ((make_cleanup_func) gdb_fclose, &outfile);
934 ALL_OBJFILES (objfile)
935 if (symname == NULL || (STREQ (symname, objfile->name)))
936 dump_msymbols (objfile, outfile);
938 fprintf_filtered (outfile, "\n\n");
939 do_cleanups (cleanups);
943 maintenance_print_objfiles (ignore, from_tty)
947 struct objfile *objfile;
952 ALL_OBJFILES (objfile)
953 dump_objfile (objfile);
957 /* Check consistency of psymtabs and symtabs. */
960 maintenance_check_symtabs (ignore, from_tty)
964 register struct symbol *sym;
965 register struct partial_symbol **psym;
966 register struct symtab *s = NULL;
967 register struct partial_symtab *ps;
968 struct blockvector *bv;
969 register struct objfile *objfile;
970 register struct block *b;
973 ALL_PSYMTABS (objfile, ps)
975 s = PSYMTAB_TO_SYMTAB (ps);
978 bv = BLOCKVECTOR (s);
979 b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
980 psym = ps->objfile->static_psymbols.list + ps->statics_offset;
981 length = ps->n_static_syms;
984 sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
985 SYMBOL_NAMESPACE (*psym));
988 printf_filtered ("Static symbol `");
989 puts_filtered (SYMBOL_NAME (*psym));
990 printf_filtered ("' only found in ");
991 puts_filtered (ps->filename);
992 printf_filtered (" psymtab\n");
996 b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
997 psym = ps->objfile->global_psymbols.list + ps->globals_offset;
998 length = ps->n_global_syms;
1001 sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
1002 SYMBOL_NAMESPACE (*psym));
1005 printf_filtered ("Global symbol `");
1006 puts_filtered (SYMBOL_NAME (*psym));
1007 printf_filtered ("' only found in ");
1008 puts_filtered (ps->filename);
1009 printf_filtered (" psymtab\n");
1013 if (ps->texthigh < ps->textlow)
1015 printf_filtered ("Psymtab ");
1016 puts_filtered (ps->filename);
1017 printf_filtered (" covers bad range ");
1018 print_address_numeric (ps->textlow, 1, gdb_stdout);
1019 printf_filtered (" - ");
1020 print_address_numeric (ps->texthigh, 1, gdb_stdout);
1021 printf_filtered ("\n");
1024 if (ps->texthigh == 0)
1026 if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b))
1028 printf_filtered ("Psymtab ");
1029 puts_filtered (ps->filename);
1030 printf_filtered (" covers ");
1031 print_address_numeric (ps->textlow, 1, gdb_stdout);
1032 printf_filtered (" - ");
1033 print_address_numeric (ps->texthigh, 1, gdb_stdout);
1034 printf_filtered (" but symtab covers only ");
1035 print_address_numeric (BLOCK_START (b), 1, gdb_stdout);
1036 printf_filtered (" - ");
1037 print_address_numeric (BLOCK_END (b), 1, gdb_stdout);
1038 printf_filtered ("\n");
1044 /* Return the nexting depth of a block within other blocks in its symtab. */
1048 struct block *block;
1051 while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
1059 /* Increase the space allocated for LISTP, which is probably
1060 global_psymbols or static_psymbols. This space will eventually
1061 be freed in free_objfile(). */
1064 extend_psymbol_list (listp, objfile)
1065 register struct psymbol_allocation_list *listp;
1066 struct objfile *objfile;
1069 if (listp->size == 0)
1072 listp->list = (struct partial_symbol **)
1073 xmmalloc (objfile->md, new_size * sizeof (struct partial_symbol *));
1077 new_size = listp->size * 2;
1078 listp->list = (struct partial_symbol **)
1079 xmrealloc (objfile->md, (char *) listp->list,
1080 new_size * sizeof (struct partial_symbol *));
1082 /* Next assumes we only went one over. Should be good if
1083 program works correctly */
1084 listp->next = listp->list + listp->size;
1085 listp->size = new_size;
1089 /* Do early runtime initializations. */
1091 _initialize_symmisc ()