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
PARAMS ((struct objfile
*));
61 static int block_depth
PARAMS ((struct block
*));
63 static void print_partial_symbols (struct partial_symbol
**, int,
64 char *, struct ui_file
*);
66 static void free_symtab_block
PARAMS ((struct objfile
*, struct block
*));
68 void _initialize_symmisc
PARAMS ((void));
70 struct print_symbol_args
72 struct symbol
*symbol
;
74 struct ui_file
*outfile
;
77 static int print_symbol
PARAMS ((PTR
));
80 free_symtab_block
PARAMS ((struct objfile
*, struct block
*));
83 /* Free a struct block <- B and all the symbols defined in that block. */
86 free_symtab_block (objfile
, b
)
87 struct objfile
*objfile
;
92 for (i
= 0; i
< n
; i
++)
94 mfree (objfile
->md
, SYMBOL_NAME (BLOCK_SYM (b
, i
)));
95 mfree (objfile
->md
, (PTR
) BLOCK_SYM (b
, i
));
97 mfree (objfile
->md
, (PTR
) b
);
100 /* Free all the storage associated with the struct symtab <- S.
101 Note that some symtabs have contents malloc'ed structure by structure,
102 while some have contents that all live inside one big block of memory,
103 and some share the contents of another symbol table and so you should
104 not free the contents on their behalf (except sometimes the linetable,
105 which maybe per symtab even when the rest is not).
106 It is s->free_code that says which alternative to use. */
110 register struct symtab
*s
;
113 register struct blockvector
*bv
;
115 switch (s
->free_code
)
118 /* All the contents are part of a big block of memory (an obstack),
119 and some other symtab is in charge of freeing that block.
120 Therefore, do nothing. */
124 /* Here all the contents were malloc'ed structure by structure
125 and must be freed that way. */
126 /* First free the blocks (and their symbols. */
127 bv
= BLOCKVECTOR (s
);
128 n
= BLOCKVECTOR_NBLOCKS (bv
);
129 for (i
= 0; i
< n
; i
++)
130 free_symtab_block (s
->objfile
, BLOCKVECTOR_BLOCK (bv
, i
));
131 /* Free the blockvector itself. */
132 mfree (s
->objfile
->md
, (PTR
) bv
);
133 /* Also free the linetable. */
136 /* Everything will be freed either by our `free_ptr'
137 or by some other symtab, except for our linetable.
140 mfree (s
->objfile
->md
, (PTR
) LINETABLE (s
));
144 /* If there is a single block of memory to free, free it. */
145 if (s
->free_ptr
!= NULL
)
146 mfree (s
->objfile
->md
, s
->free_ptr
);
148 /* Free source-related stuff */
149 if (s
->line_charpos
!= NULL
)
150 mfree (s
->objfile
->md
, (PTR
) s
->line_charpos
);
151 if (s
->fullname
!= NULL
)
152 mfree (s
->objfile
->md
, s
->fullname
);
153 if (s
->debugformat
!= NULL
)
154 mfree (s
->objfile
->md
, s
->debugformat
);
155 mfree (s
->objfile
->md
, (PTR
) s
);
159 print_symbol_bcache_statistics ()
161 struct objfile
*objfile
;
164 ALL_OBJFILES (objfile
)
166 printf_filtered ("Byte cache statistics for '%s':\n", objfile
->name
);
167 print_bcache_statistics (&objfile
->psymbol_cache
, "partial symbol cache");
173 print_objfile_statistics ()
175 struct objfile
*objfile
;
178 ALL_OBJFILES (objfile
)
180 printf_filtered ("Statistics for '%s':\n", objfile
->name
);
181 if (OBJSTAT (objfile
, n_stabs
) > 0)
182 printf_filtered (" Number of \"stab\" symbols read: %d\n",
183 OBJSTAT (objfile
, n_stabs
));
184 if (OBJSTAT (objfile
, n_minsyms
) > 0)
185 printf_filtered (" Number of \"minimal\" symbols read: %d\n",
186 OBJSTAT (objfile
, n_minsyms
));
187 if (OBJSTAT (objfile
, n_psyms
) > 0)
188 printf_filtered (" Number of \"partial\" symbols read: %d\n",
189 OBJSTAT (objfile
, n_psyms
));
190 if (OBJSTAT (objfile
, n_syms
) > 0)
191 printf_filtered (" Number of \"full\" symbols read: %d\n",
192 OBJSTAT (objfile
, n_syms
));
193 if (OBJSTAT (objfile
, n_types
) > 0)
194 printf_filtered (" Number of \"types\" defined: %d\n",
195 OBJSTAT (objfile
, n_types
));
196 if (OBJSTAT (objfile
, sz_strtab
) > 0)
197 printf_filtered (" Space used by a.out string tables: %d\n",
198 OBJSTAT (objfile
, sz_strtab
));
199 printf_filtered (" Total memory used for psymbol obstack: %d\n",
200 obstack_memory_used (&objfile
->psymbol_obstack
));
201 printf_filtered (" Total memory used for psymbol cache: %d\n",
202 obstack_memory_used (&objfile
->psymbol_cache
.cache
));
203 printf_filtered (" Total memory used for symbol obstack: %d\n",
204 obstack_memory_used (&objfile
->symbol_obstack
));
205 printf_filtered (" Total memory used for type obstack: %d\n",
206 obstack_memory_used (&objfile
->type_obstack
));
212 dump_objfile (objfile
)
213 struct objfile
*objfile
;
215 struct symtab
*symtab
;
216 struct partial_symtab
*psymtab
;
218 printf_filtered ("\nObject file %s: ", objfile
->name
);
219 printf_filtered ("Objfile at ");
220 gdb_print_host_address (objfile
, gdb_stdout
);
221 printf_filtered (", bfd at ");
222 gdb_print_host_address (objfile
->obfd
, gdb_stdout
);
223 printf_filtered (", %d minsyms\n\n",
224 objfile
->minimal_symbol_count
);
226 if (objfile
->psymtabs
)
228 printf_filtered ("Psymtabs:\n");
229 for (psymtab
= objfile
->psymtabs
;
231 psymtab
= psymtab
->next
)
233 printf_filtered ("%s at ",
235 gdb_print_host_address (psymtab
, gdb_stdout
);
236 printf_filtered (", ");
237 if (psymtab
->objfile
!= objfile
)
239 printf_filtered ("NOT ON CHAIN! ");
243 printf_filtered ("\n\n");
246 if (objfile
->symtabs
)
248 printf_filtered ("Symtabs:\n");
249 for (symtab
= objfile
->symtabs
;
251 symtab
= symtab
->next
)
253 printf_filtered ("%s at ", symtab
->filename
);
254 gdb_print_host_address (symtab
, gdb_stdout
);
255 printf_filtered (", ");
256 if (symtab
->objfile
!= objfile
)
258 printf_filtered ("NOT ON CHAIN! ");
262 printf_filtered ("\n\n");
266 /* Print minimal symbols from this objfile. */
269 dump_msymbols (objfile
, outfile
)
270 struct objfile
*objfile
;
271 struct ui_file
*outfile
;
273 struct minimal_symbol
*msymbol
;
277 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile
->name
);
278 if (objfile
->minimal_symbol_count
== 0)
280 fprintf_filtered (outfile
, "No minimal symbols found.\n");
283 for (index
= 0, msymbol
= objfile
->msymbols
;
284 SYMBOL_NAME (msymbol
) != NULL
; msymbol
++, index
++)
286 switch (msymbol
->type
)
294 case mst_solib_trampoline
:
319 fprintf_filtered (outfile
, "[%2d] %c ", index
, ms_type
);
320 print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol
), 1, outfile
);
321 fprintf_filtered (outfile
, " %s", SYMBOL_NAME (msymbol
));
322 if (SYMBOL_BFD_SECTION (msymbol
))
323 fprintf_filtered (outfile
, " section %s",
324 bfd_section_name (objfile
->obfd
,
325 SYMBOL_BFD_SECTION (msymbol
)));
326 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
328 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
330 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
331 if (msymbol
->filename
)
332 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
334 fputs_filtered ("\n", outfile
);
336 if (objfile
->minimal_symbol_count
!= index
)
338 warning ("internal error: minimal symbol count %d != %d",
339 objfile
->minimal_symbol_count
, index
);
341 fprintf_filtered (outfile
, "\n");
345 dump_psymtab (objfile
, psymtab
, outfile
)
346 struct objfile
*objfile
;
347 struct partial_symtab
*psymtab
;
348 struct ui_file
*outfile
;
352 fprintf_filtered (outfile
, "\nPartial symtab for source file %s ",
354 fprintf_filtered (outfile
, "(object ");
355 gdb_print_host_address (psymtab
, outfile
);
356 fprintf_filtered (outfile
, ")\n\n");
357 fprintf_unfiltered (outfile
, " Read from object file %s (",
359 gdb_print_host_address (objfile
, outfile
);
360 fprintf_unfiltered (outfile
, ")\n");
364 fprintf_filtered (outfile
,
365 " Full symtab was read (at ");
366 gdb_print_host_address (psymtab
->symtab
, outfile
);
367 fprintf_filtered (outfile
, " by function at ");
368 gdb_print_host_address ((PTR
) psymtab
->read_symtab
, outfile
);
369 fprintf_filtered (outfile
, ")\n");
372 fprintf_filtered (outfile
, " Relocate symbols by ");
373 for (i
= 0; i
< psymtab
->objfile
->num_sections
; ++i
)
376 fprintf_filtered (outfile
, ", ");
378 print_address_numeric (ANOFFSET (psymtab
->section_offsets
, i
),
382 fprintf_filtered (outfile
, "\n");
384 fprintf_filtered (outfile
, " Symbols cover text addresses ");
385 print_address_numeric (psymtab
->textlow
, 1, outfile
);
386 fprintf_filtered (outfile
, "-");
387 print_address_numeric (psymtab
->texthigh
, 1, outfile
);
388 fprintf_filtered (outfile
, "\n");
389 fprintf_filtered (outfile
, " Depends on %d other partial symtabs.\n",
390 psymtab
->number_of_dependencies
);
391 for (i
= 0; i
< psymtab
->number_of_dependencies
; i
++)
393 fprintf_filtered (outfile
, " %d ", i
);
394 gdb_print_host_address (psymtab
->dependencies
[i
], outfile
);
395 fprintf_filtered (outfile
, " %s\n",
396 psymtab
->dependencies
[i
]->filename
);
398 if (psymtab
->n_global_syms
> 0)
400 print_partial_symbols (objfile
->global_psymbols
.list
401 + psymtab
->globals_offset
,
402 psymtab
->n_global_syms
, "Global", outfile
);
404 if (psymtab
->n_static_syms
> 0)
406 print_partial_symbols (objfile
->static_psymbols
.list
407 + psymtab
->statics_offset
,
408 psymtab
->n_static_syms
, "Static", outfile
);
410 fprintf_filtered (outfile
, "\n");
414 dump_symtab (objfile
, symtab
, outfile
)
415 struct objfile
*objfile
;
416 struct symtab
*symtab
;
417 struct ui_file
*outfile
;
421 register struct linetable
*l
;
422 struct blockvector
*bv
;
423 register struct block
*b
;
426 fprintf_filtered (outfile
, "\nSymtab for file %s\n", symtab
->filename
);
428 fprintf_filtered (outfile
, "Compilation directory is %s\n",
430 fprintf_filtered (outfile
, "Read from object file %s (", objfile
->name
);
431 gdb_print_host_address (objfile
, outfile
);
432 fprintf_filtered (outfile
, ")\n");
433 fprintf_filtered (outfile
, "Language: %s\n", language_str (symtab
->language
));
435 /* First print the line table. */
436 l
= LINETABLE (symtab
);
439 fprintf_filtered (outfile
, "\nLine table:\n\n");
441 for (i
= 0; i
< len
; i
++)
443 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
444 print_address_numeric (l
->item
[i
].pc
, 1, outfile
);
445 fprintf_filtered (outfile
, "\n");
448 /* Now print the block info, but only for primary symtabs since we will
449 print lots of duplicate info otherwise. */
452 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
453 bv
= BLOCKVECTOR (symtab
);
454 len
= BLOCKVECTOR_NBLOCKS (bv
);
455 for (i
= 0; i
< len
; i
++)
457 b
= BLOCKVECTOR_BLOCK (bv
, i
);
458 depth
= block_depth (b
) * 2;
459 print_spaces (depth
, outfile
);
460 fprintf_filtered (outfile
, "block #%03d, object at ", i
);
461 gdb_print_host_address (b
, outfile
);
462 if (BLOCK_SUPERBLOCK (b
))
464 fprintf_filtered (outfile
, " under ");
465 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
467 blen
= BLOCK_NSYMS (b
);
468 fprintf_filtered (outfile
, ", %d syms in ", blen
);
469 print_address_numeric (BLOCK_START (b
), 1, outfile
);
470 fprintf_filtered (outfile
, "..");
471 print_address_numeric (BLOCK_END (b
), 1, outfile
);
472 if (BLOCK_FUNCTION (b
))
474 fprintf_filtered (outfile
, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b
)));
475 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
477 fprintf_filtered (outfile
, ", %s",
478 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
481 if (BLOCK_GCC_COMPILED (b
))
482 fprintf_filtered (outfile
, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b
));
483 fprintf_filtered (outfile
, "\n");
484 /* Now print each symbol in this block */
485 for (j
= 0; j
< blen
; j
++)
487 struct print_symbol_args s
;
488 s
.symbol
= BLOCK_SYM (b
, j
);
491 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
495 fprintf_filtered (outfile
, "\n");
499 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
504 maintenance_print_symbols (args
, from_tty
)
509 struct ui_file
*outfile
;
510 struct cleanup
*cleanups
;
511 char *symname
= NULL
;
512 char *filename
= DEV_TTY
;
513 struct objfile
*objfile
;
521 Arguments missing: an output file name and an optional symbol file name");
523 else if ((argv
= buildargv (args
)) == NULL
)
527 cleanups
= make_cleanup_freeargv (argv
);
532 /* If a second arg is supplied, it is a source file name to match on */
539 filename
= tilde_expand (filename
);
540 make_cleanup (free
, filename
);
542 outfile
= gdb_fopen (filename
, FOPEN_WT
);
544 perror_with_name (filename
);
545 make_cleanup_ui_file_delete (outfile
);
548 ALL_SYMTABS (objfile
, s
)
549 if (symname
== NULL
|| (STREQ (symname
, s
->filename
)))
550 dump_symtab (objfile
, s
, outfile
);
552 do_cleanups (cleanups
);
555 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
556 far to indent. ARGS is really a struct print_symbol_args *, but is
557 declared as char * to get it past catch_errors. Returns 0 for error,
564 struct symbol
*symbol
= ((struct print_symbol_args
*) args
)->symbol
;
565 int depth
= ((struct print_symbol_args
*) args
)->depth
;
566 struct ui_file
*outfile
= ((struct print_symbol_args
*) args
)->outfile
;
568 print_spaces (depth
, outfile
);
569 if (SYMBOL_NAMESPACE (symbol
) == LABEL_NAMESPACE
)
571 fprintf_filtered (outfile
, "label %s at ", SYMBOL_SOURCE_NAME (symbol
));
572 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
573 if (SYMBOL_BFD_SECTION (symbol
))
574 fprintf_filtered (outfile
, " section %s\n",
575 bfd_section_name (SYMBOL_BFD_SECTION (symbol
)->owner
,
576 SYMBOL_BFD_SECTION (symbol
)));
578 fprintf_filtered (outfile
, "\n");
581 if (SYMBOL_NAMESPACE (symbol
) == STRUCT_NAMESPACE
)
583 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
585 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
589 fprintf_filtered (outfile
, "%s %s = ",
590 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
592 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
593 ? "struct" : "union")),
594 SYMBOL_NAME (symbol
));
595 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
597 fprintf_filtered (outfile
, ";\n");
601 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
602 fprintf_filtered (outfile
, "typedef ");
603 if (SYMBOL_TYPE (symbol
))
605 /* Print details of types, except for enums where it's clutter. */
606 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_SOURCE_NAME (symbol
),
608 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
610 fprintf_filtered (outfile
, "; ");
613 fprintf_filtered (outfile
, "%s ", SYMBOL_SOURCE_NAME (symbol
));
615 switch (SYMBOL_CLASS (symbol
))
618 fprintf_filtered (outfile
, "const %ld (0x%lx)",
619 SYMBOL_VALUE (symbol
),
620 SYMBOL_VALUE (symbol
));
623 case LOC_CONST_BYTES
:
626 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
627 fprintf_filtered (outfile
, "const %u hex bytes:",
629 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
630 fprintf_filtered (outfile
, " %02x",
631 (unsigned) SYMBOL_VALUE_BYTES (symbol
)[i
]);
636 fprintf_filtered (outfile
, "static at ");
637 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
638 if (SYMBOL_BFD_SECTION (symbol
))
639 fprintf_filtered (outfile
, " section %s",
641 (SYMBOL_BFD_SECTION (symbol
)->owner
,
642 SYMBOL_BFD_SECTION (symbol
)));
646 fprintf_filtered (outfile
, "extern global at *(");
647 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
648 fprintf_filtered (outfile
, "),");
652 fprintf_filtered (outfile
, "register %ld", SYMBOL_VALUE (symbol
));
656 fprintf_filtered (outfile
, "arg at offset 0x%lx",
657 SYMBOL_VALUE (symbol
));
661 fprintf_filtered (outfile
, "arg at offset 0x%lx from fp",
662 SYMBOL_VALUE (symbol
));
666 fprintf_filtered (outfile
, "reference arg at 0x%lx", SYMBOL_VALUE (symbol
));
670 fprintf_filtered (outfile
, "parameter register %ld", SYMBOL_VALUE (symbol
));
673 case LOC_REGPARM_ADDR
:
674 fprintf_filtered (outfile
, "address parameter register %ld", SYMBOL_VALUE (symbol
));
678 fprintf_filtered (outfile
, "local at offset 0x%lx",
679 SYMBOL_VALUE (symbol
));
683 fprintf_filtered (outfile
, "local at 0x%lx from register %d",
684 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
687 case LOC_BASEREG_ARG
:
688 fprintf_filtered (outfile
, "arg at 0x%lx from register %d",
689 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
696 fprintf_filtered (outfile
, "label at ");
697 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
698 if (SYMBOL_BFD_SECTION (symbol
))
699 fprintf_filtered (outfile
, " section %s",
701 (SYMBOL_BFD_SECTION (symbol
)->owner
,
702 SYMBOL_BFD_SECTION (symbol
)));
706 fprintf_filtered (outfile
, "block object ");
707 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
708 fprintf_filtered (outfile
, ", ");
709 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
)),
712 fprintf_filtered (outfile
, "..");
713 print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
)),
716 if (SYMBOL_BFD_SECTION (symbol
))
717 fprintf_filtered (outfile
, " section %s",
719 (SYMBOL_BFD_SECTION (symbol
)->owner
,
720 SYMBOL_BFD_SECTION (symbol
)));
724 fprintf_filtered (outfile
, "unresolved");
727 case LOC_OPTIMIZED_OUT
:
728 fprintf_filtered (outfile
, "optimized out");
732 fprintf_filtered (outfile
, "botched symbol class %x",
733 SYMBOL_CLASS (symbol
));
737 fprintf_filtered (outfile
, "\n");
742 maintenance_print_psymbols (args
, from_tty
)
747 struct ui_file
*outfile
;
748 struct cleanup
*cleanups
;
749 char *symname
= NULL
;
750 char *filename
= DEV_TTY
;
751 struct objfile
*objfile
;
752 struct partial_symtab
*ps
;
758 error ("print-psymbols takes an output file name and optional symbol file name");
760 else if ((argv
= buildargv (args
)) == NULL
)
764 cleanups
= make_cleanup_freeargv (argv
);
769 /* If a second arg is supplied, it is a source file name to match on */
776 filename
= tilde_expand (filename
);
777 make_cleanup (free
, filename
);
779 outfile
= gdb_fopen (filename
, FOPEN_WT
);
781 perror_with_name (filename
);
782 make_cleanup_ui_file_delete (outfile
);
785 ALL_PSYMTABS (objfile
, ps
)
786 if (symname
== NULL
|| (STREQ (symname
, ps
->filename
)))
787 dump_psymtab (objfile
, ps
, outfile
);
789 do_cleanups (cleanups
);
793 print_partial_symbols (p
, count
, what
, outfile
)
794 struct partial_symbol
**p
;
797 struct ui_file
*outfile
;
799 fprintf_filtered (outfile
, " %s partial symbols:\n", what
);
802 fprintf_filtered (outfile
, " `%s'", SYMBOL_NAME (*p
));
803 if (SYMBOL_DEMANGLED_NAME (*p
) != NULL
)
805 fprintf_filtered (outfile
, " `%s'", SYMBOL_DEMANGLED_NAME (*p
));
807 fputs_filtered (", ", outfile
);
808 switch (SYMBOL_NAMESPACE (*p
))
810 case UNDEF_NAMESPACE
:
811 fputs_filtered ("undefined namespace, ", outfile
);
814 /* This is the usual thing -- don't print it */
816 case STRUCT_NAMESPACE
:
817 fputs_filtered ("struct namespace, ", outfile
);
819 case LABEL_NAMESPACE
:
820 fputs_filtered ("label namespace, ", outfile
);
823 fputs_filtered ("<invalid namespace>, ", outfile
);
826 switch (SYMBOL_CLASS (*p
))
829 fputs_filtered ("undefined", outfile
);
832 fputs_filtered ("constant int", outfile
);
835 fputs_filtered ("static", outfile
);
838 fputs_filtered ("extern global", outfile
);
841 fputs_filtered ("register", outfile
);
844 fputs_filtered ("pass by value", outfile
);
847 fputs_filtered ("pass by reference", outfile
);
850 fputs_filtered ("register parameter", outfile
);
852 case LOC_REGPARM_ADDR
:
853 fputs_filtered ("register address parameter", outfile
);
856 fputs_filtered ("stack parameter", outfile
);
859 fputs_filtered ("type", outfile
);
862 fputs_filtered ("label", outfile
);
865 fputs_filtered ("function", outfile
);
867 case LOC_CONST_BYTES
:
868 fputs_filtered ("constant bytes", outfile
);
871 fputs_filtered ("shuffled arg", outfile
);
874 fputs_filtered ("unresolved", outfile
);
876 case LOC_OPTIMIZED_OUT
:
877 fputs_filtered ("optimized out", outfile
);
880 fputs_filtered ("<invalid location>", outfile
);
883 fputs_filtered (", ", outfile
);
884 print_address_numeric (SYMBOL_VALUE_ADDRESS (*p
), 1, outfile
);
885 fprintf_filtered (outfile
, "\n");
891 maintenance_print_msymbols (args
, from_tty
)
896 struct ui_file
*outfile
;
897 struct cleanup
*cleanups
;
898 char *filename
= DEV_TTY
;
899 char *symname
= NULL
;
900 struct objfile
*objfile
;
906 error ("print-msymbols takes an output file name and optional symbol file name");
908 else if ((argv
= buildargv (args
)) == NULL
)
912 cleanups
= make_cleanup_freeargv (argv
);
917 /* If a second arg is supplied, it is a source file name to match on */
924 filename
= tilde_expand (filename
);
925 make_cleanup (free
, filename
);
927 outfile
= gdb_fopen (filename
, FOPEN_WT
);
929 perror_with_name (filename
);
930 make_cleanup_ui_file_delete (outfile
);
933 ALL_OBJFILES (objfile
)
934 if (symname
== NULL
|| (STREQ (symname
, objfile
->name
)))
935 dump_msymbols (objfile
, outfile
);
937 fprintf_filtered (outfile
, "\n\n");
938 do_cleanups (cleanups
);
942 maintenance_print_objfiles (ignore
, from_tty
)
946 struct objfile
*objfile
;
951 ALL_OBJFILES (objfile
)
952 dump_objfile (objfile
);
956 /* Check consistency of psymtabs and symtabs. */
959 maintenance_check_symtabs (ignore
, from_tty
)
963 register struct symbol
*sym
;
964 register struct partial_symbol
**psym
;
965 register struct symtab
*s
= NULL
;
966 register struct partial_symtab
*ps
;
967 struct blockvector
*bv
;
968 register struct objfile
*objfile
;
969 register struct block
*b
;
972 ALL_PSYMTABS (objfile
, ps
)
974 s
= PSYMTAB_TO_SYMTAB (ps
);
977 bv
= BLOCKVECTOR (s
);
978 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
979 psym
= ps
->objfile
->static_psymbols
.list
+ ps
->statics_offset
;
980 length
= ps
->n_static_syms
;
983 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
984 SYMBOL_NAMESPACE (*psym
));
987 printf_filtered ("Static symbol `");
988 puts_filtered (SYMBOL_NAME (*psym
));
989 printf_filtered ("' only found in ");
990 puts_filtered (ps
->filename
);
991 printf_filtered (" psymtab\n");
995 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
996 psym
= ps
->objfile
->global_psymbols
.list
+ ps
->globals_offset
;
997 length
= ps
->n_global_syms
;
1000 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
1001 SYMBOL_NAMESPACE (*psym
));
1004 printf_filtered ("Global symbol `");
1005 puts_filtered (SYMBOL_NAME (*psym
));
1006 printf_filtered ("' only found in ");
1007 puts_filtered (ps
->filename
);
1008 printf_filtered (" psymtab\n");
1012 if (ps
->texthigh
< ps
->textlow
)
1014 printf_filtered ("Psymtab ");
1015 puts_filtered (ps
->filename
);
1016 printf_filtered (" covers bad range ");
1017 print_address_numeric (ps
->textlow
, 1, gdb_stdout
);
1018 printf_filtered (" - ");
1019 print_address_numeric (ps
->texthigh
, 1, gdb_stdout
);
1020 printf_filtered ("\n");
1023 if (ps
->texthigh
== 0)
1025 if (ps
->textlow
< BLOCK_START (b
) || ps
->texthigh
> BLOCK_END (b
))
1027 printf_filtered ("Psymtab ");
1028 puts_filtered (ps
->filename
);
1029 printf_filtered (" covers ");
1030 print_address_numeric (ps
->textlow
, 1, gdb_stdout
);
1031 printf_filtered (" - ");
1032 print_address_numeric (ps
->texthigh
, 1, gdb_stdout
);
1033 printf_filtered (" but symtab covers only ");
1034 print_address_numeric (BLOCK_START (b
), 1, gdb_stdout
);
1035 printf_filtered (" - ");
1036 print_address_numeric (BLOCK_END (b
), 1, gdb_stdout
);
1037 printf_filtered ("\n");
1043 /* Return the nexting depth of a block within other blocks in its symtab. */
1047 struct block
*block
;
1050 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
1058 /* Increase the space allocated for LISTP, which is probably
1059 global_psymbols or static_psymbols. This space will eventually
1060 be freed in free_objfile(). */
1063 extend_psymbol_list (listp
, objfile
)
1064 register struct psymbol_allocation_list
*listp
;
1065 struct objfile
*objfile
;
1068 if (listp
->size
== 0)
1071 listp
->list
= (struct partial_symbol
**)
1072 xmmalloc (objfile
->md
, new_size
* sizeof (struct partial_symbol
*));
1076 new_size
= listp
->size
* 2;
1077 listp
->list
= (struct partial_symbol
**)
1078 xmrealloc (objfile
->md
, (char *) listp
->list
,
1079 new_size
* sizeof (struct partial_symbol
*));
1081 /* Next assumes we only went one over. Should be good if
1082 program works correctly */
1083 listp
->next
= listp
->list
+ listp
->size
;
1084 listp
->size
= new_size
;
1088 /* Do early runtime initializations. */
1090 _initialize_symmisc ()
This page took 0.062836 seconds and 5 git commands to generate.