(target_thread_architecture): New macro.
* target.c (update_current_target): Inherit to_thread_architecture.
(default_thread_architecture): New function.
(debug_to_thread_architecture): New function.
(setup_target_debug): Handle to_thread_architecture.
* regcache.h (get_thread_arch_regcache): New.
* regcache.c (struct regcache_list): New data type.
(current_regcache): Hold regcache list instead of single regcache.
(current_thread_ptid, current_thread_arch): New static variables.
(get_thread_arch_regcache): New function.
(get_thread_regcache): Use it. Call target_thread_architecture.
(regcache_thread_ptid_changed): Update to current_regcache changes.
(registers_changed): Likewise. Reset current_thread_arch and
current_thread_ptid.
* remote.c (remote_wait): Access target registers in target_gdbarch.
* linux-nat.c (linux_nat_do_thread_registers): Likewise.
* proc-service.c (ps_lgetregs, ps_lsetregs): Likewise.
(ps_lgetfpregs, ps_lsetfpregs): Likewise.
* sol-thread.c (ps_lgetregs, ps_lsetregs): Likewise.
(ps_lgetfpregs, ps_lsetfpregs): Likewise.
* solib-svr4.c (enable_break): Likewise.
(svr4_relocate_main_executable): Likewise.
+2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * target.h (struct target_ops): New member to_thread_architecture.
+ (target_thread_architecture): New macro.
+ * target.c (update_current_target): Inherit to_thread_architecture.
+ (default_thread_architecture): New function.
+ (debug_to_thread_architecture): New function.
+ (setup_target_debug): Handle to_thread_architecture.
+
+ * regcache.h (get_thread_arch_regcache): New.
+ * regcache.c (struct regcache_list): New data type.
+ (current_regcache): Hold regcache list instead of single regcache.
+ (current_thread_ptid, current_thread_arch): New static variables.
+ (get_thread_arch_regcache): New function.
+ (get_thread_regcache): Use it. Call target_thread_architecture.
+ (regcache_thread_ptid_changed): Update to current_regcache changes.
+ (registers_changed): Likewise. Reset current_thread_arch and
+ current_thread_ptid.
+
+ * remote.c (remote_wait): Access target registers in target_gdbarch.
+ * linux-nat.c (linux_nat_do_thread_registers): Likewise.
+ * proc-service.c (ps_lgetregs, ps_lsetregs): Likewise.
+ (ps_lgetfpregs, ps_lsetfpregs): Likewise.
+ * sol-thread.c (ps_lgetregs, ps_lsetregs): Likewise.
+ (ps_lgetfpregs, ps_lsetfpregs): Likewise.
+ * solib-svr4.c (enable_break): Likewise.
+ (svr4_relocate_main_executable): Likewise.
+
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* python/python-internal.h (struct language_defn): Declare.
gdb_gregset_t gregs;
gdb_fpregset_t fpregs;
unsigned long lwp = ptid_get_lwp (ptid);
- struct regcache *regcache = get_thread_regcache (ptid);
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = target_gdbarch;
+ struct regcache *regcache = get_thread_arch_regcache (ptid, gdbarch);
const struct regset *regset;
int core_regset_p;
struct cleanup *old_chain;
struct regcache *regcache;
inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
struct regcache *regcache;
inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
struct regcache *regcache;
inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
struct regcache *regcache;
inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
/* Global structure containing the current regcache. */
-/* FIXME: cagney/2002-05-11: The two global arrays registers[] and
- deprecated_register_valid[] currently point into this structure. */
-static struct regcache *current_regcache;
/* NOTE: this is a write-through cache. There is no "dirty" bit for
recording if the register values have been changed (eg. by the
user). Therefore all registers must be written back to the
target when appropriate. */
-struct regcache *get_thread_regcache (ptid_t ptid)
+struct regcache_list
{
- /* NOTE: uweigand/2007-05-05: We need to detect the thread's
- current architecture at this point. */
- struct gdbarch *thread_gdbarch = current_gdbarch;
+ struct regcache *regcache;
+ struct regcache_list *next;
+};
+
+static struct regcache_list *current_regcache;
+
+struct regcache *
+get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
+{
+ struct regcache_list *list;
+ struct regcache *new_regcache;
- if (current_regcache && ptid_equal (current_regcache->ptid, ptid)
- && get_regcache_arch (current_regcache) == thread_gdbarch)
- return current_regcache;
+ for (list = current_regcache; list; list = list->next)
+ if (ptid_equal (list->regcache->ptid, ptid)
+ && get_regcache_arch (list->regcache) == gdbarch)
+ return list->regcache;
- if (current_regcache)
- regcache_xfree (current_regcache);
+ new_regcache = regcache_xmalloc (gdbarch);
+ new_regcache->readonly_p = 0;
+ new_regcache->ptid = ptid;
- current_regcache = regcache_xmalloc (thread_gdbarch);
- current_regcache->readonly_p = 0;
- current_regcache->ptid = ptid;
+ list = xmalloc (sizeof (struct regcache_list));
+ list->regcache = new_regcache;
+ list->next = current_regcache;
+ current_regcache = list;
- return current_regcache;
+ return new_regcache;
}
-struct regcache *get_current_regcache (void)
+static ptid_t current_thread_ptid;
+static struct gdbarch *current_thread_arch;
+
+struct regcache *
+get_thread_regcache (ptid_t ptid)
+{
+ if (!current_thread_arch || !ptid_equal (current_thread_ptid, ptid))
+ {
+ current_thread_ptid = ptid;
+ current_thread_arch = target_thread_architecture (ptid);
+ }
+
+ return get_thread_arch_regcache (ptid, current_thread_arch);
+}
+
+struct regcache *
+get_current_regcache (void)
{
return get_thread_regcache (inferior_ptid);
}
static void
regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
{
- if (current_regcache != NULL
- && ptid_equal (current_regcache->ptid, old_ptid))
- current_regcache->ptid = new_ptid;
+ struct regcache_list *list;
+
+ for (list = current_regcache; list; list = list->next)
+ if (ptid_equal (list->regcache->ptid, old_ptid))
+ list->regcache->ptid = new_ptid;
}
/* Low level examining and depositing of registers.
void
registers_changed (void)
{
- int i;
+ struct regcache_list *list, *next;
+
+ for (list = current_regcache; list; list = next)
+ {
+ next = list->next;
+ regcache_xfree (list->regcache);
+ xfree (list);
+ }
- regcache_xfree (current_regcache);
current_regcache = NULL;
+ current_thread_ptid = null_ptid;
+ current_thread_arch = NULL;
+
/* Need to forget about any frames we have cached, too. */
reinit_frame_cache ();
extern struct regcache *get_current_regcache (void);
extern struct regcache *get_thread_regcache (ptid_t ptid);
+extern struct regcache *get_thread_arch_regcache (ptid_t, struct gdbarch *);
void regcache_xfree (struct regcache *regcache);
struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
old_chain = save_inferior_ptid ();
inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
- regcache = get_thread_regcache (inferior_ptid);
+ regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
most cases. */
if (!load_addr_found)
{
- struct regcache *regcache = get_thread_regcache (inferior_ptid);
+ struct regcache *regcache
+ = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
load_addr = (regcache_read_pc (regcache)
- exec_entry_point (tmp_bfd, tmp_bfd_target));
}
svr4_relocate_main_executable (void)
{
asection *interp_sect;
- struct regcache *regcache = get_thread_regcache (inferior_ptid);
+ struct regcache *regcache
+ = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
CORE_ADDR pc = regcache_read_pc (regcache);
/* Decide if the objfile needs to be relocated. As indicated above,
void *readbuf, const void *writebuf,
ULONGEST offset, LONGEST len);
+static struct gdbarch *default_thread_architecture (struct target_ops *ops,
+ ptid_t ptid);
+
static void init_dummy_target (void);
static struct target_ops debug_target;
INHERIT (to_make_corefile_notes, t);
/* Do not inherit to_get_thread_local_address. */
INHERIT (to_can_execute_reverse, t);
+ INHERIT (to_thread_architecture, t);
/* Do not inherit to_read_description. */
INHERIT (to_get_ada_task_ptid, t);
/* Do not inherit to_search_memory. */
de_fault (to_async_mask,
(int (*) (int))
return_one);
+ de_fault (to_thread_architecture,
+ default_thread_architecture);
current_target.to_read_description = NULL;
de_fault (to_get_ada_task_ptid,
(ptid_t (*) (long, long))
return addr >= start && addr < start + length;
}
+static struct gdbarch *
+default_thread_architecture (struct target_ops *ops, ptid_t ptid)
+{
+ return target_gdbarch;
+}
+
static int
return_zero (void)
{
PIDGET (ptid));
}
+static struct gdbarch *
+debug_to_thread_architecture (struct target_ops *ops, ptid_t ptid)
+{
+ struct gdbarch *retval;
+
+ retval = debug_target.to_thread_architecture (ops, ptid);
+
+ fprintf_unfiltered (gdb_stdlog, "target_thread_architecture (%s) = %p [%s]\n",
+ target_pid_to_str (ptid), retval,
+ gdbarch_bfd_arch_info (retval)->printable_name);
+ return retval;
+}
+
static void
debug_to_stop (ptid_t ptid)
{
current_target.to_stop = debug_to_stop;
current_target.to_rcmd = debug_to_rcmd;
current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
+ current_target.to_thread_architecture = debug_to_thread_architecture;
}
\f
simultaneously? */
int (*to_supports_multi_process) (void);
+ /* Determine current architecture of thread PTID. */
+ struct gdbarch *(*to_thread_architecture) (struct target_ops *, ptid_t);
+
int to_magic;
/* Need sub-structure for target machine related rather than comm related?
*/
#define target_pid_to_exec_file(pid) \
(current_target.to_pid_to_exec_file) (pid)
+/* Determine current architecture of thread PTID. */
+
+#define target_thread_architecture(ptid) \
+ (current_target.to_thread_architecture (¤t_target, ptid))
+
/*
* Iterator function for target memory regions.
* Calls a callback function once for each memory region 'mapped'