From patchwork Mon Feb 17 16:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 38171 Received: (qmail 122686 invoked by alias); 17 Feb 2020 17:01:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 119473 invoked by uid 89); 17 Feb 2020 17:00:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=Simply, *target, XNEW, xnew X-HELO: mga17.intel.com Received: from mga17.intel.com (HELO mga17.intel.com) (192.55.52.151) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Feb 2020 17:00:03 +0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2020 08:59:42 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga005.fm.intel.com with ESMTP; 17 Feb 2020 08:59:31 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 01HGxVFN028386; Mon, 17 Feb 2020 16:59:31 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 01HGxU0i027454; Mon, 17 Feb 2020 17:59:30 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 01HGxUp3027439; Mon, 17 Feb 2020 17:59:30 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Cc: palves@redhat.com Subject: [PATCH v2 57/58] gdbserver: simply copy the pointer in 'set_target_ops' Date: Mon, 17 Feb 2020 17:58:05 +0100 Message-Id: <2f9385ba380c2b61abe2b93dce1cd0926c5961d8.1581956647.git.tankut.baris.aktemur@intel.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes From: Pedro Alves The 'set_target_ops' function takes a target op vector and creates a clone of it via XNEW and memcpy. This is not necessary. 'the_target' is a singleton, and the argument that is passed to 'set_target_ops' is always the address of a global, static object. Therefore, update the implementation to simply copy the pointer. gdbserver/ChangeLog: 2020-02-10 Pedro Alves * target.cc (set_target_ops): Simply copy the given target pointer instead of creating a copy of the pointed object. --- gdbserver/target.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdbserver/target.cc b/gdbserver/target.cc index 4df1f9d4bd8..d0a7d36c868 100644 --- a/gdbserver/target.cc +++ b/gdbserver/target.cc @@ -270,8 +270,7 @@ target_supports_multi_process (void) void set_target_ops (process_stratum_target *target) { - the_target = XNEW (process_stratum_target); - memcpy (the_target, target, sizeof (*the_target)); + the_target = target; } /* Convert pid to printable format. */