29#include "gdbsupport/gdb_obstack.h"
33#include "gdbsupport/gdb_regex.h"
39#include "readline/tilde.h"
41#include "gdbsupport/buildargv.h"
54 int i, linetables, blockvectors;
62 gdb_printf (_(
" Number of \"stab\" symbols read: %d\n"),
65 gdb_printf (_(
" Number of \"minimal\" symbols read: %d\n"),
68 gdb_printf (_(
" Number of \"full\" symbols read: %d\n"),
71 gdb_printf (_(
" Number of \"types\" defined: %d\n"),
77 for (
symtab *s : cu->filetabs ())
80 if (s->linetable () != NULL)
86 gdb_printf (_(
" Number of symbol tables: %d\n"), i);
87 gdb_printf (_(
" Number of symbol tables with line tables: %d\n"),
89 gdb_printf (_(
" Number of symbol tables with blockvectors: %d\n"),
95 gdb_printf (_(
" Space used by string tables: %d\n"),
97 gdb_printf (_(
" Total memory used for objfile obstack: %s\n"),
98 pulongest (obstack_memory_used (&
objfile
100 gdb_printf (_(
" Total memory used for BFD obstack: %s\n"),
104 gdb_printf (_(
" Total memory used for string cache: %d\n"),
106 gdb_printf (_(
"Byte cache statistics for '%s':\n"),
117 gdb_printf (
"Objfile at %s, bfd at %s, %d minsyms\n\n",
118 host_address_to_string (
objfile),
133 host_address_to_string (
symtab));
155 gdb_printf (outfile,
"No minimal symbols found.\n");
163 switch (msymbol->type ())
200 gdb_printf (outfile,
"[%2d] %c ", index, ms_type);
204 CORE_ADDR
addr = (msymbol->value_raw_address ()
207 gdb_printf (outfile,
" %s", msymbol->linkage_name ());
217 if (msymbol->demangled_name () != NULL)
219 gdb_printf (outfile,
" %s", msymbol->demangled_name ());
221 if (msymbol->filename)
222 gdb_printf (outfile,
" %s", msymbol->filename);
228 warning (_(
"internal error: minimal symbol count %d != %d"),
244 gdb_printf (outfile,
"\nSymtab for file %s at %s\n",
246 host_address_to_string (
symtab));
249 gdb_printf (outfile,
"Compilation directory is %s\n",
251 gdb_printf (outfile,
"Read from object file %s (%s)\n",
253 host_address_to_string (
objfile));
263 for (
int i = 0; i < len; i++)
282 gdb_printf (outfile,
"%*sblock #%03d, object at %s",
284 host_address_to_string (b));
316 catch (
const gdb_exception_error &ex)
319 "Error printing symbol:\n");
328 const char *compunit_filename
332 "\nBlockvector same as owning compunit: %s\n\n",
342 if (cust->
user !=
nullptr)
346 gdb_printf (outfile,
"Compunit user: %s\n", addr);
349 for (
int i = 0; ; ++i)
352 if (include ==
nullptr)
356 gdb_printf (outfile,
"Compunit include: %s\n", addr);
383 char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
388 gdb_argv argv (args);
390 for (i = 0; argv != NULL && argv[i] != NULL; ++i)
392 if (strcmp (argv[i],
"-pc") == 0)
394 if (argv[i + 1] == NULL)
395 error (_(
"Missing pc value"));
396 address_arg = argv[++i];
398 else if (strcmp (argv[i],
"-source") == 0)
400 if (argv[i + 1] == NULL)
401 error (_(
"Missing source file"));
402 source_arg = argv[++i];
404 else if (strcmp (argv[i],
"-objfile") == 0)
406 if (argv[i + 1] == NULL)
407 error (_(
"Missing objfile name"));
408 objfile_arg = argv[++i];
410 else if (strcmp (argv[i],
"--") == 0)
416 else if (argv[i][0] ==
'-')
419 error (_(
"Unknown option: %s"), argv[i]);
426 if (address_arg != NULL && source_arg != NULL)
427 error (_(
"Must specify at most one of -pc and -source"));
431 if (argv != NULL && argv[outfile_idx] != NULL)
433 if (argv[outfile_idx + 1] != NULL)
434 error (_(
"Junk at end of command"));
435 gdb::unique_xmalloc_ptr<char> outfile_name
436 (tilde_expand (argv[outfile_idx]));
437 if (!arg_outfile.
open (outfile_name.get (), FOPEN_WT))
439 outfile = &arg_outfile;
442 if (address_arg != NULL)
448 error (_(
"No symtab for address: %s"), address_arg);
457 int print_for_objfile = 1;
459 if (objfile_arg != NULL)
463 if (!print_for_objfile)
468 for (
symtab *s : cu->filetabs ())
470 int print_for_source = 0;
473 if (source_arg != NULL)
480 if (source_arg == NULL
487 if (source_arg != NULL && !found)
488 error (_(
"No symtab for source file: %s"), source_arg);
532 ?
"struct" :
"union")),
605 gdb_printf (outfile,
"address parameter register %s",
627 (outfile,
"block object %s, %s..%s",
649 gdb_printf (outfile,
"botched symbol class %x",
661 char *objfile_arg = NULL;
666 gdb_argv argv (args);
668 for (i = 0; argv != NULL && argv[i] != NULL; ++i)
670 if (strcmp (argv[i],
"-objfile") == 0)
672 if (argv[i + 1] == NULL)
673 error (_(
"Missing objfile name"));
674 objfile_arg = argv[++i];
676 else if (strcmp (argv[i],
"--") == 0)
682 else if (argv[i][0] ==
'-')
685 error (_(
"Unknown option: %s"), argv[i]);
694 if (argv != NULL && argv[outfile_idx] != NULL)
696 if (argv[outfile_idx + 1] != NULL)
697 error (_(
"Junk at end of command"));
698 gdb::unique_xmalloc_ptr<char> outfile_name
699 (tilde_expand (argv[outfile_idx]));
700 if (!arg_outfile.
open (outfile_name.get (), FOPEN_WT))
702 outfile = &arg_outfile;
708 if (objfile_arg == NULL
747 int printed_objfile_start = 0;
751 int printed_compunit_symtab_start = 0;
760 if (! printed_objfile_start)
765 host_address_to_string (
objfile));
766 printed_objfile_start = 1;
768 if (! printed_compunit_symtab_start)
770 gdb_printf (
" { ((struct compunit_symtab *) %s)\n",
771 host_address_to_string (cust));
773 cust->debugformat ());
775 (cust->producer () !=
nullptr
776 ? cust->producer () :
"(null)"));
779 (cust->dirname () != NULL
780 ? cust->dirname () :
"(null)"));
782 " ((struct blockvector *) %s)\n",
783 host_address_to_string
784 (cust->blockvector ()));
786 " ((struct compunit_symtab *) %s)\n",
787 cust->user !=
nullptr
788 ? host_address_to_string (cust->user)
790 if (cust->includes !=
nullptr)
793 for (
int i = 0; ; ++i)
797 if (include ==
nullptr)
800 = host_address_to_string (include);
802 "(struct compunit_symtab *)",
807 printed_compunit_symtab_start = 1;
814 host_address_to_string (
symtab));
820 "linetable ((struct linetable *) %s)\n",
821 host_address_to_string
827 if (printed_compunit_symtab_start)
831 if (printed_objfile_start)
852 int printed_objfile_start = 0;
856 int found_something = 0;
861 if (cust->blockvector () == NULL)
867 if (! printed_objfile_start)
872 host_address_to_string (
objfile));
873 printed_objfile_start = 1;
877 if (cust->blockvector () == NULL)
883 if (printed_objfile_start)
897 gdb_argv argv (args);
905 error (_(
"Extra arguments after regexp."));
915 ([&] (
const char *
filename,
bool basenames)
919 && (regexp == NULL || re_exec (
filename)));
955 gdb_printf (_(
"objfile: %ps ((struct objfile *) %s)\n"),
958 host_address_to_string (
objfile));
959 gdb_printf (_(
"compunit_symtab: %s ((struct compunit_symtab *) %s)\n"),
962 gdb_printf (_(
"symtab: %ps ((struct symtab *) %s)\n"),
965 host_address_to_string (
symtab));
967 gdb_printf (_(
"linetable: ((struct linetable *) %s):\n"),
1048Print dump of current symbol definitions.\n\
1049Usage: mt print symbols [-pc ADDRESS] [--] [OUTFILE]\n\
1050 mt print symbols [-objfile OBJFILE] [-source SOURCE] [--] [OUTFILE]\n\
1051Entries in the full symbol table are dumped to file OUTFILE,\n\
1052or the terminal if OUTFILE is unspecified.\n\
1053If ADDRESS is provided, dump only the file for that address.\n\
1054If SOURCE is provided, dump only that file's symbols.\n\
1055If OBJFILE is provided, dump only that file's minimal symbols."),
1059Print dump of current minimal symbol definitions.\n\
1060Usage: mt print msymbols [-objfile OBJFILE] [--] [OUTFILE]\n\
1061Entries in the minimal symbol table are dumped to file OUTFILE,\n\
1062or the terminal if OUTFILE is unspecified.\n\
1063If OBJFILE is provided, dump only that file's minimal symbols."),
1067 _(
"Print dump of current object file definitions.\n\
1068With an argument REGEXP, list the object files with matching names."),
1072List the full symbol tables for all object files.\n\
1073This does not include information about individual symbols, blocks, or\n\
1074linetables --- just the symbol table structures themselves.\n\
1075With an argument REGEXP, list the symbol tables with matching names."),
1079List the contents of all line tables, from all symbol tables.\n\
1080With an argument REGEXP, list just the line tables for the symbol\n\
1081tables with matching names."),
1086Check consistency of currently expanded symtabs."),
1090 _(
"Expand symbol tables.\n\
1091With an argument REGEXP, only expand the symbol tables with matching names."),
ui_file_style style() const
bool open(const char *name, const char *mode)
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
void field_signed(const char *fldname, LONGEST value)
void text(const char *string)
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
struct cmd_list_element * maintenanceprintlist
struct cmd_list_element * maintenancelist
struct cmd_list_element * maintenanceinfolist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
cli_style_option file_name_style
EXTERN_C char * re_comp(const char *)
int mdict_size(const struct multidictionary *mdict)
#define ALL_DICT_SYMBOLS(dict, iter, sym)
CORE_ADDR parse_and_eval_address(const char *exp)
void exception_fprintf(struct ui_file *file, const struct gdb_exception &e, const char *prefix,...)
struct type * check_typedef(struct type *type)
const char * language_str(enum language lang)
const struct language_defn * current_language
enum language set_language(enum language lang)
const char * objfile_name(const struct objfile *objfile)
#define OBJSTAT(objfile, expr)
struct program_space * current_program_space
std::vector< struct program_space * > program_spaces
const char * symtab_to_fullname(struct symtab *s)
const char * symtab_to_filename_for_display(struct symtab *symtab)
const block * superblock() const
multidictionary * multidict() const
symbol * function() const
struct block * block(size_t i)
symtab * primary_filetab() const
struct blockvector * blockvector()
struct compunit_symtab * user
struct compunit_symtab ** includes
struct objfile * objfile() const
const char * dirname() const
void print_statistics(const char *type)
const char * demangled_name
const char * print_name() const
struct obj_section * obj_section(const struct objfile *objfile) const
const char * linkage_name() const
virtual void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const =0
struct linetable_entry item[1]
struct bfd_section * the_bfd_section
auto_obstack storage_obstack
struct compunit_symtab * compunit_symtabs
struct gdbarch * arch() const
struct objfile_per_bfd_storage * per_bfd
bool expand_symtabs_matching(gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, const lookup_name_info *lookup_name, gdb::function_view< expand_symtabs_symbol_matcher_ftype > symbol_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify, block_search_flags search_flags, domain_enum domain, enum search_domain kind)
void print_stats(bool print_bcache)
struct obj_section * sections
compunit_symtab_range compunits()
::section_offsets section_offsets
msymbols_range msymbols()
objfiles_range objfiles()
const block * value_block() const
address_class aclass() const
struct type * type() const
domain_enum domain() const
LONGEST value_longest() const
const gdb_byte * value_bytes() const
bool is_objfile_owned() const
CORE_ADDR value_address() const
struct objfile * objfile() const
enum language language() const
struct compunit_symtab * compunit() const
struct linetable * linetable() const
const char * name() const
static void print_symbol(struct gdbarch *gdbarch, struct symbol *symbol, int depth, ui_file *outfile)
static void maintenance_expand_symtabs(const char *args, int from_tty)
static void maintenance_print_msymbols(const char *args, int from_tty)
static void dump_objfile(struct objfile *objfile)
static int block_depth(const struct block *)
static void dump_msymbols(struct objfile *objfile, struct ui_file *outfile)
void print_objfile_statistics(void)
static void maintenance_print_symbols(const char *args, int from_tty)
static void maintenance_check_symtabs(const char *ignore, int from_tty)
static int maintenance_print_one_line_table(struct symtab *symtab, void *data)
static void maintenance_print_objfiles(const char *regexp, int from_tty)
static void dump_symtab_1(struct symtab *symtab, struct ui_file *outfile)
static void maintenance_info_symtabs(const char *regexp, int from_tty)
void _initialize_symmisc()
static void dump_symtab(struct symtab *symtab, struct ui_file *outfile)
static void maintenance_info_line_tables(const char *regexp, int from_tty)
struct symtab * find_pc_line_symtab(CORE_ADDR pc)
bool compare_filenames_for_search(const char *filename, const char *search_name)
static bool is_main_symtab_of_compunit_symtab(struct symtab *symtab)
const struct type_print_options type_print_raw_options
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
void perror_with_name(const char *string)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void print_spaces(int n, struct ui_file *stream)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)