From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id 989D23858409 for ; Mon, 22 Jan 2024 13:31:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 989D23858409 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 989D23858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705930293; cv=none; b=cEJjv9tu3bkl0Bio4srtHw2sit3/0R7wSEBKlK5aiCG6fgPEg0NaHKWRAlfybFvcelhd4YfU2OBZHD3UvwTtj7EnMaFwnoWjr0cI4z4ZoUXm44HTBYj3meS0pUXwnf/1MJGlBnOiBdnVHmCX7o3BcZAX+OlRgJ/E1L08M3KtyIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705930293; c=relaxed/simple; bh=0gy0V48gRmVib/cuzzI9akcDO+jIQ6X443IbDzfPjcw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tVSm/+9pTX5W0dsNtbVsqyMt+o0D5gux7ZG4Dr6IrdXtzxlZCQBeYZgFN6wgzpCMA5RltGn+DhMziUqhhnMNqH7gFwo8Uufe0TsSjF41jzdRg4eqPIhCIc0+PIFE/MkLru+6EMyJjZ/PCJg1u+FPnWhxvz6AaZ9x3qxauFCxbZ0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2cd2f472665so29529651fa.2 for ; Mon, 22 Jan 2024 05:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705930289; x=1706535089; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sz+p7lOr4e3MIp3X2615tboC6653nlYy8HYPMIvS4fE=; b=N1j6H+UPudRcV4NiiM/6iD0Iubdy9eTWm86t8E1/rP2dEArw0lcQPo8sTtbdgLD4kg uzd55KTCs52ZLHQn+i0jb3x0NHa3SfSkrdFN1FUZg0+tbmnP7KTxgmHT8ZRO00VQTSev EZWWSNAFQsDu255+AyIcabxr3GlBSJthRwypaeEX0ylqULAZTr6mG8V8xwrt3uQVA2sA ioOE2zYZuGi2ByvrhMm/18upLmGsCPJZhMhn6LgKZfTwU1dbx5OUzeR9PeFeoO67t1g0 aSFBziZB5Aiyi8y/v9IVvEjIiMx4r9r7VtaO9P0iAeyPuAGba/UzzthA4XeIOzan4pYN 9Iug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705930289; x=1706535089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sz+p7lOr4e3MIp3X2615tboC6653nlYy8HYPMIvS4fE=; b=xQGALq2SZKUauALBsFOpSql1MzIzEmv6FDggAys8M8hlyi+BPvOKp2bFO6XfjKt92B xgnNveI44K4cx4cIgJgwD5JgcZ/20KoL75Fz9e5JQRSvAZO0u1gWdgQcVAhY4b8a3jNZ bNxOMJJad95sGz/dEz986a89LzrUDO5zWi0Qf9GHUtBRxoLsWSPHzYN9cMCg+brX8+Wv dige3jJh9Zf0pfyj7VpcO2IZvpSpROKikR4x2LloQHCdqRj77BmsaEgNqqgUN4884Uqq H5mVw82oOoEm6RYuOX2HMk913FVSVBxAX2sDbZyX1WM6uur+3odYcmMJBTzYwDI8GyY5 rgFw== X-Gm-Message-State: AOJu0YzmnqOyIDvtNuQjkMTfgWTHGNiBQzuckiZqLvJ3n631/NVeeB1k tjpfPQwyKkvPhV6LnQkZzBY3w2RKPm51Gg2JQvP0uQYOChGAberku2jW+cjj X-Google-Smtp-Source: AGHT+IG95NefQ8vEHiz0ajw8cMjsp7Mov6Airw/0QMJTUIWYVVfYVZADtO9gyjhx42FjnTaxbaf4lw== X-Received: by 2002:a05:651c:1510:b0:2cd:3300:bde2 with SMTP id e16-20020a05651c151000b002cd3300bde2mr1830443ljf.0.1705930289376; Mon, 22 Jan 2024 05:31:29 -0800 (PST) Received: from localhost.localdomain ([2001:2044:7c:4b00:37f8:fc67:7f51:113d]) by smtp.gmail.com with ESMTPSA id s17-20020a2eb8d1000000b002cccbb7ca38sm3411187ljp.2.2024.01.22.05.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 05:31:29 -0800 (PST) From: Simon Farre To: gdb-patches@sourceware.org Cc: tom@tromey.org, Simon Farre Subject: [PATCH v3 2/5] [dap & linetable]: Add column to maint info linetable output Date: Mon, 22 Jan 2024 14:31:12 +0100 Message-ID: <20240122133115.201205-2-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122133115.201205-1-simon.farre.cx@gmail.com> References: <20240122133115.201205-1-simon.farre.cx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. v3: Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31271 --- 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; } - + +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