@@ -937,17 +937,67 @@ block_depth (const struct block *block)
}
return i;
}
-
+
+static void
+output_lt_row (ui_out *uiout, int i, const linetable_entry &item,
+ const objfile *obj)
+{
+ ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+ uiout->field_signed ("index", i);
+ if (item.line > 0)
+ {
+ uiout->field_signed ("line", item.line);
+ }
+ else
+ {
+ uiout->field_string ("line", _ ("END"));
+ }
+ uiout->field_core_addr ("rel-address", obj->arch (), item.pc (obj));
+ uiout->field_core_addr ("unrel-address", obj->arch (),
+ CORE_ADDR (item.unrelocated_pc ()));
+ uiout->field_string ("is-stmt", item.is_stmt ? "Y" : "");
+ uiout->field_string ("prologue-end", item.prologue_end ? "Y" : "");
+ uiout->field_string ("epilogue-begin", item.epilogue_begin ? "Y" : "");
+ uiout->text ("\n");
+}
+
+static auto
+output_lt_row_with_col (ui_out *uiout, int i, const linetable_entry &item,
+ const objfile *obj)
+{
+ ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+ uiout->field_signed ("index", i);
+ if (item.line > 0)
+ {
+ uiout->field_signed ("line", item.line);
+ uiout->field_signed ("col", item.col);
+ }
+ else
+ {
+ uiout->field_string ("line", _ ("END"));
+ uiout->field_string ("col", _ ("END"));
+ }
+ uiout->field_core_addr ("rel-address", obj->arch (), item.pc (obj));
+ uiout->field_core_addr ("unrel-address", obj->arch (),
+ CORE_ADDR (item.unrelocated_pc ()));
+ uiout->field_string ("is-stmt", item.is_stmt ? "Y" : "");
+ uiout->field_string ("prologue-end", item.prologue_end ? "Y" : "");
+ uiout->field_string ("epilogue-begin", item.epilogue_begin ? "Y" : "");
+ uiout->text ("\n");
+}
/* 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)
+maintenance_print_one_line_table (struct symtab *symtab, void *data,
+ bool display_col)
{
const struct linetable *linetable;
struct objfile *objfile;
+ const auto columns = display_col ? 8 : 7;
+
objfile = symtab->compunit ()->objfile ();
gdb_printf (_("objfile: %ps ((struct objfile *) %s)\n"),
styled_string (file_name_style.style (),
@@ -973,9 +1023,11 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
/* Leave space for 6 digits of index and line number. After that the
tables will just not format as well. */
struct ui_out *uiout = current_uiout;
- ui_out_emit_table table_emitter (uiout, 7, -1, "line-table");
+ ui_out_emit_table table_emitter (uiout, columns, -1, "line-table");
uiout->table_header (6, ui_left, "index", _("INDEX"));
uiout->table_header (6, ui_left, "line", _("LINE"));
+ if (display_col)
+ uiout->table_header (6, ui_left, "col", _("COL"));
uiout->table_header (18, ui_left, "rel-address", _("REL-ADDRESS"));
uiout->table_header (18, ui_left, "unrel-address", _("UNREL-ADDRESS"));
uiout->table_header (7, ui_left, "is-stmt", _("IS-STMT"));
@@ -983,26 +1035,12 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
uiout->table_header (14, ui_left, "epilogue-begin", _("EPILOGUE-BEGIN"));
uiout->table_body ();
- for (int i = 0; i < linetable->nitems; ++i)
- {
- const linetable_entry *item;
-
- item = &linetable->item [i];
- ui_out_emit_tuple tuple_emitter (uiout, nullptr);
- uiout->field_signed ("index", i);
- if (item->line > 0)
- uiout->field_signed ("line", item->line);
- else
- uiout->field_string ("line", _("END"));
- uiout->field_core_addr ("rel-address", objfile->arch (),
- item->pc (objfile));
- uiout->field_core_addr ("unrel-address", objfile->arch (),
- CORE_ADDR (item->unrelocated_pc ()));
- uiout->field_string ("is-stmt", item->is_stmt ? "Y" : "");
- uiout->field_string ("prologue-end", item->prologue_end ? "Y" : "");
- uiout->field_string ("epilogue-begin", item->epilogue_begin ? "Y" : "");
- uiout->text ("\n");
- }
+ if (display_col)
+ for (int i = 0; i < linetable->nitems; ++i)
+ output_lt_row_with_col (uiout, i, linetable->item[i], objfile);
+ else
+ for (int i = 0; i < linetable->nitems; ++i)
+ output_lt_row (uiout, i, linetable->item[i], objfile);
}
return 0;
@@ -1011,9 +1049,20 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
/* Implement the 'maint info line-table' command. */
static void
-maintenance_info_line_tables (const char *regexp, int from_tty)
+maintenance_info_line_tables (const char* args, int from_tty)
{
dont_repeat ();
+ const char* regexp = nullptr;
+ bool show_column = false;
+ gdb_argv argv (args);
+
+ for (auto i = 0; argv != nullptr && argv[i] != nullptr; ++i)
+ {
+ if (strcmp (argv[i], "-show-col") == 0)
+ show_column = true;
+ else
+ regexp = argv[i];
+ }
if (regexp != NULL)
re_comp (regexp);
@@ -1030,7 +1079,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
if (regexp == NULL
|| re_exec (symtab_to_filename_for_display (symtab)))
{
- maintenance_print_one_line_table (symtab, NULL);
+ maintenance_print_one_line_table (symtab, NULL, show_column);
gdb_printf ("\n");
}
}
@@ -1080,7 +1129,8 @@ With an argument REGEXP, list the symbol tables with matching names."),
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."),
+tables with matching names.\n\
+With the argument -show-col this command also displays column information."),
&maintenanceinfolist);
add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs,