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"
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 */
52 dump_symtab
PARAMS ((struct objfile
*, struct symtab
*, GDB_FILE
*));
55 dump_psymtab
PARAMS ((struct objfile
*, struct partial_symtab
*, GDB_FILE
*));
58 dump_msymbols
PARAMS ((struct objfile
*, GDB_FILE
*));
61 dump_objfile
PARAMS ((struct objfile
*));
64 block_depth
PARAMS ((struct block
*));
67 print_partial_symbols
PARAMS ((struct partial_symbol
**, int, char *, GDB_FILE
*));
69 struct print_symbol_args
{
70 struct symbol
*symbol
;
75 static int print_symbol
PARAMS ((char *));
78 free_symtab_block
PARAMS ((struct objfile
*, struct block
*));
81 /* Free a struct block <- B and all the symbols defined in that block. */
84 free_symtab_block (objfile
, b
)
85 struct objfile
*objfile
;
90 for (i
= 0; i
< n
; i
++)
92 mfree (objfile
-> md
, SYMBOL_NAME (BLOCK_SYM (b
, i
)));
93 mfree (objfile
-> md
, (PTR
) BLOCK_SYM (b
, i
));
95 mfree (objfile
-> md
, (PTR
) b
);
98 /* Free all the storage associated with the struct symtab <- S.
99 Note that some symtabs have contents malloc'ed structure by structure,
100 while some have contents that all live inside one big block of memory,
101 and some share the contents of another symbol table and so you should
102 not free the contents on their behalf (except sometimes the linetable,
103 which maybe per symtab even when the rest is not).
104 It is s->free_code that says which alternative to use. */
108 register struct symtab
*s
;
111 register struct blockvector
*bv
;
113 switch (s
->free_code
)
116 /* All the contents are part of a big block of memory (an obstack),
117 and some other symtab is in charge of freeing that block.
118 Therefore, do nothing. */
122 /* Here all the contents were malloc'ed structure by structure
123 and must be freed that way. */
124 /* First free the blocks (and their symbols. */
125 bv
= BLOCKVECTOR (s
);
126 n
= BLOCKVECTOR_NBLOCKS (bv
);
127 for (i
= 0; i
< n
; i
++)
128 free_symtab_block (s
-> objfile
, BLOCKVECTOR_BLOCK (bv
, i
));
129 /* Free the blockvector itself. */
130 mfree (s
-> objfile
-> md
, (PTR
) bv
);
131 /* Also free the linetable. */
134 /* Everything will be freed either by our `free_ptr'
135 or by some other symtab, except for our linetable.
138 mfree (s
-> objfile
-> md
, (PTR
) LINETABLE (s
));
142 /* If there is a single block of memory to free, free it. */
143 if (s
-> free_ptr
!= NULL
)
144 mfree (s
-> objfile
-> md
, s
-> free_ptr
);
146 /* Free source-related stuff */
147 if (s
-> line_charpos
!= NULL
)
148 mfree (s
-> objfile
-> md
, (PTR
) s
-> line_charpos
);
149 if (s
-> fullname
!= NULL
)
150 mfree (s
-> objfile
-> md
, s
-> fullname
);
151 mfree (s
-> objfile
-> md
, (PTR
) s
);
157 print_symbol_bcache_statistics ()
159 struct objfile
*objfile
;
162 ALL_OBJFILES (objfile
)
164 printf_filtered ("Byte cache statistics for '%s':\n", objfile
-> name
);
165 print_bcache_statistics (&objfile
-> psymbol_cache
, "partial symbol cache");
171 print_objfile_statistics ()
173 struct objfile
*objfile
;
176 ALL_OBJFILES (objfile
)
178 printf_filtered ("Statistics for '%s':\n", objfile
-> name
);
179 if (OBJSTAT (objfile
, n_stabs
) > 0)
180 printf_filtered (" Number of \"stab\" symbols read: %d\n",
181 OBJSTAT (objfile
, n_stabs
));
182 if (OBJSTAT (objfile
, n_minsyms
) > 0)
183 printf_filtered (" Number of \"minimal symbols read: %d\n",
184 OBJSTAT (objfile
, n_minsyms
));
185 if (OBJSTAT (objfile
, n_psyms
) > 0)
186 printf_filtered (" Number of \"partial symbols read: %d\n",
187 OBJSTAT (objfile
, n_psyms
));
188 if (OBJSTAT (objfile
, n_syms
) > 0)
189 printf_filtered (" Number of \"full symbols read: %d\n",
190 OBJSTAT (objfile
, n_syms
));
191 if (OBJSTAT (objfile
, n_types
) > 0)
192 printf_filtered (" Number of \"types defined: %d\n",
193 OBJSTAT (objfile
, n_types
));
194 if (OBJSTAT (objfile
, sz_strtab
) > 0)
195 printf_filtered (" Space used by a.out string tables: %d\n",
196 OBJSTAT (objfile
, sz_strtab
));
197 printf_filtered (" Total memory used for psymbol obstack: %d\n",
198 obstack_memory_used (&objfile
-> psymbol_obstack
));
199 printf_filtered (" Total memory used for symbol obstack: %d\n",
200 obstack_memory_used (&objfile
-> symbol_obstack
));
201 printf_filtered (" Total memory used for type obstack: %d\n",
202 obstack_memory_used (&objfile
-> type_obstack
));
208 dump_objfile (objfile
)
209 struct objfile
*objfile
;
211 struct symtab
*symtab
;
212 struct partial_symtab
*psymtab
;
214 printf_filtered ("\nObject file %s: ", objfile
-> name
);
215 printf_filtered ("Objfile at ");
216 gdb_print_address (objfile
, gdb_stdout
);
217 printf_filtered (", bfd at ");
218 gdb_print_address (objfile
->obfd
, gdb_stdout
);
219 printf_filtered (", %d minsyms\n\n",
220 objfile
->minimal_symbol_count
);
222 if (objfile
-> psymtabs
)
224 printf_filtered ("Psymtabs:\n");
225 for (psymtab
= objfile
-> psymtabs
;
227 psymtab
= psymtab
-> next
)
229 printf_filtered ("%s at ",
230 psymtab
-> filename
);
231 gdb_print_address (psymtab
, gdb_stdout
);
232 printf_filtered (", ");
233 if (psymtab
-> objfile
!= objfile
)
235 printf_filtered ("NOT ON CHAIN! ");
239 printf_filtered ("\n\n");
242 if (objfile
-> symtabs
)
244 printf_filtered ("Symtabs:\n");
245 for (symtab
= objfile
-> symtabs
;
247 symtab
= symtab
->next
)
249 printf_filtered ("%s at ", symtab
-> filename
);
250 gdb_print_address (symtab
, gdb_stdout
);
251 printf_filtered (", ");
252 if (symtab
-> objfile
!= objfile
)
254 printf_filtered ("NOT ON CHAIN! ");
258 printf_filtered ("\n\n");
262 /* Print minimal symbols from this objfile. */
265 dump_msymbols (objfile
, outfile
)
266 struct objfile
*objfile
;
269 struct minimal_symbol
*msymbol
;
273 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile
-> name
);
274 if (objfile
-> minimal_symbol_count
== 0)
276 fprintf_filtered (outfile
, "No minimal symbols found.\n");
279 for (index
= 0, msymbol
= objfile
-> msymbols
;
280 SYMBOL_NAME (msymbol
) != NULL
; msymbol
++, index
++)
282 switch (msymbol
-> type
)
290 case mst_solib_trampoline
:
315 fprintf_filtered (outfile
, "[%2d] %c %#10lx %s", index
, ms_type
,
316 SYMBOL_VALUE_ADDRESS (msymbol
), SYMBOL_NAME (msymbol
));
317 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
319 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
321 #ifdef SOFUN_ADDRESS_MAYBE_MISSING
322 if (msymbol
->filename
)
323 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
325 fputs_filtered ("\n", outfile
);
327 if (objfile
-> minimal_symbol_count
!= index
)
329 warning ("internal error: minimal symbol count %d != %d",
330 objfile
-> minimal_symbol_count
, index
);
332 fprintf_filtered (outfile
, "\n");
336 dump_psymtab (objfile
, psymtab
, outfile
)
337 struct objfile
*objfile
;
338 struct partial_symtab
*psymtab
;
343 fprintf_filtered (outfile
, "\nPartial symtab for source file %s ",
344 psymtab
-> filename
);
345 fprintf_filtered (outfile
, "(object ");
346 gdb_print_address (psymtab
, outfile
);
347 fprintf_filtered (outfile
, ")\n\n");
348 fprintf_unfiltered (outfile
, " Read from object file %s (",
350 gdb_print_address (objfile
, outfile
);
351 fprintf_unfiltered (outfile
, ")\n");
353 if (psymtab
-> readin
)
355 fprintf_filtered (outfile
,
356 " Full symtab was read (at ");
357 gdb_print_address (psymtab
->symtab
, outfile
);
358 fprintf_filtered (outfile
, " by function at ");
359 gdb_print_address ((PTR
)psymtab
->read_symtab
, outfile
);
360 fprintf_filtered (outfile
, ")\n");
363 fprintf_filtered (outfile
, " Relocate symbols by ");
364 for (i
= 0; i
< psymtab
->objfile
->num_sections
; ++i
)
367 fprintf_filtered (outfile
, ", ");
369 print_address_numeric (ANOFFSET (psymtab
->section_offsets
, i
),
373 fprintf_filtered (outfile
, "\n");
375 fprintf_filtered (outfile
, " Symbols cover text addresses ");
376 print_address_numeric (psymtab
->textlow
, 1, outfile
);
377 fprintf_filtered (outfile
, "-");
378 print_address_numeric (psymtab
->texthigh
, 1, outfile
);
379 fprintf_filtered (outfile
, "\n");
380 fprintf_filtered (outfile
, " Depends on %d other partial symtabs.\n",
381 psymtab
-> number_of_dependencies
);
382 for (i
= 0; i
< psymtab
-> number_of_dependencies
; i
++)
384 fprintf_filtered (outfile
, " %d ", i
);
385 gdb_print_address (psymtab
-> dependencies
[i
], outfile
);
386 fprintf_filtered (outfile
, " %s\n",
387 psymtab
-> dependencies
[i
] -> filename
);
389 if (psymtab
-> n_global_syms
> 0)
391 print_partial_symbols (objfile
-> global_psymbols
.list
392 + psymtab
-> globals_offset
,
393 psymtab
-> n_global_syms
, "Global", outfile
);
395 if (psymtab
-> n_static_syms
> 0)
397 print_partial_symbols (objfile
-> static_psymbols
.list
398 + psymtab
-> statics_offset
,
399 psymtab
-> n_static_syms
, "Static", outfile
);
401 fprintf_filtered (outfile
, "\n");
405 dump_symtab (objfile
, symtab
, outfile
)
406 struct objfile
*objfile
;
407 struct symtab
*symtab
;
412 register struct linetable
*l
;
413 struct blockvector
*bv
;
414 register struct block
*b
;
417 fprintf_filtered (outfile
, "\nSymtab for file %s\n", symtab
->filename
);
418 fprintf_filtered (outfile
, "Read from object file %s (", objfile
->name
);
419 gdb_print_address (objfile
, outfile
);
420 fprintf_filtered (outfile
, ")\n");
421 fprintf_filtered (outfile
, "Language: %s\n", language_str (symtab
-> language
));
423 /* First print the line table. */
424 l
= LINETABLE (symtab
);
427 fprintf_filtered (outfile
, "\nLine table:\n\n");
429 for (i
= 0; i
< len
; i
++)
431 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
432 print_address_numeric (l
->item
[i
].pc
, 1, outfile
);
433 fprintf_filtered (outfile
, "\n");
436 /* Now print the block info. */
437 fprintf_filtered (outfile
, "\nBlockvector:\n\n");
438 bv
= BLOCKVECTOR (symtab
);
439 len
= BLOCKVECTOR_NBLOCKS (bv
);
440 for (i
= 0; i
< len
; i
++)
442 b
= BLOCKVECTOR_BLOCK (bv
, i
);
443 depth
= block_depth (b
) * 2;
444 print_spaces (depth
, outfile
);
445 fprintf_filtered (outfile
, "block #%03d (object ", i
);
446 gdb_print_address (b
, outfile
);
447 fprintf_filtered (outfile
, ") ");
448 fprintf_filtered (outfile
, "[");
449 print_address_numeric (BLOCK_START (b
), 1, outfile
);
450 fprintf_filtered (outfile
, "..");
451 print_address_numeric (BLOCK_END (b
), 1, outfile
);
452 fprintf_filtered (outfile
, "]");
453 if (BLOCK_SUPERBLOCK (b
))
455 fprintf_filtered (outfile
, " (under ");
456 gdb_print_address (BLOCK_SUPERBLOCK (b
), outfile
);
457 fprintf_filtered (outfile
, ")");
459 if (BLOCK_FUNCTION (b
))
461 fprintf_filtered (outfile
, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b
)));
462 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
464 fprintf_filtered (outfile
, " %s",
465 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
468 if (BLOCK_GCC_COMPILED(b
))
469 fprintf_filtered (outfile
, " gcc%d compiled", BLOCK_GCC_COMPILED(b
));
470 fprintf_filtered (outfile
, "\n");
471 blen
= BLOCK_NSYMS (b
);
472 for (j
= 0; j
< blen
; j
++)
474 struct print_symbol_args s
;
475 s
.symbol
= BLOCK_SYM (b
, j
);
478 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
482 fprintf_filtered (outfile
, "\n");
486 maintenance_print_symbols (args
, from_tty
)
492 struct cleanup
*cleanups
;
493 char *symname
= NULL
;
494 char *filename
= DEV_TTY
;
495 struct objfile
*objfile
;
503 Arguments missing: an output file name and an optional symbol file name");
505 else if ((argv
= buildargv (args
)) == NULL
)
509 cleanups
= make_cleanup (freeargv
, (char *) argv
);
514 /* If a second arg is supplied, it is a source file name to match on */
521 filename
= tilde_expand (filename
);
522 make_cleanup (free
, filename
);
524 outfile
= gdb_fopen (filename
, FOPEN_WT
);
526 perror_with_name (filename
);
527 make_cleanup (fclose
, (char *) outfile
);
530 ALL_SYMTABS (objfile
, s
)
531 if (symname
== NULL
|| (STREQ (symname
, s
-> filename
)))
532 dump_symtab (objfile
, s
, outfile
);
534 do_cleanups (cleanups
);
537 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
538 far to indent. ARGS is really a struct print_symbol_args *, but is
539 declared as char * to get it past catch_errors. Returns 0 for error,
546 struct symbol
*symbol
= ((struct print_symbol_args
*)args
)->symbol
;
547 int depth
= ((struct print_symbol_args
*)args
)->depth
;
548 GDB_FILE
*outfile
= ((struct print_symbol_args
*)args
)->outfile
;
550 print_spaces (depth
, outfile
);
551 if (SYMBOL_NAMESPACE (symbol
) == LABEL_NAMESPACE
)
553 fprintf_filtered (outfile
, "label %s at ", SYMBOL_SOURCE_NAME (symbol
));
554 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
555 fprintf_filtered (outfile
, "\n");
558 if (SYMBOL_NAMESPACE (symbol
) == STRUCT_NAMESPACE
)
560 if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol
)))
562 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
566 fprintf_filtered (outfile
, "%s %s = ",
567 (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_ENUM
569 : (TYPE_CODE (SYMBOL_TYPE (symbol
)) == TYPE_CODE_STRUCT
570 ? "struct" : "union")),
571 SYMBOL_NAME (symbol
));
572 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), "", outfile
, 1, depth
);
574 fprintf_filtered (outfile
, ";\n");
578 if (SYMBOL_CLASS (symbol
) == LOC_TYPEDEF
)
579 fprintf_filtered (outfile
, "typedef ");
580 if (SYMBOL_TYPE (symbol
))
582 /* Print details of types, except for enums where it's clutter. */
583 LA_PRINT_TYPE (SYMBOL_TYPE (symbol
), SYMBOL_SOURCE_NAME (symbol
),
585 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
587 fprintf_filtered (outfile
, "; ");
590 fprintf_filtered (outfile
, "%s ", SYMBOL_SOURCE_NAME (symbol
));
592 switch (SYMBOL_CLASS (symbol
))
595 fprintf_filtered (outfile
, "const %ld (0x%lx),",
596 SYMBOL_VALUE (symbol
),
597 SYMBOL_VALUE (symbol
));
600 case LOC_CONST_BYTES
:
603 struct type
*type
= check_typedef (SYMBOL_TYPE (symbol
));
604 fprintf_filtered (outfile
, "const %u hex bytes:",
606 for (i
= 0; i
< TYPE_LENGTH (type
); i
++)
607 fprintf_filtered (outfile
, " %02x",
608 (unsigned)SYMBOL_VALUE_BYTES (symbol
) [i
]);
609 fprintf_filtered (outfile
, ",");
614 fprintf_filtered (outfile
, "static at ");
615 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1,outfile
);
616 fprintf_filtered (outfile
, ",");
620 fprintf_filtered (outfile
, "register %ld,", SYMBOL_VALUE (symbol
));
624 fprintf_filtered (outfile
, "arg at offset 0x%lx,",
625 SYMBOL_VALUE (symbol
));
629 fprintf_filtered (outfile
, "arg at offset 0x%lx from fp,",
630 SYMBOL_VALUE (symbol
));
634 fprintf_filtered (outfile
, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol
));
638 fprintf_filtered (outfile
, "parameter register %ld,", SYMBOL_VALUE (symbol
));
641 case LOC_REGPARM_ADDR
:
642 fprintf_filtered (outfile
, "address parameter register %ld,", SYMBOL_VALUE (symbol
));
646 fprintf_filtered (outfile
, "local at offset 0x%lx,",
647 SYMBOL_VALUE (symbol
));
651 fprintf_filtered (outfile
, "local at 0x%lx from register %d",
652 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
655 case LOC_BASEREG_ARG
:
656 fprintf_filtered (outfile
, "arg at 0x%lx from register %d,",
657 SYMBOL_VALUE (symbol
), SYMBOL_BASEREG (symbol
));
664 fprintf_filtered (outfile
, "label at ");
665 print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol
), 1, outfile
);
669 fprintf_filtered (outfile
, "block (object ");
670 gdb_print_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
671 fprintf_filtered (outfile
, ") starting at ");
672 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
)),
675 fprintf_filtered (outfile
, ",");
679 fprintf_filtered (outfile
, "unresolved");
682 case LOC_OPTIMIZED_OUT
:
683 fprintf_filtered (outfile
, "optimized out");
687 fprintf_filtered (outfile
, "botched symbol class %x",
688 SYMBOL_CLASS (symbol
));
692 fprintf_filtered (outfile
, "\n");
697 maintenance_print_psymbols (args
, from_tty
)
703 struct cleanup
*cleanups
;
704 char *symname
= NULL
;
705 char *filename
= DEV_TTY
;
706 struct objfile
*objfile
;
707 struct partial_symtab
*ps
;
713 error ("print-psymbols takes an output file name and optional symbol file name");
715 else if ((argv
= buildargv (args
)) == NULL
)
719 cleanups
= make_cleanup (freeargv
, (char *) argv
);
724 /* If a second arg is supplied, it is a source file name to match on */
731 filename
= tilde_expand (filename
);
732 make_cleanup (free
, filename
);
734 outfile
= gdb_fopen (filename
, FOPEN_WT
);
736 perror_with_name (filename
);
737 make_cleanup (fclose
, outfile
);
740 ALL_PSYMTABS (objfile
, ps
)
741 if (symname
== NULL
|| (STREQ (symname
, ps
-> filename
)))
742 dump_psymtab (objfile
, ps
, outfile
);
744 do_cleanups (cleanups
);
748 print_partial_symbols (p
, count
, what
, outfile
)
749 struct partial_symbol
**p
;
754 fprintf_filtered (outfile
, " %s partial symbols:\n", what
);
757 fprintf_filtered (outfile
, " `%s'", SYMBOL_NAME(*p
));
758 if (SYMBOL_DEMANGLED_NAME (*p
) != NULL
)
760 fprintf_filtered (outfile
, " `%s'", SYMBOL_DEMANGLED_NAME (*p
));
762 fputs_filtered (", ", outfile
);
763 switch (SYMBOL_NAMESPACE (*p
))
765 case UNDEF_NAMESPACE
:
766 fputs_filtered ("undefined namespace, ", outfile
);
769 /* This is the usual thing -- don't print it */
771 case STRUCT_NAMESPACE
:
772 fputs_filtered ("struct namespace, ", outfile
);
774 case LABEL_NAMESPACE
:
775 fputs_filtered ("label namespace, ", outfile
);
778 fputs_filtered ("<invalid namespace>, ", outfile
);
781 switch (SYMBOL_CLASS (*p
))
784 fputs_filtered ("undefined", outfile
);
787 fputs_filtered ("constant int", outfile
);
790 fputs_filtered ("static", outfile
);
793 fputs_filtered ("register", outfile
);
796 fputs_filtered ("pass by value", outfile
);
799 fputs_filtered ("pass by reference", outfile
);
802 fputs_filtered ("register parameter", outfile
);
804 case LOC_REGPARM_ADDR
:
805 fputs_filtered ("register address parameter", outfile
);
808 fputs_filtered ("stack parameter", outfile
);
811 fputs_filtered ("type", outfile
);
814 fputs_filtered ("label", outfile
);
817 fputs_filtered ("function", outfile
);
819 case LOC_CONST_BYTES
:
820 fputs_filtered ("constant bytes", outfile
);
823 fputs_filtered ("shuffled arg", outfile
);
826 fputs_filtered ("unresolved", outfile
);
828 case LOC_OPTIMIZED_OUT
:
829 fputs_filtered ("optimized out", outfile
);
832 fputs_filtered ("<invalid location>", outfile
);
835 fputs_filtered (", ", outfile
);
836 /* FIXME-32x64: Need to use SYMBOL_VALUE_ADDRESS, etc.; this
837 could be 32 bits when some of the other fields in the union
839 fprintf_filtered (outfile
, "0x%lx\n", SYMBOL_VALUE (*p
));
845 maintenance_print_msymbols (args
, from_tty
)
851 struct cleanup
*cleanups
;
852 char *filename
= DEV_TTY
;
853 char *symname
= NULL
;
854 struct objfile
*objfile
;
860 error ("print-msymbols takes an output file name and optional symbol file name");
862 else if ((argv
= buildargv (args
)) == NULL
)
866 cleanups
= make_cleanup (freeargv
, argv
);
871 /* If a second arg is supplied, it is a source file name to match on */
878 filename
= tilde_expand (filename
);
879 make_cleanup (free
, filename
);
881 outfile
= gdb_fopen (filename
, FOPEN_WT
);
883 perror_with_name (filename
);
884 make_cleanup (fclose
, outfile
);
887 ALL_OBJFILES (objfile
)
888 if (symname
== NULL
|| (STREQ (symname
, objfile
-> name
)))
889 dump_msymbols (objfile
, outfile
);
891 fprintf_filtered (outfile
, "\n\n");
892 do_cleanups (cleanups
);
896 maintenance_print_objfiles (ignore
, from_tty
)
900 struct objfile
*objfile
;
905 ALL_OBJFILES (objfile
)
906 dump_objfile (objfile
);
910 /* Check consistency of psymtabs and symtabs. */
913 maintenance_check_symtabs (ignore
, from_tty
)
917 register struct symbol
*sym
;
918 register struct partial_symbol
**psym
;
919 register struct symtab
*s
= NULL
;
920 register struct partial_symtab
*ps
;
921 struct blockvector
*bv
;
922 register struct objfile
*objfile
;
923 register struct block
*b
;
926 ALL_PSYMTABS (objfile
, ps
)
928 s
= PSYMTAB_TO_SYMTAB(ps
);
931 bv
= BLOCKVECTOR (s
);
932 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
933 psym
= ps
->objfile
->static_psymbols
.list
+ ps
->statics_offset
;
934 length
= ps
->n_static_syms
;
937 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
938 SYMBOL_NAMESPACE (*psym
));
941 printf_filtered ("Static symbol `");
942 puts_filtered (SYMBOL_NAME (*psym
));
943 printf_filtered ("' only found in ");
944 puts_filtered (ps
->filename
);
945 printf_filtered (" psymtab\n");
949 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
950 psym
= ps
->objfile
->global_psymbols
.list
+ ps
->globals_offset
;
951 length
= ps
->n_global_syms
;
954 sym
= lookup_block_symbol (b
, SYMBOL_NAME (*psym
),
955 SYMBOL_NAMESPACE (*psym
));
958 printf_filtered ("Global symbol `");
959 puts_filtered (SYMBOL_NAME (*psym
));
960 printf_filtered ("' only found in ");
961 puts_filtered (ps
->filename
);
962 printf_filtered (" psymtab\n");
966 if (ps
->texthigh
< ps
->textlow
)
968 printf_filtered ("Psymtab ");
969 puts_filtered (ps
->filename
);
970 printf_filtered (" covers bad range ");
971 print_address_numeric (ps
->textlow
, 1, stdout
);
972 printf_filtered (" - ");
973 print_address_numeric (ps
->texthigh
, 1, stdout
);
974 printf_filtered ("\n");
977 if (ps
->texthigh
== 0)
979 if (ps
->textlow
< BLOCK_START (b
) || ps
->texthigh
> BLOCK_END (b
))
981 printf_filtered ("Psymtab ");
982 puts_filtered (ps
->filename
);
983 printf_filtered (" covers ");
984 print_address_numeric (ps
->textlow
, 1, stdout
);
985 printf_filtered (" - ");
986 print_address_numeric (ps
->texthigh
, 1, stdout
);
987 printf_filtered (" but symtab covers only ");
988 print_address_numeric (BLOCK_START (b
), 1, stdout
);
989 printf_filtered (" - ");
990 print_address_numeric (BLOCK_END (b
), 1, stdout
);
991 printf_filtered ("\n");
997 /* Return the nexting depth of a block within other blocks in its symtab. */
1001 struct block
*block
;
1004 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
1011 #endif /* MAINTENANCE_CMDS */
1014 /* Increase the space allocated for LISTP, which is probably
1015 global_psymbols or static_psymbols. This space will eventually
1016 be freed in free_objfile(). */
1019 extend_psymbol_list (listp
, objfile
)
1020 register struct psymbol_allocation_list
*listp
;
1021 struct objfile
*objfile
;
1024 if (listp
->size
== 0)
1027 listp
->list
= (struct partial_symbol
**)
1028 xmmalloc (objfile
-> md
, new_size
* sizeof (struct partial_symbol
*));
1032 new_size
= listp
->size
* 2;
1033 listp
->list
= (struct partial_symbol
**)
1034 xmrealloc (objfile
-> md
, (char *) listp
->list
,
1035 new_size
* sizeof (struct partial_symbol
*));
1037 /* Next assumes we only went one over. Should be good if
1038 program works correctly */
1039 listp
->next
= listp
->list
+ listp
->size
;
1040 listp
->size
= new_size
;
1044 /* Do early runtime initializations. */
1046 _initialize_symmisc ()
This page took 0.049909 seconds and 4 git commands to generate.