From patchwork Fri Oct 21 11:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Willgerodt, Felix" X-Patchwork-Id: 59276 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 C6C733851ABD for ; Fri, 21 Oct 2022 12:03:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6C733851ABD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666353826; bh=HUhslYKr4hJg6pNfPBerdZlwcd57cGnjs9MVs+nBNaY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AaKOQFE1o+dkWlPrX5PkNoZobZP5782AWl7HvKf0Jl61E204i871JR7zDsRC3lhSF j5bQS+LYlP2FeAPtLB/tuugQVs6VTMyQOKNDwcBrDOug5TtnF1eEu+FYC0TzbxGfVp 0Skv3MYcHsMbo15iyg9CaYbRLAL/LA+mSGPcd9FY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id F08243854167 for ; Fri, 21 Oct 2022 12:02:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F08243854167 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="369034665" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="369034665" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 05:02:09 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="693676733" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="693676733" Received: from mulvlfelix.iul.intel.com (HELO localhost) ([172.28.48.92]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 05:02:08 -0700 To: gdb-patches@sourceware.org, markus.t.metzger@intel.com Subject: [PATCH v7 01/10] btrace: Introduce auxiliary instructions. Date: Fri, 21 Oct 2022 13:59:38 +0200 Message-Id: <20221021115947.359223-2-felix.willgerodt@intel.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221021115947.359223-1-felix.willgerodt@intel.com> References: <20221021115947.359223-1-felix.willgerodt@intel.com> MIME-Version: 1.0 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 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Felix Willgerodt via Gdb-patches From: "Willgerodt, Felix" Reply-To: Felix Willgerodt Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Auxiliary instructions are pseudo instructions pointing to auxiliary data. This auxiliary data can be printed in all commands displaying (record function-call-history, record instruction-history) or stepping through (stepi etc.) the execution history, which will be introduced in the next commits. This patch is in preparation for the new ptwrite feature, which is based on auxiliary instructions. --- gdb/btrace.c | 2 ++ gdb/btrace.h | 24 +++++++++++++++++++++--- gdb/doc/gdb.texinfo | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index a8e6049265c..4a1b10b7c81 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1823,6 +1823,8 @@ btrace_clear_history (struct btrace_thread_info *btinfo) btinfo->insn_history = NULL; btinfo->call_history = NULL; btinfo->replay = NULL; + + btinfo->aux_data.clear (); } /* Clear the branch trace maintenance histories in BTINFO. */ diff --git a/gdb/btrace.h b/gdb/btrace.h index 0fcf669597a..be4ce424ed5 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -52,7 +52,10 @@ enum btrace_insn_class BTRACE_INSN_RETURN, /* The instruction is an unconditional jump. */ - BTRACE_INSN_JUMP + BTRACE_INSN_JUMP, + + /* The instruction is a pseudo instruction containing auxiliary data. */ + BTRACE_INSN_AUX }; /* Instruction flags. */ @@ -68,8 +71,19 @@ DEF_ENUM_FLAGS_TYPE (enum btrace_insn_flag, btrace_insn_flags); This represents a single instruction in a branch trace. */ struct btrace_insn { - /* The address of this instruction. */ - CORE_ADDR pc; + union + { + /* The address of this instruction. Applies to btrace_insn with + iclass == BTRACE_INSN_OTHER or + iclass == BTRACE_INSN_CALL or + iclass == BTRACE_INSN_RETURN or + iclass == BTRACE_INSN_JUMP. */ + CORE_ADDR pc; + + /* Index into btrace_info::aux_data. Applies to btrace_insn with + iclass == BTRACE_INSN_AUX. */ + uint64_t aux_data_index; + }; /* The size of this instruction in bytes. */ gdb_byte size; @@ -330,6 +344,10 @@ struct btrace_thread_info function segment i will be at index (i - 1). */ std::vector functions; + /* Optional auxiliary information that is printed in all commands + displaying or stepping through the execution history. */ + std::vector aux_data; + /* The function level offset. When added to each function's LEVEL, this normalizes the function levels such that the smallest level becomes zero. */ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ea66f4ee42d..5df67eb6644 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -7545,6 +7545,9 @@ Moxie, PowerPC, PowerPC64, S/390, and x86 (i386/amd64) running GNU/Linux. Process record and replay can be used both when native debugging, and when remote debugging via @code{gdbserver}. +When recording an inferior, @value{GDBN} may print auxiliary information +during stepping commands and commands displaying the execution history. + For architecture environments that support process record and replay, @value{GDBN} provides the following commands: