1 /* Do various things to symbol tables (other than lookup), for GDB.
2 Copyright 1986, 1987, 1989, 1991-1996, 1998, 2000 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
27 #include "breakpoint.h"
33 #include "gdb_string.h"
36 #define DEV_TTY "/dev/tty"
39 /* Unfortunately for debugging, stderr is usually a macro. This is painful
40 when calling functions that take FILE *'s from the debugger.
41 So we make a variable which has the same value and which is accessible when
42 debugging GDB with itself. Because stdin et al need not be constants,
43 we initialize them in the _initialize_symmisc function at the bottom
49 /* Prototypes for local functions */
51 static void dump_symtab (struct objfile
*, struct symtab
*,
54 static void dump_psymtab (struct objfile
*, struct partial_symtab
*,
57 static void dump_msymbols (struct objfile
*, struct ui_file
*);
59 static void dump_objfile (struct objfile
*);
61 static int block_depth (struct block
*);
63 static void print_partial_symbols (struct partial_symbol
**, int,
64 char *, struct ui_file
*);
66 static void free_symtab_block (struct objfile
*, struct block
*);
68 void _initialize_symmisc (void);
70 struct print_symbol_args
72 struct symbol
*symbol
;
74 struct ui_file
*outfile
;
77 static int print_symbol (PTR
);
79 static void free_symtab_block (struct objfile
*, struct block
*);
82 /* Free a struct block <- B and all the symbols defined in that block. */
85 free_symtab_block (objfile
, b
)
86 struct objfile
*objfile
;
91 for (i
= 0; i
< n
; i
++)
93 mfree (objfile
->md
, SYMBOL_NAME (BLOCK_SYM (b
, i
)));
94 mfree (objfile
->md
, (PTR
) BLOCK_SYM (b
, i
));
96 mfree (objfile
->md
, (PTR
) b
);
99 /* Free all the storage associated with the struct symtab <- S.
100 Note that some symtabs have contents malloc'ed structure by structure,
101 while some have contents that all live inside one big block of memory,
102 and some share the contents of another symbol table and so you should
103 not free the contents on their behalf (except sometimes the linetable,
104 which maybe per symtab even when the rest is not).
105 It is s->free_code that says which alternative to use. */
109 register struct symtab
*s
;
112 register struct blockvector
*bv
;
114 switch (s
->free_code
)
117 /* All the contents are part of a big block of memory (an obstack),
118 and some other symtab is in charge of freeing that block.
119 Therefore, do nothing. */
123 /* Here all the contents were malloc'ed structure by structure
124 and must be freed that way. */
125 /* First free the blocks (and their symbols. */
126 bv
= BLOCKVECTOR (s
);
127 n
= BLOCKVECTOR_NBLOCKS (bv
);
128 for (i
= 0; i
< n
; i
++)
129 free_symtab_block (s
->objfile
, BLOCKVECTOR_BLOCK (bv
, i
));
130 /* Free the blockvector itself. */
131 mfree (s
->objfile
->md
, (PTR
) bv
);
132 /* Also free the linetable. */
135 /* Everything will be freed either by our `free_ptr'
136 or by some other symtab, except for our linetable.
139 mfree (s
->objfile
->md
, (PTR
) LINETABLE (s
));
143 /* If there is a single block of memory to free, free it. */
144 if (s
->free_ptr
!= NULL
)
145 mfree (s
->objfile
->md
, s
->free_ptr
);
147 /* Free source-related stuff */
148 if (s
->line_charpos
!= NULL
)
149 mfree (s
->objfile
->md
, (PTR
) s
->line_charpos
);
150 if (s
->fullname
!= NULL
)
151 mfree (s
->objfile
->md
, s
->fullname
);
152 if (s
->debugformat
!= NULL
)
153 mfree (s
->objfile
->md
, s
->debugformat
);
154 mfree (s
->objfile
->md
, (PTR
) s
);
158 print_symbol_bcache_statistics ()
160 struct objfile
*objfile
;
163 ALL_OBJFILES (objfile
)
165 printf_filtered ("Byte cache statistics for '%s':\n", objfile
->name
);
166 print_bcache_statistics (&objfile
->psymbol_cache
, "partial symbol cache");
172 print_objfile_statistics ()
174 struct objfile
*objfile
;
177 ALL_OBJFILES (objfile
)
179 printf_filtered ("Statistics for '%s':\n", objfile
->name
);
180 if (OBJSTAT (objfile
, n_stabs
) > 0)
181 printf_filtered (" Number of \"stab\" symbols read: %d\n",
182 OBJSTAT (objfile
, n_stabs
));
183 if (OBJSTAT (objfile
, n_minsyms
) > 0)
184 printf_filtered (" Number of \"minimal\" symbols read: %d\n",
185 OBJSTAT (objfile
, n_minsyms
));
186 if (OBJSTAT (objfile
, n_psyms
) > 0)
187 printf_filtered (" Number of \"partial\" symbols read: %d\n",
188 OBJSTAT (objfile
, n_psyms
));
189 if (OBJSTAT (objfile
, n_syms
) > 0)
190 printf_filtered (" Number of \"full\" symbols read: %d\n",
191 OBJSTAT (objfile
, n_syms
));
192 if (OBJSTAT (objfile
, n_types
) > 0)
193 printf_filtered (" Number of \"types\" defined: %d\n",
194 OBJSTAT (objfile
, n_types
));
195 if (OBJSTAT (objfile
, sz_strtab
) > 0)
196 printf_filtered (" Space used by a.out string tables: %d\n",
197 OBJSTAT (objfile
, sz_strtab
));
198 printf_filtered (" Total memory used for psymbol obstack: %d\n",
199 obstack_memory_used (&objfile
->psymbol_obstack
));
200 printf_filtered (" Total memory used for psymbol cache: %d\n",
201 obstack_memory_used (&objfile
->psymbol_cache
.cache
));
202 printf_filtered (" Total memory used for symbol obstack: %d\n",
203 obstack_memory_used (&objfile
->symbol_obstack
));
204 printf_filtered (" Total memory used for type obstack: %d\n",
205 obstack_memory_used (&objfile
->type_obstack
));
211 dump_objfile (objfile
)
212 struct objfile
*objfile
;
214 struct symtab
*symtab
;
215 struct partial_symtab
*psymtab
;
217 printf_filtered ("\nObject file %s: ", objfile
->name
);
218 printf_filtered ("Objfile at ");
219 gdb_print_host_address (objfile
, gdb_stdout
);
220 printf_filtered (", bfd at ");
221 gdb_print_host_address (objfile
->obfd
, gdb_stdout
);
222 printf_filtered (", %d minsyms\n\n",
223 objfile
->minimal_symbol_count
);
225 if (objfile
->psymtabs
)
227 printf_filtered ("Psymtabs:\n");
228 for (psymtab
= objfile
->psymtabs
;
230 psymtab
= psymtab
->next
)
232 printf_filtered ("%s at ",
234 gdb_print_host_address (psymtab
, gdb_stdout
);
235 printf_filtered (", ");
236 if (psymtab
->objfile
!= objfile
)
238 printf_filtered ("NOT ON CHAIN! ");
242 printf_filtered ("\n\n");
245 if (objfile
->symtabs
)
247 printf_filtered ("Symtabs:\n");
248 for (symtab
= objfile
->symtabs
;
250 symtab
= symtab
->next
)
252 printf_filtered ("%s at ", symtab
->filename
);
253 gdb_print_host_address (symtab
, gdb_stdout
);
254 printf_filtered (", ");
255 if (symtab
->objfile
!= objfile
)
257 printf_filtered ("NOT ON CHAIN! ");
261 printf_filtered ("\n\n");
265 /* Print minimal symbols from this objfile. */
268 dump_msymbols (objfile
, outfile
)
269 struct objfile
*objfile
;
270 struct ui_file
*outfile
;
272 struct minimal_symbol
*msymbol
;
276 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile
->name
);
277 if (objfile
->minimal_symbol_count
== 0)
279 fprintf_filtered (outfile
, "No minimal symbols found.\n");
282 for (index
= 0, msymbol
= objfile
->msymbols
;
283 SYMBOL_NAME (msymbol
) != NULL
; msymbol
++, index
++)
285 switch (msymbol
->type
)
293 case mst_solib_trampoline
:
318 fprintf_filtered (outfile
, "[%2d] %c ", index
, ms_type
);
319 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol
), 1, outfile
);
320 fprintf_filtered (outfile
, " %s", SYMBOL_NAME (msymbol
));
321 if (SYMBOL_BFD_SECTION (msymbol
))
322 fprintf_filtered (outfile
, " section %s",
323 bfd_section_name (objfile
->obfd
,
324 SYMBOL_BFD_SECTION (msymbol
)));
325 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
327 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
329 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
330 if (msymbol
->filename
)
331 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
333 fputs_filtered ("\n", outfile
);
335 if (objfile
->minimal_symbol_count
!= index
)
337 warning ("internal error: minimal symbol count %d != %d",
338 objfile
->minimal_symbol_count
, index
);
340 fprintf_filtered (outfile
, "\n");
344 dump_psymtab (objfile
, psymtab
, outfile
)
345 struct objfile
*objfile
;
346 struct partial_symtab
*psymtab
;
347 struct ui_file
*outfile
;
351 fprintf_filtered (outfile
, "\nPartial symtab for source file %s ",
353 fprintf_filtered (outfile
, "(object ");
354 gdb_print_host_address (psymtab
, outfile
);
355 fprintf_filtered (outfile
, ")\n\n");
356 fprintf_unfiltered (outfile
, " Read from object file %s (",
358 gdb_print_host_address (objfile
, outfile
);
359 fprintf_unfiltered (outfile
, ")\n");
363 fprintf_filtered (outfile
,
364 " Full symtab was read (at ");
365 gdb_print_host_address (psymtab
->symtab
, outfile
);
366 fprintf_filtered (outfile
, " by function at ");
367 gdb_print_host_address ((PTR
) psymtab
->read_symtab
, outfile
);
368 fprintf_filtered (outfile
, ")\n");
371 fprintf_filtered (outfile
, " Relocate symbols by ");
372 for (i
= 0; i
< psymtab
->objfile
->num_sections
; ++i
)
375 fprintf_filtered (outfile
, ", ");
377 print_address_numeric (ANOFFSET (psymtab
->section_offsets
, i
),
381 fprintf_filtered (outfile
, "\n");
383 fprintf_filtered (outfile
, " Symbols cover text addresses ");
384 print_address_numeric (psymtab
->textlow
, 1, outfile
);
385 fprintf_filtered (outfile
, "-");
386 print_address_numeric (psymtab
->texthigh
, 1, outfile
);
387 fprintf_filtered (outfile
, "\n");
388 fprintf_filtered (outfile
, " Depends on %d other partial symtabs.\n",
389 psymtab
->number_of_dependencies
);
390 for (i
= 0; i
< psymtab
->number_of_dependencies
; i
++)
392 fprintf_filtered (outfile
, " %d ", i
);
393 gdb_print_host_address (psymtab
->dependencies
[i
], outfile
);
394 fprintf_filtered (outfile
, " %s\n",
395 psymtab
->dependencies
[i
]->filename
);
397 if (psymtab
->n_global_syms
> 0)
399 print_partial_symbols (objfile
->global_psymbols
.list
400 + psymtab
->globals_offset
,
401 psymtab
->n_global_syms
, "Global", outfile
);
403 if (psymtab
->n_static_syms
> 0)
405 print_partial_symbols (objfile
->static_psymbols
.list
406 + psymtab
->statics_offset
,
407 psymtab
->n_static_syms
, "Static", outfile
);
409 fprintf_filtered (outfile
, "\n");
413 dump_symtab (objfile
, symtab
, outfile
)
414 struct objfile
*objfile
;
415 struct symtab
*symtab
;
416 struct ui_file
*outfile
;
420 register struct linetable
*l
;
421 struct blockvector
*bv
;
422 register struct block
*b
;
425 fprintf_filtered (outfile
, "\nSymtab for file %s\n", symtab
->filename
);
427 fprintf_filtered (outfile
, "Compilation directory is %s\n",
429 fprintf_filtered (outfile
, "Read from object file %s (", objfile
->name
);
430 gdb_print_host_address (objfile
, outfile
);
431 fprintf_filtered (outfile
, ")\n");
432 fprintf_filtered (outfile
, "Language: %s\n", language_str (symtab
->language
));
434 /* First print the line table. */
435 l
= LINETABLE (symtab
);
438 fprintf_filtered (outfile
, "\nLine table:\n\n");
440 for (i
= 0; i
< len
; i
++)
442 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
443 print_address_numeric (l
->item
[i
].pc
, 1, outfile
);
444 fprintf_filtered (outfile
, "\n");
447 /* Now print the block info, but only for primary symtabs since we will
448 print lots of duplicate info otherwise. */
451 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
452 bv
= BLOCKVECTOR (symtab
);
453 len
= BLOCKVECTOR_NBLOCKS (bv
);
454 for (i
= 0; i
< len
; i
++)
456 b
= BLOCKVECTOR_BLOCK (bv
, i
);
457 depth
= block_depth (b
) * 2;
458 print_spaces (depth
, outfile
);
459 fprintf_filtered (outfile
, "block #%03d, object at ", i
);
460 gdb_print_host_address (b
, outfile
);
461 if (BLOCK_SUPERBLOCK (b
))
463 fprintf_filtered (outfile
, " under ");
464 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
466 blen
= BLOCK_NSYMS (b
);
467 fprintf_filtered (outfile
, ", %d syms in ", blen
);
468 print_address_numeric (BLOCK_START (b
), 1, outfile
);
469 fprintf_filtered (outfile
, "..");
470 print_address_numeric (BLOCK_END (b
), 1, outfile
);
471 if (BLOCK_FUNCTION (b
))
473 fprintf_filtered (outfile
, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b
)));
474 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
476 fprintf_filtered (outfile
, ", %s",
477 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
480 if (BLOCK_GCC_COMPILED (b
))
481 fprintf_filtered (outfile
, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b
));
482 fprintf_filtered (outfile
, "\n");
483 /* Now print each symbol in this block */
484 for (j
= 0; j
< blen
; j
++)
486 struct print_symbol_args s
;
487 s
.symbol
= BLOCK_SYM (b
, j
);
490 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
494 fprintf_filtered (outfile
, "\n");
498 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
503 maintenance_print_symbols (args
, from_tty
)
508 struct ui_file
*outfile
;
509 struct cleanup
*cleanups
;
510 char *symname
= NULL
;
511 char *filename
= DEV_TTY
;
512 struct objfile
*objfile
;
520 Arguments missing: an output file name and an optional symbol file name");
522 else if ((argv
= buildargv (args
)) == NULL
)
526 cleanups
= make_cleanup_freeargv (argv
);
531 /* If a second arg is supplied, it is a source file name to match on */
538 filename
= tilde_expand (filename
);
539 make_cleanup (free
, filename
);
541 outfile
= gdb_fopen (filename
, FOPEN_WT
);
543 perror_with_name (filename
);
544 make_cleanup_ui_file_delete (outfile
);
547 ALL_SYMTABS (objfile
, s
)
548 if (symname
== NULL
|| (STREQ (symname
, s
->filename
)))
549 dump_symtab (objfile
, s
, outfile
);
551 do_cleanups (cleanups
);
554 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
555 far to indent. ARGS is really a struct print_symbol_args *, but is
556 declared as char * to get it past catch_errors. Returns 0 for error,
563 struct symbol
*symbol
= ((struct print_symbol_args
*) args
)->symbol
;
564 int depth
= ((struct print_symbol_args
*) args
)->depth
;
565 struct ui_file
*outfile
= ((struct print_symbol_args
*) args
)->outfile
;
567 print_spaces (depth
, outfile
);
568 if (SYMBOL_NAMESPACE (symbol
) == LABEL_NAMESPACE
)
570 fprintf_filtered (outfile
, "label %s at ", SYMBOL_SOURCE_NAME (symbol
));
571 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
572 if (SYMBOL_BFD_SECTION (symbol
))
573 fprintf_filtered (outfile
, " section %s\n",
574 bfd_section_name (SYMBOL_BFD_SECTION (symbol
)->owner
,
575 SYMBOL_BFD_SECTION (symbol
)));
577 fprintf_filtered (outfile
, "\n");
580 if (SYMBOL_NAMESPACE (symbol
) == STRUCT_NAMESPACE
)
582 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
584 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
588 fprintf_filtered (outfile
, "%s %s = ",
589 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
591 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
592 ? "struct" : "union")),
593 SYMBOL_NAME (symbol
));
594 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
596 fprintf_filtered (outfile
, ";\n");
600 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
601 fprintf_filtered (outfile
, "typedef ");
602 if (SYMBOL_TYPE (symbol
))
604 /* Print details of types, except for enums where it's clutter. */
605 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_SOURCE_NAME (symbol
),
607 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
609 fprintf_filtered (outfile
, "; ");
612 fprintf_filtered (outfile
, "%s ", SYMBOL_SOURCE_NAME (symbol
));
614 switch (SYMBOL_CLASS (symbol
))
617 fprintf_filtered (outfile
, "const %ld (0x%lx)",
618 SYMBOL_VALUE (symbol
),
619 SYMBOL_VALUE (symbol
));
622 case LOC_CONST_BYTES
:
625 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
626 fprintf_filtered (outfile
, "const %u hex bytes:",
628 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
629 fprintf_filtered (outfile
, " %02x",
630 (unsigned) SYMBOL_VALUE_BYTES (symbol
)[i
]);
635 fprintf_filtered (outfile
, "static at ");
636 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
637 if (SYMBOL_BFD_SECTION (symbol
))
638 fprintf_filtered (outfile
, " section %s",
640 (SYMBOL_BFD_SECTION (symbol
)->owner
,
641 SYMBOL_BFD_SECTION (symbol
)));
645 fprintf_filtered (outfile
, "extern global at *(");
646 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
647 fprintf_filtered (outfile
, "),");
651 fprintf_filtered (outfile
, "register %ld", SYMBOL_VALUE (symbol
));
655 fprintf_filtered (outfile
, "arg at offset 0x%lx",
656 SYMBOL_VALUE (symbol
));
660 fprintf_filtered (outfile
, "arg at offset 0x%lx from fp",
661 SYMBOL_VALUE (symbol
));
665 fprintf_filtered (outfile
, "reference arg at 0x%lx", SYMBOL_VALUE (symbol
));
669 fprintf_filtered (outfile
, "parameter register %ld", SYMBOL_VALUE (symbol
));
672 case LOC_REGPARM_ADDR
:
673 fprintf_filtered (outfile
, "address parameter register %ld", SYMBOL_VALUE (symbol
));
677 fprintf_filtered (outfile
, "local at offset 0x%lx",
678 SYMBOL_VALUE (symbol
));
682 fprintf_filtered (outfile
, "local at 0x%lx from register %d",
683 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
686 case LOC_BASEREG_ARG
:
687 fprintf_filtered (outfile
, "arg at 0x%lx from register %d",
688 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
695 fprintf_filtered (outfile
, "label at ");
696 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
697 if (SYMBOL_BFD_SECTION (symbol
))
698 fprintf_filtered (outfile
, " section %s",
700 (SYMBOL_BFD_SECTION (symbol
)->owner
,
701 SYMBOL_BFD_SECTION (symbol
)));
705 fprintf_filtered (outfile
, "block object ");
706 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
707 fprintf_filtered (outfile
, ", ");
708 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
)),
711 fprintf_filtered (outfile
, "..");
712 print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
)),
715 if (SYMBOL_BFD_SECTION (symbol
))
716 fprintf_filtered (outfile
, " section %s",
718 (SYMBOL_BFD_SECTION (symbol
)->owner
,
719 SYMBOL_BFD_SECTION (symbol
)));
723 fprintf_filtered (outfile
, "unresolved");
726 case LOC_OPTIMIZED_OUT
:
727 fprintf_filtered (outfile
, "optimized out");
731 fprintf_filtered (outfile
, "botched symbol class %x",
732 SYMBOL_CLASS (symbol
));
736 fprintf_filtered (outfile
, "\n");
741 maintenance_print_psymbols (args
, from_tty
)
746 struct ui_file
*outfile
;
747 struct cleanup
*cleanups
;
748 char *symname
= NULL
;
749 char *filename
= DEV_TTY
;
750 struct objfile
*objfile
;
751 struct partial_symtab
*ps
;
757 error ("print-psymbols takes an output file name and optional symbol file name");
759 else if ((argv
= buildargv (args
)) == NULL
)
763 cleanups
= make_cleanup_freeargv (argv
);
768 /* If a second arg is supplied, it is a source file name to match on */
775 filename
= tilde_expand (filename
);
776 make_cleanup (free
, filename
);
778 outfile
= gdb_fopen (filename
, FOPEN_WT
);
780 perror_with_name (filename
);
781 make_cleanup_ui_file_delete (outfile
);
784 ALL_PSYMTABS (objfile
, ps
)
785 if (symname
== NULL
|| (STREQ (symname
, ps
->filename
)))
786 dump_psymtab (objfile
, ps
, outfile
);
788 do_cleanups (cleanups
);
792 print_partial_symbols (p
, count
, what
, outfile
)
793 struct partial_symbol
**p
;
796 struct ui_file
*outfile
;
798 fprintf_filtered (outfile
, " %s partial symbols:\n", what
);
801 fprintf_filtered (outfile
, " `%s'", SYMBOL_NAME (*p
));
802 if (SYMBOL_DEMANGLED_NAME (*p
) != NULL
)
804 fprintf_filtered (outfile
, " `%s'", SYMBOL_DEMANGLED_NAME (*p
));
806 fputs_filtered (", ", outfile
);
807 switch (SYMBOL_NAMESPACE (*p
))
809 case UNDEF_NAMESPACE
:
810 fputs_filtered ("undefined namespace, ", outfile
);
813 /* This is the usual thing -- don't print it */
815 case STRUCT_NAMESPACE
:
816 fputs_filtered ("struct namespace, ", outfile
);
818 case LABEL_NAMESPACE
:
819 fputs_filtered ("label namespace, ", outfile
);
822 fputs_filtered ("<invalid namespace>, ", outfile
);
825 switch (SYMBOL_CLASS (*p
))
828 fputs_filtered ("undefined", outfile
);
831 fputs_filtered ("constant int", outfile
);
834 fputs_filtered ("static", outfile
);
837 fputs_filtered ("extern global", outfile
);
840 fputs_filtered ("register", outfile
);
843 fputs_filtered ("pass by value", outfile
);
846 fputs_filtered ("pass by reference", outfile
);
849 fputs_filtered ("register parameter", outfile
);
851 case LOC_REGPARM_ADDR
:
852 fputs_filtered ("register address parameter", outfile
);
855 fputs_filtered ("stack parameter", outfile
);
858 fputs_filtered ("type", outfile
);
861 fputs_filtered ("label", outfile
);
864 fputs_filtered ("function", outfile
);
866 case LOC_CONST_BYTES
:
867 fputs_filtered ("constant bytes", outfile
);
870 fputs_filtered ("shuffled arg", outfile
);
873 fputs_filtered ("unresolved", outfile
);
875 case LOC_OPTIMIZED_OUT
:
876 fputs_filtered ("optimized out", outfile
);
879 fputs_filtered ("<invalid location>", outfile
);
882 fputs_filtered (", ", outfile
);
883 print_address_numeric (SYMBOL_VALUE_ADDRESS (*p
), 1, outfile
);
884 fprintf_filtered (outfile
, "\n");
890 maintenance_print_msymbols (args
, from_tty
)
895 struct ui_file
*outfile
;
896 struct cleanup
*cleanups
;
897 char *filename
= DEV_TTY
;
898 char *symname
= NULL
;
899 struct objfile
*objfile
;
905 error ("print-msymbols takes an output file name and optional symbol file name");
907 else if ((argv
= buildargv (args
)) == NULL
)
911 cleanups
= make_cleanup_freeargv (argv
);
916 /* If a second arg is supplied, it is a source file name to match on */
923 filename
= tilde_expand (filename
);
924 make_cleanup (free
, filename
);
926 outfile
= gdb_fopen (filename
, FOPEN_WT
);
928 perror_with_name (filename
);
929 make_cleanup_ui_file_delete (outfile
);
932 ALL_OBJFILES (objfile
)
933 if (symname
== NULL
|| (STREQ (symname
, objfile
->name
)))
934 dump_msymbols (objfile
, outfile
);
936 fprintf_filtered (outfile
, "\n\n");
937 do_cleanups (cleanups
);
941 maintenance_print_objfiles (ignore
, from_tty
)
945 struct objfile
*objfile
;
950 ALL_OBJFILES (objfile
)
951 dump_objfile (objfile
);
955 /* Check consistency of psymtabs and symtabs. */
958 maintenance_check_symtabs (ignore
, from_tty
)
962 register struct symbol
*sym
;
963 register struct partial_symbol
**psym
;
964 register struct symtab
*s
= NULL
;
965 register struct partial_symtab
*ps
;
966 struct blockvector
*bv
;
967 register struct objfile
*objfile
;
968 register struct block
*b
;
971 ALL_PSYMTABS (objfile
, ps
)
973 s
= PSYMTAB_TO_SYMTAB (ps
);
976 bv
= BLOCKVECTOR (s
);
977 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
978 psym
= ps
->objfile
->static_psymbols
.list
+ ps
->statics_offset
;
979 length
= ps
->n_static_syms
;
982 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
983 SYMBOL_NAMESPACE (*psym
));
986 printf_filtered ("Static symbol `");
987 puts_filtered (SYMBOL_NAME (*psym
));
988 printf_filtered ("' only found in ");
989 puts_filtered (ps
->filename
);
990 printf_filtered (" psymtab\n");
994 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
995 psym
= ps
->objfile
->global_psymbols
.list
+ ps
->globals_offset
;
996 length
= ps
->n_global_syms
;
999 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
1000 SYMBOL_NAMESPACE (*psym
));
1003 printf_filtered ("Global symbol `");
1004 puts_filtered (SYMBOL_NAME (*psym
));
1005 printf_filtered ("' only found in ");
1006 puts_filtered (ps
->filename
);
1007 printf_filtered (" psymtab\n");
1011 if (ps
->texthigh
< ps
->textlow
)
1013 printf_filtered ("Psymtab ");
1014 puts_filtered (ps
->filename
);
1015 printf_filtered (" covers bad range ");
1016 print_address_numeric (ps
->textlow
, 1, gdb_stdout
);
1017 printf_filtered (" - ");
1018 print_address_numeric (ps
->texthigh
, 1, gdb_stdout
);
1019 printf_filtered ("\n");
1022 if (ps
->texthigh
== 0)
1024 if (ps
->textlow
< BLOCK_START (b
) || ps
->texthigh
> BLOCK_END (b
))
1026 printf_filtered ("Psymtab ");
1027 puts_filtered (ps
->filename
);
1028 printf_filtered (" covers ");
1029 print_address_numeric (ps
->textlow
, 1, gdb_stdout
);
1030 printf_filtered (" - ");
1031 print_address_numeric (ps
->texthigh
, 1, gdb_stdout
);
1032 printf_filtered (" but symtab covers only ");
1033 print_address_numeric (BLOCK_START (b
), 1, gdb_stdout
);
1034 printf_filtered (" - ");
1035 print_address_numeric (BLOCK_END (b
), 1, gdb_stdout
);
1036 printf_filtered ("\n");
1042 /* Return the nexting depth of a block within other blocks in its symtab. */
1046 struct block
*block
;
1049 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
1057 /* Increase the space allocated for LISTP, which is probably
1058 global_psymbols or static_psymbols. This space will eventually
1059 be freed in free_objfile(). */
1062 extend_psymbol_list (listp
, objfile
)
1063 register struct psymbol_allocation_list
*listp
;
1064 struct objfile
*objfile
;
1067 if (listp
->size
== 0)
1070 listp
->list
= (struct partial_symbol
**)
1071 xmmalloc (objfile
->md
, new_size
* sizeof (struct partial_symbol
*));
1075 new_size
= listp
->size
* 2;
1076 listp
->list
= (struct partial_symbol
**)
1077 xmrealloc (objfile
->md
, (char *) listp
->list
,
1078 new_size
* sizeof (struct partial_symbol
*));
1080 /* Next assumes we only went one over. Should be good if
1081 program works correctly */
1082 listp
->next
= listp
->list
+ listp
->size
;
1083 listp
->size
= new_size
;
1087 /* Do early runtime initializations. */
1089 _initialize_symmisc ()