From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/3] spu: Use ptid from regcache instead of inferior_ptid
Date: Sat, 18 Mar 2017 17:08:00 -0000 [thread overview]
Message-ID: <20170318170801.22988-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20170318170801.22988-1-simon.marchi@polymtl.ca>
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. */
--
2.12.0
next prev parent reply other threads:[~2017-03-18 17:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-18 17:08 [PATCH 1/3] Use ptid from regcache in almost all remaining nat files Simon Marchi
2017-03-18 17:08 ` Simon Marchi [this message]
2017-03-20 15:54 ` [PATCH 2/3] spu: Use ptid from regcache instead of inferior_ptid Pedro Alves
2017-03-20 21:50 ` Simon Marchi
2017-03-20 21:52 ` [PATCH v2 " Simon Marchi
2017-03-20 22:06 ` Pedro Alves
2017-03-20 22:24 ` Simon Marchi
2017-03-18 17:08 ` [PATCH 3/3] windows: Use ptid from regcache in register fetch/store Simon Marchi
2017-03-20 15:56 ` Pedro Alves
2017-03-20 22:22 ` Simon Marchi
2017-03-21 14:27 ` Pedro Alves
2017-03-21 15:24 ` Simon Marchi
2017-03-21 15:39 ` [pushed] " Simon Marchi
2017-03-20 15:54 ` [PATCH 1/3] Use ptid from regcache in almost all remaining nat files Pedro Alves
2017-03-20 21:39 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170318170801.22988-2-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox