From patchwork Tue Feb 28 11:28:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 65737 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 731F638515F1 for ; Tue, 28 Feb 2023 11:29:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 731F638515F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583792; bh=nfHlk5N12fQU2lkwlwJ6aiSsQkzwQ7LGpnhqtUbnf90=; 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=pm/7BTAbRWZgDhjZzopULY7a911DKQIgA2H4yHMMzk8ul3wLST598gBiwCWYtLH2H 7zcktW33GWamQba/juoOw0QEgiIXup0tS9KcRLatEvdLNYDKm7VoX7W4t59EBIqufP P1wrf2u/jNlRWt3F+6gxcHsr3DMaTR4kadNLuVuk= 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 5FF9C3851409 for ; Tue, 28 Feb 2023 11:29:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FF9C3851409 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="396679464" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="396679464" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:29:23 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="919748174" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="919748174" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:29:23 -0800 To: gdb-patches@sourceware.org Subject: [PATCH 07/26] gdbserver: convert regcache_cpy into regcache::copy_from Date: Tue, 28 Feb 2023 12:28:05 +0100 Message-Id: <4e915141249ac9e6f38b414f702d68755344ff70.1677582744.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: 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: Tankut Baris Aktemur via Gdb-patches From: Tankut Baris Aktemur Reply-To: Tankut Baris Aktemur Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Convert the free `regcache_cpy` function to a method of the regcache struct. --- gdbserver/regcache.cc | 16 ++++++++-------- gdbserver/regcache.h | 5 +++-- gdbserver/tracepoint.cc | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 89ecdfec6f3..be01df342bb 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -180,19 +180,19 @@ free_register_cache (struct regcache *regcache) #endif void -regcache_cpy (struct regcache *dst, struct regcache *src) +regcache::copy_from (regcache *src) { - gdb_assert (src != NULL && dst != NULL); - gdb_assert (src->tdesc == dst->tdesc); - gdb_assert (src != dst); + gdb_assert (src != nullptr); + gdb_assert (src->tdesc == this->tdesc); + gdb_assert (src != this); - memcpy (dst->registers, src->registers, src->tdesc->registers_size); + memcpy (this->registers, src->registers, src->tdesc->registers_size); #ifndef IN_PROCESS_AGENT - if (dst->register_status != NULL && src->register_status != NULL) - memcpy (dst->register_status, src->register_status, + if (this->register_status != nullptr && src->register_status != nullptr) + memcpy (this->register_status, src->register_status, src->tdesc->reg_defs.size ()); #endif - dst->registers_valid = src->registers_valid; + this->registers_valid = src->registers_valid; } /* Return a reference to the description of register N. */ diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 7eae6cb724a..32b3a8dccfc 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -70,9 +70,10 @@ struct regcache : public reg_buffer_common /* Fetch the registers from the target, if not done already. */ void fetch (); -}; -void regcache_cpy (struct regcache *dst, struct regcache *src); + /* Copy the contents of SRC into this regcache. */ + void copy_from (regcache *src); +}; regcache *get_thread_regcache (thread_info *thread, bool fetch = true); diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 82bb74addd1..26003422a70 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -4802,7 +4802,7 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx, tregcache.initialize (context_regcache->tdesc, regspace + 1); /* Copy the register data to the regblock. */ - regcache_cpy (&tregcache, context_regcache); + tregcache.copy_from (context_regcache); #ifndef IN_PROCESS_AGENT /* On some platforms, trap-based tracepoints will have the PC