2007-10-08 Markus Deuling <deuling@de.ibm.com>

* ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write):
	Replace current_gdbarch by gdbarch.
	* ia64-tdep.c (ia64_frame_prev_register
	(ia64_sigtramp_frame_prev_register)
	(ia64_libunwind_frame_prev_register): Use get_regcache_arch or
	get_frame_arch to get at the current architecture by regcache or by
	frame, respectively.
	* ia64-linux-nat.c (ia64_linux_fetch_register)
	(ia64_linux_fetch_registers, ia64_linux_store_register)
	(ia64_linux_store_registers): Likewise.
This commit is contained in:
Ulrich Weigand 2007-10-08 12:51:54 +00:00
parent 464963c92c
commit 088568da7d
3 changed files with 62 additions and 40 deletions

View File

@ -1,3 +1,16 @@
2007-10-08 Markus Deuling <deuling@de.ibm.com>
* ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write):
Replace current_gdbarch by gdbarch.
* ia64-tdep.c (ia64_frame_prev_register
(ia64_sigtramp_frame_prev_register)
(ia64_libunwind_frame_prev_register): Use get_regcache_arch or
get_frame_arch to get at the current architecture by regcache or by
frame, respectively.
* ia64-linux-nat.c (ia64_linux_fetch_register)
(ia64_linux_fetch_registers, ia64_linux_store_register)
(ia64_linux_store_registers): Likewise.
2007-10-08 Markus Deuling <deuling@de.ibm.com>
* hppa-tdep.c (hppa_stub_unwind_sniffer, hppa_dump_tdep): Replace

View File

@ -674,6 +674,7 @@ ia64_linux_can_use_hw_breakpoint (int type, int cnt, int othertype)
static void
ia64_linux_fetch_register (struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
@ -693,7 +694,7 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (regnum);
size = register_size (current_gdbarch, regnum);
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
buf = alloca (size);
@ -705,7 +706,7 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0);
if (errno != 0)
error (_("Couldn't read register %s (#%d): %s."),
gdbarch_register_name (current_gdbarch, regnum),
gdbarch_register_name (gdbarch, regnum),
regnum, safe_strerror (errno));
addr += sizeof (PTRACE_TYPE_RET);
@ -720,7 +721,9 @@ static void
ia64_linux_fetch_registers (struct regcache *regcache, int regnum)
{
if (regnum == -1)
for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
ia64_linux_fetch_register (regcache, regnum);
else
ia64_linux_fetch_register (regcache, regnum);
@ -731,6 +734,7 @@ ia64_linux_fetch_registers (struct regcache *regcache, int regnum)
static void
ia64_linux_store_register (const struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
@ -747,7 +751,7 @@ ia64_linux_store_register (const struct regcache *regcache, int regnum)
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (regnum);
size = register_size (current_gdbarch, regnum);
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
buf = alloca (size);
@ -760,7 +764,7 @@ ia64_linux_store_register (const struct regcache *regcache, int regnum)
ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]);
if (errno != 0)
error (_("Couldn't write register %s (#%d): %s."),
gdbarch_register_name (current_gdbarch, regnum),
gdbarch_register_name (gdbarch, regnum),
regnum, safe_strerror (errno));
addr += sizeof (PTRACE_TYPE_RET);
@ -774,7 +778,9 @@ static void
ia64_linux_store_registers (struct regcache *regcache, int regnum)
{
if (regnum == -1)
for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
ia64_linux_store_register (regcache, regnum);
else
ia64_linux_store_register (regcache, regnum);

View File

@ -715,10 +715,10 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
{
ULONGEST reg_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
reg = read_memory_integer ((CORE_ADDR)reg_addr, 8);
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), reg);
store_unsigned_integer (buf, register_size (gdbarch, regnum), reg);
}
else
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), 0);
store_unsigned_integer (buf, register_size (gdbarch, regnum), 0);
}
}
else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
@ -727,7 +727,7 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
ULONGEST unat;
regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0;
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), unatN_val);
store_unsigned_integer (buf, register_size (gdbarch, regnum), unatN_val);
}
else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
{
@ -762,7 +762,7 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
natN_val = (nat_collection >> nat_bit) & 1;
}
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), natN_val);
store_unsigned_integer (buf, register_size (gdbarch, regnum), natN_val);
}
else if (regnum == VBOF_REGNUM)
{
@ -777,7 +777,7 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
/* The bsp points at the end of the register frame so we
subtract the size of frame from it to get beginning of frame. */
vbsp = rse_address_add (bsp, -(cfm & 0x7f));
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), vbsp);
store_unsigned_integer (buf, register_size (gdbarch, regnum), vbsp);
}
else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
{
@ -799,10 +799,10 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ ((regnum - VP16_REGNUM) + rrb_pr) % 48;
}
prN_val = (pr & (1LL << (regnum - VP0_REGNUM))) != 0;
store_unsigned_integer (buf, register_size (current_gdbarch, regnum), prN_val);
store_unsigned_integer (buf, register_size (gdbarch, regnum), prN_val);
}
else
memset (buf, 0, register_size (current_gdbarch, regnum));
memset (buf, 0, register_size (gdbarch, regnum));
}
static void
@ -829,7 +829,7 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
{
ULONGEST unatN_val, unat, unatN_mask;
regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
unatN_val = extract_unsigned_integer (buf, register_size (current_gdbarch, regnum));
unatN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
unatN_mask = (1LL << (regnum - IA64_NAT0_REGNUM));
if (unatN_val == 0)
unat &= ~unatN_mask;
@ -853,7 +853,7 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
if ((cfm & 0x7f) > regnum - V32_REGNUM)
gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
natN_val = extract_unsigned_integer (buf, register_size (current_gdbarch, regnum));
natN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
if (gr_addr != 0 && (natN_val == 0 || natN_val == 1))
{
@ -882,7 +882,7 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
nat_collection |= natN_mask;
else
nat_collection &= ~natN_mask;
store_unsigned_integer (nat_buf, register_size (current_gdbarch, regnum), nat_collection);
store_unsigned_integer (nat_buf, register_size (gdbarch, regnum), nat_collection);
write_memory (nat_addr, nat_buf, 8);
}
}
@ -907,7 +907,7 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
regnum = VP16_REGNUM
+ ((regnum - VP16_REGNUM) + rrb_pr) % 48;
}
prN_val = extract_unsigned_integer (buf, register_size (current_gdbarch, regnum));
prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
prN_mask = (1LL << (regnum - VP0_REGNUM));
if (prN_val == 0)
pr &= ~prN_mask;
@ -1600,6 +1600,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
enum lval_type *lvalp, CORE_ADDR *addrp,
int *realnump, gdb_byte *valuep)
{
struct gdbarch *gdbarch = get_frame_arch (next_frame);
struct ia64_frame_cache *cache =
ia64_frame_cache (next_frame, this_cache);
char dummy_valp[MAX_REGISTER_SIZE];
@ -1620,12 +1621,12 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
if (!valuep)
valuep = dummy_valp;
memset (valuep, 0, register_size (current_gdbarch, regnum));
memset (valuep, 0, register_size (gdbarch, regnum));
if (regnum == gdbarch_sp_regnum (current_gdbarch))
if (regnum == gdbarch_sp_regnum (gdbarch))
{
/* Handle SP values for all frames but the topmost. */
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum),
store_unsigned_integer (valuep, register_size (gdbarch, regnum),
cache->base);
}
else if (regnum == IA64_BSP_REGNUM)
@ -1650,7 +1651,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
bsp = rse_address_add (cache->bsp, -(cache->sof));
prev_bsp = rse_address_add (bsp, (prev_cfm & 0x7f) - ((prev_cfm >> 7) & 0x7f));
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum),
store_unsigned_integer (valuep, register_size (gdbarch, regnum),
prev_bsp);
}
else if (regnum == IA64_CFM_REGNUM)
@ -1661,10 +1662,10 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
else if (cache->prev_cfm)
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum), cache->prev_cfm);
store_unsigned_integer (valuep, register_size (gdbarch, regnum), cache->prev_cfm);
else if (cache->frameless)
{
CORE_ADDR cfm = 0;
@ -1678,7 +1679,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
above. If the function lacks one of these frame pointers, we can
still provide a value since we know the size of the frame. */
CORE_ADDR vfp = cache->base;
store_unsigned_integer (valuep, register_size (current_gdbarch, IA64_VFP_REGNUM), vfp);
store_unsigned_integer (valuep, register_size (gdbarch, IA64_VFP_REGNUM), vfp);
}
else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
{
@ -1702,7 +1703,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
}
prN_val = extract_bit_field ((unsigned char *) pr_valuep,
regnum - VP0_REGNUM, 1);
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum), prN_val);
store_unsigned_integer (valuep, register_size (gdbarch, regnum), prN_val);
}
else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
{
@ -1716,7 +1717,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
&unat_optim, &unat_lval, &unat_addr, &unat_realnum, unat_valuep);
unatN_val = extract_bit_field ((unsigned char *) unat_valuep,
regnum - IA64_NAT0_REGNUM, 1);
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum),
store_unsigned_integer (valuep, register_size (gdbarch, regnum),
unatN_val);
}
else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
@ -1751,7 +1752,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
natval = (nat_collection >> nat_bit) & 1;
}
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum), natval);
store_unsigned_integer (valuep, register_size (gdbarch, regnum), natval);
}
else if (regnum == IA64_IP_REGNUM)
{
@ -1762,7 +1763,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, buf, register_size (current_gdbarch, IA64_IP_REGNUM));
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
pc = extract_unsigned_integer (buf, 8);
}
else if (cache->frameless)
@ -1791,7 +1792,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, buf, register_size (current_gdbarch, IA64_IP_REGNUM));
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
pc = extract_unsigned_integer (buf, 8);
}
else if (cache->frameless)
@ -1813,7 +1814,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, buf, register_size (current_gdbarch, IA64_BR0_REGNUM));
read_memory (addr, buf, register_size (gdbarch, IA64_BR0_REGNUM));
br0 = extract_unsigned_integer (buf, 8);
}
store_unsigned_integer (valuep, 8, br0);
@ -1829,7 +1830,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
else if (cache->frameless)
{
@ -1853,7 +1854,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM));
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
}
else
@ -1877,7 +1878,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
/* Otherwise, punt and get the current value of the register. */
else
@ -2003,6 +2004,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *next_frame,
char dummy_valp[MAX_REGISTER_SIZE];
char buf[MAX_REGISTER_SIZE];
struct gdbarch *gdbarch = get_frame_arch (next_frame);
struct ia64_frame_cache *cache =
ia64_sigtramp_frame_cache (next_frame, this_cache);
@ -2021,7 +2023,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *next_frame,
if (!valuep)
valuep = dummy_valp;
memset (valuep, 0, register_size (current_gdbarch, regnum));
memset (valuep, 0, register_size (gdbarch, regnum));
if (regnum == IA64_IP_REGNUM)
{
@ -2032,7 +2034,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *next_frame,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, buf, register_size (current_gdbarch, IA64_IP_REGNUM));
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
pc = extract_unsigned_integer (buf, 8);
}
pc &= ~0xf;
@ -2049,7 +2051,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *next_frame,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
}
else
@ -2060,7 +2062,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *next_frame,
{
*lvalp = lval_memory;
*addrp = addr;
read_memory (addr, valuep, register_size (current_gdbarch, regnum));
read_memory (addr, valuep, register_size (gdbarch, regnum));
}
}
@ -2701,6 +2703,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *next_frame,
{
int reg = regnum;
struct gdbarch *gdbarch = get_frame_arch (next_frame);
if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
reg = IA64_PR_REGNUM;
else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
@ -2736,7 +2739,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *next_frame,
}
prN_val = extract_bit_field ((unsigned char *) valuep,
regnum - VP0_REGNUM, 1);
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum), prN_val);
store_unsigned_integer (valuep, register_size (gdbarch, regnum), prN_val);
}
else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
{
@ -2744,7 +2747,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *next_frame,
unatN_val = extract_bit_field ((unsigned char *) valuep,
regnum - IA64_NAT0_REGNUM, 1);
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum),
store_unsigned_integer (valuep, register_size (gdbarch, regnum),
unatN_val);
}
else if (regnum == IA64_BSP_REGNUM)
@ -2766,7 +2769,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *next_frame,
prev_cfm = extract_unsigned_integer (cfm_valuep, 8);
prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f));
store_unsigned_integer (valuep, register_size (current_gdbarch, regnum),
store_unsigned_integer (valuep, register_size (gdbarch, regnum),
prev_bsp);
}