From patchwork Tue Jan 29 05:03:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omair Javaid X-Patchwork-Id: 31238 Received: (qmail 36632 invoked by alias); 29 Jan 2019 05:03:53 -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 36578 invoked by uid 89); 29 Jan 2019 05:03:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Jan 2019 05:03:51 +0000 Received: by mail-wm1-f65.google.com with SMTP id t200so16353483wmt.0 for ; Mon, 28 Jan 2019 21:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MAU60c+YNnp3KKlU6gK942RBpXVaYOWPDURgvD49lOM=; b=hrafobq6XXo8VFwP6jsjWZVesDUSspP8XtKVVLQh/PWSt0ZZLQTXcbkxeaZtdfusPi /pDAc4WPHnaW0zv0pE4191KNBv1Q+OAMTN2qvmiXHoSxSQpb9zjlNjW3jH/5tU/adKWX uU5EdO0o7tx9+bHp8hAq6B6f638lc4ZEpKcpE= Return-Path: Received: from localhost.localdomain ([43.251.253.48]) by smtp.gmail.com with ESMTPSA id s1sm170325615wro.9.2019.01.28.21.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 21:03:48 -0800 (PST) From: Omair Javaid To: gdb-patches@sourceware.org Cc: palves@redhat.com, prudo@linux.ibm.com, arnez@linux.vnet.ibm.com, peter.griffin@linaro.org, Ulrich.Weigand@de.ibm.com, kieran@linuxembedded.co.uk Subject: [RFC PATCH 3/6] Add scoped_restore_regcache_ptid Date: Tue, 29 Jan 2019 10:03:16 +0500 Message-Id: <1548738199-9403-4-git-send-email-omair.javaid@linaro.org> In-Reply-To: <1548738199-9403-1-git-send-email-omair.javaid@linaro.org> References: <1548738199-9403-1-git-send-email-omair.javaid@linaro.org> X-IsSubscribed: yes From: Philipp Rudo When a target and its target beneath use different ptids to identify a thread the regcaches ptid has to be set/restored when calls are passed down to the target beneath to e.g. fetch_registers. Add a scoped_restore to simplify this. gdb/ChangeLog: regcache.h (scoped_restore_regcache_ptid): New class. --- gdb/regcache.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gdb/regcache.h b/gdb/regcache.h index 2b703ea..389d220 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -429,6 +429,27 @@ private: registers_changed_ptid (ptid_t ptid); }; +/* Save/restore the current ptid of REGCACHE. */ + +class scoped_restore_regcache_ptid +{ +public: + scoped_restore_regcache_ptid (regcache *regcache) + : m_regcache (regcache), m_ptid (regcache->ptid ()) + {} + + ~scoped_restore_regcache_ptid () + { + m_regcache->set_ptid (m_ptid); + } + + DISABLE_COPY_AND_ASSIGN (scoped_restore_regcache_ptid); + +private: + regcache *m_regcache; + ptid_t m_ptid; +}; + class readonly_detached_regcache : public readable_regcache { public: