From patchwork Wed Mar 22 17:29:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 19703 Received: (qmail 78490 invoked by alias); 22 Mar 2017 17:29:39 -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 78476 invoked by uid 89); 22 Mar 2017 17:29:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy= X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Mar 2017 17:29:37 +0000 Received: from ESESSHC009.ericsson.se (Unknown_Domain [153.88.183.45]) by (Symantec Mail Security) with SMTP id FE.1E.14680.E74B2D85; Wed, 22 Mar 2017 18:29:35 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.45) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 22 Mar 2017 18:29:34 +0100 Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=ericsson.com; Received: from elxcz23q12-y4.ca.am.ericsson.se (192.75.88.130) by DB5PR07MB1717.eurprd07.prod.outlook.com (2603:10a6:0:12::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.4; Wed, 22 Mar 2017 17:29:32 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Remove some unnecessary inferior_ptid setting/restoring when fetching/storing registers Date: Wed, 22 Mar 2017 13:29:19 -0400 Message-ID: <20170322172919.26538-1-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: DM5PR17CA0034.namprd17.prod.outlook.com (2603:10b6:3:83::20) To DB5PR07MB1717.eurprd07.prod.outlook.com (2603:10a6:0:12::22) X-MS-Office365-Filtering-Correlation-Id: 2fc55c87-3616-40c2-0936-08d47149014e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB5PR07MB1717; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 3:a8gvnmBY03kD1AW4EFDTlooMyzHPfQfxlzVbhMK1MgRIzcMctQwqDp3N8dmxDqU2TqIZ3fncy0yhxkEEtcl/tDVpor2/pYTyi4Z+GJSBNc/ylLCoDJkkHID/Twq1p6QKZhRKayGVzrQTo10dBZsS2WL3BGSMOOORVPFjkUiu5F0OdrzPAtxeR61Yzc7XWceOtOHzLrwPyvtURU8m1F0Wv5T6X3904rM/Eesne4o+qQQPjHKzza0ZNbq/RZugO1S0iHUcMGZWMbjrqzZKMjg7Ew==; 25:YQv8wC2y+bMKIqRXBKtQ/EZNKRwOpbIPBOJR8vlQpCOFNFU3OvHUaPx1ceng8EWjXMx1pFeSFq+jgYbh7U5R1f1Jyg2RWkzKqXImXOcJS/zS4zZr5spH9+CA+7O2vm06HYVLxLrdSVzzPBabT3HJlNTkXvxsHo/R5U7T2S+NhzAqkVokBMxVrtkuTuSyAWqjuKPSVgNwaJlFbnTIaI9jJoggURZUnt3sGMYjt7wZnyL0UCJ8HefHGoGcNovB20ne8GEM3taFPvjIYJ3m8kUspPDoTZg+BDMxn2CIuGFSZOFBUbz89n12Spqhx0L1HfUv+89SLUR2MMw23C/SkDIf0QiKE06c5UZwFIt+Of/jgO8w79sjeq7ClEtnh8fEcYBcKwNd1yyDltpH5RmxF7qIUBUauGN6UOzrwnEELnnOYk3//oCS38wtZRJVUj99qtNl80Iq/6F30KN9eA+ziNS2ow== X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 31:Bn4qw2EQL+m8AuQABDW4aBIyf0Rhh3i+6ktijExriAbWngxQalwfXKlBM1PiZdl2TzkhkguTYxHhdLb1n1bkJHYsh1AzazEBCRNmwfYVkIcalgEb1gzTQcfAsBt5tt1NRum1kYVa28XSj3zsT+Vlk3tbKq7AmhwSEm3zWvkPUqDjbj/fifkxcc5OyYr/R6nN64Tk4Yr7/QP6IaV7h61OQiDEhbcOtd/iwkLDjd4+z10=; 20:LFb36jEwQeSm68pFrPFWpZdqj21jg6gG2a0widpAuUTU/8caXIfAzsDPjpNnicEWDf76wrx/c+rCVpxc/yzMnLEahkHtmQtU3iuVEQddMREwbCfxh4p95iBg9i0r2G23jM3MOOj2oz5skiKEkQkAyRMe4M45ar294xcIo7fXsl2jphavkI2X3s4a0nhKJogUdAgRqw0yGu+s+A8135zW2W2clp27jpliF/cWU7G41KdDe2zASfdyRbX9Rw3mBqvO6FJl4YUmAEn4QxW3ENZd82UcXWhbOnw+vLlGuqWTj/8+PSnqoig4BEdzraIy1JkiJzZ7TrXQ5eD0Ng+XIzWLjmcvb+AKrcygN0ugB4gwOKD56FMM853sIKTs0041sohGkEzTzgyDoNPC/5B3586ENH4kfWenCZbHdGED/T+D3tHabiel7xosA6yW309jtj8YQ10OPaASjTRvkLioAWgVuYxZCHQ3/6ov4NyMGjVjwXywm22hA3qr3/dNohkBbQjp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123558025)(20161123560025)(6072148); SRVR:DB5PR07MB1717; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB1717; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 4:P90SlyrUJCtVlAqJi6h+RaJXh8gGwtNDvJN+SfeOU5xEubEn4/Q7wPYmCmpfb5K+0WcUobFo6qITLNufCkKR+oKZAjLbHQmH8XcsMMK0g3CWgnmzV0SElxOyGPp24NIsFneF/7CGcbbRpk1Pbsx8/piHP7Z5UUwwxTzDgCyruGBBDUPNJo8bJW0Zz7vyPjknqVTTIP7G6ll0QyA/ULH4eCYrqcYoNs58y1GcMdQy3kP03jiIcAOqWJ69Hq2xqG49C0U1zAQWsfLbeqTMtxnrt7p3iZyg6QQgaWmxfBxGbPxNdOqqvJLzZ3E5AAM84pX+N1yJdmniibwbB8JgMHte6p9tfG7A3rWwcA3TsFIoRBwwT+ctLx19Y43k14t8UffAgFTYrKKsZXe+LgPFwhjgpLWZYzSs2OfcZ9DnEibezEMZ0nWFLqh9e4oTiX3qtm8Dou6+3WYLzYbfhzDp+s8sOOv9OCJyUvQKQCadhAgGcrYrKEW+8AhSxQYFYkqK4Gwher/6P2o/2xpqzIMSsLri45zOlrvVbueeYOY97Gr9wCpcNZh/Owj3ZdO14llH+MQXuZ/MopEnnu/8yLtL30Ym2W4rxRO4rUbc6k2YGQdW2vI= X-Forefront-PRVS: 02543CD7CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(54534003)(6116002)(42186005)(33646002)(53936002)(81166006)(5660300001)(25786009)(189998001)(36756003)(6506006)(3846002)(1076002)(305945005)(5003940100001)(6916009)(50226002)(2351001)(50986999)(7736002)(8676002)(6512007)(110136004)(66066001)(47776003)(48376002)(38730400002)(107886003)(4326008)(6666003)(50466002)(575784001)(2906002)(6486002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR07MB1717; H:elxcz23q12-y4.ca.am.ericsson.se; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 23:YWbT2KJRNopOlk014XYldcVfcRvFAGU+8H+P2jXtfsnf/CNHANJ6X52zKPGJjCyFpvXvTE2eFS1GySpfb3C8RIJtQhK6L09CzPNpWMz99HS6kJFwJlmviu46KUCzZpTrVLSFtLXFKHaBn1RzoVCl4RAN5inu4FRaUWEQD3nfgeLJLFeAC6mxrwTaNdbV8CDguNWfnqvvvEShcSCIrI8A17BSmxFpwgbk4yYTJzGirkAje8oQmI/v/+avLlnBJijLSs97QYQCkJPX1iVdHgMPzi76TjYBpK8gXPzUQiWS5CrxZ9cZBoJ8wS85NDNAWmFXOS8pQak6+rGeZT3nng0INtYRPPrbtNgOKaKBOrkZAhMG0vqvDTPY8B3ucv7p5iycmKRqueBnCOorTgBSzily8lGdrYiS4rYIab7xK0/UgZYskOvfXiHwQLbiKqXs8yFlyw/eauTEuUWyZwaLMq4m3H9xaWa5LIsVemNY9uiNuum5a6AzbmLY1FPYqfOrNsMAUiRjaJVoUGe/OvgfkXVtNahrxgZSg9ORbh9vXeY5td0fuJR0mvDktBvrwJbmI3tAFRZ/WcnjpsL6XCrDbVnKpR9aU5wojOPuMekxJFOQxZfe/bF+RSyetIEKFC8HrwEGKsNEZ8Vs9zMAGwqKzEhDw0A4oXdqYI5W1JpBEfZXyyB42Ghkwt6Ei2ck/72EaMZLGhugncESFIRuAeug3+dHMqE0m6fR00YiQY1A+w4ZR48/EgWx23ILbbTWPCL9fuzTMevhJ9NK451/QGkzs5ptlTSx2r7vBBNphUZPC7ZB5mfghhevECIeZRbfanUQ+y/y27As/2u5o3xuKdK89KWIELFqsI9u8t3hQ8YMgYvOuZtd98ge56X/MbZayGbD98Pf/lWYCY3kOuFY79xPbAXafrK/u3vcw+rl3ALxobk74tmIwFF87T2FRQrwagpIBSNV X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 6:rCqefXU7Kyjsr17dqEGQJiMLfhy+uI+vqXyx2NSwIrq0WnkGi9cTvf83Nla6SeOWmdiUk3hzpmgyIwE/VWEIKdXEJQ0Pc1ps42NncAxRrGKaVHw1KJDrmeU7rjODlHaWSD+aY7ntUeR6Xf6fL3HtkW5y+DKNYu5j8PL/g5LArrauWgJJoGbK9kn2EPDV2ImAc+nAcwN3U2MKGIXN+ofOyn8TKxem8HcBxdbnWX24lQ1hDU63jan1xibNbRxV5v5rRQdCVX1WKhax/YnvdvZa6rdWmKJa9zp0VxRAX+VF8OkU3D9g/gNzUM71sqyDDJfLAY1Fvw4t5iK07hccvajyp9YIYal0LSs/RDuYm7ZFunR7i1SuqqEQESkukHCY/1HwpsJ4dCWA9gShjb1rIOkzkQ==; 5:StNpKpyRzmqY9j2t4VbyZ4T7tiAfZZYebiQzqzMMycrR4cZuZnMetchNKgAN3vpb2zsY05cW1eIXXUwbbB8JcV32FgPw9PknVGVOrYWJ1kYKpYnv+oxD+dE4TGOEqWaByQG/W3JNqKyxUPX8cicN4g==; 24:WF/WPg6TV8Yr+U3ydqUwyBKwJVW9Wy0FMAHn5AOyNdARrOhOC+LS1466o72Vw1TRgaMbv1tXxyBqY6Z4T0xrexY0y5lhxW077lnhjkhKEgw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 7:IJ+lSmR4iVuLlGHHcc0f9wjhjt8gjCaCkashusd2Hm/ZtHFj9oxSREoDgMtilpZABvMWD6EtpFi3Bc5lSLcgf+Q/lYsnTSjG0Lrv7I6078B/FkIl8o59X+IOVOGg6KVOy2mhNSsPgrSimyduLrW8BRHz+jaX6xEGlGZaKA6SkmqRmfe7zcHqa0lY2doaOY+IRlyPYfIgILI410+PKtijhQ+Nmajfj+g9R+GgIhOaAVbPtIaqLQ8mt1xRvR4d6W8PykBvCwMWBAH9RNjbyEYxafaqaOlZ7Nu/FK1IivefCRiijpGX8AhI51JybN/hQZunO53Z3nAAoIlMWnhg1PTR5Q== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 17:29:32.8900 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB1717 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes Now that the to_fetch_registers, to_store_registers and to_prepare_to_store target methods don't rely on the value of inferior_ptid anymore, we can remove a bunch of now unnecessary setting and restoring of inferior_ptid. The asserts added recently in target_fetch_registers and target_store_registers, which validate that inferior_ptid matches the regcache's ptid, must go away. It's the whole point of this effort, to not require inferior_ptid to have a particular value when calling these functions. One thing that I noticed is how sol-thread.c's ps_lgetregs and friends use the current value of inferior_ptid instead of what's passed as argument (ph->ptid), unlike proc-service.c's versions of the same functions. Is it expected? I left it like this in the current patch, but unless there's a good reason for it to be that way, I guess we should make it use the parameter. gdb/ChangeLog: * fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore inferior_ptid. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * regcache.c (regcache_raw_update, regcache_raw_write): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * target.c (target_fetch_registers, target_store_registers): Remove asserts. --- gdb/fbsd-tdep.c | 4 ---- gdb/proc-service.c | 36 ++++++++++++------------------------ gdb/regcache.c | 17 +++-------------- gdb/sol-thread.c | 46 ++++++++++++---------------------------------- gdb/target.c | 4 ---- 5 files changed, 27 insertions(+), 80 deletions(-) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index e757910023..46875d8efd 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -193,15 +193,11 @@ static void fbsd_corefile_thread (struct thread_info *info, struct fbsd_corefile_thread_data *args) { - struct cleanup *old_chain; struct regcache *regcache; regcache = get_thread_arch_regcache (info->ptid, args->gdbarch); - old_chain = save_inferior_ptid (); - inferior_ptid = info->ptid; target_fetch_registers (regcache, -1); - do_cleanups (old_chain); args->note_data = fbsd_collect_thread_registers (regcache, info->ptid, args->obfd, args->note_data, diff --git a/gdb/proc-service.c b/gdb/proc-service.c index d39830cb69..415ba0a7f3 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -158,16 +158,13 @@ ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr, ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_ptid (); - struct regcache *regcache; - - inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); target_fetch_registers (regcache, -1); fill_gregset (regcache, (gdb_gregset_t *) gregset, -1); - do_cleanups (old_chain); return PS_OK; } @@ -177,16 +174,13 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) ps_err_e ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_ptid (); - struct regcache *regcache; - - inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); supply_gregset (regcache, (const gdb_gregset_t *) gregset); target_store_registers (regcache, -1); - do_cleanups (old_chain); return PS_OK; } @@ -197,16 +191,13 @@ ps_err_e ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_ptid (); - struct regcache *regcache; - - inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); target_fetch_registers (regcache, -1); fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1); - do_cleanups (old_chain); return PS_OK; } @@ -217,16 +208,13 @@ ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_ptid (); - struct regcache *regcache; - - inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset); target_store_registers (regcache, -1); - do_cleanups (old_chain); return PS_OK; } diff --git a/gdb/regcache.c b/gdb/regcache.c index 58d4f56292..71223a1dc4 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -666,11 +666,7 @@ regcache_raw_update (struct regcache *regcache, int regnum) if (!regcache->readonly_p && regcache_register_status (regcache, regnum) == REG_UNKNOWN) { - struct cleanup *old_chain = save_inferior_ptid (); - - inferior_ptid = regcache->ptid; target_fetch_registers (regcache, regnum); - do_cleanups (old_chain); /* A number of targets can't access the whole set of raw registers (because the debug API provides no means to get at @@ -937,8 +933,7 @@ void regcache_raw_write (struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct cleanup *chain_before_save_inferior; - struct cleanup *chain_before_invalidate_register; + struct cleanup *old_chain; gdb_assert (regcache != NULL && buf != NULL); gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); @@ -956,24 +951,18 @@ regcache_raw_write (struct regcache *regcache, int regnum, regcache->descr->sizeof_register[regnum]) == 0)) return; - chain_before_save_inferior = save_inferior_ptid (); - inferior_ptid = regcache->ptid; - target_prepare_to_store (regcache); regcache_raw_set_cached_value (regcache, regnum, buf); /* Register a cleanup function for invalidating the register after it is written, in case of a failure. */ - chain_before_invalidate_register - = make_cleanup_regcache_invalidate (regcache, regnum); + old_chain = make_cleanup_regcache_invalidate (regcache, regnum); target_store_registers (regcache, regnum); /* The target did not throw an error so we can discard invalidating the register and restore the cleanup chain to what it was. */ - discard_cleanups (chain_before_invalidate_register); - - do_cleanups (chain_before_save_inferior); + discard_cleanups (old_chain); } void diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index efb3bd0b21..ae9b1411cf 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -881,19 +881,13 @@ ps_ptwrite (gdb_ps_prochandle_t ph, gdb_ps_addr_t addr, ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) { - struct cleanup *old_chain; - struct regcache *regcache; - - old_chain = save_inferior_ptid (); - - inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); target_fetch_registers (regcache, -1); fill_gregset (regcache, (gdb_gregset_t *) gregset, -1); - do_cleanups (old_chain); - return PS_OK; } @@ -903,13 +897,9 @@ ps_err_e ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) { - struct cleanup *old_chain; - struct regcache *regcache; - - old_chain = save_inferior_ptid (); - - inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); supply_gregset (regcache, (const gdb_gregset_t *) gregset); target_store_registers (regcache, -1); @@ -961,19 +951,13 @@ ps_err_e ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prfpregset_t *fpregset) { - struct cleanup *old_chain; - struct regcache *regcache; - - old_chain = save_inferior_ptid (); - - inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); target_fetch_registers (regcache, -1); fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1); - do_cleanups (old_chain); - return PS_OK; } @@ -983,19 +967,13 @@ ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t * fpregset) { - struct cleanup *old_chain; - struct regcache *regcache; - - old_chain = save_inferior_ptid (); - - inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); - regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ()); + ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0); + struct regcache *regcache + = get_thread_arch_regcache (ptid, target_gdbarch ()); supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset); target_store_registers (regcache, -1); - do_cleanups (old_chain); - return PS_OK; } diff --git a/gdb/target.c b/gdb/target.c index 359bf0dec9..0ff8515d3b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3587,8 +3587,6 @@ debug_print_register (const char * func, void target_fetch_registers (struct regcache *regcache, int regno) { - gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid)); - current_target.to_fetch_registers (¤t_target, regcache, regno); if (targetdebug) debug_print_register ("target_fetch_registers", regcache, regno); @@ -3600,8 +3598,6 @@ target_store_registers (struct regcache *regcache, int regno) if (!may_write_registers) error (_("Writing to registers is not allowed (regno %d)"), regno); - gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid)); - current_target.to_store_registers (¤t_target, regcache, regno); if (targetdebug) {