From patchwork Mon Mar 12 15:31:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rudo X-Patchwork-Id: 26286 Received: (qmail 4436 invoked by alias); 12 Mar 2018 15:31:31 -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 4282 invoked by uid 89); 12 Mar 2018 15:31:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Mar 2018 15:31:28 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2CFUV3h073265 for ; Mon, 12 Mar 2018 11:31:26 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gnsvfqjad-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 12 Mar 2018 11:31:25 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Mar 2018 15:31:23 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Mar 2018 15:31:20 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2CFVKlE23003320; Mon, 12 Mar 2018 15:31:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA1C75203F; Mon, 12 Mar 2018 14:22:52 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 6CC1052047; Mon, 12 Mar 2018 14:22:52 +0000 (GMT) From: Philipp Rudo To: gdb-patches@sourceware.org Cc: Omair Javaid , Yao Qi , arnez@linux.vnet.ibm.com Subject: [RFC PATCH v5 3/9] Add scoped_restore_regcache_ptid Date: Mon, 12 Mar 2018 16:31:09 +0100 In-Reply-To: <20180312153115.47321-1-prudo@linux.vnet.ibm.com> References: <20180312153115.47321-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18031215-0008-0000-0000-000004DB80F6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031215-0009-0000-0000-00001E6EAF8C Message-Id: <20180312153115.47321-4-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-12_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803120176 X-IsSubscribed: yes 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 d7bb8b5c93..8e45d7c513 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -403,6 +403,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: