1 /* Do various things to symbol tables (other than lookup), for GDB.
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2008
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 #include "breakpoint.h"
30 #include "gdb_obstack.h"
31 #include "exceptions.h"
35 #include "gdb_regex.h"
37 #include "dictionary.h"
39 #include "gdb_string.h"
40 #include "readline/readline.h"
43 #define DEV_TTY "/dev/tty"
46 /* Unfortunately for debugging, stderr is usually a macro. This is painful
47 when calling functions that take FILE *'s from the debugger.
48 So we make a variable which has the same value and which is accessible when
49 debugging GDB with itself. Because stdin et al need not be constants,
50 we initialize them in the _initialize_symmisc function at the bottom
56 /* Prototypes for local functions */
58 static void dump_symtab (struct objfile
*, struct symtab
*,
61 static void dump_psymtab (struct objfile
*, struct partial_symtab
*,
64 static void dump_msymbols (struct objfile
*, struct ui_file
*);
66 static void dump_objfile (struct objfile
*);
68 static int block_depth (struct block
*);
70 static void print_partial_symbols (struct partial_symbol
**, int,
71 char *, struct ui_file
*);
73 void _initialize_symmisc (void);
75 struct print_symbol_args
77 struct symbol
*symbol
;
79 struct ui_file
*outfile
;
82 static int print_symbol (void *);
84 /* Free all the storage associated with the struct symtab <- S.
85 Note that some symtabs have contents that all live inside one big block of
86 memory, and some share the contents of another symbol table and so you
87 should not free the contents on their behalf (except sometimes the
88 linetable, which maybe per symtab even when the rest is not).
89 It is s->free_code that says which alternative to use. */
92 free_symtab (struct symtab
*s
)
95 struct blockvector
*bv
;
100 /* All the contents are part of a big block of memory (an obstack),
101 and some other symtab is in charge of freeing that block.
102 Therefore, do nothing. */
106 /* Everything will be freed either by our `free_func'
107 or by some other symtab, except for our linetable.
110 xfree (LINETABLE (s
));
114 /* If there is a single block of memory to free, free it. */
115 if (s
->free_func
!= NULL
)
118 /* Free source-related stuff */
119 if (s
->line_charpos
!= NULL
)
120 xfree (s
->line_charpos
);
121 if (s
->fullname
!= NULL
)
123 if (s
->debugformat
!= NULL
)
124 xfree (s
->debugformat
);
129 print_symbol_bcache_statistics (void)
131 struct objfile
*objfile
;
134 ALL_OBJFILES (objfile
)
136 printf_filtered (_("Byte cache statistics for '%s':\n"), objfile
->name
);
137 print_bcache_statistics (objfile
->psymbol_cache
, "partial symbol cache");
143 print_objfile_statistics (void)
145 struct objfile
*objfile
;
147 struct partial_symtab
*ps
;
148 int i
, linetables
, blockvectors
;
151 ALL_OBJFILES (objfile
)
153 printf_filtered (_("Statistics for '%s':\n"), objfile
->name
);
154 if (OBJSTAT (objfile
, n_stabs
) > 0)
155 printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
156 OBJSTAT (objfile
, n_stabs
));
157 if (OBJSTAT (objfile
, n_minsyms
) > 0)
158 printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
159 OBJSTAT (objfile
, n_minsyms
));
160 if (OBJSTAT (objfile
, n_psyms
) > 0)
161 printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
162 OBJSTAT (objfile
, n_psyms
));
163 if (OBJSTAT (objfile
, n_syms
) > 0)
164 printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
165 OBJSTAT (objfile
, n_syms
));
166 if (OBJSTAT (objfile
, n_types
) > 0)
167 printf_filtered (_(" Number of \"types\" defined: %d\n"),
168 OBJSTAT (objfile
, n_types
));
170 ALL_OBJFILE_PSYMTABS (objfile
, ps
)
175 printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i
);
176 i
= linetables
= blockvectors
= 0;
177 ALL_OBJFILE_SYMTABS (objfile
, s
)
180 if (s
->linetable
!= NULL
)
185 printf_filtered (_(" Number of symbol tables: %d\n"), i
);
186 printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
188 printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
191 if (OBJSTAT (objfile
, sz_strtab
) > 0)
192 printf_filtered (_(" Space used by a.out string tables: %d\n"),
193 OBJSTAT (objfile
, sz_strtab
));
194 printf_filtered (_(" Total memory used for objfile obstack: %d\n"),
195 obstack_memory_used (&objfile
->objfile_obstack
));
196 printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
197 bcache_memory_used (objfile
->psymbol_cache
));
198 printf_filtered (_(" Total memory used for macro cache: %d\n"),
199 bcache_memory_used (objfile
->macro_cache
));
205 dump_objfile (struct objfile
*objfile
)
207 struct symtab
*symtab
;
208 struct partial_symtab
*psymtab
;
210 printf_filtered ("\nObject file %s: ", objfile
->name
);
211 printf_filtered ("Objfile at ");
212 gdb_print_host_address (objfile
, gdb_stdout
);
213 printf_filtered (", bfd at ");
214 gdb_print_host_address (objfile
->obfd
, gdb_stdout
);
215 printf_filtered (", %d minsyms\n\n",
216 objfile
->minimal_symbol_count
);
218 if (objfile
->psymtabs
)
220 printf_filtered ("Psymtabs:\n");
221 for (psymtab
= objfile
->psymtabs
;
223 psymtab
= psymtab
->next
)
225 printf_filtered ("%s at ",
227 gdb_print_host_address (psymtab
, gdb_stdout
);
228 printf_filtered (", ");
229 if (psymtab
->objfile
!= objfile
)
231 printf_filtered ("NOT ON CHAIN! ");
235 printf_filtered ("\n\n");
238 if (objfile
->symtabs
)
240 printf_filtered ("Symtabs:\n");
241 for (symtab
= objfile
->symtabs
;
243 symtab
= symtab
->next
)
245 printf_filtered ("%s at ", symtab
->filename
);
246 gdb_print_host_address (symtab
, gdb_stdout
);
247 printf_filtered (", ");
248 if (symtab
->objfile
!= objfile
)
250 printf_filtered ("NOT ON CHAIN! ");
254 printf_filtered ("\n\n");
258 /* Print minimal symbols from this objfile. */
261 dump_msymbols (struct objfile
*objfile
, struct ui_file
*outfile
)
263 struct minimal_symbol
*msymbol
;
267 fprintf_filtered (outfile
, "\nObject file %s:\n\n", objfile
->name
);
268 if (objfile
->minimal_symbol_count
== 0)
270 fprintf_filtered (outfile
, "No minimal symbols found.\n");
273 for (index
= 0, msymbol
= objfile
->msymbols
;
274 DEPRECATED_SYMBOL_NAME (msymbol
) != NULL
; msymbol
++, index
++)
276 switch (msymbol
->type
)
284 case mst_solib_trampoline
:
309 fprintf_filtered (outfile
, "[%2d] %c ", index
, ms_type
);
310 fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (msymbol
)), outfile
);
311 fprintf_filtered (outfile
, " %s", DEPRECATED_SYMBOL_NAME (msymbol
));
312 if (SYMBOL_BFD_SECTION (msymbol
))
313 fprintf_filtered (outfile
, " section %s",
314 bfd_section_name (objfile
->obfd
,
315 SYMBOL_BFD_SECTION (msymbol
)));
316 if (SYMBOL_DEMANGLED_NAME (msymbol
) != NULL
)
318 fprintf_filtered (outfile
, " %s", SYMBOL_DEMANGLED_NAME (msymbol
));
320 if (msymbol
->filename
)
321 fprintf_filtered (outfile
, " %s", msymbol
->filename
);
322 fputs_filtered ("\n", outfile
);
324 if (objfile
->minimal_symbol_count
!= index
)
326 warning (_("internal error: minimal symbol count %d != %d"),
327 objfile
->minimal_symbol_count
, index
);
329 fprintf_filtered (outfile
, "\n");
333 dump_psymtab (struct objfile
*objfile
, struct partial_symtab
*psymtab
,
334 struct ui_file
*outfile
)
338 fprintf_filtered (outfile
, "\nPartial symtab for source file %s ",
340 fprintf_filtered (outfile
, "(object ");
341 gdb_print_host_address (psymtab
, outfile
);
342 fprintf_filtered (outfile
, ")\n\n");
343 fprintf_unfiltered (outfile
, " Read from object file %s (",
345 gdb_print_host_address (objfile
, outfile
);
346 fprintf_unfiltered (outfile
, ")\n");
350 fprintf_filtered (outfile
,
351 " Full symtab was read (at ");
352 gdb_print_host_address (psymtab
->symtab
, outfile
);
353 fprintf_filtered (outfile
, " by function at ");
354 gdb_print_host_address (psymtab
->read_symtab
, outfile
);
355 fprintf_filtered (outfile
, ")\n");
358 fprintf_filtered (outfile
, " Relocate symbols by ");
359 for (i
= 0; i
< psymtab
->objfile
->num_sections
; ++i
)
362 fprintf_filtered (outfile
, ", ");
364 fputs_filtered (paddress (ANOFFSET (psymtab
->section_offsets
, i
)),
367 fprintf_filtered (outfile
, "\n");
369 fprintf_filtered (outfile
, " Symbols cover text addresses ");
370 fputs_filtered (paddress (psymtab
->textlow
), outfile
);
371 fprintf_filtered (outfile
, "-");
372 fputs_filtered (paddress (psymtab
->texthigh
), outfile
);
373 fprintf_filtered (outfile
, "\n");
374 fprintf_filtered (outfile
, " Depends on %d other partial symtabs.\n",
375 psymtab
->number_of_dependencies
);
376 for (i
= 0; i
< psymtab
->number_of_dependencies
; i
++)
378 fprintf_filtered (outfile
, " %d ", i
);
379 gdb_print_host_address (psymtab
->dependencies
[i
], outfile
);
380 fprintf_filtered (outfile
, " %s\n",
381 psymtab
->dependencies
[i
]->filename
);
383 if (psymtab
->n_global_syms
> 0)
385 print_partial_symbols (objfile
->global_psymbols
.list
386 + psymtab
->globals_offset
,
387 psymtab
->n_global_syms
, "Global", outfile
);
389 if (psymtab
->n_static_syms
> 0)
391 print_partial_symbols (objfile
->static_psymbols
.list
392 + psymtab
->statics_offset
,
393 psymtab
->n_static_syms
, "Static", outfile
);
395 fprintf_filtered (outfile
, "\n");
399 dump_symtab_1 (struct objfile
*objfile
, struct symtab
*symtab
,
400 struct ui_file
*outfile
)
403 struct dict_iterator iter
;
406 struct blockvector
*bv
;
411 fprintf_filtered (outfile
, "\nSymtab for file %s\n", symtab
->filename
);
413 fprintf_filtered (outfile
, "Compilation directory is %s\n",
415 fprintf_filtered (outfile
, "Read from object file %s (", objfile
->name
);
416 gdb_print_host_address (objfile
, outfile
);
417 fprintf_filtered (outfile
, ")\n");
418 fprintf_filtered (outfile
, "Language: %s\n", language_str (symtab
->language
));
420 /* First print the line table. */
421 l
= LINETABLE (symtab
);
424 fprintf_filtered (outfile
, "\nLine table:\n\n");
426 for (i
= 0; i
< len
; i
++)
428 fprintf_filtered (outfile
, " line %d at ", l
->item
[i
].line
);
429 fputs_filtered (paddress (l
->item
[i
].pc
), outfile
);
430 fprintf_filtered (outfile
, "\n");
433 /* Now print the block info, but only for primary symtabs since we will
434 print lots of duplicate info otherwise. */
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 at ", i
);
446 gdb_print_host_address (b
, outfile
);
447 if (BLOCK_SUPERBLOCK (b
))
449 fprintf_filtered (outfile
, " under ");
450 gdb_print_host_address (BLOCK_SUPERBLOCK (b
), outfile
);
452 /* drow/2002-07-10: We could save the total symbols count
453 even if we're using a hashtable, but nothing else but this message
455 fprintf_filtered (outfile
, ", %d syms/buckets in ",
456 dict_size (BLOCK_DICT (b
)));
457 fputs_filtered (paddress (BLOCK_START (b
)), outfile
);
458 fprintf_filtered (outfile
, "..");
459 fputs_filtered (paddress (BLOCK_END (b
)), outfile
);
460 if (BLOCK_FUNCTION (b
))
462 fprintf_filtered (outfile
, ", function %s", DEPRECATED_SYMBOL_NAME (BLOCK_FUNCTION (b
)));
463 if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)) != NULL
)
465 fprintf_filtered (outfile
, ", %s",
466 SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b
)));
469 fprintf_filtered (outfile
, "\n");
470 /* Now print each symbol in this block (in no particular order, if
471 we're using a hashtable). */
472 ALL_BLOCK_SYMBOLS (b
, iter
, sym
)
474 struct print_symbol_args s
;
478 catch_errors (print_symbol
, &s
, "Error printing symbol:\n",
482 fprintf_filtered (outfile
, "\n");
486 fprintf_filtered (outfile
, "\nBlockvector same as previous symtab\n\n");
491 dump_symtab (struct objfile
*objfile
, struct symtab
*symtab
,
492 struct ui_file
*outfile
)
494 enum language saved_lang
;
496 /* Set the current language to the language of the symtab we're dumping
497 because certain routines used during dump_symtab() use the current
498 language to print an image of the symbol. We'll restore it later. */
499 saved_lang
= set_language (symtab
->language
);
501 dump_symtab_1 (objfile
, symtab
, outfile
);
503 set_language (saved_lang
);
507 maintenance_print_symbols (char *args
, int from_tty
)
510 struct ui_file
*outfile
;
511 struct cleanup
*cleanups
;
512 char *symname
= NULL
;
513 char *filename
= DEV_TTY
;
514 struct objfile
*objfile
;
522 Arguments missing: an output file name and an optional symbol file name"));
524 else if ((argv
= buildargv (args
)) == NULL
)
528 cleanups
= make_cleanup_freeargv (argv
);
533 /* If a second arg is supplied, it is a source file name to match on */
540 filename
= tilde_expand (filename
);
541 make_cleanup (xfree
, filename
);
543 outfile
= gdb_fopen (filename
, FOPEN_WT
);
545 perror_with_name (filename
);
546 make_cleanup_ui_file_delete (outfile
);
549 ALL_SYMTABS (objfile
, s
)
550 if (symname
== NULL
|| strcmp (symname
, s
->filename
) == 0)
551 dump_symtab (objfile
, s
, outfile
);
553 do_cleanups (cleanups
);
556 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
557 far to indent. ARGS is really a struct print_symbol_args *, but is
558 declared as char * to get it past catch_errors. Returns 0 for error,
562 print_symbol (void *args
)
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_DOMAIN (symbol
) == LABEL_DOMAIN
)
571 fprintf_filtered (outfile
, "label %s at ", SYMBOL_PRINT_NAME (symbol
));
572 fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (symbol
)), 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_DOMAIN (symbol
) == STRUCT_DOMAIN
)
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 DEPRECATED_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_PRINT_NAME (symbol
),
608 TYPE_CODE (SYMBOL_TYPE (symbol
)) != TYPE_CODE_ENUM
,
610 fprintf_filtered (outfile
, "; ");
613 fprintf_filtered (outfile
, "%s ", SYMBOL_PRINT_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 fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (symbol
)), 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 if (SYMBOL_IS_ARGUMENT (symbol
))
647 fprintf_filtered (outfile
, "parameter register %ld",
648 SYMBOL_VALUE (symbol
));
650 fprintf_filtered (outfile
, "register %ld", SYMBOL_VALUE (symbol
));
654 fprintf_filtered (outfile
, "arg at offset 0x%lx",
655 SYMBOL_VALUE (symbol
));
659 fprintf_filtered (outfile
, "reference arg at 0x%lx", SYMBOL_VALUE (symbol
));
662 case LOC_REGPARM_ADDR
:
663 fprintf_filtered (outfile
, "address parameter register %ld", SYMBOL_VALUE (symbol
));
667 fprintf_filtered (outfile
, "local at offset 0x%lx",
668 SYMBOL_VALUE (symbol
));
675 fprintf_filtered (outfile
, "label at ");
676 fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (symbol
)), outfile
);
677 if (SYMBOL_BFD_SECTION (symbol
))
678 fprintf_filtered (outfile
, " section %s",
680 (SYMBOL_BFD_SECTION (symbol
)->owner
,
681 SYMBOL_BFD_SECTION (symbol
)));
685 fprintf_filtered (outfile
, "block object ");
686 gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol
), outfile
);
687 fprintf_filtered (outfile
, ", ");
688 fputs_filtered (paddress (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol
))),
690 fprintf_filtered (outfile
, "..");
691 fputs_filtered (paddress (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol
))),
693 if (SYMBOL_BFD_SECTION (symbol
))
694 fprintf_filtered (outfile
, " section %s",
696 (SYMBOL_BFD_SECTION (symbol
)->owner
,
697 SYMBOL_BFD_SECTION (symbol
)));
701 fprintf_filtered (outfile
, "computed at runtime");
705 fprintf_filtered (outfile
, "unresolved");
708 case LOC_OPTIMIZED_OUT
:
709 fprintf_filtered (outfile
, "optimized out");
713 fprintf_filtered (outfile
, "botched symbol class %x",
714 SYMBOL_CLASS (symbol
));
718 fprintf_filtered (outfile
, "\n");
723 maintenance_print_psymbols (char *args
, int from_tty
)
726 struct ui_file
*outfile
;
727 struct cleanup
*cleanups
;
728 char *symname
= NULL
;
729 char *filename
= DEV_TTY
;
730 struct objfile
*objfile
;
731 struct partial_symtab
*ps
;
737 error (_("print-psymbols takes an output file name and optional symbol file name"));
739 else if ((argv
= buildargv (args
)) == NULL
)
743 cleanups
= make_cleanup_freeargv (argv
);
748 /* If a second arg is supplied, it is a source file name to match on */
755 filename
= tilde_expand (filename
);
756 make_cleanup (xfree
, filename
);
758 outfile
= gdb_fopen (filename
, FOPEN_WT
);
760 perror_with_name (filename
);
761 make_cleanup_ui_file_delete (outfile
);
764 ALL_PSYMTABS (objfile
, ps
)
765 if (symname
== NULL
|| strcmp (symname
, ps
->filename
) == 0)
766 dump_psymtab (objfile
, ps
, outfile
);
768 do_cleanups (cleanups
);
772 print_partial_symbols (struct partial_symbol
**p
, int count
, char *what
,
773 struct ui_file
*outfile
)
775 fprintf_filtered (outfile
, " %s partial symbols:\n", what
);
778 fprintf_filtered (outfile
, " `%s'", DEPRECATED_SYMBOL_NAME (*p
));
779 if (SYMBOL_DEMANGLED_NAME (*p
) != NULL
)
781 fprintf_filtered (outfile
, " `%s'", SYMBOL_DEMANGLED_NAME (*p
));
783 fputs_filtered (", ", outfile
);
784 switch (SYMBOL_DOMAIN (*p
))
787 fputs_filtered ("undefined domain, ", outfile
);
790 /* This is the usual thing -- don't print it */
793 fputs_filtered ("struct domain, ", outfile
);
796 fputs_filtered ("label domain, ", outfile
);
799 fputs_filtered ("<invalid domain>, ", outfile
);
802 switch (SYMBOL_CLASS (*p
))
805 fputs_filtered ("undefined", outfile
);
808 fputs_filtered ("constant int", outfile
);
811 fputs_filtered ("static", outfile
);
814 fputs_filtered ("register", outfile
);
817 fputs_filtered ("pass by value", outfile
);
820 fputs_filtered ("pass by reference", outfile
);
822 case LOC_REGPARM_ADDR
:
823 fputs_filtered ("register address parameter", outfile
);
826 fputs_filtered ("stack parameter", outfile
);
829 fputs_filtered ("type", outfile
);
832 fputs_filtered ("label", outfile
);
835 fputs_filtered ("function", outfile
);
837 case LOC_CONST_BYTES
:
838 fputs_filtered ("constant bytes", outfile
);
841 fputs_filtered ("unresolved", outfile
);
843 case LOC_OPTIMIZED_OUT
:
844 fputs_filtered ("optimized out", outfile
);
847 fputs_filtered ("computed at runtime", outfile
);
850 fputs_filtered ("<invalid location>", outfile
);
853 fputs_filtered (", ", outfile
);
854 fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (*p
)), outfile
);
855 fprintf_filtered (outfile
, "\n");
861 maintenance_print_msymbols (char *args
, int from_tty
)
864 struct ui_file
*outfile
;
865 struct cleanup
*cleanups
;
866 char *filename
= DEV_TTY
;
867 char *symname
= NULL
;
868 struct objfile
*objfile
;
870 struct stat sym_st
, obj_st
;
876 error (_("print-msymbols takes an output file name and optional symbol file name"));
878 else if ((argv
= buildargv (args
)) == NULL
)
882 cleanups
= make_cleanup_freeargv (argv
);
887 /* If a second arg is supplied, it is a source file name to match on */
890 symname
= xfullpath (argv
[1]);
891 make_cleanup (xfree
, symname
);
892 if (symname
&& stat (symname
, &sym_st
))
893 perror_with_name (symname
);
897 filename
= tilde_expand (filename
);
898 make_cleanup (xfree
, filename
);
900 outfile
= gdb_fopen (filename
, FOPEN_WT
);
902 perror_with_name (filename
);
903 make_cleanup_ui_file_delete (outfile
);
906 ALL_OBJFILES (objfile
)
908 || (!stat (objfile
->name
, &obj_st
) && sym_st
.st_ino
== obj_st
.st_ino
))
909 dump_msymbols (objfile
, outfile
);
911 fprintf_filtered (outfile
, "\n\n");
912 do_cleanups (cleanups
);
916 maintenance_print_objfiles (char *ignore
, int from_tty
)
918 struct objfile
*objfile
;
923 ALL_OBJFILES (objfile
)
924 dump_objfile (objfile
);
929 /* List all the symbol tables whose names match REGEXP (optional). */
931 maintenance_info_symtabs (char *regexp
, int from_tty
)
933 struct objfile
*objfile
;
938 ALL_OBJFILES (objfile
)
940 struct symtab
*symtab
;
942 /* We don't want to print anything for this objfile until we
943 actually find a symtab whose name matches. */
944 int printed_objfile_start
= 0;
946 ALL_OBJFILE_SYMTABS (objfile
, symtab
)
948 || re_exec (symtab
->filename
))
950 if (! printed_objfile_start
)
952 printf_filtered ("{ objfile %s ", objfile
->name
);
954 printf_filtered ("((struct objfile *) %p)\n", objfile
);
955 printed_objfile_start
= 1;
958 printf_filtered (" { symtab %s ", symtab
->filename
);
960 printf_filtered ("((struct symtab *) %p)\n", symtab
);
961 printf_filtered (" dirname %s\n",
962 symtab
->dirname
? symtab
->dirname
: "(null)");
963 printf_filtered (" fullname %s\n",
964 symtab
->fullname
? symtab
->fullname
: "(null)");
965 printf_filtered (" blockvector ((struct blockvector *) %p)%s\n",
967 symtab
->primary
? " (primary)" : "");
968 printf_filtered (" linetable ((struct linetable *) %p)\n",
970 printf_filtered (" debugformat %s\n", symtab
->debugformat
);
971 printf_filtered (" }\n");
974 if (printed_objfile_start
)
975 printf_filtered ("}\n");
980 /* List all the partial symbol tables whose names match REGEXP (optional). */
982 maintenance_info_psymtabs (char *regexp
, int from_tty
)
984 struct objfile
*objfile
;
989 ALL_OBJFILES (objfile
)
991 struct partial_symtab
*psymtab
;
993 /* We don't want to print anything for this objfile until we
994 actually find a symtab whose name matches. */
995 int printed_objfile_start
= 0;
997 ALL_OBJFILE_PSYMTABS (objfile
, psymtab
)
999 || re_exec (psymtab
->filename
))
1001 if (! printed_objfile_start
)
1003 printf_filtered ("{ objfile %s ", objfile
->name
);
1005 printf_filtered ("((struct objfile *) %p)\n", objfile
);
1006 printed_objfile_start
= 1;
1009 printf_filtered (" { psymtab %s ", psymtab
->filename
);
1011 printf_filtered ("((struct partial_symtab *) %p)\n", psymtab
);
1012 printf_filtered (" readin %s\n",
1013 psymtab
->readin
? "yes" : "no");
1014 printf_filtered (" fullname %s\n",
1015 psymtab
->fullname
? psymtab
->fullname
: "(null)");
1016 printf_filtered (" text addresses ");
1017 fputs_filtered (paddress (psymtab
->textlow
), gdb_stdout
);
1018 printf_filtered (" -- ");
1019 fputs_filtered (paddress (psymtab
->texthigh
), gdb_stdout
);
1020 printf_filtered ("\n");
1021 printf_filtered (" globals ");
1022 if (psymtab
->n_global_syms
)
1024 printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n",
1025 (psymtab
->objfile
->global_psymbols
.list
1026 + psymtab
->globals_offset
),
1027 psymtab
->n_global_syms
);
1030 printf_filtered ("(none)\n");
1031 printf_filtered (" statics ");
1032 if (psymtab
->n_static_syms
)
1034 printf_filtered ("(* (struct partial_symbol **) %p @ %d)\n",
1035 (psymtab
->objfile
->static_psymbols
.list
1036 + psymtab
->statics_offset
),
1037 psymtab
->n_static_syms
);
1040 printf_filtered ("(none)\n");
1041 printf_filtered (" dependencies ");
1042 if (psymtab
->number_of_dependencies
)
1046 printf_filtered ("{\n");
1047 for (i
= 0; i
< psymtab
->number_of_dependencies
; i
++)
1049 struct partial_symtab
*dep
= psymtab
->dependencies
[i
];
1051 /* Note the string concatenation there --- no comma. */
1052 printf_filtered (" psymtab %s "
1053 "((struct partial_symtab *) %p)\n",
1054 dep
->filename
, dep
);
1056 printf_filtered (" }\n");
1059 printf_filtered ("(none)\n");
1060 printf_filtered (" }\n");
1063 if (printed_objfile_start
)
1064 printf_filtered ("}\n");
1069 /* Check consistency of psymtabs and symtabs. */
1072 maintenance_check_symtabs (char *ignore
, int from_tty
)
1075 struct partial_symbol
**psym
;
1076 struct symtab
*s
= NULL
;
1077 struct partial_symtab
*ps
;
1078 struct blockvector
*bv
;
1079 struct objfile
*objfile
;
1083 ALL_PSYMTABS (objfile
, ps
)
1085 s
= PSYMTAB_TO_SYMTAB (ps
);
1088 bv
= BLOCKVECTOR (s
);
1089 b
= BLOCKVECTOR_BLOCK (bv
, STATIC_BLOCK
);
1090 psym
= ps
->objfile
->static_psymbols
.list
+ ps
->statics_offset
;
1091 length
= ps
->n_static_syms
;
1094 sym
= lookup_block_symbol (b
, DEPRECATED_SYMBOL_NAME (*psym
),
1095 NULL
, SYMBOL_DOMAIN (*psym
));
1098 printf_filtered ("Static symbol `");
1099 puts_filtered (DEPRECATED_SYMBOL_NAME (*psym
));
1100 printf_filtered ("' only found in ");
1101 puts_filtered (ps
->filename
);
1102 printf_filtered (" psymtab\n");
1106 b
= BLOCKVECTOR_BLOCK (bv
, GLOBAL_BLOCK
);
1107 psym
= ps
->objfile
->global_psymbols
.list
+ ps
->globals_offset
;
1108 length
= ps
->n_global_syms
;
1111 sym
= lookup_block_symbol (b
, DEPRECATED_SYMBOL_NAME (*psym
),
1112 NULL
, SYMBOL_DOMAIN (*psym
));
1115 printf_filtered ("Global symbol `");
1116 puts_filtered (DEPRECATED_SYMBOL_NAME (*psym
));
1117 printf_filtered ("' only found in ");
1118 puts_filtered (ps
->filename
);
1119 printf_filtered (" psymtab\n");
1123 if (ps
->texthigh
< ps
->textlow
)
1125 printf_filtered ("Psymtab ");
1126 puts_filtered (ps
->filename
);
1127 printf_filtered (" covers bad range ");
1128 fputs_filtered (paddress (ps
->textlow
), gdb_stdout
);
1129 printf_filtered (" - ");
1130 fputs_filtered (paddress (ps
->texthigh
), gdb_stdout
);
1131 printf_filtered ("\n");
1134 if (ps
->texthigh
== 0)
1136 if (ps
->textlow
< BLOCK_START (b
) || ps
->texthigh
> BLOCK_END (b
))
1138 printf_filtered ("Psymtab ");
1139 puts_filtered (ps
->filename
);
1140 printf_filtered (" covers ");
1141 fputs_filtered (paddress (ps
->textlow
), gdb_stdout
);
1142 printf_filtered (" - ");
1143 fputs_filtered (paddress (ps
->texthigh
), gdb_stdout
);
1144 printf_filtered (" but symtab covers only ");
1145 fputs_filtered (paddress (BLOCK_START (b
)), gdb_stdout
);
1146 printf_filtered (" - ");
1147 fputs_filtered (paddress (BLOCK_END (b
)), gdb_stdout
);
1148 printf_filtered ("\n");
1154 /* Return the nexting depth of a block within other blocks in its symtab. */
1157 block_depth (struct block
*block
)
1160 while ((block
= BLOCK_SUPERBLOCK (block
)) != NULL
)
1168 /* Increase the space allocated for LISTP, which is probably
1169 global_psymbols or static_psymbols. This space will eventually
1170 be freed in free_objfile(). */
1173 extend_psymbol_list (struct psymbol_allocation_list
*listp
,
1174 struct objfile
*objfile
)
1177 if (listp
->size
== 0)
1180 listp
->list
= (struct partial_symbol
**)
1181 xmalloc (new_size
* sizeof (struct partial_symbol
*));
1185 new_size
= listp
->size
* 2;
1186 listp
->list
= (struct partial_symbol
**)
1187 xrealloc ((char *) listp
->list
,
1188 new_size
* sizeof (struct partial_symbol
*));
1190 /* Next assumes we only went one over. Should be good if
1191 program works correctly */
1192 listp
->next
= listp
->list
+ listp
->size
;
1193 listp
->size
= new_size
;
1197 /* Do early runtime initializations. */
1199 _initialize_symmisc (void)
This page took 0.054282 seconds and 4 git commands to generate.