From patchwork Wed Mar 8 16:41:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 19486 Received: (qmail 119730 invoked by alias); 8 Mar 2017 16:42:11 -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 119520 invoked by uid 89); 8 Mar 2017 16:42:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 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=33413, 1978, Signal 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, 08 Mar 2017 16:42:07 +0000 Received: from ESESSHC015.ericsson.se (Unknown_Domain [153.88.183.63]) by (Symantec Mail Security) with SMTP id 44.1D.18508.B5430C85; Wed, 8 Mar 2017 17:42:03 +0100 (CET) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.63) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 8 Mar 2017 17:42:02 +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_256_CBC_SHA384_P384) id 15.1.961.8; Wed, 8 Mar 2017 16:42:01 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 4/7] Pass down ptid in bsd_uthread_ops layer Date: Wed, 8 Mar 2017 11:41:37 -0500 Message-ID: <20170308164140.7281-5-simon.marchi@ericsson.com> In-Reply-To: <20170308164140.7281-1-simon.marchi@ericsson.com> References: <20170308164140.7281-1-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: MWHPR21CA0024.namprd21.prod.outlook.com (2603:10b6:300:6e::34) To DB5PR07MB1717.eurprd07.prod.outlook.com (2603:10a6:0:12::22) X-MS-Office365-Filtering-Correlation-Id: 80b8368a-7e42-4bf0-3b07-08d466420bd8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB5PR07MB1717; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 3:NU8cp1/2FHfmuEJFU4KEsOx3yND7DaVvP4v+PAsIiVCb39klWWbUF/5vUnHn1e5hYgR8lGjCTni4evDImyM9mjQLqy0n6xC2JDRGvWhgOZjev69SIntf37myku5s7+lIPd0pPN6JM0FRH8Uj9WWLMRA/b1swG1j70cl7jEzBQLlTlKkg64kqiGPBGDKBHS5aEgFZiOpAh/fFsWS1yfHKLyekUNA57L458jNJjM6T14qw079KjPwVNuorKyL084E7kCmIKv5woJMyOfuDjAVykg==; 25:rtLeSizT5WlILtw2T4bFhuIdolOnc1x9UIoeyRqf/75OfORy9JsyVYZznckjwLeXVHtVS1/rA6WV8AWeQlPuRK2GDYqf62gx9m9G4YETNkZ9lQ+QPmQoxzrqFW9vnKCBl+gXkUIsTJhvGspthos+/N6ZYbeBMFDTQGnf4gxj9o8tLPl9qoSNwggOpqqvlsfR7bEM1Hyo4il2STeywii47EMWvAV/3JnZwcLQYR2orNLKWiiJccswaGm7t992pes451jQueb/0+hbiTVcAe6fjJRFp2LXZXITqqZ2Q18fbCSSUz+ZPXUDepQZM+kqbGYpaXgnP4gReq3anePoXZ1eCX9pJL4MZBtoB12o+jFYImv2VdOnT3Hlm5RqXoQa2R192DwjKyZrhL3b35aO9T8/dID61XwkX8dAnxvLuFHo9DODsJa3MmWtmwQLX2LeufyQOrpA48XNqO+ib0fduzgKDA== X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 31:ElSDc+NpgIsxsHo4GnsMaqJN2+izDHBGb2lRTv41AMZNhDAKOwprxngQnMgr5xm9EHXJq7LzatgtXjzP57gdsF37XbKdKtvN4Che5HjjlABpZmeaYzQX+qXIPOB6WhJHAHGB04rfzzwarGFDhdb0o9s0gS/HKB5n8x/3Zwl8z16xtfj+9w1a0njAdn/xpaMDUYYOZARvkT7bfcdUVOl+NtVJguciuqRP2Ygh8WA7n/r0g8kgLq56DnHD2QFJMUoH; 20:Hlin1pe6Q7D8r4opWxz8mHkDNxQCwN0ldewJPvj0LGrtL1dmZwgQXDCkvA3q+rIzTsWpqA0YG3A9BZeE5PcKZS9lryOAK/1Mc+r9rIBEv5Z8GAbpzasCIEm7vUE3FXlVIryiLE8XrSh+WYFrA1dVvzaiMAjL2gCq2RUFDHIuqimsuHfic7fIgYlsSoNJ45WaVJykcprsiJW1biadqL/2ZVCdc9HOLP8TyMMZITkAWSs6g7gwfofsp2JKBS1piXVyTWLHtZXFN1lvNYvnDc4JJ9z0cMhGccA7qpto7JZ/RggVFNcemsBHw7PpE6vt7Fp3uIy1RTr7mj607qki6vEGM4nym4TjM9WoYt7wCFJaLBvmHWF68amHOCVRxBb9f7dgRJ+ae5TG8YgKNSqHDBm/IMU01n2Dd4dJmBYtz2NsdDD+q+twY78ljM6u+u33nES7hL9AD4J56KHqvrsBNQtK/O1WxgP+XH/mBBU76yNpNWEC39hyc/14aeLreEvMPZlY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123558025)(20161123560025)(20161123564025)(20161123555025)(20161123562025)(6072148); SRVR:DB5PR07MB1717; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB1717; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 4:59jHNGTXi831vT8wdGVaokqDxAT8IYaFK61bKwrUN/OTDUDCGzIf7LA3ao4QvsMrYqwswoycf4FxhS/9O9rl4g+WVk0zIfaZG/EGmqKcYD1FC/YZkOEg75kzoBPwJKJ1O8Xv5nDDgrM+hJRAQRlPvx7H5+f7Lfv825fWCWlw1Ioql2kxoGVqlJKA8wAmHJYTbzDCxysM1tBCb0Z6ZUTzFPh2f8ATnMyDOPDE+9oDnzLE8A15sLEXs+5xLu5SQoqaVecmNz093/FHGIKfb9AJlUuquEQ/fVx1IJjL2yQcMCuv6LsCXIMJM/k0iojPsYWknhH3JA6F4Mq3ehCn7m5nrHnmOWyWAw9b8AscOGtxzFEB3LhruwDV4CnVyK+IEUfFbTUUX3SwgPUmoiLPTMKoCQ4TcnJjWsnIFlptldF/6AzUkbuttuBCzg5Sc1MS7rNAP6pwWjpS6GEfxqnXBMqKg5KmUXoLrOuFYP11MHKANg6ZjcVhbk974L+Wfrzcs7AnStLLgKgU9ift/G90SbrvjyrQ5PHAB9wkS01tkKJR/mM8gubeintjj8lsTaI3tZ54kLTf7hExUyw899wOc2jbUZidwRaEb0KIorh2VrldDMA= X-Forefront-PRVS: 02408926C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(6116002)(107886003)(38730400002)(53936002)(5003940100001)(110136004)(48376002)(81166006)(8676002)(189998001)(76176999)(50226002)(6512007)(4326008)(3846002)(5660300001)(47776003)(50986999)(6486002)(6506006)(66066001)(2950100002)(6666003)(305945005)(36756003)(2351001)(2906002)(86362001)(575784001)(1076002)(33646002)(50466002)(7736002)(42186005); 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:w/pisVxoRzxzo2niaQuuVAaWq9sATFB/FZcDkAJBhC20hwEj1DLsAFVPT0kMKPYKEw2l4z9BAu9b/WjaVWgSTrNb17nagMcm4VbNrsDfVQNtV57HaNY00p578adMhu28qxXeMAtyvoiAFFgIx/sW6WJzRUGdTsytUXoPIaeyrWakV/6Wh+IsCioB+v4BhlXaCmNreIQ3nOTwdOZRL1R8BSXdPlIaHaedYAqy21m8tkT+ec3pMarDXGczS22SVKoiE6psJhgUWEuvjzxFQBUjw7jnSNjAgu4zRwdWiXRc8aEp1udeHQjNmqSCZlf+1exaEISN0d/yqqPKRPdF80rhVGHDJVF0iFUoiskuwLD/GRxybxqaz1UKGWkKWdvA+0XdcSayY5P4odeR+nn209kDoRdr2+STu+GyDN0GStrENonCDOoD/WNBCm2gn3Joh/etFlvDPCIZIResDdDQwY4/4jpLkZcBqi3X2XHlgFZI1aBbUXWnSlg96IEoXESTuNK33BLoaOSWExbWH6tpaFJOtwM2AgUpfwZATuB+QAZTKKNLvmb6WC15U99c3/B1KAAZatJxWeqaFzMMHpsFaeLDWJEJazi91a3TbeqbGN6oROcaG93EXQlPMUhhpC7NvpUC9CgIJAEQ1KoW9tqHYCc3CwpEY4cuUc83FDk8WvpxDo/0mF8yZtLMPKnb0E/kj5Yn4GrASQ8dVJn7+lG7tIvMhwhMdlbQivajVZfVIEZeQi90s5VfQOEMuZq6u/EEb945W/x74/lPc0UqCW+EEpouqVOh8HE4ympoINy3JBOiPg47t1W792ielQmfwjngNxrRXyjmgRQm2wq3srl6uVrEYjTLbMKCVPEtWpF33FOkk2vlEHPxeLr4qJ7bsjhMp8YigBZbAFqHEeVD8qAELY/BnUBFq5F/GUbFtTQrgYRfH5YCI0oTa80OO3kDj7imnsWM X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 6:s0Yi7Iawh6Vzp0jJ+9C63/ogNnsmIuS16WRbPrpzTl/Ig2I4bpI8lw/vHJy10xIYVd+cd2dzKHLcSKtA0KsBRuhUrW5s7XAsEBqoIXfhWQQdLM9MfD7NkY3Eggm6vcL0JVywNfzqfi+yuEL8ow5HUVjm1WF0UL+tZTg7H7av+QAifDziXx0Bdlm/w+OdDeVTLaxoLey1lecnpM1jdJW0mYNgRfgSMI9MmpzTQz4WAsqrW1Zji4kzJi4BbVwF/j/oUpoWBR1MZy3jqSoZGFyNBfURzPYkXb2U9tPkeAaVwEnygYcyGEJ5p1f16kH28tXXDUHuSZS43ZaqXnOI/evQSVKa8BJBK5VRf5gznqhy17SDuZpWf0cU+3+JAWV8fkCrCfF1pQBx1p0dYd987ui+wg==; 5:upmXH9nunVbEytDgHbDwfkV2U5qU2uFS7m7izPjWrX6nVt/XIIzN2PZumXK9Cq/DldxHAu62rOq+wCDIhgM02HMWIxWjvRSDDlkfdXvusNSrVloXZK/m8dhijSXrbvrjOzEs/d8mRXTm4CynULKrzA==; 24:yXLCSl+Fu+1kVywPSkfiZ+u7JjvAXgLrtDfX8jLIkGDEzA1LgzqEZ9WUcAYuj+zyvmqLrNU03wnkReeYfCjoyWnIAA8bI89mAv1svAil+zY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB1717; 7:nUwxBg6g05dc16I9nsav50twj9uoqkTPzP+t6+BWbf76QnEfaJ73hiPf5e7QChxL32FRn1jZc6Nxla6VfK0g7fLHaQMfgtnxgIsx7KFYEnT94LTsYJJLJ2oKPHtPxdN3gxDyKoIM9+m/YouEqzsZ8AT74lflWDwNJYO1qRfXfN00zBmCPDEzOIJRyEI9GWvesgHh2V2Vup3IaVcWfP0DTS37Lc9UxLwkc001r8UrwEBsJEuI+ZSlzrX9KDJNoM8JN5Fm+htRrDqDb4WtYYGMZ+nb4LVB2VR8Fg0FZL11WjZxnarNN3H2MVzg1IliJ6vKpM1gDyMo86f8zWh8IoJcqg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 16:42:01.0239 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB1717 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes The following patches will add a ptid_t parameter to target_fetch_registers and target_store_registers. In the bsd uthread implementations, there's another indirection layer in the form of bsd_uthread_ops. This patch adds the same ptid_t parameter to this layer, so that the implementations of bsd_uthread_ops don't rely on the current value of inferior_ptid. From what I understand, the register values of the userspace threads (uthreads) are stored in the memory of the "real" thread to which those userspace threads are mapped. Therefore, the implementation of these register fetching/storing functions consists of reading/writing memory. Since the memory read/write functions still rely on the value of inferior_ptid to know which thread to read/write memory from/to, it is necessary to set and restore inferior_ptid in those functions (e.g. amd64fbsd_supply_uthread). Eventually, when we add a ptid_t parameter to the memory functions, this should go away as we'll simply pass down the ptid parameter. I was not able to test this patch, so it would be appreciated if some *bsd user was able to give it a quick go. gdb/ChangeLog: * amd64-fbsd-tdep.c (amd64fbsd_supply_uthread, amd64fbsd_collect_uthread): Add ptid parameter, set and restore inferior_ptid. * amd64-obsd.tdep.c (amd64fbsd_collect_uthread, amd64obsd_supply_uthread): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Pass ptid value to supply_uthread. (bsd_uthread_store_registers): Pass ptid value to collect_uthread. * bsd-uthread.h (bsd_uthread_supply_register_ftype, bsd_uthread_collect_register_ftype): Add ptid parameter. * i386-fbsd-tdep.c (i386fbsd_supply_uthread, i386fbsd_collect_uthread): Add ptid parameter, set and restore inferior_ptid. * i386-obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread): Add ptid parameter, set and restore inferior_ptid. * sparc-obsd-tdep.c (sparc32obsd_supply_uthread, sparc32obsd_collect_uthread): Add ptid parameter, set and restore inferior_ptid. * sparc-obsd-tdep.c (sparc64obsd_supply_uthread, sparc64obsd_collect_uthread): Add ptid parameter, set and restore inferior_ptid. --- gdb/amd64-fbsd-tdep.c | 13 +++++++++++-- gdb/amd64-obsd-tdep.c | 13 +++++++++++-- gdb/bsd-uthread.c | 10 ++++++---- gdb/bsd-uthread.h | 6 +++--- gdb/i386-fbsd-tdep.c | 13 +++++++++++-- gdb/i386-obsd-tdep.c | 13 +++++++++++-- gdb/sparc-obsd-tdep.c | 13 +++++++++++-- gdb/sparc64-obsd-tdep.c | 13 +++++++++++-- 8 files changed, 75 insertions(+), 19 deletions(-) diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c index b8ef25821b..d4c81de26e 100644 --- a/gdb/amd64-fbsd-tdep.c +++ b/gdb/amd64-fbsd-tdep.c @@ -31,6 +31,7 @@ #include "bsd-uthread.h" #include "fbsd-tdep.h" #include "solib-svr4.h" +#include "inferior.h" /* Support for signal handlers. */ @@ -226,11 +227,13 @@ amd64fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, } static void -amd64fbsd_supply_uthread (struct regcache *regcache, +amd64fbsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { gdb_byte buf[8]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -243,14 +246,18 @@ amd64fbsd_supply_uthread (struct regcache *regcache, regcache_raw_supply (regcache, i, buf); } } + + do_cleanups (cleanup); } static void -amd64fbsd_collect_uthread (const struct regcache *regcache, +amd64fbsd_collect_uthread (const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { gdb_byte buf[8]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -263,6 +270,8 @@ amd64fbsd_collect_uthread (const struct regcache *regcache, write_memory (addr + amd64fbsd_jmp_buf_reg_offset[i], buf, 8); } } + + do_cleanups (cleanup); } static void diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c index 72895b6fc6..ac39c51b3f 100644 --- a/gdb/amd64-obsd-tdep.c +++ b/gdb/amd64-obsd-tdep.c @@ -34,6 +34,7 @@ #include "i387-tdep.h" #include "solib-svr4.h" #include "bsd-uthread.h" +#include "inferior.h" /* Support for signal handlers. */ @@ -217,7 +218,7 @@ static int amd64obsd_uthread_reg_offset[] = #define AMD64OBSD_UTHREAD_RSP_OFFSET 400 static void -amd64obsd_supply_uthread (struct regcache *regcache, +amd64obsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -226,6 +227,8 @@ amd64obsd_supply_uthread (struct regcache *regcache, CORE_ADDR sp = 0; gdb_byte buf[8]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -258,10 +261,12 @@ amd64obsd_supply_uthread (struct regcache *regcache, regcache_raw_supply (regcache, i, buf); } } + + do_cleanups (cleanup); } static void -amd64obsd_collect_uthread (const struct regcache *regcache, +amd64obsd_collect_uthread (const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -270,6 +275,8 @@ amd64obsd_collect_uthread (const struct regcache *regcache, CORE_ADDR sp = 0; gdb_byte buf[8]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -306,6 +313,8 @@ amd64obsd_collect_uthread (const struct regcache *regcache, write_memory (sp + amd64obsd_uthread_reg_offset[i], buf, 8); } } + + do_cleanups (cleanup); } /* Kernel debugging support. */ diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 09a9de28ae..2111128f21 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -286,7 +286,8 @@ bsd_uthread_fetch_registers (struct target_ops *ops, struct gdbarch *gdbarch = get_regcache_arch (regcache); struct bsd_uthread_ops *uthread_ops = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data); - CORE_ADDR addr = ptid_get_tid (inferior_ptid); + ptid_t ptid = inferior_ptid; + CORE_ADDR addr = ptid_get_tid (ptid); struct target_ops *beneath = find_target_beneath (ops); CORE_ADDR active_addr; @@ -302,7 +303,7 @@ bsd_uthread_fetch_registers (struct target_ops *ops, if (addr != 0 && addr != active_addr) { bsd_uthread_check_magic (addr); - uthread_ops->supply_uthread (regcache, regnum, + uthread_ops->supply_uthread (regcache, ptid, regnum, addr + bsd_uthread_thread_ctx_offset); } } @@ -315,14 +316,15 @@ bsd_uthread_store_registers (struct target_ops *ops, struct bsd_uthread_ops *uthread_ops = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data); struct target_ops *beneath = find_target_beneath (ops); - CORE_ADDR addr = ptid_get_tid (inferior_ptid); + ptid_t ptid = inferior_ptid; + CORE_ADDR addr = ptid_get_tid (ptid); CORE_ADDR active_addr; active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr); if (addr != 0 && addr != active_addr) { bsd_uthread_check_magic (addr); - uthread_ops->collect_uthread (regcache, regnum, + uthread_ops->collect_uthread (regcache, ptid, regnum, addr + bsd_uthread_thread_ctx_offset); } else diff --git a/gdb/bsd-uthread.h b/gdb/bsd-uthread.h index 4802d019ae..b61415331d 100644 --- a/gdb/bsd-uthread.h +++ b/gdb/bsd-uthread.h @@ -20,10 +20,10 @@ #ifndef BSD_UTHREAD_H #define BSD_UTHREAD_H 1 -typedef void (*bsd_uthread_supply_register_ftype) (struct regcache *, int, - CORE_ADDR); +typedef void (*bsd_uthread_supply_register_ftype) (struct regcache *, ptid_t, + int, CORE_ADDR); typedef void (*bsd_uthread_collect_register_ftype) (const struct regcache *, - int, CORE_ADDR); + ptid_t ptid, int, CORE_ADDR); /* Set the function that supplies registers for an inactive thread for architecture GDBARCH to FUNC. */ diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c index b0bf7270bb..6d8f213489 100644 --- a/gdb/i386-fbsd-tdep.c +++ b/gdb/i386-fbsd-tdep.c @@ -31,6 +31,7 @@ #include "bsd-uthread.h" #include "fbsd-tdep.h" #include "solib-svr4.h" +#include "inferior.h" /* Support for signal handlers. */ @@ -333,11 +334,13 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, } static void -i386fbsd_supply_uthread (struct regcache *regcache, +i386fbsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { gdb_byte buf[4]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -350,14 +353,18 @@ i386fbsd_supply_uthread (struct regcache *regcache, regcache_raw_supply (regcache, i, buf); } } + + do_cleanups (cleanup); } static void -i386fbsd_collect_uthread (const struct regcache *regcache, +i386fbsd_collect_uthread (const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { gdb_byte buf[4]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -370,6 +377,8 @@ i386fbsd_collect_uthread (const struct regcache *regcache, write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4); } } + + do_cleanups (cleanup); } static void diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c index 22375c5b75..6d675da59f 100644 --- a/gdb/i386-obsd-tdep.c +++ b/gdb/i386-obsd-tdep.c @@ -35,6 +35,7 @@ #include "i387-tdep.h" #include "solib-svr4.h" #include "bsd-uthread.h" +#include "inferior.h" /* Support for signal handlers. */ @@ -187,7 +188,7 @@ static int i386obsd_uthread_reg_offset[] = #define I386OBSD_UTHREAD_ESP_OFFSET 176 static void -i386obsd_supply_uthread (struct regcache *regcache, +i386obsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -196,6 +197,8 @@ i386obsd_supply_uthread (struct regcache *regcache, CORE_ADDR sp = 0; gdb_byte buf[4]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -228,10 +231,12 @@ i386obsd_supply_uthread (struct regcache *regcache, regcache_raw_supply (regcache, i, buf); } } + + do_cleanups (cleanup); } static void -i386obsd_collect_uthread (const struct regcache *regcache, +i386obsd_collect_uthread (const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -240,6 +245,8 @@ i386obsd_collect_uthread (const struct regcache *regcache, CORE_ADDR sp = 0; gdb_byte buf[4]; int i; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -276,6 +283,8 @@ i386obsd_collect_uthread (const struct regcache *regcache, write_memory (sp + i386obsd_uthread_reg_offset[i], buf, 4); } } + + do_cleanups (cleanup); } /* Kernel debugging support. */ diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c index b7d3d3cf47..1bfcd64c6f 100644 --- a/gdb/sparc-obsd-tdep.c +++ b/gdb/sparc-obsd-tdep.c @@ -31,6 +31,7 @@ #include "sparc-tdep.h" #include "solib-svr4.h" #include "bsd-uthread.h" +#include "inferior.h" /* Signal trampolines. */ @@ -150,13 +151,15 @@ static const struct frame_unwind sparc32obsd_sigtramp_frame_unwind = #define SPARC32OBSD_UTHREAD_PC_OFFSET 132 static void -sparc32obsd_supply_uthread (struct regcache *regcache, +sparc32obsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR fp, fp_addr = addr + SPARC32OBSD_UTHREAD_FP_OFFSET; gdb_byte buf[4]; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -192,16 +195,20 @@ sparc32obsd_supply_uthread (struct regcache *regcache, } sparc_supply_rwindow (regcache, fp, regnum); + + do_cleanups (cleanup); } static void -sparc32obsd_collect_uthread(const struct regcache *regcache, +sparc32obsd_collect_uthread(const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR sp; gdb_byte buf[4]; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -228,6 +235,8 @@ sparc32obsd_collect_uthread(const struct regcache *regcache, regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf); sp = extract_unsigned_integer (buf, 4, byte_order); sparc_collect_rwindow (regcache, sp, regnum); + + do_cleanups (cleanup); } diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c index 0da50b1dc7..49ca460d03 100644 --- a/gdb/sparc64-obsd-tdep.c +++ b/gdb/sparc64-obsd-tdep.c @@ -32,6 +32,7 @@ #include "sparc64-tdep.h" #include "solib-svr4.h" #include "bsd-uthread.h" +#include "inferior.h" /* Older OpenBSD versions used the traditional NetBSD core file format, even for ports that use ELF. These core files don't use @@ -320,13 +321,15 @@ static const struct frame_unwind sparc64obsd_trapframe_unwind = #define SPARC64OBSD_UTHREAD_PC_OFFSET 240 static void -sparc64obsd_supply_uthread (struct regcache *regcache, +sparc64obsd_supply_uthread (struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR fp, fp_addr = addr + SPARC64OBSD_UTHREAD_FP_OFFSET; gdb_byte buf[8]; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -362,16 +365,20 @@ sparc64obsd_supply_uthread (struct regcache *regcache, } sparc_supply_rwindow (regcache, fp, regnum); + + do_cleanups (cleanup); } static void -sparc64obsd_collect_uthread(const struct regcache *regcache, +sparc64obsd_collect_uthread(const struct regcache *regcache, ptid_t ptid, int regnum, CORE_ADDR addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR sp; gdb_byte buf[8]; + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = ptid; gdb_assert (regnum >= -1); @@ -398,6 +405,8 @@ sparc64obsd_collect_uthread(const struct regcache *regcache, regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf); sp = extract_unsigned_integer (buf, 8, byte_order); sparc_collect_rwindow (regcache, sp, regnum); + + do_cleanups (cleanup); }