From: Simon Farre <simon.farre.cx@gmail.com>
To: gdb-patches@sourceware.org
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: [PATCH v2 2/5] [dap & linetable]: Add column to maint info linetable output
Date: Wed, 17 Jan 2024 22:05:17 +0100 [thread overview]
Message-ID: <20240117210518.1784638-2-simon.farre.cx@gmail.com> (raw)
In-Reply-To: <20240117210518.1784638-1-simon.farre.cx@gmail.com>
This adds "COL" to the output of the maintenance command "info
line-table"
v2.
maint info line-table: Make display of column optional
Toggle the display (on) of column meta data by adding `-show-col`
to the command. This command is used way too much in testing to change
at this point making any feature that touches this almost impossible to
move forward due to test maintenance hell.
---
gdb/symmisc.c | 102 +++++++++++++++++++++++++++++++++++++-------------
1 file changed, 76 insertions(+), 26 deletions(-)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 5dfb9fca8f0..b7dccb3893e 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -937,17 +937,67 @@ block_depth (const struct block *block)
}
return i;
}
-\f
+
+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,
--
2.43.0
next prev parent reply other threads:[~2024-01-17 21:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 21:05 [PATCH v2 1/5] [dap & linetable]: Add column to linetable entry Simon Farre
2024-01-17 21:05 ` Simon Farre [this message]
2024-01-17 21:05 ` [PATCH v2 4/5] [dap & linetable]: Add breakpointLocations request Simon Farre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240117210518.1784638-2-simon.farre.cx@gmail.com \
--to=simon.farre.cx@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).