diff options
author | Pedro Alves <palves@redhat.com> | 2010-01-20 22:55:38 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2010-01-20 22:55:38 +0000 |
commit | 442ea881059b935fdaed15fc9dae1080a3e6e729 (patch) | |
tree | 2874096a824110a6fb4c2208a1f1c81e6f8928c8 /gdb | |
parent | 23787403e03ea97653aeafcd6ae898b21991de3b (diff) | |
download | gdb-442ea881059b935fdaed15fc9dae1080a3e6e729.zip gdb-442ea881059b935fdaed15fc9dae1080a3e6e729.tar.gz gdb-442ea881059b935fdaed15fc9dae1080a3e6e729.tar.bz2 |
* regcache.h (struct thread_info): Forward declare.
(struct regcache): New.
(new_register_cache): Adjust prototype.
(get_thread_regcache): Declare.
(free_register_cache): Adjust prototype.
(registers_to_string, registers_from_string): Ditto.
(supply_register, supply_register_by_name, collect_register)
(collect_register_as_string, collect_register_by_name): Ditto.
* regcache.c (struct inferior_regcache_data): Delete.
(get_regcache): Rename to ...
(get_thread_regcache): ... this. Adjust. Switch inferior before
fetching registers.
(regcache_invalidate_one): Adjust.
(regcache_invalidate): Fix prototype.
(new_register_cache): Return the new register cache.
(free_register_cache): Change prototype.
(realloc_register_cache): Adjust.
(registers_to_string): Change prototype to take a regcache. Adjust.
(registers_from_string): Ditto.
(register_data): Ditto.
(supply_register): Ditto.
(supply_register_by_name): Ditto.
(collect_register): Ditto.
(collect_register_as_string): Ditto.
(collect_register_by_name): Ditto.
* server.c (process_serial_event): Adjust.
* linux-low.h (regset_fill_func, regset_store_func): Change
prototype.
(get_pc, set_pc, collect_ptrace_register, supply_ptrace_register):
Change prototype.
* linux-low.c (get_stop_pc): Adjust.
(check_removed_breakpoint): Adjust.
(linux_wait_for_event): Adjust.
(linux_resume_one_lwp): Adjust.
(fetch_register): Add regcache parameter. Adjust.
(usr_store_inferior_registers): Ditto.
(regsets_fetch_inferior_registers): Ditto.
(regsets_store_inferior_registers): Ditto.
(linux_fetch_registers, linux_store_registers): Ditto.
* i387-fp.c (i387_cache_to_fsave): Change prototype to take a
regcache. Adjust.
(i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto.
* i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change
prototype to take a regcache.
(i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto.
* remote-utils.c (convert_ascii_to_int, outreg)
(prepare_resume_reply): Change prototype to take a regcache.
Adjust.
* target.h (struct target_ops) <fetch_registers, store_registers>:
Change prototype to take a regcache.
(fetch_inferior_registers, store_inferior_registers): Change
prototype to take a regcache. Adjust.
* proc-service.c (ps_lgetregs): Adjust.
* linux-x86-low.c (x86_fill_gregset, x86_store_gregset)
(x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset)
(x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to
take a regcache. Adjust.
* linux-arm-low.c (arm_fill_gregset, arm_store_gregset)
(arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset)
(arm_store_vfpregset, arm_get_pc, arm_set_pc):
(arm_breakpoint_at): Change prototype to take a regcache. Adjust.
* linux-cris-low.c (cris_get_pc, cris_set_pc)
(cris_cannot_fetch_register):
(cris_breakpoint_at): Change prototype to take a regcache.
Adjust.
* linux-crisv32-low.c (cris_get_pc, cris_set_pc,
cris_reinsert_addr, cris_write_data_breakpoint): Change prototype
to take a regcache. Adjust.
(cris_breakpoint_at, cris_insert_point, cris_remove_point):
Adjust.
* linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to
take a regcache. Adjust.
* linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset)
(m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc,
(m68k_set_pc): Change prototype to take a regcache. Adjust.
* linux-mips-low.c (mips_get_pc):
(mips_set_pc): Change prototype to take a regcache. Adjust.
(mips_reinsert_addr): Adjust.
(mips_collect_register): Change prototype to take a regcache.
Adjust.
(mips_supply_register):
(mips_collect_register_32bit, mips_supply_register_32bit)
(mips_fill_gregset, mips_store_gregset, mips_fill_fpregset)
(mips_store_fpregset): Ditto.
* linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register):
Ditto.
(parse_spufs_run): Adjust.
(ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset)
(ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset)
(ppc_fill_evrregset, ppc_store_evrregset): Change prototype to
take a regcache. Adjust.
* linux-s390-low.c (s390_collect_ptrace_register)
(s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc)
(s390_set_pc): Change prototype to take a regcache. Adjust.
(s390_arch_setup): Adjust.
* linux-sh-low.c (sh_get_pc, sh_breakpoint_at)
(sh_fill_gregset): Change prototype to take a regcache. Adjust.
* linux-sparc-low.c (sparc_fill_gregset_to_stack)
(sparc_fill_gregset, sparc_store_gregset_from_stack)
(sparc_store_gregset, sparc_get_pc): Change prototype to take a
regcache. Adjust.
(sparc_breakpoint_at): Adjust.
* linux-xtensa-low.c (xtensa_fill_gregset):
(xtensa_store_gregset):
(xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc)
(xtensa_set_pc): Change prototype to take a regcache. Adjust.
* nto-low.c (nto_fetch_registers, nto_store_registers): Change
prototype to take a regcache. Adjust.
* win32-arm-low.c (arm_fetch_inferior_register)
(arm_store_inferior_register): Change prototype to take a
regcache. Adjust.
* win32-i386-low.c (i386_fetch_inferior_register)
(i386_store_inferior_register): Change prototype to take a
regcache. Adjust.
* win32-low.c (child_fetch_inferior_registers)
(child_store_inferior_registers): Change prototype to take a
regcache. Adjust.
(win32_wait): Adjust.
(win32_fetch_inferior_registers): Change prototype to take a
regcache. Adjust.
(win32_store_inferior_registers): Adjust.
* win32-low.h (struct win32_target_ops) <fetch_inferior_register,
store_inferior_register>: Change prototype to take a regcache.
Diffstat (limited to 'gdb')
28 files changed, 664 insertions, 457 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 2113f51..393d22d 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,129 @@ +2010-01-20 Pedro Alves <pedro@codesourcery.com> + + * regcache.h (struct thread_info): Forward declare. + (struct regcache): New. + (new_register_cache): Adjust prototype. + (get_thread_regcache): Declare. + (free_register_cache): Adjust prototype. + (registers_to_string, registers_from_string): Ditto. + (supply_register, supply_register_by_name, collect_register) + (collect_register_as_string, collect_register_by_name): Ditto. + * regcache.c (struct inferior_regcache_data): Delete. + (get_regcache): Rename to ... + (get_thread_regcache): ... this. Adjust. Switch inferior before + fetching registers. + (regcache_invalidate_one): Adjust. + (regcache_invalidate): Fix prototype. + (new_register_cache): Return the new register cache. + (free_register_cache): Change prototype. + (realloc_register_cache): Adjust. + (registers_to_string): Change prototype to take a regcache. Adjust. + (registers_from_string): Ditto. + (register_data): Ditto. + (supply_register): Ditto. + (supply_register_by_name): Ditto. + (collect_register): Ditto. + (collect_register_as_string): Ditto. + (collect_register_by_name): Ditto. + * server.c (process_serial_event): Adjust. + * linux-low.h (regset_fill_func, regset_store_func): Change + prototype. + (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): + Change prototype. + * linux-low.c (get_stop_pc): Adjust. + (check_removed_breakpoint): Adjust. + (linux_wait_for_event): Adjust. + (linux_resume_one_lwp): Adjust. + (fetch_register): Add regcache parameter. Adjust. + (usr_store_inferior_registers): Ditto. + (regsets_fetch_inferior_registers): Ditto. + (regsets_store_inferior_registers): Ditto. + (linux_fetch_registers, linux_store_registers): Ditto. + * i387-fp.c (i387_cache_to_fsave): Change prototype to take a + regcache. Adjust. + (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. + * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change + prototype to take a regcache. + (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. + * remote-utils.c (convert_ascii_to_int, outreg) + (prepare_resume_reply): Change prototype to take a regcache. + Adjust. + * target.h (struct target_ops) <fetch_registers, store_registers>: + Change prototype to take a regcache. + (fetch_inferior_registers, store_inferior_registers): Change + prototype to take a regcache. Adjust. + * proc-service.c (ps_lgetregs): Adjust. + * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) + (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) + (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to + take a regcache. Adjust. + * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) + (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) + (arm_store_vfpregset, arm_get_pc, arm_set_pc): + (arm_breakpoint_at): Change prototype to take a regcache. Adjust. + * linux-cris-low.c (cris_get_pc, cris_set_pc) + (cris_cannot_fetch_register): + (cris_breakpoint_at): Change prototype to take a regcache. + Adjust. + * linux-crisv32-low.c (cris_get_pc, cris_set_pc, + cris_reinsert_addr, cris_write_data_breakpoint): Change prototype + to take a regcache. Adjust. + (cris_breakpoint_at, cris_insert_point, cris_remove_point): + Adjust. + * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to + take a regcache. Adjust. + * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) + (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, + (m68k_set_pc): Change prototype to take a regcache. Adjust. + * linux-mips-low.c (mips_get_pc): + (mips_set_pc): Change prototype to take a regcache. Adjust. + (mips_reinsert_addr): Adjust. + (mips_collect_register): Change prototype to take a regcache. + Adjust. + (mips_supply_register): + (mips_collect_register_32bit, mips_supply_register_32bit) + (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) + (mips_store_fpregset): Ditto. + * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): + Ditto. + (parse_spufs_run): Adjust. + (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) + (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) + (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to + take a regcache. Adjust. + * linux-s390-low.c (s390_collect_ptrace_register) + (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) + (s390_set_pc): Change prototype to take a regcache. Adjust. + (s390_arch_setup): Adjust. + * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) + (sh_fill_gregset): Change prototype to take a regcache. Adjust. + * linux-sparc-low.c (sparc_fill_gregset_to_stack) + (sparc_fill_gregset, sparc_store_gregset_from_stack) + (sparc_store_gregset, sparc_get_pc): Change prototype to take a + regcache. Adjust. + (sparc_breakpoint_at): Adjust. + * linux-xtensa-low.c (xtensa_fill_gregset): + (xtensa_store_gregset): + (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) + (xtensa_set_pc): Change prototype to take a regcache. Adjust. + * nto-low.c (nto_fetch_registers, nto_store_registers): Change + prototype to take a regcache. Adjust. + * win32-arm-low.c (arm_fetch_inferior_register) + (arm_store_inferior_register): Change prototype to take a + regcache. Adjust. + * win32-i386-low.c (i386_fetch_inferior_register) + (i386_store_inferior_register): Change prototype to take a + regcache. Adjust. + * win32-low.c (child_fetch_inferior_registers) + (child_store_inferior_registers): Change prototype to take a + regcache. Adjust. + (win32_wait): Adjust. + (win32_fetch_inferior_registers): Change prototype to take a + regcache. Adjust. + (win32_store_inferior_registers): Adjust. + * win32-low.h (struct win32_target_ops) <fetch_inferior_register, + store_inferior_register>: Change prototype to take a regcache. + 2010-01-20 Doug Evans <dje@google.com> * linux-low.c (linux_create_inferior): Wrap use of __SIGRTMIN in diff --git a/gdb/gdbserver/i387-fp.c b/gdb/gdbserver/i387-fp.c index aaeb336..7ef4ba3 100644 --- a/gdb/gdbserver/i387-fp.c +++ b/gdb/gdbserver/i387-fp.c @@ -73,7 +73,7 @@ struct i387_fxsave { }; void -i387_cache_to_fsave (void *buf) +i387_cache_to_fsave (struct regcache *regcache, void *buf) { struct i387_fsave *fp = (struct i387_fsave *) buf; int i; @@ -81,38 +81,39 @@ i387_cache_to_fsave (void *buf) unsigned long val, val2; for (i = 0; i < 8; i++) - collect_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i * 10); + collect_register (regcache, i + st0_regnum, + ((char *) &fp->st_space[0]) + i * 10); - collect_register_by_name ("fioff", &fp->fioff); - collect_register_by_name ("fooff", &fp->fooff); + collect_register_by_name (regcache, "fioff", &fp->fioff); + collect_register_by_name (regcache, "fooff", &fp->fooff); /* This one's 11 bits... */ - collect_register_by_name ("fop", &val2); + collect_register_by_name (regcache, "fop", &val2); fp->fop = (val2 & 0x7FF) | (fp->fop & 0xF800); /* Some registers are 16-bit. */ - collect_register_by_name ("fctrl", &val); + collect_register_by_name (regcache, "fctrl", &val); fp->fctrl = val; - collect_register_by_name ("fstat", &val); + collect_register_by_name (regcache, "fstat", &val); val &= 0xFFFF; fp->fstat = val; - collect_register_by_name ("ftag", &val); + collect_register_by_name (regcache, "ftag", &val); val &= 0xFFFF; fp->ftag = val; - collect_register_by_name ("fiseg", &val); + collect_register_by_name (regcache, "fiseg", &val); val &= 0xFFFF; fp->fiseg = val; - collect_register_by_name ("foseg", &val); + collect_register_by_name (regcache, "foseg", &val); val &= 0xFFFF; fp->foseg = val; } void -i387_fsave_to_cache (const void *buf) +i387_fsave_to_cache (struct regcache *regcache, const void *buf) { struct i387_fsave *fp = (struct i387_fsave *) buf; int i; @@ -120,34 +121,35 @@ i387_fsave_to_cache (const void *buf) unsigned long val; for (i = 0; i < 8; i++) - supply_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i * 10); + supply_register (regcache, i + st0_regnum, + ((char *) &fp->st_space[0]) + i * 10); - supply_register_by_name ("fioff", &fp->fioff); - supply_register_by_name ("fooff", &fp->fooff); + supply_register_by_name (regcache, "fioff", &fp->fioff); + supply_register_by_name (regcache, "fooff", &fp->fooff); /* Some registers are 16-bit. */ val = fp->fctrl & 0xFFFF; - supply_register_by_name ("fctrl", &val); + supply_register_by_name (regcache, "fctrl", &val); val = fp->fstat & 0xFFFF; - supply_register_by_name ("fstat", &val); + supply_register_by_name (regcache, "fstat", &val); val = fp->ftag & 0xFFFF; - supply_register_by_name ("ftag", &val); + supply_register_by_name (regcache, "ftag", &val); val = fp->fiseg & 0xFFFF; - supply_register_by_name ("fiseg", &val); + supply_register_by_name (regcache, "fiseg", &val); val = fp->foseg & 0xFFFF; - supply_register_by_name ("foseg", &val); + supply_register_by_name (regcache, "foseg", &val); /* fop has only 11 valid bits. */ val = (fp->fop) & 0x7FF; - supply_register_by_name ("fop", &val); + supply_register_by_name (regcache, "fop", &val); } void -i387_cache_to_fxsave (void *buf) +i387_cache_to_fxsave (struct regcache *regcache, void *buf) { struct i387_fxsave *fp = (struct i387_fxsave *) buf; int i; @@ -156,27 +158,29 @@ i387_cache_to_fxsave (void *buf) unsigned long val, val2; for (i = 0; i < 8; i++) - collect_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i * 16); + collect_register (regcache, i + st0_regnum, + ((char *) &fp->st_space[0]) + i * 16); for (i = 0; i < num_xmm_registers; i++) - collect_register (i + xmm0_regnum, ((char *) &fp->xmm_space[0]) + i * 16); + collect_register (regcache, i + xmm0_regnum, + ((char *) &fp->xmm_space[0]) + i * 16); - collect_register_by_name ("fioff", &fp->fioff); - collect_register_by_name ("fooff", &fp->fooff); - collect_register_by_name ("mxcsr", &fp->mxcsr); + collect_register_by_name (regcache, "fioff", &fp->fioff); + collect_register_by_name (regcache, "fooff", &fp->fooff); + collect_register_by_name (regcache, "mxcsr", &fp->mxcsr); /* This one's 11 bits... */ - collect_register_by_name ("fop", &val2); + collect_register_by_name (regcache, "fop", &val2); fp->fop = (val2 & 0x7FF) | (fp->fop & 0xF800); /* Some registers are 16-bit. */ - collect_register_by_name ("fctrl", &val); + collect_register_by_name (regcache, "fctrl", &val); fp->fctrl = val; - collect_register_by_name ("fstat", &val); + collect_register_by_name (regcache, "fstat", &val); fp->fstat = val; /* Convert to the simplifed tag form stored in fxsave data. */ - collect_register_by_name ("ftag", &val); + collect_register_by_name (regcache, "ftag", &val); val &= 0xFFFF; val2 = 0; for (i = 7; i >= 0; i--) @@ -188,10 +192,10 @@ i387_cache_to_fxsave (void *buf) } fp->ftag = val2; - collect_register_by_name ("fiseg", &val); + collect_register_by_name (regcache, "fiseg", &val); fp->fiseg = val; - collect_register_by_name ("foseg", &val); + collect_register_by_name (regcache, "foseg", &val); fp->foseg = val; } @@ -243,7 +247,7 @@ i387_ftag (struct i387_fxsave *fp, int regno) } void -i387_fxsave_to_cache (const void *buf) +i387_fxsave_to_cache (struct regcache *regcache, const void *buf) { struct i387_fxsave *fp = (struct i387_fxsave *) buf; int i, top; @@ -252,20 +256,22 @@ i387_fxsave_to_cache (const void *buf) unsigned long val; for (i = 0; i < 8; i++) - supply_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i * 16); + supply_register (regcache, i + st0_regnum, + ((char *) &fp->st_space[0]) + i * 16); for (i = 0; i < num_xmm_registers; i++) - supply_register (i + xmm0_regnum, ((char *) &fp->xmm_space[0]) + i * 16); + supply_register (regcache, i + xmm0_regnum, + ((char *) &fp->xmm_space[0]) + i * 16); - supply_register_by_name ("fioff", &fp->fioff); - supply_register_by_name ("fooff", &fp->fooff); - supply_register_by_name ("mxcsr", &fp->mxcsr); + supply_register_by_name (regcache, "fioff", &fp->fioff); + supply_register_by_name (regcache, "fooff", &fp->fooff); + supply_register_by_name (regcache, "mxcsr", &fp->mxcsr); /* Some registers are 16-bit. */ val = fp->fctrl & 0xFFFF; - supply_register_by_name ("fctrl", &val); + supply_register_by_name (regcache, "fctrl", &val); val = fp->fstat & 0xFFFF; - supply_register_by_name ("fstat", &val); + supply_register_by_name (regcache, "fstat", &val); /* Generate the form of ftag data that GDB expects. */ top = (fp->fstat >> 11) & 0x7; @@ -279,14 +285,14 @@ i387_fxsave_to_cache (const void *buf) tag = 3; val |= tag << (2 * i); } - supply_register_by_name ("ftag", &val); + supply_register_by_name (regcache, "ftag", &val); val = fp->fiseg & 0xFFFF; - supply_register_by_name ("fiseg", &val); + supply_register_by_name (regcache, "fiseg", &val); val = fp->foseg & 0xFFFF; - supply_register_by_name ("foseg", &val); + supply_register_by_name (regcache, "foseg", &val); val = (fp->fop) & 0x7FF; - supply_register_by_name ("fop", &val); + supply_register_by_name (regcache, "fop", &val); } diff --git a/gdb/gdbserver/i387-fp.h b/gdb/gdbserver/i387-fp.h index 0c5127d..d1e0681 100644 --- a/gdb/gdbserver/i387-fp.h +++ b/gdb/gdbserver/i387-fp.h @@ -20,11 +20,11 @@ #ifndef I387_FP_H #define I387_FP_H -void i387_cache_to_fsave (void *buf); -void i387_fsave_to_cache (const void *buf); +void i387_cache_to_fsave (struct regcache *regcache, void *buf); +void i387_fsave_to_cache (struct regcache *regcache, const void *buf); -void i387_cache_to_fxsave (void *buf); -void i387_fxsave_to_cache (const void *buf); +void i387_cache_to_fxsave (struct regcache *regcache, void *buf); +void i387_fxsave_to_cache (struct regcache *regcache, const void *buf); extern int num_xmm_registers; diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index abb637d..965b029 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -81,17 +81,17 @@ arm_cannot_fetch_register (int regno) } static void -arm_fill_gregset (void *buf) +arm_fill_gregset (struct regcache *regcache, void *buf) { int i; for (i = 0; i < arm_num_regs; i++) if (arm_regmap[i] != -1) - collect_register (i, ((char *) buf) + arm_regmap[i]); + collect_register (regcache, i, ((char *) buf) + arm_regmap[i]); } static void -arm_store_gregset (const void *buf) +arm_store_gregset (struct regcache *regcache, const void *buf) { int i; char zerobuf[8]; @@ -99,13 +99,13 @@ arm_store_gregset (const void *buf) memset (zerobuf, 0, 8); for (i = 0; i < arm_num_regs; i++) if (arm_regmap[i] != -1) - supply_register (i, ((char *) buf) + arm_regmap[i]); + supply_register (regcache, i, ((char *) buf) + arm_regmap[i]); else - supply_register (i, zerobuf); + supply_register (regcache, i, zerobuf); } static void -arm_fill_wmmxregset (void *buf) +arm_fill_wmmxregset (struct regcache *regcache, void *buf) { int i; @@ -113,15 +113,16 @@ arm_fill_wmmxregset (void *buf) return; for (i = 0; i < 16; i++) - collect_register (arm_num_regs + i, (char *) buf + i * 8); + collect_register (regcache, arm_num_regs + i, (char *) buf + i * 8); /* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */ for (i = 0; i < 6; i++) - collect_register (arm_num_regs + i + 16, (char *) buf + 16 * 8 + i * 4); + collect_register (regcache, arm_num_regs + i + 16, + (char *) buf + 16 * 8 + i * 4); } static void -arm_store_wmmxregset (const void *buf) +arm_store_wmmxregset (struct regcache *regcache, const void *buf) { int i; @@ -129,15 +130,16 @@ arm_store_wmmxregset (const void *buf) return; for (i = 0; i < 16; i++) - supply_register (arm_num_regs + i, (char *) buf + i * 8); + supply_register (regcache, arm_num_regs + i, (char *) buf + i * 8); /* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */ for (i = 0; i < 6; i++) - supply_register (arm_num_regs + i + 16, (char *) buf + 16 * 8 + i * 4); + supply_register (regcache, arm_num_regs + i + 16, + (char *) buf + 16 * 8 + i * 4); } static void -arm_fill_vfpregset (void *buf) +arm_fill_vfpregset (struct regcache *regcache, void *buf) { int i, num, base; @@ -151,13 +153,13 @@ arm_fill_vfpregset (void *buf) base = find_regno ("d0"); for (i = 0; i < num; i++) - collect_register (base + i, (char *) buf + i * 8); + collect_register (regcache, base + i, (char *) buf + i * 8); - collect_register_by_name ("fpscr", (char *) buf + 32 * 8); + collect_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8); } static void -arm_store_vfpregset (const void *buf) +arm_store_vfpregset (struct regcache *regcache, const void *buf) { int i, num, base; @@ -171,28 +173,28 @@ arm_store_vfpregset (const void *buf) base = find_regno ("d0"); for (i = 0; i < num; i++) - supply_register (base + i, (char *) buf + i * 8); + supply_register (regcache, base + i, (char *) buf + i * 8); - supply_register_by_name ("fpscr", (char *) buf + 32 * 8); + supply_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8); } extern int debug_threads; static CORE_ADDR -arm_get_pc () +arm_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); if (debug_threads) fprintf (stderr, "stop pc is %08lx\n", pc); return pc; } static void -arm_set_pc (CORE_ADDR pc) +arm_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } /* Correct in either endianness. */ @@ -210,9 +212,10 @@ static const unsigned long arm_eabi_breakpoint = 0xe7f001f0; static int arm_breakpoint_at (CORE_ADDR where) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); unsigned long cpsr; - collect_register_by_name ("cpsr", &cpsr); + collect_register_by_name (regcache, "cpsr", &cpsr); if (cpsr & 0x20) { @@ -243,10 +246,11 @@ arm_breakpoint_at (CORE_ADDR where) is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR -arm_reinsert_addr () +arm_reinsert_addr (void) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); unsigned long pc; - collect_register_by_name ("lr", &pc); + collect_register_by_name (regcache, "lr", &pc); return pc; } diff --git a/gdb/gdbserver/linux-cris-low.c b/gdb/gdbserver/linux-cris-low.c index d83d0a1..7155742 100644 --- a/gdb/gdbserver/linux-cris-low.c +++ b/gdb/gdbserver/linux-cris-low.c @@ -62,20 +62,20 @@ cris_cannot_fetch_register (int regno) extern int debug_threads; static CORE_ADDR -cris_get_pc (void) +cris_get_pc (struct regcache *regcache, void) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); if (debug_threads) fprintf (stderr, "stop pc is %08lx\n", pc); return pc; } static void -cris_set_pc (CORE_ADDR pc) +cris_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } static const unsigned short cris_breakpoint = 0xe938; @@ -102,8 +102,9 @@ cris_breakpoint_at (CORE_ADDR where) static CORE_ADDR cris_reinsert_addr (void) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); unsigned long pc; - collect_register_by_name ("srp", &pc); + collect_register_by_name (regcache, "srp", &pc); return pc; } diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c index 058e8c7..6ba48b6 100644 --- a/gdb/gdbserver/linux-crisv32-low.c +++ b/gdb/gdbserver/linux-crisv32-low.c @@ -54,20 +54,20 @@ static int cris_regmap[] = { extern int debug_threads; static CORE_ADDR -cris_get_pc (void) +cris_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); if (debug_threads) fprintf (stderr, "stop pc is %08lx\n", pc); return pc; } static void -cris_set_pc (CORE_ADDR pc) +cris_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } static const unsigned short cris_breakpoint = 0xe938; @@ -99,39 +99,41 @@ cris_breakpoint_at (CORE_ADDR where) static CORE_ADDR cris_reinsert_addr (void) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); unsigned long pc; - collect_register_by_name ("srp", &pc); + collect_register_by_name (regcache, "srp", &pc); return pc; } static void -cris_write_data_breakpoint (int bp, unsigned long start, unsigned long end) +cris_write_data_breakpoint (struct regcache *regcache, + int bp, unsigned long start, unsigned long end) { switch (bp) { case 0: - supply_register_by_name ("s3", &start); - supply_register_by_name ("s4", &end); + supply_register_by_name (regcache, "s3", &start); + supply_register_by_name (regcache, "s4", &end); break; case 1: - supply_register_by_name ("s5", &start); - supply_register_by_name ("s6", &end); + supply_register_by_name (regcache, "s5", &start); + supply_register_by_name (regcache, "s6", &end); break; case 2: - supply_register_by_name ("s7", &start); - supply_register_by_name ("s8", &end); + supply_register_by_name (regcache, "s7", &start); + supply_register_by_name (regcache, "s8", &end); break; case 3: - supply_register_by_name ("s9", &start); - supply_register_by_name ("s10", &end); + supply_register_by_name (regcache, "s9", &start); + supply_register_by_name (regcache, "s10", &end); break; case 4: - supply_register_by_name ("s11", &start); - supply_register_by_name ("s12", &end); + supply_register_by_name (regcache, "s11", &start); + supply_register_by_name (regcache, "s12", &end); break; case 5: - supply_register_by_name ("s13", &start); - supply_register_by_name ("s14", &end); + supply_register_by_name (regcache, "s13", &start); + supply_register_by_name (regcache, "s14", &end); break; } } @@ -143,6 +145,7 @@ cris_insert_point (char type, CORE_ADDR addr, int len) unsigned long bp_ctrl; unsigned long start, end; unsigned long ccs; + struct regcache *regcache; /* Breakpoint/watchpoint types (GDB terminology): 0 = memory breakpoint for instructions @@ -158,13 +161,15 @@ cris_insert_point (char type, CORE_ADDR addr, int len) return 1; } + regcache = get_thread_regcache (current_inferior, 1); + /* Read watchpoints are set as access watchpoints, because of GDB's inability to deal with pure read watchpoints. */ if (type == '3') type = '4'; /* Get the configuration register. */ - collect_register_by_name ("s0", &bp_ctrl); + collect_register_by_name (regcache, "s0", &bp_ctrl); /* The watchpoint allocation scheme is the simplest possible. For example, if a region is watched for read and @@ -202,19 +207,19 @@ cris_insert_point (char type, CORE_ADDR addr, int len) } /* Setup the configuration register. */ - supply_register_by_name ("s0", &bp_ctrl); + supply_register_by_name (regcache, "s0", &bp_ctrl); /* Setup the range. */ start = addr; end = addr + len - 1; /* Configure the watchpoint register. */ - cris_write_data_breakpoint (bp, start, end); + cris_write_data_breakpoint (regcache, bp, start, end); - collect_register_by_name ("ccs", &ccs); + collect_register_by_name (regcache, "ccs", &ccs); /* Set the S1 flag to enable watchpoints. */ ccs |= (1 << 19); - supply_register_by_name ("ccs", &ccs); + supply_register_by_name (regcache, "ccs", &ccs); return 0; } @@ -225,6 +230,7 @@ cris_remove_point (char type, CORE_ADDR addr, int len) int bp; unsigned long bp_ctrl; unsigned long start, end; + struct regcache *regcache; /* Breakpoint/watchpoint types: 0 = memory breakpoint for instructions @@ -236,13 +242,15 @@ cris_remove_point (char type, CORE_ADDR addr, int len) if (type < '2' || type > '4') return -1; + regcache = get_thread_regcache (current_inferior, 1); + /* Read watchpoints are set as access watchpoints, because of GDB's inability to deal with pure read watchpoints. */ if (type == '3') type = '4'; /* Get the configuration register. */ - collect_register_by_name ("s0", &bp_ctrl); + collect_register_by_name (regcache, "s0", &bp_ctrl); /* Try to find a watchpoint that is configured for the specified range, then check that read/write also matches. */ @@ -254,18 +262,18 @@ cris_remove_point (char type, CORE_ADDR addr, int len) unsigned long bp_d_regs[12]; /* Get all range registers to simplify search. */ - collect_register_by_name ("s3", &bp_d_regs[0]); - collect_register_by_name ("s4", &bp_d_regs[1]); - collect_register_by_name ("s5", &bp_d_regs[2]); - collect_register_by_name ("s6", &bp_d_regs[3]); - collect_register_by_name ("s7", &bp_d_regs[4]); - collect_register_by_name ("s8", &bp_d_regs[5]); - collect_register_by_name ("s9", &bp_d_regs[6]); - collect_register_by_name ("s10", &bp_d_regs[7]); - collect_register_by_name ("s11", &bp_d_regs[8]); - collect_register_by_name ("s12", &bp_d_regs[9]); - collect_register_by_name ("s13", &bp_d_regs[10]); - collect_register_by_name ("s14", &bp_d_regs[11]); + collect_register_by_name (regcache, "s3", &bp_d_regs[0]); + collect_register_by_name (regcache, "s4", &bp_d_regs[1]); + collect_register_by_name (regcache, "s5", &bp_d_regs[2]); + collect_register_by_name (regcache, "s6", &bp_d_regs[3]); + collect_register_by_name (regcache, "s7", &bp_d_regs[4]); + collect_register_by_name (regcache, "s8", &bp_d_regs[5]); + collect_register_by_name (regcache, "s9", &bp_d_regs[6]); + collect_register_by_name (regcache, "s10", &bp_d_regs[7]); + collect_register_by_name (regcache, "s11", &bp_d_regs[8]); + collect_register_by_name (regcache, "s12", &bp_d_regs[9]); + collect_register_by_name (regcache, "s13", &bp_d_regs[10]); + collect_register_by_name (regcache, "s14", &bp_d_regs[11]); for (bp = 0; bp < 6; bp++) { @@ -299,11 +307,11 @@ cris_remove_point (char type, CORE_ADDR addr, int len) start/end addresses. */ bp_ctrl &= ~(3 << (2 + (bp * 4))); /* Setup the configuration register. */ - supply_register_by_name ("s0", &bp_ctrl); + supply_register_by_name (regcache, "s0", &bp_ctrl); start = end = 0; /* Configure the watchpoint register. */ - cris_write_data_breakpoint (bp, start, end); + cris_write_data_breakpoint (regcache, bp, start, end); /* Note that we don't clear the S1 flag here. It's done when continuing. */ return 0; diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 4869db3..bd00d5f 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -451,7 +451,8 @@ handle_extended_wait (struct lwp_info *event_child, int wstat) static CORE_ADDR get_stop_pc (void) { - CORE_ADDR stop_pc = (*the_low_target.get_pc) (); + struct regcache *regcache = get_thread_regcache (current_inferior, 1); + CORE_ADDR stop_pc = (*the_low_target.get_pc) (regcache); if (! get_thread_lwp (current_inferior)->stepping) stop_pc -= the_low_target.decr_pc_after_break; @@ -884,6 +885,7 @@ check_removed_breakpoint (struct lwp_info *event_child) { CORE_ADDR stop_pc; struct thread_info *saved_inferior; + struct regcache *regcache; if (event_child->pending_is_breakpoint == 0) return 0; @@ -894,7 +896,7 @@ check_removed_breakpoint (struct lwp_info *event_child) saved_inferior = current_inferior; current_inferior = get_lwp_thread (event_child); - + regcache = get_thread_regcache (current_inferior, 1); stop_pc = get_stop_pc (); /* If the PC has changed since we stopped, then we shouldn't do @@ -930,7 +932,7 @@ check_removed_breakpoint (struct lwp_info *event_child) { if (debug_threads) fprintf (stderr, "Set pc to 0x%lx\n", (long) stop_pc); - (*the_low_target.set_pc) (stop_pc); + (*the_low_target.set_pc) (regcache, stop_pc); } /* We consumed the pending SIGTRAP. */ @@ -1063,11 +1065,12 @@ retry: && the_low_target.get_pc != NULL) { struct thread_info *saved_inferior = current_inferior; + struct regcache *regcache = get_thread_regcache (current_inferior, 1); CORE_ADDR pc; current_inferior = (struct thread_info *) find_inferior_id (&all_threads, child->head.id); - pc = (*the_low_target.get_pc) (); + pc = (*the_low_target.get_pc) (regcache); fprintf (stderr, "linux_wait_for_lwp: pc is 0x%lx\n", (long) pc); current_inferior = saved_inferior; } @@ -1832,7 +1835,8 @@ linux_resume_one_lwp (struct lwp_info *lwp, if (debug_threads && the_low_target.get_pc != NULL) { - CORE_ADDR pc = (*the_low_target.get_pc) (); + struct regcache *regcache = get_thread_regcache (current_inferior, 1); + CORE_ADDR pc = (*the_low_target.get_pc) (regcache); fprintf (stderr, " resuming from pc 0x%lx\n", (long) pc); } @@ -2121,7 +2125,7 @@ register_addr (int regnum) /* Fetch one register. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -2160,29 +2164,29 @@ fetch_register (int regno) } if (the_low_target.supply_ptrace_register) - the_low_target.supply_ptrace_register (regno, buf); + the_low_target.supply_ptrace_register (regcache, regno, buf); else - supply_register (regno, buf); + supply_register (regcache, regno, buf); error_exit:; } /* Fetch all registers, or just one, from the child process. */ static void -usr_fetch_inferior_registers (int regno) +usr_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1) for (regno = 0; regno < the_low_target.num_regs; regno++) - fetch_register (regno); + fetch_register (regcache, regno); else - fetch_register (regno); + fetch_register (regcache, regno); } /* Store our register values back into the inferior. If REGNO is -1, do this for all registers. Otherwise, REGNO specifies which register (so we can save time). */ static void -usr_store_inferior_registers (int regno) +usr_store_inferior_registers (struct regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -2207,9 +2211,9 @@ usr_store_inferior_registers (int regno) memset (buf, 0, size); if (the_low_target.collect_ptrace_register) - the_low_target.collect_ptrace_register (regno, buf); + the_low_target.collect_ptrace_register (regcache, regno, buf); else - collect_register (regno, buf); + collect_register (regcache, regno, buf); pid = lwpid_of (get_thread_lwp (current_inferior)); for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) @@ -2241,7 +2245,7 @@ usr_store_inferior_registers (int regno) } else for (regno = 0; regno < the_low_target.num_regs; regno++) - usr_store_inferior_registers (regno); + usr_store_inferior_registers (regcache, regno); } #endif /* HAVE_LINUX_USRREGS */ @@ -2250,7 +2254,7 @@ usr_store_inferior_registers (int regno) #ifdef HAVE_LINUX_REGSETS static int -regsets_fetch_inferior_registers () +regsets_fetch_inferior_registers (struct regcache *regcache) { struct regset_info *regset; int saw_general_regs = 0; @@ -2296,7 +2300,7 @@ regsets_fetch_inferior_registers () } else if (regset->type == GENERAL_REGS) saw_general_regs = 1; - regset->store_function (buf); + regset->store_function (regcache, buf); regset ++; free (buf); } @@ -2307,7 +2311,7 @@ regsets_fetch_inferior_registers () } static int -regsets_store_inferior_registers () +regsets_store_inferior_registers (struct regcache *regcache) { struct regset_info *regset; int saw_general_regs = 0; @@ -2341,7 +2345,7 @@ regsets_store_inferior_registers () if (res == 0) { /* Then overlay our cached registers on that. */ - regset->fill_function (buf); + regset->fill_function (regcache, buf); /* Only now do we write the register set. */ #ifndef __sparc__ @@ -2391,26 +2395,26 @@ regsets_store_inferior_registers () void -linux_fetch_registers (int regno) +linux_fetch_registers (struct regcache *regcache, int regno) { #ifdef HAVE_LINUX_REGSETS - if (regsets_fetch_inferior_registers () == 0) + if (regsets_fetch_inferior_registers (regcache) == 0) return; #endif #ifdef HAVE_LINUX_USRREGS - usr_fetch_inferior_registers (regno); + usr_fetch_inferior_registers (regcache, regno); #endif } void -linux_store_registers (int regno) +linux_store_registers (struct regcache *regcache, int regno) { #ifdef HAVE_LINUX_REGSETS - if (regsets_store_inferior_registers () == 0) + if (regsets_store_inferior_registers (regcache) == 0) return; #endif #ifdef HAVE_LINUX_USRREGS - usr_store_inferior_registers (regno); + usr_store_inferior_registers (regcache, regno); #endif } diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index f3f8a60..82ad00c 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -24,8 +24,8 @@ #include "gdb_proc_service.h" #ifdef HAVE_LINUX_REGSETS -typedef void (*regset_fill_func) (void *); -typedef void (*regset_store_func) (const void *); +typedef void (*regset_fill_func) (struct regcache *, void *); +typedef void (*regset_store_func) (struct regcache *, const void *); enum regset_type { GENERAL_REGS, FP_REGS, @@ -70,8 +70,8 @@ struct linux_target_ops store the register, and 2 if failure to store the register is acceptable. */ int (*cannot_store_register) (int); - CORE_ADDR (*get_pc) (void); - void (*set_pc) (CORE_ADDR newpc); + CORE_ADDR (*get_pc) (struct regcache *regcache); + void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); const unsigned char *breakpoint; int breakpoint_len; CORE_ADDR (*breakpoint_reinsert_addr) (void); @@ -88,8 +88,10 @@ struct linux_target_ops /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular for registers smaller than an xfer unit). */ - void (*collect_ptrace_register) (int regno, char *buf); - void (*supply_ptrace_register) (int regno, const char *buf); + void (*collect_ptrace_register) (struct regcache *regcache, + int regno, char *buf); + void (*supply_ptrace_register) (struct regcache *regcache, + int regno, const char *buf); /* Hook to convert from target format to ptrace format and back. Returns true if any conversion was done; false otherwise. diff --git a/gdb/gdbserver/linux-m32r-low.c b/gdb/gdbserver/linux-m32r-low.c index 6fb6d13..3baaf2f 100644 --- a/gdb/gdbserver/linux-m32r-low.c +++ b/gdb/gdbserver/linux-m32r-low.c @@ -53,18 +53,20 @@ m32r_cannot_fetch_register (int regno) } static CORE_ADDR -m32r_get_pc () +m32r_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); + if (debug_threads) + fprintf (stderr, "stop pc is %08lx\n", pc); return pc; } static void -m32r_set_pc (CORE_ADDR pc) +m32r_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } static const unsigned short m32r_breakpoint = 0x10f1; diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c index 512bdf6..14e3864 100644 --- a/gdb/gdbserver/linux-m68k-low.c +++ b/gdb/gdbserver/linux-m68k-low.c @@ -71,40 +71,40 @@ m68k_cannot_fetch_register (int regno) #include <sys/ptrace.h> static void -m68k_fill_gregset (void *buf) +m68k_fill_gregset (struct regcache *regcache, void *buf) { int i; for (i = 0; i < m68k_num_gregs; i++) - collect_register (i, (char *) buf + m68k_regmap[i]); + collect_register (regcache, i, (char *) buf + m68k_regmap[i]); } static void -m68k_store_gregset (const void *buf) +m68k_store_gregset (struct regcache *regcache, const void *buf) { int i; for (i = 0; i < m68k_num_gregs; i++) - supply_register (i, (const char *) buf + m68k_regmap[i]); + supply_register (regcache, i, (const char *) buf + m68k_regmap[i]); } static void -m68k_fill_fpregset (void *buf) +m68k_fill_fpregset (struct regcache *regcache, void *buf) { int i; for (i = m68k_num_gregs; i < m68k_num_regs; i++) - collect_register (i, ((char *) buf - + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs]))); + collect_register (regcache, i, ((char *) buf + + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs]))); } static void -m68k_store_fpregset (const void *buf) +m68k_store_fpregset (struct regcache *regcache, const void *buf) { int i; for (i = m68k_num_gregs; i < m68k_num_regs; i++) - supply_register (i, ((const char *) buf + supply_register (regcache, i, ((const char *) buf + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs]))); } @@ -126,20 +126,20 @@ static const unsigned char m68k_breakpoint[] = { 0x4E, 0x4F }; #define m68k_breakpoint_len 2 static CORE_ADDR -m68k_get_pc () +m68k_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); return pc; } static void -m68k_set_pc (CORE_ADDR value) +m68k_set_pc (struct regcache *regcache, CORE_ADDR value) { unsigned long newpc = value; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } static int diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index a36803d..70f6700 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -115,15 +115,15 @@ mips_cannot_store_register (int regno) } static CORE_ADDR -mips_get_pc () +mips_get_pc (struct regcache *regcache) { union mips_register pc; - collect_register_by_name ("pc", pc.buf); + collect_register_by_name (regcache, "pc", pc.buf); return register_size (0) == 4 ? pc.reg32 : pc.reg64; } static void -mips_set_pc (CORE_ADDR pc) +mips_set_pc (struct regcache *regcache, CORE_ADDR pc) { union mips_register newpc; if (register_size (0) == 4) @@ -131,7 +131,7 @@ mips_set_pc (CORE_ADDR pc) else newpc.reg64 = pc; - supply_register_by_name ("pc", newpc.buf); + supply_register_by_name (regcache, "pc", newpc.buf); } /* Correct in either endianness. */ @@ -142,10 +142,11 @@ static const unsigned int mips_breakpoint = 0x0005000d; is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR -mips_reinsert_addr () +mips_reinsert_addr (void) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); union mips_register ra; - collect_register_by_name ("r31", ra.buf); + collect_register_by_name (regcache, "r31", ra.buf); return register_size (0) == 4 ? ra.reg32 : ra.reg64; } @@ -183,24 +184,26 @@ ps_get_thread_area (const struct ps_prochandle *ph, #ifdef HAVE_PTRACE_GETREGS static void -mips_collect_register (int use_64bit, int regno, union mips_register *reg) +mips_collect_register (struct regcache *regcache, + int use_64bit, int regno, union mips_register *reg) { union mips_register tmp_reg; if (use_64bit) { - collect_register (regno, &tmp_reg.reg64); + collect_register (regcache, regno, &tmp_reg.reg64); *reg = tmp_reg; } else { - collect_register (regno, &tmp_reg.reg32); + collect_register (regcache, regno, &tmp_reg.reg32); reg->reg64 = tmp_reg.reg32; } } static void -mips_supply_register (int use_64bit, int regno, const union mips_register *reg) +mips_supply_register (struct regcache *regcache, + int use_64bit, int regno, const union mips_register *reg) { int offset = 0; @@ -209,33 +212,35 @@ mips_supply_register (int use_64bit, int regno, const union mips_register *reg) if (__BYTE_ORDER == __BIG_ENDIAN && !use_64bit) offset = 4; - supply_register (regno, reg->buf + offset); + supply_register (regcache, regno, reg->buf + offset); } static void -mips_collect_register_32bit (int use_64bit, int regno, unsigned char *buf) +mips_collect_register_32bit (struct regcache *regcache, + int use_64bit, int regno, unsigned char *buf) { union mips_register tmp_reg; int reg32; - mips_collect_register (use_64bit, regno, &tmp_reg); + mips_collect_register (regcache, use_64bit, regno, &tmp_reg); reg32 = tmp_reg.reg64; memcpy (buf, ®32, 4); } static void -mips_supply_register_32bit (int use_64bit, int regno, const unsigned char *buf) +mips_supply_register_32bit (struct regcache *regcache, + int use_64bit, int regno, const unsigned char *buf) { union mips_register tmp_reg; int reg32; memcpy (®32, buf, 4); tmp_reg.reg64 = reg32; - mips_supply_register (use_64bit, regno, &tmp_reg); + mips_supply_register (regcache, use_64bit, regno, &tmp_reg); } static void -mips_fill_gregset (void *buf) +mips_fill_gregset (struct regcache *regcache, void *buf) { union mips_register *regset = buf; int i, use_64bit; @@ -243,20 +248,27 @@ mips_fill_gregset (void *buf) use_64bit = (register_size (0) == 8); for (i = 1; i < 32; i++) - mips_collect_register (use_64bit, i, regset + i); - - mips_collect_register (use_64bit, find_regno ("lo"), regset + 32); - mips_collect_register (use_64bit, find_regno ("hi"), regset + 33); - mips_collect_register (use_64bit, find_regno ("pc"), regset + 34); - mips_collect_register (use_64bit, find_regno ("badvaddr"), regset + 35); - mips_collect_register (use_64bit, find_regno ("status"), regset + 36); - mips_collect_register (use_64bit, find_regno ("cause"), regset + 37); - - mips_collect_register (use_64bit, find_regno ("restart"), regset + 0); + mips_collect_register (regcache, use_64bit, i, regset + i); + + mips_collect_register (regcache, use_64bit, + find_regno ("lo"), regset + 32); + mips_collect_register (regcache, use_64bit, + find_regno ("hi"), regset + 33); + mips_collect_register (regcache, use_64bit, + find_regno ("pc"), regset + 34); + mips_collect_register (regcache, use_64bit, + find_regno ("badvaddr"), regset + 35); + mips_collect_register (regcache, use_64bit, + find_regno ("status"), regset + 36); + mips_collect_register (regcache, use_64bit, + find_regno ("cause"), regset + 37); + + mips_collect_register (regcache, use_64bit, + find_regno ("restart"), regset + 0); } static void -mips_store_gregset (const void *buf) +mips_store_gregset (struct regcache *regcache, const void *buf) { const union mips_register *regset = buf; int i, use_64bit; @@ -264,20 +276,24 @@ mips_store_gregset (const void *buf) use_64bit = (register_size (0) == 8); for (i = 0; i < 32; i++) - mips_supply_register (use_64bit, i, regset + i); - - mips_supply_register (use_64bit, find_regno ("lo"), regset + 32); - mips_supply_register (use_64bit, find_regno ("hi"), regset + 33); - mips_supply_register (use_64bit, find_regno ("pc"), regset + 34); - mips_supply_register (use_64bit, find_regno ("badvaddr"), regset + 35); - mips_supply_register (use_64bit, find_regno ("status"), regset + 36); - mips_supply_register (use_64bit, find_regno ("cause"), regset + 37); - - mips_supply_register (use_64bit, find_regno ("restart"), regset + 0); + mips_supply_register (regcache, use_64bit, i, regset + i); + + mips_supply_register (regcache, use_64bit, find_regno ("lo"), regset + 32); + mips_supply_register (regcache, use_64bit, find_regno ("hi"), regset + 33); + mips_supply_register (regcache, use_64bit, find_regno ("pc"), regset + 34); + mips_supply_register (regcache, use_64bit, + find_regno ("badvaddr"), regset + 35); + mips_supply_register (regcache, use_64bit, + find_regno ("status"), regset + 36); + mips_supply_register (regcache, use_64bit, + find_regno ("cause"), regset + 37); + + mips_supply_register (regcache, use_64bit, + find_regno ("restart"), regset + 0); } static void -mips_fill_fpregset (void *buf) +mips_fill_fpregset (struct regcache *regcache, void *buf) { union mips_register *regset = buf; int i, use_64bit, first_fp, big_endian; @@ -289,18 +305,19 @@ mips_fill_fpregset (void *buf) /* See GDB for a discussion of this peculiar layout. */ for (i = 0; i < 32; i++) if (use_64bit) - collect_register (first_fp + i, regset[i].buf); + collect_register (regcache, first_fp + i, regset[i].buf); else - collect_register (first_fp + i, + collect_register (regcache, first_fp + i, regset[i & ~1].buf + 4 * (big_endian != (i & 1))); - mips_collect_register_32bit (use_64bit, find_regno ("fcsr"), regset[32].buf); - mips_collect_register_32bit (use_64bit, find_regno ("fir"), + mips_collect_register_32bit (regcache, use_64bit, + find_regno ("fcsr"), regset[32].buf); + mips_collect_register_32bit (regcache, use_64bit, find_regno ("fir"), regset[32].buf + 4); } static void -mips_store_fpregset (const void *buf) +mips_store_fpregset (struct regcache *regcache, const void *buf) { const union mips_register *regset = buf; int i, use_64bit, first_fp, big_endian; @@ -312,13 +329,14 @@ mips_store_fpregset (const void *buf) /* See GDB for a discussion of this peculiar layout. */ for (i = 0; i < 32; i++) if (use_64bit) - supply_register (first_fp + i, regset[i].buf); + supply_register (regcache, first_fp + i, regset[i].buf); else - supply_register (first_fp + i, + supply_register (regcache, first_fp + i, regset[i & ~1].buf + 4 * (big_endian != (i & 1))); - mips_supply_register_32bit (use_64bit, find_regno ("fcsr"), regset[32].buf); - mips_supply_register_32bit (use_64bit, find_regno ("fir"), + mips_supply_register_32bit (regcache, use_64bit, + find_regno ("fcsr"), regset[32].buf); + mips_supply_register_32bit (regcache, use_64bit, find_regno ("fir"), regset[32].buf + 4); } #endif /* HAVE_PTRACE_GETREGS */ diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index 161ba76..5832dc7 100644 --- a/gdb/gdbserver/linux-ppc-low.c +++ b/gdb/gdbserver/linux-ppc-low.c @@ -169,26 +169,27 @@ ppc_cannot_fetch_register (int regno) } static void -ppc_collect_ptrace_register (int regno, char *buf) +ppc_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) { int size = register_size (regno); memset (buf, 0, sizeof (long)); if (size < sizeof (long)) - collect_register (regno, buf + sizeof (long) - size); + collect_register (regcache, regno, buf + sizeof (long) - size); else - collect_register (regno, buf); + collect_register (regcache, regno, buf); } static void -ppc_supply_ptrace_register (int regno, const char *buf) +ppc_supply_ptrace_register (struct regcache *regcache, + int regno, const char *buf) { int size = register_size (regno); if (size < sizeof (long)) - supply_register (regno, buf + sizeof (long) - size); + supply_register (regcache, regno, buf + sizeof (long) - size); else - supply_register (regno, buf); + supply_register (regcache, regno, buf); } @@ -199,7 +200,7 @@ ppc_supply_ptrace_register (int regno, const char *buf) return to FD and ADDR the file handle and NPC parameter address used with the system call. Return non-zero if successful. */ static int -parse_spufs_run (int *fd, CORE_ADDR *addr) +parse_spufs_run (struct regcache *regcache, int *fd, CORE_ADDR *addr) { CORE_ADDR curr_pc; int curr_insn; @@ -208,10 +209,10 @@ parse_spufs_run (int *fd, CORE_ADDR *addr) if (register_size (0) == 4) { unsigned int pc, r0, r3, r4; - collect_register_by_name ("pc", &pc); - collect_register_by_name ("r0", &r0); - collect_register_by_name ("orig_r3", &r3); - collect_register_by_name ("r4", &r4); + collect_register_by_name (regcache, "pc", &pc); + collect_register_by_name (regcache, "r0", &r0); + collect_register_by_name (regcache, "orig_r3", &r3); + collect_register_by_name (regcache, "r4", &r4); curr_pc = (CORE_ADDR) pc; curr_r0 = (int) r0; *fd = (int) r3; @@ -220,10 +221,10 @@ parse_spufs_run (int *fd, CORE_ADDR *addr) else { unsigned long pc, r0, r3, r4; - collect_register_by_name ("pc", &pc); - collect_register_by_name ("r0", &r0); - collect_register_by_name ("orig_r3", &r3); - collect_register_by_name ("r4", &r4); + collect_register_by_name (regcache, "pc", &pc); + collect_register_by_name (regcache, "r0", &r0); + collect_register_by_name (regcache, "orig_r3", &r3); + collect_register_by_name (regcache, "r4", &r4); curr_pc = (CORE_ADDR) pc; curr_r0 = (int) r0; *fd = (int) r3; @@ -245,12 +246,12 @@ parse_spufs_run (int *fd, CORE_ADDR *addr) } static CORE_ADDR -ppc_get_pc (void) +ppc_get_pc (struct regcache *regcache) { CORE_ADDR addr; int fd; - if (parse_spufs_run (&fd, &addr)) + if (parse_spufs_run (regcache, &fd, &addr)) { unsigned int pc; (*the_target->read_memory) (addr, (unsigned char *) &pc, 4); @@ -259,24 +260,24 @@ ppc_get_pc (void) else if (register_size (0) == 4) { unsigned int pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); return (CORE_ADDR) pc; } else { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); return (CORE_ADDR) pc; } } static void -ppc_set_pc (CORE_ADDR pc) +ppc_set_pc (struct regcache *regcache, CORE_ADDR pc) { CORE_ADDR addr; int fd; - if (parse_spufs_run (&fd, &addr)) + if (parse_spufs_run (regcache, &fd, &addr)) { unsigned int newpc = pc; (*the_target->write_memory) (addr, (unsigned char *) &newpc, 4); @@ -284,12 +285,12 @@ ppc_set_pc (CORE_ADDR pc) else if (register_size (0) == 4) { unsigned int newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } else { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } } @@ -449,18 +450,18 @@ ppc_breakpoint_at (CORE_ADDR where) /* Provide only a fill function for the general register set. ps_lgetregs will use this for NPTL support. */ -static void ppc_fill_gregset (void *buf) +static void ppc_fill_gregset (struct regcache *regcache, void *buf) { int i; for (i = 0; i < 32; i++) - ppc_collect_ptrace_register (i, (char *) buf + ppc_regmap[i]); + ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); for (i = 64; i < 70; i++) - ppc_collect_ptrace_register (i, (char *) buf + ppc_regmap[i]); + ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); for (i = 71; i < 73; i++) - ppc_collect_ptrace_register (i, (char *) buf + ppc_regmap[i]); + ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); } #ifndef PTRACE_GETVSXREGS @@ -471,7 +472,7 @@ static void ppc_fill_gregset (void *buf) #define SIZEOF_VSXREGS 32*8 static void -ppc_fill_vsxregset (void *buf) +ppc_fill_vsxregset (struct regcache *regcache, void *buf) { int i, base; char *regset = buf; @@ -481,11 +482,11 @@ ppc_fill_vsxregset (void *buf) base = find_regno ("vs0h"); for (i = 0; i < 32; i++) - collect_register (base + i, ®set[i * 8]); + collect_register (regcache, base + i, ®set[i * 8]); } static void -ppc_store_vsxregset (const void *buf) +ppc_store_vsxregset (struct regcache *regcache, const void *buf) { int i, base; const char *regset = buf; @@ -495,7 +496,7 @@ ppc_store_vsxregset (const void *buf) base = find_regno ("vs0h"); for (i = 0; i < 32; i++) - supply_register (base + i, ®set[i * 8]); + supply_register (regcache, base + i, ®set[i * 8]); } #ifndef PTRACE_GETVRREGS @@ -506,7 +507,7 @@ ppc_store_vsxregset (const void *buf) #define SIZEOF_VRREGS 33*16+4 static void -ppc_fill_vrregset (void *buf) +ppc_fill_vrregset (struct regcache *regcache, void *buf) { int i, base; char *regset = buf; @@ -516,14 +517,14 @@ ppc_fill_vrregset (void *buf) base = find_regno ("vr0"); for (i = 0; i < 32; i++) - collect_register (base + i, ®set[i * 16]); + collect_register (regcache, base + i, ®set[i * 16]); - collect_register_by_name ("vscr", ®set[32 * 16 + 12]); - collect_register_by_name ("vrsave", ®set[33 * 16]); + collect_register_by_name (regcache, "vscr", ®set[32 * 16 + 12]); + collect_register_by_name (regcache, "vrsave", ®set[33 * 16]); } static void -ppc_store_vrregset (const void *buf) +ppc_store_vrregset (struct regcache *regcache, const void *buf) { int i, base; const char *regset = buf; @@ -533,10 +534,10 @@ ppc_store_vrregset (const void *buf) base = find_regno ("vr0"); for (i = 0; i < 32; i++) - supply_register (base + i, ®set[i * 16]); + supply_register (regcache, base + i, ®set[i * 16]); - supply_register_by_name ("vscr", ®set[32 * 16 + 12]); - supply_register_by_name ("vrsave", ®set[33 * 16]); + supply_register_by_name (regcache, "vscr", ®set[32 * 16 + 12]); + supply_register_by_name (regcache, "vrsave", ®set[33 * 16]); } #ifndef PTRACE_GETEVRREGS @@ -552,7 +553,7 @@ struct gdb_evrregset_t }; static void -ppc_fill_evrregset (void *buf) +ppc_fill_evrregset (struct regcache *regcache, void *buf) { int i, ev0; struct gdb_evrregset_t *regset = buf; @@ -562,14 +563,14 @@ ppc_fill_evrregset (void *buf) ev0 = find_regno ("ev0h"); for (i = 0; i < 32; i++) - collect_register (ev0 + i, ®set->evr[i]); + collect_register (regcache, ev0 + i, ®set->evr[i]); - collect_register_by_name ("acc", ®set->acc); - collect_register_by_name ("spefscr", ®set->spefscr); + collect_register_by_name (regcache, "acc", ®set->acc); + collect_register_by_name (regcache, "spefscr", ®set->spefscr); } static void -ppc_store_evrregset (const void *buf) +ppc_store_evrregset (struct regcache *regcache, const void *buf) { int i, ev0; const struct gdb_evrregset_t *regset = buf; @@ -579,10 +580,10 @@ ppc_store_evrregset (const void *buf) ev0 = find_regno ("ev0h"); for (i = 0; i < 32; i++) - supply_register (ev0 + i, ®set->evr[i]); + supply_register (regcache, ev0 + i, ®set->evr[i]); - supply_register_by_name ("acc", ®set->acc); - supply_register_by_name ("spefscr", ®set->spefscr); + supply_register_by_name (regcache, "acc", ®set->acc); + supply_register_by_name (regcache, "spefscr", ®set->spefscr); } struct regset_info target_regsets[] = { diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c index 64b1065..4cbce06 100644 --- a/gdb/gdbserver/linux-s390-low.c +++ b/gdb/gdbserver/linux-s390-low.c @@ -106,7 +106,7 @@ s390_cannot_store_register (int regno) } static void -s390_collect_ptrace_register (int regno, char *buf) +s390_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) { int size = register_size (regno); if (size < sizeof (long)) @@ -123,9 +123,9 @@ s390_collect_ptrace_register (int regno, char *buf) } else if (regaddr == PT_PSWADDR || (regaddr >= PT_GPR0 && regaddr <= PT_GPR15)) - collect_register (regno, buf + sizeof (long) - size); + collect_register (regcache, regno, buf + sizeof (long) - size); else - collect_register (regno, buf); + collect_register (regcache, regno, buf); /* When debugging a 32-bit inferior on a 64-bit host, make sure the 31-bit addressing mode bit is set in the PSW mask. */ @@ -137,7 +137,7 @@ s390_collect_ptrace_register (int regno, char *buf) } static void -s390_supply_ptrace_register (int regno, const char *buf) +s390_supply_ptrace_register (struct regcache *regcache, int regno, const char *buf) { int size = register_size (regno); if (size < sizeof (long)) @@ -152,18 +152,18 @@ s390_supply_ptrace_register (int regno, const char *buf) } else if (regaddr == PT_PSWADDR || (regaddr >= PT_GPR0 && regaddr <= PT_GPR15)) - supply_register (regno, buf + sizeof (long) - size); + supply_register (regcache, regno, buf + sizeof (long) - size); else - supply_register (regno, buf); + supply_register (regcache, regno, buf); } else - supply_register (regno, buf); + supply_register (regcache, regno, buf); } /* Provide only a fill function for the general register set. ps_lgetregs will use this for NPTL support. */ -static void s390_fill_gregset (void *buf) +static void s390_fill_gregset (struct regcache *regcache, void *buf) { int i; @@ -173,7 +173,7 @@ static void s390_fill_gregset (void *buf) || the_low_target.regmap[i] > PT_ACR15) continue; - s390_collect_ptrace_register (i, (char *) buf + s390_collect_ptrace_register (regcache, i, (char *) buf + the_low_target.regmap[i]); } } @@ -188,12 +188,12 @@ static const unsigned char s390_breakpoint[] = { 0, 1 }; #define s390_breakpoint_len 2 static CORE_ADDR -s390_get_pc () +s390_get_pc (struct regcache *regcache) { if (register_size (0) == 4) { unsigned int pc; - collect_register_by_name ("pswa", &pc); + collect_register_by_name (regcache, "pswa", &pc); #ifndef __s390x__ pc &= 0x7fffffff; #endif @@ -202,13 +202,13 @@ s390_get_pc () else { unsigned long pc; - collect_register_by_name ("pswa", &pc); + collect_register_by_name (regcache, "pswa", &pc); return pc; } } static void -s390_set_pc (CORE_ADDR newpc) +s390_set_pc (struct regcache *regcache, CORE_ADDR newpc) { if (register_size (0) == 4) { @@ -216,12 +216,12 @@ s390_set_pc (CORE_ADDR newpc) #ifndef __s390x__ pc |= 0x80000000; #endif - supply_register_by_name ("pswa", &pc); + supply_register_by_name (regcache, "pswa", &pc); } else { unsigned long pc = newpc; - supply_register_by_name ("pswa", &pc); + supply_register_by_name (regcache, "pswa", &pc); } } @@ -268,7 +268,8 @@ s390_arch_setup (void) #ifdef __s390x__ { unsigned int pswm; - collect_register_by_name ("pswm", &pswm); + struct regcache *regcache = get_thread_regcache (current_inferior, 1); + collect_register_by_name (regcache, "pswm", &pswm); if (pswm & 1) init_registers_s390x_linux64 (); diff --git a/gdb/gdbserver/linux-sh-low.c b/gdb/gdbserver/linux-sh-low.c index 769cab5..9d27e7f 100644 --- a/gdb/gdbserver/linux-sh-low.c +++ b/gdb/gdbserver/linux-sh-low.c @@ -59,18 +59,18 @@ sh_cannot_fetch_register (int regno) } static CORE_ADDR -sh_get_pc () +sh_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); return pc; } static void -sh_set_pc (CORE_ADDR pc) +sh_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } /* Correct in either endianness, obviously. */ @@ -94,13 +94,13 @@ sh_breakpoint_at (CORE_ADDR where) /* Provide only a fill function for the general register set. ps_lgetregs will use this for NPTL support. */ -static void sh_fill_gregset (void *buf) +static void sh_fill_gregset (struct regcache *regcache, void *buf) { int i; for (i = 0; i < 23; i++) if (sh_regmap[i] != -1) - collect_register (i, (char *) buf + sh_regmap[i]); + collect_register (regcache, i, (char *) buf + sh_regmap[i]); } struct regset_info target_regsets[] = { diff --git a/gdb/gdbserver/linux-sparc-low.c b/gdb/gdbserver/linux-sparc-low.c index 5c285bb..0bb5f2f 100644 --- a/gdb/gdbserver/linux-sparc-low.c +++ b/gdb/gdbserver/linux-sparc-low.c @@ -113,7 +113,7 @@ sparc_cannot_fetch_register (int regno) } static void -sparc_fill_gregset_to_stack (const void *buf) +sparc_fill_gregset_to_stack (struct regcache *regcache, const void *buf) { int i; CORE_ADDR addr = 0; @@ -128,14 +128,14 @@ sparc_fill_gregset_to_stack (const void *buf) for (i = l0_regno; i <= i7_regno; i++) { - collect_register (i, tmp_reg_buf); + collect_register (regcache, i, tmp_reg_buf); (*the_target->write_memory) (addr, tmp_reg_buf, sizeof(tmp_reg_buf)); addr += sizeof(tmp_reg_buf); } } static void -sparc_fill_gregset (void *buf) +sparc_fill_gregset (struct regcache *regcache, void *buf) { int i; int range; @@ -143,25 +143,25 @@ sparc_fill_gregset (void *buf) for (range = 0; range < N_GREGS_RANGES; range++) for (i = gregs_ranges[range].regno_start; i <= gregs_ranges[range].regno_end; i++) if (sparc_regmap[i] != -1) - collect_register (i, ((char *) buf) + sparc_regmap[i]); + collect_register (regcache, i, ((char *) buf) + sparc_regmap[i]); - sparc_fill_gregset_to_stack (buf); + sparc_fill_gregset_to_stack (regcache, buf); } static void -sparc_fill_fpregset (void *buf) +sparc_fill_fpregset (struct regcache *regcache, void *buf) { int i; int range; for (range = 0; range < N_FPREGS_RANGES; range++) for (i = fpregs_ranges[range].regno_start; i <= fpregs_ranges[range].regno_end; i++) - collect_register (i, ((char *) buf) + sparc_regmap[i]); + collect_register (regcache, i, ((char *) buf) + sparc_regmap[i]); } static void -sparc_store_gregset_from_stack (const void *buf) +sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf) { int i; CORE_ADDR addr = 0; @@ -177,13 +177,13 @@ sparc_store_gregset_from_stack (const void *buf) for (i = l0_regno; i <= i7_regno; i++) { (*the_target->read_memory) (addr, tmp_reg_buf, sizeof(tmp_reg_buf)); - supply_register (i, tmp_reg_buf); + supply_register (regcache, i, tmp_reg_buf); addr += sizeof(tmp_reg_buf); } } static void -sparc_store_gregset (const void *buf) +sparc_store_gregset (struct regcache *regcache, const void *buf) { int i; char zerobuf[8]; @@ -194,31 +194,33 @@ sparc_store_gregset (const void *buf) for (range = 0; range < N_GREGS_RANGES; range++) for (i = gregs_ranges[range].regno_start; i <= gregs_ranges[range].regno_end; i++) if (sparc_regmap[i] != -1) - supply_register (i, ((char *) buf) + sparc_regmap[i]); + supply_register (regcache, i, ((char *) buf) + sparc_regmap[i]); else - supply_register (i, zerobuf); + supply_register (regcache, i, zerobuf); - sparc_store_gregset_from_stack (buf); + sparc_store_gregset_from_stack (regcache, buf); } static void -sparc_store_fpregset (const void *buf) +sparc_store_fpregset (struct regcache *regcache, const void *buf) { int i; int range; for (range = 0; range < N_FPREGS_RANGES; range++) - for (i = fpregs_ranges[range].regno_start; i <= fpregs_ranges[range].regno_end; i++) - supply_register (i, ((char *) buf) + sparc_regmap[i]); + for (i = fpregs_ranges[range].regno_start; + i <= fpregs_ranges[range].regno_end; + i++) + supply_register (regcache, i, ((char *) buf) + sparc_regmap[i]); } extern int debug_threads; static CORE_ADDR -sparc_get_pc () +sparc_get_pc (struct regcache *regcache) { - CORE_ADDR pc; - collect_register_by_name ("pc", &pc); + unsigned long pc; + collect_register_by_name (regcache, "pc", &pc); if (debug_threads) fprintf (stderr, "stop pc is %08lx\n", pc); return pc; @@ -247,11 +249,12 @@ sparc_breakpoint_at (CORE_ADDR where) is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR -sparc_reinsert_addr () +sparc_reinsert_addr (void) { + struct regcache *regcache = get_thread_regcache (current_inferior, 1); CORE_ADDR lr; /* O7 is the equivalent to the 'lr' of other archs. */ - collect_register_by_name ("o7", &lr); + collect_register_by_name (regcache, "o7", &lr); return lr; } diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index e3060ba..0062432 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -173,7 +173,7 @@ i386_cannot_fetch_register (int regno) } static void -x86_fill_gregset (void *buf) +x86_fill_gregset (struct regcache *regcache, void *buf) { int i; @@ -182,19 +182,20 @@ x86_fill_gregset (void *buf) { for (i = 0; i < X86_64_NUM_REGS; i++) if (x86_64_regmap[i] != -1) - collect_register (i, ((char *) buf) + x86_64_regmap[i]); + collect_register (regcache, i, ((char *) buf) + x86_64_regmap[i]); return; } #endif for (i = 0; i < I386_NUM_REGS; i++) - collect_register (i, ((char *) buf) + i386_regmap[i]); + collect_register (regcache, i, ((char *) buf) + i386_regmap[i]); - collect_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); + collect_register_by_name (regcache, "orig_eax", + ((char *) buf) + ORIG_EAX * 4); } static void -x86_store_gregset (const void *buf) +x86_store_gregset (struct regcache *regcache, const void *buf) { int i; @@ -203,49 +204,50 @@ x86_store_gregset (const void *buf) { for (i = 0; i < X86_64_NUM_REGS; i++) if (x86_64_regmap[i] != -1) - supply_register (i, ((char *) buf) + x86_64_regmap[i]); + supply_register (regcache, i, ((char *) buf) + x86_64_regmap[i]); return; } #endif for (i = 0; i < I386_NUM_REGS; i++) - supply_register (i, ((char *) buf) + i386_regmap[i]); + supply_register (regcache, i, ((char *) buf) + i386_regmap[i]); - supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); + supply_register_by_name (regcache, "orig_eax", + ((char *) buf) + ORIG_EAX * 4); } static void -x86_fill_fpregset (void *buf) +x86_fill_fpregset (struct regcache *regcache, void *buf) { #ifdef __x86_64__ - i387_cache_to_fxsave (buf); + i387_cache_to_fxsave (regcache, buf); #else - i387_cache_to_fsave (buf); + i387_cache_to_fsave (regcache, buf); #endif } static void -x86_store_fpregset (const void *buf) +x86_store_fpregset (struct regcache *regcache, const void *buf) { #ifdef __x86_64__ - i387_fxsave_to_cache (buf); + i387_fxsave_to_cache (regcache, buf); #else - i387_fsave_to_cache (buf); + i387_fsave_to_cache (regcache, buf); #endif } #ifndef __x86_64__ static void -x86_fill_fpxregset (void *buf) +x86_fill_fpxregset (struct regcache *regcache, void *buf) { - i387_cache_to_fxsave (buf); + i387_cache_to_fxsave (regcache, buf); } static void -x86_store_fpxregset (const void *buf) +x86_store_fpxregset (struct regcache *regcache, const void *buf) { - i387_fxsave_to_cache (buf); + i387_fxsave_to_cache (regcache, buf); } #endif @@ -280,38 +282,38 @@ struct regset_info target_regsets[] = }; static CORE_ADDR -x86_get_pc (void) +x86_get_pc (struct regcache *regcache) { int use_64bit = register_size (0) == 8; if (use_64bit) { unsigned long pc; - collect_register_by_name ("rip", &pc); + collect_register_by_name (regcache, "rip", &pc); return (CORE_ADDR) pc; } else { unsigned int pc; - collect_register_by_name ("eip", &pc); + collect_register_by_name (regcache, "eip", &pc); return (CORE_ADDR) pc; } } static void -x86_set_pc (CORE_ADDR pc) +x86_set_pc (struct regcache *regcache, CORE_ADDR pc) { int use_64bit = register_size (0) == 8; if (use_64bit) { unsigned long newpc = pc; - supply_register_by_name ("rip", &newpc); + supply_register_by_name (regcache, "rip", &newpc); } else { unsigned int newpc = pc; - supply_register_by_name ("eip", &newpc); + supply_register_by_name (regcache, "eip", &newpc); } } diff --git a/gdb/gdbserver/linux-xtensa-low.c b/gdb/gdbserver/linux-xtensa-low.c index 460747c..c5ed351 100644 --- a/gdb/gdbserver/linux-xtensa-low.c +++ b/gdb/gdbserver/linux-xtensa-low.c @@ -37,7 +37,7 @@ enum regnum { }; static void -xtensa_fill_gregset (void *buf) +xtensa_fill_gregset (struct regcache *regcache, void *buf) { elf_greg_t* rset = (elf_greg_t*)buf; int ar0_regnum; @@ -51,27 +51,27 @@ xtensa_fill_gregset (void *buf) for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++) { - collect_register (i, ptr); + collect_register (regcache, i, ptr); ptr += register_size(i); } /* Loop registers, if hardware has it. */ #if XCHAL_HAVE_LOOP - collect_register_by_name ("lbeg", (char*)&rset[R_LBEG]); - collect_register_by_name ("lend", (char*)&rset[R_LEND]); - collect_register_by_name ("lcount", (char*)&rset[R_LCOUNT]); + collect_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]); + collect_register_by_name (regcache, "lend", (char*)&rset[R_LEND]); + collect_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]); #endif - collect_register_by_name ("sar", (char*)&rset[R_SAR]); - collect_register_by_name ("pc", (char*)&rset[R_PC]); - collect_register_by_name ("ps", (char*)&rset[R_PS]); - collect_register_by_name ("windowbase", (char*)&rset[R_WB]); - collect_register_by_name ("windowstart", (char*)&rset[R_WS]); + collect_register_by_name (regcache, "sar", (char*)&rset[R_SAR]); + collect_register_by_name (regcache, "pc", (char*)&rset[R_PC]); + collect_register_by_name (regcache, "ps", (char*)&rset[R_PS]); + collect_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]); + collect_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]); } static void -xtensa_store_gregset (const void *buf) +xtensa_store_gregset (struct regcache *regcache, const void *buf) { const elf_greg_t* rset = (const elf_greg_t*)buf; int ar0_regnum; @@ -85,47 +85,47 @@ xtensa_store_gregset (const void *buf) for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++) { - supply_register (i, ptr); + supply_register (regcache, i, ptr); ptr += register_size(i); } /* Loop registers, if hardware has it. */ #if XCHAL_HAVE_LOOP - supply_register_by_name ("lbeg", (char*)&rset[R_LBEG]); - supply_register_by_name ("lend", (char*)&rset[R_LEND]); - supply_register_by_name ("lcount", (char*)&rset[R_LCOUNT]); + supply_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]); + supply_register_by_name (regcache, "lend", (char*)&rset[R_LEND]); + supply_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]); #endif - supply_register_by_name ("sar", (char*)&rset[R_SAR]); - supply_register_by_name ("pc", (char*)&rset[R_PC]); - supply_register_by_name ("ps", (char*)&rset[R_PS]); - supply_register_by_name ("windowbase", (char*)&rset[R_WB]); - supply_register_by_name ("windowstart", (char*)&rset[R_WS]); + supply_register_by_name (regcache, "sar", (char*)&rset[R_SAR]); + supply_register_by_name (regcache, "pc", (char*)&rset[R_PC]); + supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]); + supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]); + supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]); } /* Xtensa GNU/Linux PTRACE interface includes extended register set. */ static void -xtensa_fill_xtregset (void *buf) +xtensa_fill_xtregset (struct regcache *regcache, void *buf) { const xtensa_regtable_t *ptr; for (ptr = xtensa_regmap_table; ptr->name; ptr++) { - collect_register_by_name (ptr->name, + collect_register_by_name (regcache, ptr->name, (char*)buf + ptr->ptrace_offset); } } static void -xtensa_store_xtregset (const void *buf) +xtensa_store_xtregset (struct regcache *regcache, const void *buf) { const xtensa_regtable_t *ptr; for (ptr = xtensa_regmap_table; ptr->name; ptr++) { - supply_register_by_name (ptr->name, + supply_register_by_name (regcache, ptr->name, (char*)buf + ptr->ptrace_offset); } } @@ -150,19 +150,19 @@ static const unsigned char xtensa_breakpoint[] = XTENSA_BREAKPOINT; #define xtensa_breakpoint_len 2 static CORE_ADDR -xtensa_get_pc (void) +xtensa_get_pc (struct regcache *regcache) { unsigned long pc; - collect_register_by_name ("pc", &pc); + collect_register_by_name (regcache, "pc", &pc); return pc; } static void -xtensa_set_pc (CORE_ADDR pc) +xtensa_set_pc (struct regcache *regcache, CORE_ADDR pc) { unsigned long newpc = pc; - supply_register_by_name ("pc", &newpc); + supply_register_by_name (regcache, "pc", &newpc); } static int diff --git a/gdb/gdbserver/nto-low.c b/gdb/gdbserver/nto-low.c index d82e951..89933b9 100644 --- a/gdb/gdbserver/nto-low.c +++ b/gdb/gdbserver/nto-low.c @@ -601,7 +601,7 @@ nto_wait (ptid_t ptid, If REGNO is -1, fetch all registers, or REGNO register only otherwise. */ static void -nto_fetch_registers (int regno) +nto_fetch_registers (struct regcache *regcache, int regno) { int regsize; procfs_greg greg; @@ -629,7 +629,7 @@ nto_fetch_registers (int regno) { const unsigned int registeroffset = the_low_target.register_offset (regno); - supply_register (regno, ((char *)&greg) + registeroffset); + supply_register (regcache, regno, ((char *)&greg) + registeroffset); } } else @@ -638,7 +638,7 @@ nto_fetch_registers (int regno) = the_low_target.register_offset (regno); if (registeroffset == -1) return; - supply_register (regno, ((char *)&greg) + registeroffset); + supply_register (regcache, regno, ((char *)&greg) + registeroffset); } } else @@ -649,7 +649,7 @@ nto_fetch_registers (int regno) We always store all registers, regardless of REGNO. */ static void -nto_store_registers (int regno) +nto_store_registers (struct regcache *regcache, int regno) { procfs_greg greg; int err; @@ -671,7 +671,7 @@ nto_store_registers (int regno) { const unsigned int regoffset = the_low_target.register_offset (regno); - collect_register (regno, ((char *)&greg) + regoffset); + collect_register (regcache, regno, ((char *)&greg) + regoffset); } err = devctl (nto_inferior.ctl_fd, DCMD_PROC_SETGREG, &greg, sizeof (greg), 0); diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c index 29d0514..3bb9194 100644 --- a/gdb/gdbserver/proc-service.c +++ b/gdb/gdbserver/proc-service.c @@ -101,6 +101,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) #ifdef HAVE_REGSETS struct lwp_info *lwp; struct thread_info *reg_inferior, *save_inferior; + struct regcache *regcache; lwp = find_lwp_pid (pid_to_ptid (lwpid)); if (lwp == NULL) @@ -109,9 +110,9 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) reg_inferior = get_lwp_thread (lwp); save_inferior = current_inferior; current_inferior = reg_inferior; - - the_target->fetch_registers (-1); - gregset_info ()->fill_function (gregset); + regcache = get_thread_regcache (current_inferior, 1); + the_target->fetch_registers (regcache, -1); + gregset_info ()->fill_function (regcache, gregset); current_inferior = save_inferior; return PS_OK; diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index 6ec6816..2082604 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -23,16 +23,6 @@ #include <stdlib.h> #include <string.h> -/* The private data for the register cache. Note that we have one - per inferior; this is primarily for simplicity, as the performance - benefit is minimal. */ - -struct inferior_regcache_data -{ - int registers_valid; - unsigned char *registers; -}; - static int register_bytes; static struct reg *reg_defs; @@ -40,20 +30,23 @@ static int num_registers; const char **gdbserver_expedite_regs; -static struct inferior_regcache_data * -get_regcache (struct thread_info *inf, int fetch) +struct regcache * +get_thread_regcache (struct thread_info *thread, int fetch) { - struct inferior_regcache_data *regcache; + struct regcache *regcache; - regcache = (struct inferior_regcache_data *) inferior_regcache_data (inf); + regcache = (struct regcache *) inferior_regcache_data (thread); if (regcache == NULL) fatal ("no register cache"); - /* FIXME - fetch registers for INF */ if (fetch && regcache->registers_valid == 0) { - fetch_inferior_registers (-1); + struct thread_info *saved_inferior = current_inferior; + + current_inferior = thread; + fetch_inferior_registers (regcache, -1); + current_inferior = saved_inferior; regcache->registers_valid = 1; } @@ -64,16 +57,16 @@ void regcache_invalidate_one (struct inferior_list_entry *entry) { struct thread_info *thread = (struct thread_info *) entry; - struct inferior_regcache_data *regcache; + struct regcache *regcache; - regcache = (struct inferior_regcache_data *) inferior_regcache_data (thread); + regcache = (struct regcache *) inferior_regcache_data (thread); if (regcache->registers_valid) { struct thread_info *saved_inferior = current_inferior; current_inferior = thread; - store_inferior_registers (-1); + store_inferior_registers (regcache, -1); current_inferior = saved_inferior; } @@ -81,24 +74,25 @@ regcache_invalidate_one (struct inferior_list_entry *entry) } void -regcache_invalidate () +regcache_invalidate (void) { for_each_inferior (&all_threads, regcache_invalidate_one); } -void * +struct regcache * new_register_cache (void) { - struct inferior_regcache_data *regcache; + struct regcache *regcache; if (register_bytes == 0) return NULL; /* The architecture hasn't been initialized yet. */ regcache = xmalloc (sizeof (*regcache)); - /* Make sure to zero-initialize the register cache when it is created, - in case there are registers the target never fetches. This way they'll - read as zero instead of garbage. */ + /* Make sure to zero-initialize the register cache when it is + created, in case there are registers the target never + fetches. This way they'll read as zero instead of + garbage. */ regcache->registers = xcalloc (1, register_bytes); regcache->registers_valid = 0; @@ -107,11 +101,8 @@ new_register_cache (void) } void -free_register_cache (void *regcache_p) +free_register_cache (struct regcache *regcache) { - struct inferior_regcache_data *regcache - = (struct inferior_regcache_data *) regcache_p; - if (regcache) { free (regcache->registers); @@ -123,8 +114,10 @@ static void realloc_register_cache (struct inferior_list_entry *thread_p) { struct thread_info *thread = (struct thread_info *) thread_p; + struct regcache *regcache + = (struct regcache *) inferior_regcache_data (thread); - free_register_cache (inferior_regcache_data (thread)); + free_register_cache (regcache); set_inferior_regcache_data (thread, new_register_cache ()); } @@ -154,18 +147,18 @@ set_register_cache (struct reg *regs, int n) } void -registers_to_string (char *buf) +registers_to_string (struct regcache *regcache, char *buf) { - unsigned char *registers = get_regcache (current_inferior, 1)->registers; + unsigned char *registers = regcache->registers; convert_int_to_ascii (registers, buf, register_bytes); } void -registers_from_string (char *buf) +registers_from_string (struct regcache *regcache, char *buf) { int len = strlen (buf); - unsigned char *registers = get_regcache (current_inferior, 1)->registers; + unsigned char *registers = regcache->registers; if (len != register_bytes * 2) { @@ -214,40 +207,40 @@ register_size (int n) } static unsigned char * -register_data (int n, int fetch) +register_data (struct regcache *regcache, int n, int fetch) { - unsigned char *registers - = get_regcache (current_inferior, fetch)->registers; - - return registers + (reg_defs[n].offset / 8); + return regcache->registers + (reg_defs[n].offset / 8); } void -supply_register (int n, const void *buf) +supply_register (struct regcache *regcache, int n, const void *buf) { - memcpy (register_data (n, 0), buf, register_size (n)); + memcpy (register_data (regcache, n, 0), buf, register_size (n)); } void -supply_register_by_name (const char *name, const void *buf) +supply_register_by_name (struct regcache *regcache, + const char *name, const void *buf) { - supply_register (find_regno (name), buf); + supply_register (regcache, find_regno (name), buf); } void -collect_register (int n, void *buf) +collect_register (struct regcache *regcache, int n, void *buf) { - memcpy (buf, register_data (n, 1), register_size (n)); + memcpy (buf, register_data (regcache, n, 1), register_size (n)); } void -collect_register_as_string (int n, char *buf) +collect_register_as_string (struct regcache *regcache, int n, char *buf) { - convert_int_to_ascii (register_data (n, 1), buf, register_size (n)); + convert_int_to_ascii (register_data (regcache, n, 1), + buf, register_size (n)); } void -collect_register_by_name (const char *name, void *buf) +collect_register_by_name (struct regcache *regcache, + const char *name, void *buf) { - collect_register (find_regno (name), buf); + collect_register (regcache, find_regno (name), buf); } diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h index 2f5f82a..6aa001f 100644 --- a/gdb/gdbserver/regcache.h +++ b/gdb/gdbserver/regcache.h @@ -21,14 +21,27 @@ #define REGCACHE_H struct inferior_list_entry; +struct thread_info; + +/* The data for the register cache. Note that we have one per + inferior; this is primarily for simplicity, as the performance + benefit is minimal. */ + +struct regcache +{ + int registers_valid; + unsigned char *registers; +}; /* Create a new register cache for INFERIOR. */ -void *new_register_cache (void); +struct regcache *new_register_cache (void); + +struct regcache *get_thread_regcache (struct thread_info *thread, int fetch); /* Release all memory associated with the register cache for INFERIOR. */ -void free_register_cache (void *regcache); +void free_register_cache (struct regcache *regcache); /* Invalidate cached registers for one or all threads. */ @@ -38,11 +51,11 @@ void regcache_invalidate (void); /* Convert all registers to a string in the currently specified remote format. */ -void registers_to_string (char *buf); +void registers_to_string (struct regcache *regcache, char *buf); /* Convert a string to register values and fill our register cache. */ -void registers_from_string (char *buf); +void registers_from_string (struct regcache *regcache, char *buf); /* Return a pointer to the description of register ``n''. */ @@ -57,14 +70,15 @@ int find_regno (const char *name); extern const char **gdbserver_expedite_regs; extern const char *gdbserver_xmltarget; -void supply_register (int n, const void *buf); +void supply_register (struct regcache *regcache, int n, const void *buf); -void supply_register_by_name (const char *name, const void *buf); +void supply_register_by_name (struct regcache *regcache, + const char *name, const void *buf); -void collect_register (int n, void *buf); +void collect_register (struct regcache *regcache, int n, void *buf); -void collect_register_as_string (int n, char *buf); +void collect_register_as_string (struct regcache *regcache, int n, char *buf); -void collect_register_by_name (const char *name, void *buf); +void collect_register_by_name (struct regcache *regcache, const char *name, void *buf); #endif /* REGCACHE_H */ diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 76953ae..7cd1e2d 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -1053,7 +1053,7 @@ convert_ascii_to_int (char *from, unsigned char *to, int n) } static char * -outreg (int regno, char *buf) +outreg (struct regcache *regcache, int regno, char *buf) { if ((regno >> 12) != 0) *buf++ = tohex ((regno >> 12) & 0xf); @@ -1062,7 +1062,7 @@ outreg (int regno, char *buf) *buf++ = tohex ((regno >> 4) & 0xf); *buf++ = tohex (regno & 0xf); *buf++ = ':'; - collect_register_as_string (regno, buf); + collect_register_as_string (regcache, regno, buf); buf += 2 * register_size (regno); *buf++ = ';'; @@ -1116,6 +1116,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, { struct thread_info *saved_inferior; const char **regp; + struct regcache *regcache; sprintf (buf, "T%02x", status->value.sig); buf += strlen (buf); @@ -1126,6 +1127,8 @@ prepare_resume_reply (char *buf, ptid_t ptid, current_inferior = find_thread_ptid (ptid); + regcache = get_thread_regcache (current_inferior, 1); + if (the_target->stopped_by_watchpoint != NULL && (*the_target->stopped_by_watchpoint) ()) { @@ -1148,7 +1151,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, while (*regp) { - buf = outreg (find_regno (*regp), buf); + buf = outreg (regcache, find_regno (*regp), buf); regp ++; } *buf = '\0'; diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index c781552..a03f877 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -2456,15 +2456,25 @@ process_serial_event (void) } break; case 'g': - require_running (own_buf); - set_desired_inferior (1); - registers_to_string (own_buf); + { + struct regcache *regcache; + + require_running (own_buf); + set_desired_inferior (1); + regcache = get_thread_regcache (current_inferior, 1); + registers_to_string (regcache, own_buf); + } break; case 'G': - require_running (own_buf); - set_desired_inferior (1); - registers_from_string (&own_buf[1]); - write_ok (own_buf); + { + struct regcache *regcache; + + require_running (own_buf); + set_desired_inferior (1); + regcache = get_thread_regcache (current_inferior, 1); + registers_from_string (regcache, &own_buf[1]); + write_ok (own_buf); + } break; case 'm': require_running (own_buf); diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 0c761e9..ac68652 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -166,13 +166,13 @@ struct target_ops If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ - void (*fetch_registers) (int regno); + void (*fetch_registers) (struct regcache *regcache, int regno); /* Store registers to the inferior process. If REGNO is -1, store all registers; otherwise, store at least REGNO. */ - void (*store_registers) (int regno); + void (*store_registers) (struct regcache *regcache, int regno); /* Read memory from the inferior process. This should generally be called through read_inferior_memory, which handles breakpoint shadowing. @@ -307,11 +307,11 @@ void set_target_ops (struct target_ops *); #define mythread_alive(pid) \ (*the_target->thread_alive) (pid) -#define fetch_inferior_registers(regno) \ - (*the_target->fetch_registers) (regno) +#define fetch_inferior_registers(regcache, regno) \ + (*the_target->fetch_registers) (regcache, regno) -#define store_inferior_registers(regno) \ - (*the_target->store_registers) (regno) +#define store_inferior_registers(regcache, regno) \ + (*the_target->store_registers) (regcache, regno) #define join_inferior(pid) \ (*the_target->join) (pid) diff --git a/gdb/gdbserver/win32-arm-low.c b/gdb/gdbserver/win32-arm-low.c index 23d7022..332846d 100644 --- a/gdb/gdbserver/win32-arm-low.c +++ b/gdb/gdbserver/win32-arm-low.c @@ -93,17 +93,19 @@ regptr (CONTEXT* c, int r) /* Fetch register from gdbserver regcache data. */ static void -arm_fetch_inferior_register (win32_thread_info *th, int r) +arm_fetch_inferior_register (struct regcache *regcache, + win32_thread_info *th, int r) { char *context_offset = regptr (&th->context, r); - supply_register (r, context_offset); + supply_register (regcache, r, context_offset); } /* Store a new register value into the thread context of TH. */ static void -arm_store_inferior_register (win32_thread_info *th, int r) +arm_store_inferior_register (struct regcache *regcache, + win32_thread_info *th, int r) { - collect_register (r, regptr (&th->context, r)); + collect_register (regcache, r, regptr (&th->context, r)); } /* Correct in either endianness. We do not support Thumb yet. */ diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index a976398..bd146b9 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -271,7 +271,8 @@ static const int mappings[] = { /* Fetch register from gdbserver regcache data. */ static void -i386_fetch_inferior_register (win32_thread_info *th, int r) +i386_fetch_inferior_register (struct regcache *regcache, + win32_thread_info *th, int r) { char *context_offset = (char *) &th->context + mappings[r]; @@ -279,23 +280,24 @@ i386_fetch_inferior_register (win32_thread_info *th, int r) if (r == FCS_REGNUM) { l = *((long *) context_offset) & 0xffff; - supply_register (r, (char *) &l); + supply_register (regcache, r, (char *) &l); } else if (r == FOP_REGNUM) { l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1); - supply_register (r, (char *) &l); + supply_register (regcache, r, (char *) &l); } else - supply_register (r, context_offset); + supply_register (regcache, r, context_offset); } /* Store a new register value into the thread context of TH. */ static void -i386_store_inferior_register (win32_thread_info *th, int r) +i386_store_inferior_register (struct regcache *regcache, + win32_thread_info *th, int r) { char *context_offset = (char *) &th->context + mappings[r]; - collect_register (r, context_offset); + collect_register (regcache, r, context_offset); } static const unsigned char i386_win32_breakpoint = 0xcc; diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 3d738b1..904d614 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -372,29 +372,29 @@ child_continue (DWORD continue_status, int thread_id) /* Fetch register(s) from the current thread context. */ static void -child_fetch_inferior_registers (int r) +child_fetch_inferior_registers (struct regcache *regcache, int r) { int regno; win32_thread_info *th = thread_rec (current_inferior_ptid (), TRUE); if (r == -1 || r > NUM_REGS) - child_fetch_inferior_registers (NUM_REGS); + child_fetch_inferior_registers (regcache, NUM_REGS); else for (regno = 0; regno < r; regno++) - (*the_low_target.fetch_inferior_register) (th, regno); + (*the_low_target.fetch_inferior_register) (regcache, th, regno); } /* Store a new register value into the current thread context. We don't change the program's context until later, when we resume it. */ static void -child_store_inferior_registers (int r) +child_store_inferior_registers (struct regcache *regcache, int r) { int regno; win32_thread_info *th = thread_rec (current_inferior_ptid (), TRUE); if (r == -1 || r == 0 || r > NUM_REGS) - child_store_inferior_registers (NUM_REGS); + child_store_inferior_registers (regcache, NUM_REGS); else for (regno = 0; regno < r; regno++) - (*the_low_target.store_inferior_register) (th, regno); + (*the_low_target.store_inferior_register) (regcache, th, regno); } /* Map the Windows error number in ERROR to a locale-dependent error @@ -1569,6 +1569,7 @@ static ptid_t win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) { struct process_info *process; + struct regcache *regcache; while (1) { @@ -1590,7 +1591,8 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) OUTMSG2 (("Child Stopped with signal = %d \n", ourstatus->value.sig)); - child_fetch_inferior_registers (-1); + regcache = get_thread_regcache (current_inferior, 1); + child_fetch_inferior_registers (regcache, -1); if (ourstatus->kind == TARGET_WAITKIND_LOADED && !server_waiting) @@ -1622,17 +1624,17 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) /* Fetch registers from the inferior process. If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ static void -win32_fetch_inferior_registers (int regno) +win32_fetch_inferior_registers (struct regcache *regcache, int regno) { - child_fetch_inferior_registers (regno); + child_fetch_inferior_registers (regcache, regno); } /* Store registers to the inferior process. If REGNO is -1, store all registers; otherwise, store at least REGNO. */ static void -win32_store_inferior_registers (int regno) +win32_store_inferior_registers (struct regcache *regcache, int regno) { - child_store_inferior_registers (regno); + child_store_inferior_registers (regcache, regno); } /* Read memory from the inferior process. This should generally be diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h index c47f698..d5ddf16 100644 --- a/gdb/gdbserver/win32-low.h +++ b/gdb/gdbserver/win32-low.h @@ -61,10 +61,12 @@ struct win32_target_ops void (*thread_added) (win32_thread_info *th); /* Fetch register from gdbserver regcache data. */ - void (*fetch_inferior_register) (win32_thread_info *th, int r); + void (*fetch_inferior_register) (struct regcache *regcache, + win32_thread_info *th, int r); /* Store a new register value into the thread context of TH. */ - void (*store_inferior_register) (win32_thread_info *th, int r); + void (*store_inferior_register) (struct regcache *regcache, + win32_thread_info *th, int r); void (*single_step) (win32_thread_info *th); |