From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 3E1133858C62 for ; Tue, 28 Feb 2023 11:28:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E1133858C62 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=1677583731; x=1709119731; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=MZLHTzWPTeiCWDkSiHMc/BlN0LE6M89WJ0NymrWhh3g=; b=Jf8ttjNJAbVxCrgkqWtaCtJaWQUP7sDVkLgcGvvvuXgURk2lvzKWXSGE lLfWxS3gLIxxM1m7yvyVox8ctqd6YgL/xjEI2fw52UnB6AfljYrwblm1x KXyYhucQonR23t3HK+7pnvh1HSVPdV35LYAGWNqWHrwGNUNBydh6+1F3p bFnEZJllhS6nWddXg8xpVtxHcuIzTgvFCvCKM6qEK2CF1bEkSxHaNpHpk RSSnTHh+HcAIXWlu6nw4DkQRYYihIfy5SUXFj7GihLrCWoe3RJthI4lEH tImIQLU/6WXwW5umEQGe8/atiGUGzmQbdxt2rwR+YMsqCa8cLgyj36L4d A==; X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="314536301" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="314536301" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:28:50 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="738120400" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="738120400" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 03:28:49 -0800 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 02/26] gdbserver: convert new_register_cache into a regcache constructor Date: Tue, 28 Feb 2023 12:28:00 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: 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 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: Convert the `new_register_cache` function into a constructor of the regcache struct. Also define a default ctor because it is used in other places, in particular, tracepoint.cc. --- gdbserver/regcache.cc | 11 +++-------- gdbserver/regcache.h | 8 ++++---- gdbserver/server.cc | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 7987c406ab4..1410dd96551 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -43,7 +43,7 @@ get_thread_regcache (struct thread_info *thread, int fetch) gdb_assert (proc->tdesc != NULL); - regcache = new_register_cache (proc->tdesc); + regcache = new struct regcache (proc->tdesc); set_thread_regcache_data (thread, regcache); } @@ -151,15 +151,10 @@ regcache::initialize (const target_desc *tdesc, #ifndef IN_PROCESS_AGENT -struct regcache * -new_register_cache (const struct target_desc *tdesc) +regcache::regcache (const target_desc *tdesc) { - struct regcache *regcache = new struct regcache; - gdb_assert (tdesc->registers_size != 0); - regcache->initialize (tdesc, nullptr); - - return regcache; + initialize (tdesc, nullptr); } void diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 15b7e2b4dff..0002726ed00 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -44,6 +44,10 @@ struct regcache : public reg_buffer_common #ifndef IN_PROCESS_AGENT /* One of REG_UNAVAILABLE or REG_VALID. */ unsigned char *register_status = nullptr; + + /* Constructors. */ + regcache () = default; + regcache (const target_desc *tdesc); #endif /* Init the regcache data. */ @@ -64,10 +68,6 @@ struct regcache : public reg_buffer_common void regcache_cpy (struct regcache *dst, struct regcache *src); -/* Create a new register cache for INFERIOR. */ - -struct regcache *new_register_cache (const struct target_desc *tdesc); - struct regcache *get_thread_regcache (struct thread_info *thread, int fetch); /* Release all memory associated with the register cache for INFERIOR. */ diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 949849b63a2..f85d7ed9cf5 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -4238,7 +4238,7 @@ process_serial_event (void) if (cs.current_traceframe >= 0) { struct regcache *regcache - = new_register_cache (current_target_desc ()); + = new struct regcache (current_target_desc ()); if (fetch_traceframe_registers (cs.current_traceframe, regcache, -1) == 0) -- 2.25.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