diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2016-01-21 11:03:32 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2016-03-11 22:48:21 +0000 |
commit | f2403c39342b723a18a2bea5ed209c8c96203d2b (patch) | |
tree | fae4982a4dbea2848a4f8468dd00b05bc90b8f50 /gdb/symmisc.c | |
parent | c4b3e547d50b01dcf909498119ff6c0af482f2c8 (diff) | |
download | gdb-f2403c39342b723a18a2bea5ed209c8c96203d2b.zip gdb-f2403c39342b723a18a2bea5ed209c8c96203d2b.tar.gz gdb-f2403c39342b723a18a2bea5ed209c8c96203d2b.tar.bz2 |
gdb: New maint info line-table command.
Add a new command 'maint info line-table' to display the contents of
GDB's internal line table structure. Useful when trying to understand
problems (within gdb) relating to line tables.
gdb/ChangeLog:
* symmisc.c (maintenance_info_line_tables): New function.
(maintenance_print_one_line_table): New function.
(_initialize_symmisc): Register 'maint info line-table' command.
* NEWS: Mention new command.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'maint info line-table'
command.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp: New tests for 'maint info line-table'.
Diffstat (limited to 'gdb/symmisc.c')
-rw-r--r-- | gdb/symmisc.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 69b7e8e..88daf09 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -949,6 +949,90 @@ block_depth (struct block *block) } +/* Used by MAINTENANCE_INFO_LINE_TABLES to print the information about a + single line table. */ + +static int +maintenance_print_one_line_table (struct symtab *symtab, void *data) +{ + struct linetable *linetable; + struct objfile *objfile; + + objfile = symtab->compunit_symtab->objfile; + printf_filtered (_("objfile: %s ((struct objfile *) %s)\n"), + objfile_name (objfile), + host_address_to_string (objfile)); + printf_filtered (_("compunit_symtab: ((struct compunit_symtab *) %s)\n"), + host_address_to_string (symtab->compunit_symtab)); + printf_filtered (_("symtab: %s ((struct symtab *) %s)\n"), + symtab_to_fullname (symtab), + host_address_to_string (symtab)); + linetable = SYMTAB_LINETABLE (symtab); + printf_filtered (_("linetable: ((struct linetable *) %s):\n"), + host_address_to_string (linetable)); + + if (linetable == NULL) + printf_filtered (_("No line table.\n")); + else if (linetable->nitems <= 0) + printf_filtered (_("Line table has no lines.\n")); + else + { + int i; + + /* Leave space for 6 digits of index and line number. After that the + tables will just not format as well. */ + printf_filtered (_("%-6s %6s %s\n"), + _("INDEX"), _("LINE"), _("ADDRESS")); + + for (i = 0; i < linetable->nitems; ++i) + { + struct linetable_entry *item; + struct cleanup *row_cleanup; + + item = &linetable->item [i]; + printf_filtered (_("%-6d %6d %s\n"), i, item->line, + core_addr_to_string (item->pc)); + } + } + + return 0; +} + +/* Implement the 'maint info line-table' command. */ + +static void +maintenance_info_line_tables (char *regexp, int from_tty) +{ + struct program_space *pspace; + struct objfile *objfile; + + dont_repeat (); + + if (regexp != NULL) + re_comp (regexp); + + ALL_PSPACES (pspace) + ALL_PSPACE_OBJFILES (pspace, objfile) + { + struct compunit_symtab *cust; + struct symtab *symtab; + + ALL_OBJFILE_COMPUNITS (objfile, cust) + { + ALL_COMPUNIT_FILETABS (cust, symtab) + { + QUIT; + + if (regexp == NULL + || re_exec (symtab_to_filename_for_display (symtab))) + maintenance_print_one_line_table (symtab, NULL); + } + } + } +} + + + /* Do early runtime initializations. */ void @@ -982,6 +1066,12 @@ linetables --- just the symbol table structures themselves.\n\ With an argument REGEXP, list the symbol tables with matching names."), &maintenanceinfolist); + add_cmd ("line-table", class_maintenance, maintenance_info_line_tables, _("\ +List the contents of all line tables, from all symbol tables.\n\ +With an argument REGEXP, list just the line tables for the symbol\n\ +tables with matching names."), + &maintenanceinfolist); + add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, _("\ Check consistency of currently expanded symtabs."), |