From patchwork Sat Mar 18 17:08:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 19651 Received: (qmail 40755 invoked by alias); 18 Mar 2017 17:08:10 -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 40711 invoked by uid 89); 18 Mar 2017 17:08:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HCc:D*ca X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Mar 2017 17:08:05 +0000 X-ASG-Debug-ID: 1489856883-0c856e65d51913dc0001-fS2M51 Received: from smtp.electronicbox.net (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id T7lUHqWBmh8V1OJN (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 18 Mar 2017 13:08:03 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (unknown [173.246.11.162]) by smtp.electronicbox.net (Postfix) with ESMTP id D9BBE440EEA; Sat, 18 Mar 2017 13:08:03 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: cable-11.246.173-162.electronicbox.net[173.246.11.162] X-Barracuda-Apparent-Source-IP: 173.246.11.162 X-Barracuda-RBL-IP: 173.246.11.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/3] spu: Use ptid from regcache instead of inferior_ptid Date: Sat, 18 Mar 2017 13:08:00 -0400 X-ASG-Orig-Subj: [PATCH 2/3] spu: Use ptid from regcache instead of inferior_ptid Message-Id: <20170318170801.22988-2-simon.marchi@polymtl.ca> In-Reply-To: <20170318170801.22988-1-simon.marchi@polymtl.ca> References: <20170318170801.22988-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1489856883 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4903 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.37321 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes The implementations of to_fetch_regiters/to_store_registers in the spu code use some functions that rely on inferior_ptid. It's simpler for now to set/restore inferior_ptid. * spu-linux-nat.c (spu_fetch_inferior_registers, spu_store_inferior_registers): Use ptid from regcache, set and restore inferior_ptid. * spu-multiarch.c (spu_fetch_registers, spu_store_registers): Likewise. --- gdb/spu-linux-nat.c | 24 ++++++++++++++++++++++-- gdb/spu-multiarch.c | 26 ++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c index c5b91222c1..5ec7b65ad9 100644 --- a/gdb/spu-linux-nat.c +++ b/gdb/spu-linux-nat.c @@ -492,9 +492,17 @@ spu_fetch_inferior_registers (struct target_ops *ops, int fd; ULONGEST addr; + /* Since we use functions that rely on inferior_ptid, we need to set and + restore it. */ + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = regcache_get_ptid (regcache); + /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (&fd, &addr)) - return; + { + do_cleanups (cleanup); + return; + } /* The ID register holds the spufs file handle. */ if (regno == -1 || regno == SPU_ID_REGNUM) @@ -529,6 +537,8 @@ spu_fetch_inferior_registers (struct target_ops *ops, for (i = 0; i < SPU_NUM_GPRS; i++) regcache_raw_supply (regcache, i, buf + i*16); } + + do_cleanups (cleanup); } /* Override the store_inferior_register routine. */ @@ -539,9 +549,17 @@ spu_store_inferior_registers (struct target_ops *ops, int fd; ULONGEST addr; + /* Since we use functions that rely on inferior_ptid, we need to set and + restore it. */ + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = regcache_get_ptid (regcache); + /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (&fd, &addr)) - return; + { + do_cleanups (cleanup); + return; + } /* The NPC register is found at ADDR. */ if (regno == -1 || regno == SPU_PC_REGNUM) @@ -565,6 +583,8 @@ spu_store_inferior_registers (struct target_ops *ops, xsnprintf (annex, sizeof annex, "%d/regs", fd); spu_proc_xfer_spu (annex, NULL, buf, 0, sizeof buf, &len); } + + do_cleanups (cleanup); } /* Override the to_xfer_partial routine. */ diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c index b99a1a3de3..220464ad27 100644 --- a/gdb/spu-multiarch.c +++ b/gdb/spu-multiarch.c @@ -149,16 +149,25 @@ spu_fetch_registers (struct target_ops *ops, int spufs_fd; CORE_ADDR spufs_addr; + /* Since we use functions that rely on inferior_ptid, we need to set and + restore it. */ + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = regcache_get_ptid (regcache); + /* This version applies only if we're currently in spu_run. */ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu) { ops_beneath->to_fetch_registers (ops_beneath, regcache, regno); + do_cleanups (cleanup); return; } /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (inferior_ptid, &spufs_fd, &spufs_addr)) - return; + { + do_cleanups (cleanup); + return; + } /* The ID register holds the spufs file handle. */ if (regno == -1 || regno == SPU_ID_REGNUM) @@ -191,6 +200,8 @@ spu_fetch_registers (struct target_ops *ops, for (i = 0; i < SPU_NUM_GPRS; i++) regcache_raw_supply (regcache, i, buf + i*16); } + + do_cleanups (cleanup); } /* Override the to_store_registers routine. */ @@ -203,16 +214,25 @@ spu_store_registers (struct target_ops *ops, int spufs_fd; CORE_ADDR spufs_addr; + /* Since we use functions that rely on inferior_ptid, we need to set and + restore it. */ + struct cleanup *cleanup = save_inferior_ptid (); + inferior_ptid = regcache_get_ptid (regcache); + /* This version applies only if we're currently in spu_run. */ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu) { ops_beneath->to_store_registers (ops_beneath, regcache, regno); + do_cleanups (cleanup); return; } /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (inferior_ptid, &spufs_fd, &spufs_addr)) - return; + { + do_cleanups (cleanup); + return; + } /* The NPC register is found in PPC memory at SPUFS_ADDR. */ if (regno == -1 || regno == SPU_PC_REGNUM) @@ -238,6 +258,8 @@ spu_store_registers (struct target_ops *ops, target_write (ops_beneath, TARGET_OBJECT_SPU, annex, buf, 0, sizeof buf); } + + do_cleanups (cleanup); } /* Override the to_xfer_partial routine. */