1 /* Do various things to symbol tables (other than lookup), for GDB.
2 Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996
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, Boston, MA 02111-1307, USA. */
27 #include "breakpoint.h"
32 #include "gdb_string.h"
35 #define DEV_TTY "/dev/tty"
38 /* Unfortunately for debugging, stderr is usually a macro. This is painful
39 when calling functions that take FILE *'s from the debugger.
40 So we make a variable which has the same value and which is accessible when
41 debugging GDB with itself. Because stdin et al need not be constants,
42 we initialize them in the _initialize_symmisc function at the bottom
48 /* Prototypes for local functions */
51 dump_symtab
PARAMS ((struct objfile
*, struct symtab
*, GDB_FILE
*));
54 dump_psymtab
PARAMS ((struct objfile
*, struct partial_symtab
*, GDB_FILE
*));
57 dump_msymbols
PARAMS ((struct objfile
*, GDB_FILE
*));
60 dump_objfile
PARAMS ((struct objfile
*));
63 block_depth
PARAMS ((struct block
*));
66 print_partial_symbol
PARAMS ((struct partial_symbol
*, int, char *, GDB_FILE
*));
68 struct print_symbol_args
{
69 struct symbol
*symbol
;
74 static int print_symbol
PARAMS ((char *));
77 free_symtab_block
PARAMS ((struct objfile
*, struct block
*));
80 /* Free a struct block <- B and all the symbols defined in that block. */
83 free_symtab_block (objfile
, b
)
84 struct objfile
*objfile
;
89 for (i
= 0; i
< n
; i
++)
91 mfree (objfile
-> md
, SYMBOL_NAME (BLOCK_SYM (b
, i
)));
92 mfree (objfile
-> md
, (PTR
) BLOCK_SYM (b
, i
));
94 mfree (objfile
-> md
, (PTR
) b
);
97 /* Free all the storage associated with the struct symtab <- S.
98 Note that some symtabs have contents malloc'ed structure by structure,
99 while some have contents that all live inside one big block of memory,
100 and some share the contents of another symbol table and so you should
101 not free the contents on their behalf (except sometimes the linetable,
102 which maybe per symtab even when the rest is not).
103 It is s->free_code that says which alternative to use. */
107 register struct symtab
*s
;
110 register struct blockvector
*bv
;
112 switch (s
->free_code
)
115 /* All the contents are part of a big block of memory (an obstack),
116 and some other symtab is in charge of freeing that block.
117 Therefore, do nothing. */
121 /* Here all the contents were malloc'ed structure by structure
122 and must be freed that way. */
123 /* First free the blocks (and their symbols. */
124 bv
= BLOCKVECTOR (s
);
125 n
= BLOCKVECTOR_NBLOCKS (bv
);
126 for (i
= 0; i
< n
; i
++)
127 free_symtab_block (s
-> objfile
, BLOCKVECTOR_BLOCK (bv
, i
));
128 /* Free the blockvector itself. */
129 mfree (s
-> objfile
-> md
, (PTR
) bv
);
130 /* Also free the linetable. */
133 /* Everything will be freed either by our `free_ptr'
134 or by some other symtab, except for our linetable.
137 mfree (s
-> objfile
-> md
, (PTR
) LINETABLE (s
));
141 /* If there is a single block of memory to free, free it. */
142 if (s
-> free_ptr
!= NULL
)
143 mfree (s
-> objfile
-> md
, s
-> free_ptr
);
145 /* Free source-related stuff */
146 if (s
-> line_charpos
!= NULL
)
147 mfree (s
-> objfile
-> md
, (PTR
) s
-> line_charpos
);
148 if (s
-> fullname
!= NULL
)
149 mfree (s
-> objfile
-> md
, s
-> fullname
);
150 mfree (s
-> objfile
-> md
, (PTR
) s
);
156 print_objfile_statistics ()
158 struct objfile
*objfile
;
161 ALL_OBJFILES (objfile
)
163 printf_filtered ("Statistics for '%s':\n", objfile
-> name
);
164 if (OBJSTAT (objfile
, n_stabs
) > 0)
165 printf_filtered (" Number of \"stab\" symbols read: %d\n",
166 OBJSTAT (objfile
, n_stabs
));
167 if (OBJSTAT (objfile
, n_minsyms
) > 0)
168 printf_filtered (" Number of \"minimal symbols read: %d\n",
169 OBJSTAT (objfile
, n_minsyms
));
170 if (OBJSTAT (objfile
, n_psyms
) > 0)
171 printf_filtered (" Number of \"partial symbols read: %d\n",
172 OBJSTAT (objfile
, n_psyms
));
173 if (OBJSTAT (objfile
, n_syms
) > 0)
174 printf_filtered (" Number of \"full symbols read: %d\n",
175 OBJSTAT (objfile
, n_syms
));
176 if (OBJSTAT (objfile
, n_types
) > 0)
177 printf_filtered (" Number of \"types defined: %d\n",
178 OBJSTAT (objfile
, n_types
));
179 if (OBJSTAT (objfile
, sz_strtab
) > 0)
180 printf_filtered (" Space used by a.out string tables: %d\n",
181 OBJSTAT (objfile
, sz_strtab
));
182 printf_filtered (" Total memory used for psymbol obstack: %d\n",
183 obstack_memory_used (&objfile
-> psymbol_obstack
));
184 printf_filtered (" Total memory used for symbol obstack: %d\n",
185 obstack_memory_used (&objfile
-> symbol_obstack
));
186 printf_filtered (" Total memory used for type obstack: %d\n",
187 obstack_memory_used (&objfile
-> type_obstack
));
193 dump_objfile (objfile
)
194 struct objfile
*objfile
;
196 struct symtab
*symtab
;
197 struct partial_symtab
*psymtab
;
199 printf_filtered ("\nObject file %s: ", objfile
-> name
);
200 printf_filtered ("Objfile at ");
201 gdb_print_address (objfile
, gdb_stdout
);
202 printf_filtered (", bfd at ");
203 gdb_print_address (objfile
->obfd
, gdb_stdout
);
204 printf_filtered (", %d minsyms\n\n",
205 objfile
->minimal_symbol_count
);
207 if (objfile
-> psymtabs
)
209 printf_filtered ("Psymtabs:\n");
210 for (psymtab
= objfile
-> psymtabs
;
212 psymtab
= psymtab
-> next
)
214 printf_filtered ("%s at ",
215 psymtab
-> filename
);
216 gdb_print_address (psymtab
, gdb_stdout
);
217 printf_filtered (", ");
218 if (psymtab
-> objfile
!= objfile
)
220 printf_filtered ("NOT ON CHAIN! ");
224 printf_filtered ("\n\n");
227 if (objfile
-> symtabs
)
229 printf_filtered ("Symtabs:\n");
230 for (symtab
= objfile
-> symtabs
;
232 symtab
= symtab
->next
)
234 printf_filtered ("%s at ", symtab
-> filename
);
235 gdb_print_address (symtab
, gdb_stdout
);
236 printf_filtered (", ");
237 if (symtab
-> objfile
!= objfile
)
239 printf_filtered ("NOT ON CHAIN! ");
243 printf_filtered ("\n\n");
247 /* Print minimal symbols from this objfile. */
250 dump_msymbols (objfile
, outfile
)
251 struct objfile
*objfile
;
254 struct minimal_symbol
*msymbol
;
258 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile
-> name
);
259 if (objfile
-> minimal_symbol_count
== 0)
261 fprintf_filtered (outfile
, "No minimal symbols found.\n");
264 for (index
= 0, msymbol
= objfile
-> msymbols
;
265 SYMBOL_NAME (msymbol
) != NULL
; msymbol
++, index
++)
267 switch (msymbol
-> type
)
275 case mst_solib_trampoline
:
300 fprintf_filtered (outfile
, "[%2d] %c %#10lx %s", index
, ms_type
,
301 SYMBOL_VALUE_ADDRESS (msymbol
), SYMBOL_NAME (msymbol
));
302 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
304 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
306 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
307 if (msymbol
->filename
)
308 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
310 fputs_filtered ("\n", outfile
);
312 if (objfile
-> minimal_symbol_count
!= index
)
314 warning ("internal error: minimal symbol count %d != %d",
315 objfile
-> minimal_symbol_count
, index
);
317 fprintf_filtered (outfile
, "\n");
321 dump_psymtab (objfile
, psymtab
, outfile
)
322 struct objfile
*objfile
;
323 struct partial_symtab
*psymtab
;
328 fprintf_filtered (outfile
, "\nPartial symtab for source file %s ",
329 psymtab
-> filename
);
330 fprintf_filtered (outfile
, "(object ");
331 gdb_print_address (psymtab
, outfile
);
332 fprintf_filtered (outfile
, ")\n\n");
333 fprintf_unfiltered (outfile
, " Read from object file %s (",
335 gdb_print_address (objfile
, outfile
);
336 fprintf_unfiltered (outfile
, ")\n");
338 if (psymtab
-> readin
)
340 fprintf_filtered (outfile
,
341 " Full symtab was read (at ");
342 gdb_print_address (psymtab
->symtab
, outfile
);
343 fprintf_filtered (outfile
, " by function at ");
344 gdb_print_address ((PTR
)psymtab
->read_symtab
, outfile
);
345 fprintf_filtered (outfile
, ")\n");
348 fprintf_filtered (outfile
, " Relocate symbols by ");
349 for (i
= 0; i
< psymtab
->objfile
->num_sections
; ++i
)
352 fprintf_filtered (outfile
, ", ");
354 print_address_numeric (ANOFFSET (psymtab
->section_offsets
, i
),
358 fprintf_filtered (outfile
, "\n");
360 fprintf_filtered (outfile
, " Symbols cover text addresses ");
361 print_address_numeric (psymtab
->textlow
, 1, outfile
);
362 fprintf_filtered (outfile
, "-");
363 print_address_numeric (psymtab
->texthigh
, 1, outfile
);
364 fprintf_filtered (outfile
, "\n");
365 fprintf_filtered (outfile
, " Depends on %d other partial symtabs.\n",
366 psymtab
-> number_of_dependencies
);
367 for (i
= 0; i
< psymtab
-> number_of_dependencies
; i
++)
369 fprintf_filtered (outfile
, " %d ", i
);
370 gdb_print_address (psymtab
-> dependencies
[i
], outfile
);
371 fprintf_filtered (outfile
, " %s\n",
372 psymtab
-> dependencies
[i
] -> filename
);
374 if (psymtab
-> n_global_syms
> 0)
376 print_partial_symbol (objfile
-> global_psymbols
.list
377 + psymtab
-> globals_offset
,
378 psymtab
-> n_global_syms
, "Global", outfile
);
380 if (psymtab
-> n_static_syms
> 0)
382 print_partial_symbol (objfile
-> static_psymbols
.list
383 + psymtab
-> statics_offset
,
384 psymtab
-> n_static_syms
, "Static", outfile
);
386 fprintf_filtered (outfile
, "\n");
390 dump_symtab (objfile
, symtab
, outfile
)
391 struct objfile
*objfile
;
392 struct symtab
*symtab
;
397 register struct linetable
*l
;
398 struct blockvector
*bv
;
399 register struct block
*b
;
402 fprintf_filtered (outfile
, "\nSymtab for file %s\n", symtab
->filename
);
403 fprintf_filtered (outfile
, "Read from object file %s (", objfile
->name
);
404 gdb_print_address (objfile
, outfile
);
405 fprintf_filtered (outfile
, ")\n");
406 fprintf_filtered (outfile
, "Language: %s\n", language_str (symtab
-> language
));
408 /* First print the line table. */
409 l
= LINETABLE (symtab
);
412 fprintf_filtered (outfile
, "\nLine table:\n\n");
414 for (i
= 0; i
< len
; i
++)
416 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
417 print_address_numeric (l
->item
[i
].pc
, 1, outfile
);
418 fprintf_filtered (outfile
, "\n");
421 /* Now print the block info. */
422 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
423 bv
= BLOCKVECTOR (symtab
);
424 len
= BLOCKVECTOR_NBLOCKS (bv
);
425 for (i
= 0; i
< len
; i
++)
427 b
= BLOCKVECTOR_BLOCK (bv
, i
);
428 depth
= block_depth (b
) * 2;
429 print_spaces (depth
, outfile
);
430 fprintf_filtered (outfile
, "block #%03d (object ", i
);
431 gdb_print_address (b
, outfile
);
432 fprintf_filtered (outfile
, ") ");
433 fprintf_filtered (outfile
, "[");
434 print_address_numeric (BLOCK_START (b
), 1, outfile
);
435 fprintf_filtered (outfile
, "..");
436 print_address_numeric (BLOCK_END (b
), 1, outfile
);
437 fprintf_filtered (outfile
, "]");
438 if (BLOCK_SUPERBLOCK (b
))
440 fprintf_filtered (outfile
, " (under ");
441 gdb_print_address (BLOCK_SUPERBLOCK (b
), outfile
);
442 fprintf_filtered (outfile
, ")");
444 if (BLOCK_FUNCTION (b
))
446 fprintf_filtered (outfile
, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b
)));
447 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
449 fprintf_filtered (outfile
, " %s",
450 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
453 if (BLOCK_GCC_COMPILED(b
))
454 fprintf_filtered (outfile
, " gcc%d compiled", BLOCK_GCC_COMPILED(b
));
455 fprintf_filtered (outfile
, "\n");
456 blen
= BLOCK_NSYMS (b
);
457 for (j
= 0; j
< blen
; j
++)
459 struct print_symbol_args s
;
460 s
.symbol
= BLOCK_SYM (b
, j
);
463 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
467 fprintf_filtered (outfile
, "\n");
471 maintenance_print_symbols (args
, from_tty
)
477 struct cleanup
*cleanups
;
478 char *symname
= NULL
;
479 char *filename
= DEV_TTY
;
480 struct objfile
*objfile
;
488 Arguments missing: an output file name and an optional symbol file name");
490 else if ((argv
= buildargv (args
)) == NULL
)
494 cleanups
= make_cleanup (freeargv
, (char *) argv
);
499 /* If a second arg is supplied, it is a source file name to match on */
506 filename
= tilde_expand (filename
);
507 make_cleanup (free
, filename
);
509 outfile
= gdb_fopen (filename
, FOPEN_WT
);
511 perror_with_name (filename
);
512 make_cleanup (fclose
, (char *) outfile
);
515 ALL_SYMTABS (objfile
, s
)
516 if (symname
== NULL
|| (STREQ (symname
, s
-> filename
)))
517 dump_symtab (objfile
, s
, outfile
);
519 do_cleanups (cleanups
);
522 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
523 far to indent. ARGS is really a struct print_symbol_args *, but is
524 declared as char * to get it past catch_errors. Returns 0 for error,
531 struct symbol
*symbol
= ((struct print_symbol_args
*)args
)->symbol
;
532 int depth
= ((struct print_symbol_args
*)args
)->depth
;
533 GDB_FILE
*outfile
= ((struct print_symbol_args
*)args
)->outfile
;
535 print_spaces (depth
, outfile
);
536 if (SYMBOL_NAMESPACE (symbol
) == LABEL_NAMESPACE
)
538 fprintf_filtered (outfile
, "label %s at ", SYMBOL_SOURCE_NAME (symbol
));
539 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
540 fprintf_filtered (outfile
, "\n");
543 if (SYMBOL_NAMESPACE (symbol
) == STRUCT_NAMESPACE
)
545 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
547 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
551 fprintf_filtered (outfile
, "%s %s = ",
552 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
554 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
555 ? "struct" : "union")),
556 SYMBOL_NAME (symbol
));
557 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
559 fprintf_filtered (outfile
, ";\n");
563 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
564 fprintf_filtered (outfile
, "typedef ");
565 if (SYMBOL_TYPE (symbol
))
567 /* Print details of types, except for enums where it's clutter. */
568 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_SOURCE_NAME (symbol
),
570 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
572 fprintf_filtered (outfile
, "; ");
575 fprintf_filtered (outfile
, "%s ", SYMBOL_SOURCE_NAME (symbol
));
577 switch (SYMBOL_CLASS (symbol
))
580 fprintf_filtered (outfile
, "const %ld (0x%lx),",
581 SYMBOL_VALUE (symbol
),
582 SYMBOL_VALUE (symbol
));
585 case LOC_CONST_BYTES
:
588 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
589 fprintf_filtered (outfile
, "const %u hex bytes:",
591 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
592 fprintf_filtered (outfile
, " %02x",
593 (unsigned)SYMBOL_VALUE_BYTES (symbol
) [i
]);
594 fprintf_filtered (outfile
, ",");
599 fprintf_filtered (outfile
, "static at ");
600 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1,outfile
);
601 fprintf_filtered (outfile
, ",");
605 fprintf_filtered (outfile
, "register %ld,", SYMBOL_VALUE (symbol
));
609 fprintf_filtered (outfile
, "arg at offset 0x%lx,",
610 SYMBOL_VALUE (symbol
));
614 fprintf_filtered (outfile
, "arg at offset 0x%lx from fp,",
615 SYMBOL_VALUE (symbol
));
619 fprintf_filtered (outfile
, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol
));
623 fprintf_filtered (outfile
, "parameter register %ld,", SYMBOL_VALUE (symbol
));
626 case LOC_REGPARM_ADDR
:
627 fprintf_filtered (outfile
, "address parameter register %ld,", SYMBOL_VALUE (symbol
));
631 fprintf_filtered (outfile
, "local at offset 0x%lx,",
632 SYMBOL_VALUE (symbol
));
636 fprintf_filtered (outfile
, "local at 0x%lx from register %d",
637 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
640 case LOC_BASEREG_ARG
:
641 fprintf_filtered (outfile
, "arg at 0x%lx from register %d,",
642 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
649 fprintf_filtered (outfile
, "label at ");
650 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
654 fprintf_filtered (outfile
, "block (object ");
655 gdb_print_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
656 fprintf_filtered (outfile
, ") starting at ");
657 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
)),
660 fprintf_filtered (outfile
, ",");
664 fprintf_filtered (outfile
, "unresolved");
667 case LOC_OPTIMIZED_OUT
:
668 fprintf_filtered (outfile
, "optimized out");
672 fprintf_filtered (outfile
, "botched symbol class %x",
673 SYMBOL_CLASS (symbol
));
677 fprintf_filtered (outfile
, "\n");
682 maintenance_print_psymbols (args
, from_tty
)
688 struct cleanup
*cleanups
;
689 char *symname
= NULL
;
690 char *filename
= DEV_TTY
;
691 struct objfile
*objfile
;
692 struct partial_symtab
*ps
;
698 error ("print-psymbols takes an output file name and optional symbol file name");
700 else if ((argv
= buildargv (args
)) == NULL
)
704 cleanups
= make_cleanup (freeargv
, (char *) argv
);
709 /* If a second arg is supplied, it is a source file name to match on */
716 filename
= tilde_expand (filename
);
717 make_cleanup (free
, filename
);
719 outfile
= gdb_fopen (filename
, FOPEN_WT
);
721 perror_with_name (filename
);
722 make_cleanup (fclose
, outfile
);
725 ALL_PSYMTABS (objfile
, ps
)
726 if (symname
== NULL
|| (STREQ (symname
, ps
-> filename
)))
727 dump_psymtab (objfile
, ps
, outfile
);
729 do_cleanups (cleanups
);
733 print_partial_symbol (p
, count
, what
, outfile
)
734 struct partial_symbol
*p
;
740 fprintf_filtered (outfile
, " %s partial symbols:\n", what
);
743 fprintf_filtered (outfile
, " `%s'", SYMBOL_NAME(p
));
744 if (SYMBOL_DEMANGLED_NAME (p
) != NULL
)
746 fprintf_filtered (outfile
, " `%s'", SYMBOL_DEMANGLED_NAME (p
));
748 fputs_filtered (", ", outfile
);
749 switch (SYMBOL_NAMESPACE (p
))
751 case UNDEF_NAMESPACE
:
752 fputs_filtered ("undefined namespace, ", outfile
);
755 /* This is the usual thing -- don't print it */
757 case STRUCT_NAMESPACE
:
758 fputs_filtered ("struct namespace, ", outfile
);
760 case LABEL_NAMESPACE
:
761 fputs_filtered ("label namespace, ", outfile
);
764 fputs_filtered ("<invalid namespace>, ", outfile
);
767 switch (SYMBOL_CLASS (p
))
770 fputs_filtered ("undefined", outfile
);
773 fputs_filtered ("constant int", outfile
);
776 fputs_filtered ("static", outfile
);
779 fputs_filtered ("register", outfile
);
782 fputs_filtered ("pass by value", outfile
);
785 fputs_filtered ("pass by reference", outfile
);
788 fputs_filtered ("register parameter", outfile
);
790 case LOC_REGPARM_ADDR
:
791 fputs_filtered ("register address parameter", outfile
);
794 fputs_filtered ("stack parameter", outfile
);
797 fputs_filtered ("type", outfile
);
800 fputs_filtered ("label", outfile
);
803 fputs_filtered ("function", outfile
);
805 case LOC_CONST_BYTES
:
806 fputs_filtered ("constant bytes", outfile
);
809 fputs_filtered ("shuffled arg", outfile
);
812 fputs_filtered ("unresolved", outfile
);
814 case LOC_OPTIMIZED_OUT
:
815 fputs_filtered ("optimized out", outfile
);
818 fputs_filtered ("<invalid location>", outfile
);
821 fputs_filtered (", ", outfile
);
822 /* FIXME-32x64: Need to use SYMBOL_VALUE_ADDRESS, etc.; this
823 could be 32 bits when some of the other fields in the union
825 fprintf_filtered (outfile
, "0x%lx\n", SYMBOL_VALUE (p
));
831 maintenance_print_msymbols (args
, from_tty
)
837 struct cleanup
*cleanups
;
838 char *filename
= DEV_TTY
;
839 char *symname
= NULL
;
840 struct objfile
*objfile
;
846 error ("print-msymbols takes an output file name and optional symbol file name");
848 else if ((argv
= buildargv (args
)) == NULL
)
852 cleanups
= make_cleanup (freeargv
, argv
);
857 /* If a second arg is supplied, it is a source file name to match on */
864 filename
= tilde_expand (filename
);
865 make_cleanup (free
, filename
);
867 outfile
= gdb_fopen (filename
, FOPEN_WT
);
869 perror_with_name (filename
);
870 make_cleanup (fclose
, outfile
);
873 ALL_OBJFILES (objfile
)
874 if (symname
== NULL
|| (STREQ (symname
, objfile
-> name
)))
875 dump_msymbols (objfile
, outfile
);
877 fprintf_filtered (outfile
, "\n\n");
878 do_cleanups (cleanups
);
882 maintenance_print_objfiles (ignore
, from_tty
)
886 struct objfile
*objfile
;
891 ALL_OBJFILES (objfile
)
892 dump_objfile (objfile
);
896 /* Check consistency of psymtabs and symtabs. */
899 maintenance_check_symtabs (ignore
, from_tty
)
903 register struct symbol
*sym
;
904 register struct partial_symbol
*psym
;
905 register struct symtab
*s
= NULL
;
906 register struct partial_symtab
*ps
;
907 struct blockvector
*bv
;
908 register struct objfile
*objfile
;
909 register struct block
*b
;
912 ALL_PSYMTABS (objfile
, ps
)
914 s
= PSYMTAB_TO_SYMTAB(ps
);
917 bv
= BLOCKVECTOR (s
);
918 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
919 psym
= ps
->objfile
->static_psymbols
.list
+ ps
->statics_offset
;
920 length
= ps
->n_static_syms
;
923 sym
= lookup_block_symbol (b
, SYMBOL_NAME (psym
),
924 SYMBOL_NAMESPACE (psym
));
927 printf_filtered ("Static symbol `");
928 puts_filtered (SYMBOL_NAME (psym
));
929 printf_filtered ("' only found in ");
930 puts_filtered (ps
->filename
);
931 printf_filtered (" psymtab\n");
935 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
936 psym
= ps
->objfile
->global_psymbols
.list
+ ps
->globals_offset
;
937 length
= ps
->n_global_syms
;
940 sym
= lookup_block_symbol (b
, SYMBOL_NAME (psym
),
941 SYMBOL_NAMESPACE (psym
));
944 printf_filtered ("Global symbol `");
945 puts_filtered (SYMBOL_NAME (psym
));
946 printf_filtered ("' only found in ");
947 puts_filtered (ps
->filename
);
948 printf_filtered (" psymtab\n");
952 if (ps
->texthigh
< ps
->textlow
)
954 printf_filtered ("Psymtab ");
955 puts_filtered (ps
->filename
);
956 printf_filtered (" covers bad range ");
957 print_address_numeric (ps
->textlow
, 1, stdout
);
958 printf_filtered (" - ");
959 print_address_numeric (ps
->texthigh
, 1, stdout
);
960 printf_filtered ("\n");
963 if (ps
->texthigh
== 0)
965 if (ps
->textlow
< BLOCK_START (b
) || ps
->texthigh
> BLOCK_END (b
))
967 printf_filtered ("Psymtab ");
968 puts_filtered (ps
->filename
);
969 printf_filtered (" covers ");
970 print_address_numeric (ps
->textlow
, 1, stdout
);
971 printf_filtered (" - ");
972 print_address_numeric (ps
->texthigh
, 1, stdout
);
973 printf_filtered (" but symtab covers only ");
974 print_address_numeric (BLOCK_START (b
), 1, stdout
);
975 printf_filtered (" - ");
976 print_address_numeric (BLOCK_END (b
), 1, stdout
);
977 printf_filtered ("\n");
983 /* Return the nexting depth of a block within other blocks in its symtab. */
990 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
997 #endif /* MAINTENANCE_CMDS */
1000 /* Increase the space allocated for LISTP, which is probably
1001 global_psymbol_list or static_psymbol_list. This space will eventually
1002 be freed in free_objfile(). */
1005 extend_psymbol_list (listp
, objfile
)
1006 register struct psymbol_allocation_list
*listp
;
1007 struct objfile
*objfile
;
1010 if (listp
->size
== 0)
1013 listp
->list
= (struct partial_symbol
*)
1014 xmmalloc (objfile
-> md
, new_size
* sizeof (struct partial_symbol
));
1018 new_size
= listp
->size
* 2;
1019 listp
->list
= (struct partial_symbol
*)
1020 xmrealloc (objfile
-> md
, (char *) listp
->list
,
1021 new_size
* sizeof (struct partial_symbol
));
1023 /* Next assumes we only went one over. Should be good if
1024 program works correctly */
1025 listp
->next
= listp
->list
+ listp
->size
;
1026 listp
->size
= new_size
;
1030 /* Do early runtime initializations. */
1032 _initialize_symmisc ()
This page took 0.056362 seconds and 4 git commands to generate.