From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 23FC5385772B for ; Tue, 18 Jul 2023 11:56:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23FC5385772B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689681419; x=1721217419; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=IHl11/bYMLCnoNWALq9GfnHS2qqfRxXY9O09+ZMO33c=; b=KAEQRnDdRLzb0yHWCveZQkRxdd8+xP4gKgqpxgxFkGG0JdEujL5hElHu GI3ONrwNiG43fWZ8aXN78LMewdglOOqwr242nYf1YdG/519DITTfv/Yit I92shV3zOX+Gm/JgwLrTb1pzy8vQ2aDaZKDAgNsBRciuV7GkcCROZgGAS bZ8BUYMD7XfGFZY+NvmI/lLaW6Piukymsysl6setoi6eN/sAw83CEl3j1 6RiwOKbdP4ru963p+Ip2pRqGFC3l/NlqJVArg3kUG1sDC7kDsDi0w5cck KPtpq/lTidKZcExzqY9AAswcO5k05avPUFmnN9uUoLQ4DQ6XNPp+aIb0g A==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="363650478" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="363650478" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 04:56:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="837260815" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="837260815" Received: from unknown (HELO localhost) ([10.216.210.22]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 04:56:57 -0700 From: Felix Willgerodt To: gdb-patches@sourceware.org, markus.t.metzger@intel.com, simark@simark.ca Subject: [PATCH v10 03/10] btrace: Enable auxiliary instructions in record function-call-history. Date: Tue, 18 Jul 2023 13:56:30 +0200 Message-Id: <20230718115637.3531-4-felix.willgerodt@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718115637.3531-1-felix.willgerodt@intel.com> References: <20230718115637.3531-1-felix.willgerodt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,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: Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX is encountered in the function-call-history. Printing is active by default, it can be silenced with the /a modifier. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. Reviewed-By: Eli Zaretskii --- gdb/btrace.h | 6 +++++- gdb/doc/gdb.texinfo | 5 +++-- gdb/record-btrace.c | 21 +++++++++++++++++++++ gdb/record.c | 5 +++++ gdb/record.h | 5 ++++- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/gdb/btrace.h b/gdb/btrace.h index dd80d3e6806..f6a8274bb16 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -105,7 +105,11 @@ enum btrace_function_flag /* The 'up' link points to a tail call. This obviously only makes sense if bfun_up_links_to_ret is clear. */ - BFUN_UP_LINKS_TO_TAILCALL = (1 << 1) + BFUN_UP_LINKS_TO_TAILCALL = (1 << 1), + + /* Indicates that at least one auxiliary instruction is in the current + function segment. */ + BFUN_CONTAINS_AUX = (1 << 2) }; DEF_ENUM_FLAGS_TYPE (enum btrace_function_flag, btrace_function_flags); diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 6c812af2b00..2cd0a6c49e7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8134,8 +8134,9 @@ that function, the source lines for this instruction sequence (if the @code{/l} modifier is specified), and the instructions numbers that form the sequence (if the @code{/i} modifier is specified). The function names are indented to reflect the call stack depth if the @code{/c} modifier is -specified. The @code{/l}, @code{/i}, and @code{/c} modifiers can be given -together. +specified. Printing auxiliary information is enabled by default and can be +omitted with the @code{/a} modifier. The @code{/l}, @code{/i}, @code{/a}, +and @code{/c} modifiers can be given together. @smallexample (@value{GDBP}) @b{list 1, 10} diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 36247d5b31d..02e71889eaf 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1159,6 +1159,23 @@ btrace_get_bfun_name (const struct btrace_function *bfun) return "??"; } +static void +btrace_print_aux_insn (struct ui_out *uiout, + const struct btrace_function *bfun, + const struct btrace_thread_info *btinfo) +{ + for (const btrace_insn &insn : bfun->insn) + { + if (insn.iclass == BTRACE_INSN_AUX) + { + uiout->text ("\t\t["); + uiout->field_fmt ("aux-data", "%s", + btinfo->aux_data.at (insn.aux_data_index).c_str ()); + uiout->text ("]\n"); + } + } +} + /* Disassemble a section of the recorded function trace. */ static void @@ -1234,6 +1251,10 @@ btrace_call_history (struct ui_out *uiout, } uiout->text ("\n"); + + if (((flags & RECORD_DONT_PRINT_AUX) == 0) + && ((bfun->flags & BFUN_CONTAINS_AUX) != 0)) + btrace_print_aux_insn(uiout, bfun, btinfo); } } diff --git a/gdb/record.c b/gdb/record.c index f1f472aa426..c359613913d 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -640,6 +640,9 @@ get_call_history_modifiers (const char **arg) case 'c': modifiers |= RECORD_PRINT_INDENT_CALLS; break; + case 'a': + modifiers |= RECORD_DONT_PRINT_AUX; + break; default: error (_("Invalid modifier: %c."), *args); } @@ -884,6 +887,8 @@ Without modifiers, it prints the function name.\n\ With a /l modifier, the source file and line number range is included.\n\ With a /i modifier, the instruction number range is included.\n\ With a /c modifier, the output is indented based on the call stack depth.\n\ +With a /a modifier, omits output of auxiliary data, which is enabled \ +by default.\n\ With no argument, prints ten more lines after the previous ten-line print.\n\ \"record function-call-history -\" prints ten lines before a previous ten-line \ print.\n\ diff --git a/gdb/record.h b/gdb/record.h index 166b5349988..ec06aaa7909 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -62,7 +62,10 @@ enum record_print_flag RECORD_PRINT_INSN_RANGE = (1 << 1), /* Indent based on call stack depth (if applicable). */ - RECORD_PRINT_INDENT_CALLS = (1 << 2) + RECORD_PRINT_INDENT_CALLS = (1 << 2), + + /* Deactivate printing auxiliary data (if applicable). */ + RECORD_DONT_PRINT_AUX = (1 << 3) }; DEF_ENUM_FLAGS_TYPE (enum record_print_flag, record_print_flags); -- 2.34.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928