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: 156930 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4230792jaa; Mon, 28 Jan 2019 21:04:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4AYAQ7zjOpDoVUKBczWRvlNNCsaV34Y2aL+HlpP5/mIe5KqmizF2RkB+34G18TOuLHlN3w X-Received: by 2002:a63:4a4d:: with SMTP id j13mr22740630pgl.127.1548738250174; Mon, 28 Jan 2019 21:04:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548738250; cv=none; d=google.com; s=arc-20160816; b=MdW/oowQqeuCj3zMoeRIoS52W7q0YHmscUtrntKTA/3FYXOkD66UaXBxnm67kM9frC lYVSlupbkt2vpWllZ8epKqOYpEklUL4A5Fd8Dlohwf3rpA932fjemMgCm1+QQiZegg5O 28qPjJa5gNauSqkQTpL19QzGn7UW8wldjUScIC4qeYZAZfRlzhDLLsVw9LU/rbnJHGgc 3PsU1zGbZUL95p8g8E5qoCezpzj+J+oemq0GKfv/HLwHo5eJMCvw/dcKqewxEPxu/EsB H/mPtI058gCqCiCtxPw0u2vkT47Dj7fE8pD4X3dnH6RcL3ByKCr+0D8DT6OH3TPW8N1u si0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=MAU60c+YNnp3KKlU6gK942RBpXVaYOWPDURgvD49lOM=; b=j+CC9jgZAF6vuCHE1qULo01c3HIRRvMgEFWyQmB6Lmm4lBsmFL++TA7zMwWMSQKq2N 5YOwlNxO8eHpJiZCAmPAe6FhC2KClkxkFB08WVY63VenP9HglOwWGk24smj9tMM4w/66 QKH7qwyufSpI+yQQsASMPx/UPUyx28KtBYhX061Fhq+rJ2GtU+tK74mx7HYmZSYxe8Rk rpJey1kP7lDjuvkyM5Dv6x5TeebxdEkCRB7cyEVMhMmIszAuuU5fdIcfN94QcRKAikPh H3Tkv1WwMVHvWLAyYMkP/7GpeMjMkSGyHDRWPXab1zgugk5Re1/lPMeM+eujiCsW/Akh 8l5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=a0tLBSAG; dkim=pass header.i=@linaro.org header.s=google header.b=hrafobq6; spf=pass (google.com: domain of gdb-patches-return-153709-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-153709-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r4si33903875pgi.387.2019.01.28.21.04.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 21:04:10 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-return-153709-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=a0tLBSAG; dkim=pass header.i=@linaro.org header.s=google header.b=hrafobq6; spf=pass (google.com: domain of gdb-patches-return-153709-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gdb-patches-return-153709-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=c04LSURir+qLBshlawzhFkxqyGqGXq8 K1MXLLVKZ1CD5tD2QDrjo9KTG6Q6rspGU1oifJ3WAM1H8atT6n9hYvpl30SGbd5Z qsPMPK2U4mnhfMID2tB1IgsxOLx11/mbZ7qFeTiptyf1oo0zTGd1ERbRxyUY0IUb BYxuAyn5WK7M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=Sa/AJk31aN9r1AV6Lpx1CXZqKtg=; b=a0tLB SAGtB5wfxM68yWD+FiHiRKsaH/p9fXMVDNF+aP/T3Bn633WSMUYBA8HYyaWhGyFa 3NR+hAUp+Qq2SMXLNc5sJlEIzPfVbATdAN5P8ozBjQfYX93+GZ9rxp22F+En6+cN PRpUZMPWWeVLvgzIMVg6ynZiU6tYRrBQzPNgiA= 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(+) -- 2.7.4 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: