From patchwork Wed Jan 17 21:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farre X-Patchwork-Id: 84301 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABEEA385783F for ; Wed, 17 Jan 2024 21:06:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id DABC43858C42 for ; Wed, 17 Jan 2024 21:05:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DABC43858C42 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 DABC43858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705525536; cv=none; b=AdVfE6bcOJ7lymLS2/0K4LhAqhZKdeuU/A/LXZ7AVN9ELM9iVznkjIUlRfYFRa8RLKaO/5MXvWAQH4IJ0ko1byxHSFcNhF3rM2jArrELrkNfjsMa2uJLFSzfThqrnopsHB9Xlbk1tYYX3UDPmioaLGFH5hNjuk89qKkCtygXqv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705525536; c=relaxed/simple; bh=U4wQNKq+aEaPS9Q/cUXK/adKfZsVjdZ43Az4GJTn624=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NfzZnwizggNFEjdQiiKuQvKgHwmzwSBp3oAHHUrcX7gNVpPJGa+C/eg9Q5FXACF8KkSZk/bajADbXwgBEJVx+gJAmgyCPvZoakEKZRKH86vs+OjetGV73ueZLHnaQyoCqCMtRiopfo2yIShlFMDsW0RsxFhIffne+cHatwzz8dk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-50e7d6565b5so13856581e87.0 for ; Wed, 17 Jan 2024 13:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705525532; x=1706130332; 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=A/TreDoy9d20Hbj2TGLACjsO5K45QcveR7IQEzaInyY=; b=d6f/X6Y/FCmegTMEuKXItmxCAdZGn3DsmqKvE6di5aCTzpUnYcDK+6DWC8ES+Rt97K VZED7fCF4T8d5zMrQQdVG+Pm+aNr1e9VcfRZl5WRcbT976AxJ9B/asURQbjo5GusAuie R2dKnk81EKqegnue2l/XUsX5kRoDnYunDKwBEq/raFD+t1iKLN4SXbidVtViQUW650Uv Juxp4WF9yaMoA/prbdBZTXH2bfQg57Epsegx3AH7jZ3LNEtVMqEGLxBdwL8Nx7Vsqhae CmVFAbQDc5kWgEgFc8s4W8GS+1uaxeTYTkWasoFuvV9Y+56pdHDghpWtjojPmF1oYAeH li5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705525532; x=1706130332; 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=A/TreDoy9d20Hbj2TGLACjsO5K45QcveR7IQEzaInyY=; b=Ub8RNhlAQ8h/NhSVk+X52SFGiv/VhUCMt8ghfJ6rIBCLmUz53xytPb8YIv1H4nx+qG d+v6MU9G2byIYULCP3o8+FK1PlFkUczIJcfWDCytNScdSL4Louf+bs0Fcutnmz3WT2wr gMcOw0aNkgHonl8UCNMOrvcQtEsdTZ9f4zo21qwPI1o3dSy3VpACSq9fsA7yIkeHHvjw V1zKtXpO0xMplulLWy+g5uES+/GNcCPUb89THS2KKj6BaJhWnmrwML4v8apVH/rSskSz L8/r2SD1lMf7Ljn9SE6tbVS10PyFqQgrFa7z8LBFIwSCXdpoxDVtI4PwWnBa7/K1LSL6 Yt0g== X-Gm-Message-State: AOJu0Yy5yFf2UAnZ+UYQaTJvT+Z7cmiM3wVk/l+w5pcVJ8+zhXFQ7sl8 NLeMT9blHg0DhngDgNQytmfZGdLFcp8= X-Google-Smtp-Source: AGHT+IH+C4ikEWm/+l1hfqIpvpIpRfSlFPlxtU/DrP7X8I83QyypNRHTmnm3fBM1eUnqw7aEpae0dQ== X-Received: by 2002:a19:9108:0:b0:50e:754c:84fd with SMTP id t8-20020a199108000000b0050e754c84fdmr4565921lfd.110.1705525531489; Wed, 17 Jan 2024 13:05:31 -0800 (PST) Received: from localhost.localdomain ([2001:2044:7c:4b00:37f8:fc67:7f51:113d]) by smtp.gmail.com with ESMTPSA id n1-20020ac242c1000000b0050ecae41c51sm375386lfl.135.2024.01.17.13.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 13:05:31 -0800 (PST) From: Simon Farre To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v2 2/5] [dap & linetable]: Add column to maint info linetable output Date: Wed, 17 Jan 2024 22:05:17 +0100 Message-ID: <20240117210518.1784638-2-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117210518.1784638-1-simon.farre.cx@gmail.com> References: <20240117210518.1784638-1-simon.farre.cx@gmail.com> MIME-Version: 1.0 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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; } - + +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,