diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-02-07 17:04:38 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-03-07 10:56:40 -0500 |
commit | 825c8a4e88a55b027e8b76d2a64f527a103fd68b (patch) | |
tree | 0cdd63fa4e6a90bd8fffc885fe1bd3ef1e81394e | |
parent | 35e8c540b1014bd4a8baa3233886e1342b14ec5d (diff) | |
download | gdb-825c8a4e88a55b027e8b76d2a64f527a103fd68b.zip gdb-825c8a4e88a55b027e8b76d2a64f527a103fd68b.tar.gz gdb-825c8a4e88a55b027e8b76d2a64f527a103fd68b.tar.bz2 |
Pass down ptid in bsd_uthread_ops layer
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.
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.
-rw-r--r-- | gdb/amd64-fbsd-tdep.c | 13 | ||||
-rw-r--r-- | gdb/amd64-obsd-tdep.c | 13 | ||||
-rw-r--r-- | gdb/bsd-uthread.c | 10 | ||||
-rw-r--r-- | gdb/bsd-uthread.h | 6 | ||||
-rw-r--r-- | gdb/i386-fbsd-tdep.c | 13 | ||||
-rw-r--r-- | gdb/i386-obsd-tdep.c | 13 | ||||
-rw-r--r-- | gdb/sparc-obsd-tdep.c | 13 | ||||
-rw-r--r-- | 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 b8ef258..d4c81de 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 72895b6..ac39c51 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 09a9de2..2111128 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 4802d01..b614153 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 b0bf727..6d8f213 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 22375c5..6d675da 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 b7d3d3c..1bfcd64 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 0da50b1..49ca460 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); } |