From patchwork Tue Feb 28 11:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aktemur, Tankut Baris" X-Patchwork-Id: 65745 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 D08EE385020B for ; Tue, 28 Feb 2023 11:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D08EE385020B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677583854; bh=lPN3YtIKYAQx4TsXc1zi0YvDqUd6nOX0yqf5/ykRL6k=; 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=bhqnbKprA4aWnMCXwcdDqFJ0HzRL9z1M6InMa6wkf6VKvEpZ142Gn22GqiNgQw0xg Yp47u6xMUk2fA8ysyr2mBjTSDLI3THLEX5nR/yvmpAmtlg8QAQ2KqXphYofgfTkxS9 Ux2Y6bOqrGJSRnuRIPAE0elIEWJpFfS5YUeZx14w= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 1A605385843E for ; Tue, 28 Feb 2023 11:29:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A605385843E X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="420374035" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="420374035" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:29:58 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="848213443" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="848213443" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:29:57 -0800 To: gdb-patches@sourceware.org Subject: [PATCH 12/26] gdbserver: convert supply_regblock to regcache::supply_regblock Date: Tue, 28 Feb 2023 12:28:10 +0100 Message-Id: <1281d173376d23b5da5e09529aafeb6618672fd6.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.5 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: "Aktemur, Tankut Baris" Reply-To: Tankut Baris Aktemur Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Convert the supply_regblock function into a method of the regcache struct. Also do some minor code modernization. --- gdbserver/regcache.cc | 32 ++++++++------------------------ gdbserver/regcache.h | 7 +++++-- gdbserver/tracepoint.cc | 8 ++++---- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 156fda7068d..31f1e7bb3dc 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -376,39 +376,23 @@ supply_register_by_name_zeroed (struct regcache *regcache, #endif -/* Supply the whole register set whose contents are stored in BUF, to - REGCACHE. If BUF is NULL, all the registers' values are recorded - as unavailable. */ - void -supply_regblock (struct regcache *regcache, const void *buf) +regcache::supply_regblock (const void *buf) { - if (buf) + if (buf != nullptr) { - const struct target_desc *tdesc = regcache->tdesc; - - memcpy (regcache->registers, buf, tdesc->registers_size); + memcpy (registers, buf, tdesc->registers_size); #ifndef IN_PROCESS_AGENT - { - int i; - - for (i = 0; i < tdesc->reg_defs.size (); i++) - regcache->register_status[i] = REG_VALID; - } + for (int i = 0; i < tdesc->reg_defs.size (); i++) + register_status[i] = REG_VALID; #endif } else { - const struct target_desc *tdesc = regcache->tdesc; - - memset (regcache->registers, 0, tdesc->registers_size); + memset (registers, 0, tdesc->registers_size); #ifndef IN_PROCESS_AGENT - { - int i; - - for (i = 0; i < tdesc->reg_defs.size (); i++) - regcache->register_status[i] = REG_UNAVAILABLE; - } + for (int i = 0; i < tdesc->reg_defs.size (); i++) + register_status[i] = REG_UNAVAILABLE; #endif } } diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 6aa03a70352..944718070b4 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -91,6 +91,11 @@ struct regcache : public reg_buffer_common /* Convert a string to register values and fill our register cache. */ void registers_from_string (const char *buf); + + /* Supply the whole register set whose contents are stored in BUF, + to this regcache. If BUF is NULL, all the registers' values are + recorded as unavailable. */ + void supply_regblock (const void *buf); }; regcache *get_thread_regcache (thread_info *thread, bool fetch = true); @@ -138,8 +143,6 @@ void supply_register_by_name (struct regcache *regcache, void supply_register_by_name_zeroed (struct regcache *regcache, const char *name); -void supply_regblock (struct regcache *regcache, const void *buf); - void collect_register (struct regcache *regcache, int n, void *buf); void collect_register_as_string (struct regcache *regcache, int n, char *buf); diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 26003422a70..9833e7c3b0f 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -4707,7 +4707,7 @@ get_context_regcache (struct tracepoint_hit_ctx *ctx) { fctx->regcache_initted = 1; fctx->regcache.initialize (ipa_tdesc, fctx->regspace); - supply_regblock (&fctx->regcache, NULL); + fctx->regcache.supply_regblock (nullptr); supply_fast_tracepoint_registers (&fctx->regcache, fctx->regs); } regcache = &fctx->regcache; @@ -4722,7 +4722,7 @@ get_context_regcache (struct tracepoint_hit_ctx *ctx) { sctx->regcache_initted = 1; sctx->regcache.initialize (ipa_tdesc, sctx->regspace); - supply_regblock (&sctx->regcache, NULL); + sctx->regcache.supply_regblock (nullptr); /* Pass down the tracepoint address, because REGS doesn't include the PC, but we know what it must have been. */ supply_static_tracepoint_registers (&sctx->regcache, @@ -5180,7 +5180,7 @@ fetch_traceframe_registers (int tfnum, struct regcache *regcache, int regnum) if (dataptr == NULL) { /* Mark registers unavailable. */ - supply_regblock (regcache, NULL); + regcache->supply_regblock (nullptr); /* We can generally guess at a PC, although this will be misleading for while-stepping frames and multi-location @@ -5190,7 +5190,7 @@ fetch_traceframe_registers (int tfnum, struct regcache *regcache, int regnum) regcache_write_pc (regcache, tpoint->address); } else - supply_regblock (regcache, dataptr); + regcache->supply_regblock (dataptr); return 0; }