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 = (CORE_ADDR (msymbol->unrelocated_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"),
242 gdb_printf (outfile,
"\nSymtab for file %s at %s\n",
244 host_address_to_string (
symtab));
247 gdb_printf (outfile,
"Compilation directory is %s\n",
249 gdb_printf (outfile,
"Read from object file %s (%s)\n",
251 host_address_to_string (
objfile));
261 for (
int i = 0; i < len; i++)
280 gdb_printf (outfile,
"%*sblock #%03d, object at %s",
282 host_address_to_string (b));
314 catch (
const gdb_exception_error &ex)
317 "Error printing symbol:\n");
326 const char *compunit_filename
330 "\nBlockvector same as owning compunit: %s\n\n",
340 if (cust->
user !=
nullptr)
344 gdb_printf (outfile,
"Compunit user: %s\n", addr);
347 for (
int i = 0; ; ++i)
350 if (include ==
nullptr)
354 gdb_printf (outfile,
"Compunit include: %s\n", addr);
380 char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
385 gdb_argv argv (args);
387 for (i = 0; argv != NULL && argv[i] != NULL; ++i)
389 if (strcmp (argv[i],
"-pc") == 0)
391 if (argv[i + 1] == NULL)
392 error (_(
"Missing pc value"));
393 address_arg = argv[++i];
395 else if (strcmp (argv[i],
"-source") == 0)
397 if (argv[i + 1] == NULL)
398 error (_(
"Missing source file"));
399 source_arg = argv[++i];
401 else if (strcmp (argv[i],
"-objfile") == 0)
403 if (argv[i + 1] == NULL)
404 error (_(
"Missing objfile name"));
405 objfile_arg = argv[++i];
407 else if (strcmp (argv[i],
"--") == 0)
413 else if (argv[i][0] ==
'-')
416 error (_(
"Unknown option: %s"), argv[i]);
423 if (address_arg != NULL && source_arg != NULL)
424 error (_(
"Must specify at most one of -pc and -source"));
428 if (argv != NULL && argv[outfile_idx] != NULL)
430 if (argv[outfile_idx + 1] != NULL)
431 error (_(
"Junk at end of command"));
432 gdb::unique_xmalloc_ptr<char> outfile_name
433 (tilde_expand (argv[outfile_idx]));
434 if (!arg_outfile.
open (outfile_name.get (), FOPEN_WT))
435 perror_with_name (outfile_name.get ());
436 outfile = &arg_outfile;
439 if (address_arg != NULL)
445 error (_(
"No symtab for address: %s"), address_arg);
454 int print_for_objfile = 1;
456 if (objfile_arg != NULL)
460 if (!print_for_objfile)
465 for (
symtab *s : cu->filetabs ())
467 int print_for_source = 0;
470 if (source_arg != NULL)
477 if (source_arg == NULL
484 if (source_arg != NULL && !found)
485 error (_(
"No symtab for source file: %s"), source_arg);
529 ?
"struct" :
"union")),
602 gdb_printf (outfile,
"address parameter register %s",
624 (outfile,
"block object %s, %s..%s",
646 gdb_printf (outfile,
"botched symbol class %x",
658 char *objfile_arg = NULL;
663 gdb_argv argv (args);
665 for (i = 0; argv != NULL && argv[i] != NULL; ++i)
667 if (strcmp (argv[i],
"-objfile") == 0)
669 if (argv[i + 1] == NULL)
670 error (_(
"Missing objfile name"));
671 objfile_arg = argv[++i];
673 else if (strcmp (argv[i],
"--") == 0)
679 else if (argv[i][0] ==
'-')
682 error (_(
"Unknown option: %s"), argv[i]);
691 if (argv != NULL && argv[outfile_idx] != NULL)
693 if (argv[outfile_idx + 1] != NULL)
694 error (_(
"Junk at end of command"));
695 gdb::unique_xmalloc_ptr<char> outfile_name
696 (tilde_expand (argv[outfile_idx]));
697 if (!arg_outfile.
open (outfile_name.get (), FOPEN_WT))
698 perror_with_name (outfile_name.get ());
699 outfile = &arg_outfile;
705 if (objfile_arg == NULL
744 int printed_objfile_start = 0;
748 int printed_compunit_symtab_start = 0;
757 if (! printed_objfile_start)
762 host_address_to_string (
objfile));
763 printed_objfile_start = 1;
765 if (! printed_compunit_symtab_start)
767 gdb_printf (
" { ((struct compunit_symtab *) %s)\n",
768 host_address_to_string (cust));
770 cust->debugformat ());
772 (cust->producer () !=
nullptr
773 ? cust->producer () :
"(null)"));
776 (cust->dirname () != NULL
777 ? cust->dirname () :
"(null)"));
779 " ((struct blockvector *) %s)\n",
780 host_address_to_string
781 (cust->blockvector ()));
783 " ((struct compunit_symtab *) %s)\n",
784 cust->user !=
nullptr
785 ? host_address_to_string (cust->user)
787 if (cust->includes !=
nullptr)
790 for (
int i = 0; ; ++i)
794 if (include ==
nullptr)
797 = host_address_to_string (include);
799 "(struct compunit_symtab *)",
804 printed_compunit_symtab_start = 1;
811 host_address_to_string (
symtab));
817 "linetable ((struct linetable *) %s)\n",
818 host_address_to_string
824 if (printed_compunit_symtab_start)
828 if (printed_objfile_start)
849 int printed_objfile_start = 0;
853 int found_something = 0;
858 if (cust->blockvector () == NULL)
864 if (! printed_objfile_start)
869 host_address_to_string (
objfile));
870 printed_objfile_start = 1;
874 if (cust->blockvector () == NULL)
880 if (printed_objfile_start)
894 gdb_argv argv (args);
902 error (_(
"Extra arguments after regexp."));
912 ([&] (
const char *
filename,
bool basenames)
916 && (regexp == NULL || re_exec (
filename)));
952 gdb_printf (_(
"objfile: %ps ((struct objfile *) %s)\n"),
955 host_address_to_string (
objfile));
956 gdb_printf (_(
"compunit_symtab: %s ((struct compunit_symtab *) %s)\n"),
959 gdb_printf (_(
"symtab: %ps ((struct symtab *) %s)\n"),
962 host_address_to_string (
symtab));
964 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 symbols for the file with code at that address.\n\
1054If SOURCE is provided, dump only that file's symbols.\n\
1055If OBJFILE is provided, dump only that object file's 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)
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)
static void set_language(const char *language)
const char * language_str(enum language lang)
const struct language_defn * current_language
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
iterator_range< mdict_iterator_wrapper > multidict_symbols() 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
CORE_ADDR pc(const struct objfile *objfile) const
unrelocated_addr unrelocated_pc() const
struct linetable_entry item[1]
struct bfd_section * the_bfd_section
auto_obstack storage_obstack
struct obj_section * sections_start
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)
objfile(gdb_bfd_ref_ptr, const char *, objfile_flags)
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
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={})
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)