This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
PATCH: Fix MT MAC register access
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 11 Apr 2006 20:26:10 -0700
- Subject: PATCH: Fix MT MAC register access
- Reply-to: mark at codesourcery dot com
The MT port has a per-coprocessor pseudo-register for the MAC
register, which is formed by combining the original and extended MAC
registers. However, when asked for the MAC pseudo-register, we were
accessing the coprocessor number pseudo-register instead.
This patch makes us access the right register, and by avoiding the
confusing "MT_COPRO_PSEUDOREG_REGS - 1" way of saying "the
per-coprocessor MAC pseudo-register" makes the code a bit more
straightforward.
OK to apply?
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2006-04-11 Mark Mitchell <mark@codesourcery.com>
* mt-tdep.c (mt_gdb_regnums): Define
MT_COPRO_PSEUDOREG_MAC_REGNUM.
(mt_register_name): Use it.
(mt_copro_register_type): Likewise.
(mt_register_type): Likewise.
(mt_pseudo_register_read): Likewise. Read the MAC register, not
the coprocessor register.
(mt_pseudo_register_write): Likewise.
Index: gdb/mt-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mt-tdep.c,v
retrieving revision 1.4
diff -c -5 -p -r1.4 mt-tdep.c
*** gdb/mt-tdep.c 16 Jan 2006 13:23:15 -0000 1.4
--- gdb/mt-tdep.c 12 Apr 2006 03:21:26 -0000
*************** enum mt_gdb_regnums
*** 118,128 ****
MT_MAC_PSEUDOREG_REGNUM,
MT_COPRO_PSEUDOREG_ARRAY,
MT_COPRO_PSEUDOREG_DIM_1 = 2,
MT_COPRO_PSEUDOREG_DIM_2 = 8,
! MT_COPRO_PSEUDOREG_REGS = 32,
/* Two pseudo-regs ('coprocessor' and 'mac'). */
MT_NUM_PSEUDO_REGS = 2 + (MT_COPRO_PSEUDOREG_REGS
* MT_COPRO_PSEUDOREG_DIM_1
* MT_COPRO_PSEUDOREG_DIM_2)
--- 118,133 ----
MT_MAC_PSEUDOREG_REGNUM,
MT_COPRO_PSEUDOREG_ARRAY,
MT_COPRO_PSEUDOREG_DIM_1 = 2,
MT_COPRO_PSEUDOREG_DIM_2 = 8,
! /* The number of pseudo-registers for each coprocessor. These
! include the real coprocessor registers, the pseudo-registe for
! the coprocessor number, and the pseudo-register for the MAC. */
! MT_COPRO_PSEUDOREG_REGS = MT_NUM_REGS - MT_NUM_CPU_REGS + 2,
! /* The register number of the MAC, relative to a given coprocessor. */
! MT_COPRO_PSEUDOREG_MAC_REGNUM = MT_COPRO_PSEUDOREG_REGS - 1,
/* Two pseudo-regs ('coprocessor' and 'mac'). */
MT_NUM_PSEUDO_REGS = 2 + (MT_COPRO_PSEUDOREG_REGS
* MT_COPRO_PSEUDOREG_DIM_1
* MT_COPRO_PSEUDOREG_DIM_2)
*************** mt_register_name (int regnum)
*** 169,179 ****
index = regnum % MT_COPRO_PSEUDOREG_REGS;
dim_2 = (regnum / MT_COPRO_PSEUDOREG_REGS) % MT_COPRO_PSEUDOREG_DIM_2;
dim_1 = ((regnum / MT_COPRO_PSEUDOREG_REGS / MT_COPRO_PSEUDOREG_DIM_2)
% MT_COPRO_PSEUDOREG_DIM_1);
! if (index == MT_COPRO_PSEUDOREG_REGS - 1)
stub = register_names[MT_MAC_PSEUDOREG_REGNUM];
else if (index > MT_QCHANNEL_REGNUM - MT_CPR0_REGNUM)
stub = "";
else
stub = register_names[index + MT_CPR0_REGNUM];
--- 174,184 ----
index = regnum % MT_COPRO_PSEUDOREG_REGS;
dim_2 = (regnum / MT_COPRO_PSEUDOREG_REGS) % MT_COPRO_PSEUDOREG_DIM_2;
dim_1 = ((regnum / MT_COPRO_PSEUDOREG_REGS / MT_COPRO_PSEUDOREG_DIM_2)
% MT_COPRO_PSEUDOREG_DIM_1);
! if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
stub = register_names[MT_MAC_PSEUDOREG_REGNUM];
else if (index > MT_QCHANNEL_REGNUM - MT_CPR0_REGNUM)
stub = "";
else
stub = register_names[index + MT_CPR0_REGNUM];
*************** mt_copro_register_type (struct gdbarch *
*** 217,227 ****
case MT_FLAG_REGNUM:
return builtin_type_unsigned_char;
default:
if (regnum >= MT_CPR0_REGNUM && regnum <= MT_CPR15_REGNUM)
return builtin_type_int16;
! else if (regnum == MT_CPR0_REGNUM + MT_COPRO_PSEUDOREG_REGS - 1)
{
if (gdbarch_bfd_arch_info (arch)->mach == bfd_mach_mrisc2
|| gdbarch_bfd_arch_info (arch)->mach == bfd_mach_ms2)
return builtin_type_uint64;
else
--- 222,232 ----
case MT_FLAG_REGNUM:
return builtin_type_unsigned_char;
default:
if (regnum >= MT_CPR0_REGNUM && regnum <= MT_CPR15_REGNUM)
return builtin_type_int16;
! else if (regnum == MT_CPR0_REGNUM + MT_COPRO_PSEUDOREG_MAC_REGNUM)
{
if (gdbarch_bfd_arch_info (arch)->mach == bfd_mach_mrisc2
|| gdbarch_bfd_arch_info (arch)->mach == bfd_mach_ms2)
return builtin_type_uint64;
else
*************** mt_register_type (struct gdbarch *arch,
*** 267,277 ****
case MT_COPRO_PSEUDOREG_REGNUM:
return copro_type;
case MT_MAC_PSEUDOREG_REGNUM:
return mt_copro_register_type (arch,
MT_CPR0_REGNUM
! + MT_COPRO_PSEUDOREG_REGS - 1);
default:
if (regnum >= MT_R0_REGNUM && regnum <= MT_R15_REGNUM)
return builtin_type_int32;
else if (regnum < MT_COPRO_PSEUDOREG_ARRAY)
return mt_copro_register_type (arch, regnum);
--- 272,282 ----
case MT_COPRO_PSEUDOREG_REGNUM:
return copro_type;
case MT_MAC_PSEUDOREG_REGNUM:
return mt_copro_register_type (arch,
MT_CPR0_REGNUM
! + MT_COPRO_PSEUDOREG_MAC_REGNUM);
default:
if (regnum >= MT_R0_REGNUM && regnum <= MT_R15_REGNUM)
return builtin_type_int32;
else if (regnum < MT_COPRO_PSEUDOREG_ARRAY)
return mt_copro_register_type (arch, regnum);
*************** mt_pseudo_register_read (struct gdbarch
*** 528,540 ****
break;
default:
{
unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
! if (index == MT_COPRO_PSEUDOREG_REGS - 1)
mt_pseudo_register_read (gdbarch, regcache,
! MT_COPRO_PSEUDOREG_REGNUM, buf);
else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
regcache_raw_read (regcache, index + MT_CPR0_REGNUM, buf);
}
break;
}
--- 533,545 ----
break;
default:
{
unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
! if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
mt_pseudo_register_read (gdbarch, regcache,
! MT_MAC_PSEUDOREG_REGNUM, buf);
else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
regcache_raw_read (regcache, index + MT_CPR0_REGNUM, buf);
}
break;
}
*************** mt_pseudo_register_write (struct gdbarch
*** 582,594 ****
break;
default:
{
unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
! if (index == MT_COPRO_PSEUDOREG_REGS - 1)
mt_pseudo_register_write (gdbarch, regcache,
! MT_COPRO_PSEUDOREG_REGNUM, buf);
else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
regcache_raw_write (regcache, index + MT_CPR0_REGNUM, buf);
}
break;
}
--- 587,599 ----
break;
default:
{
unsigned index = mt_select_coprocessor (gdbarch, regcache, regno);
! if (index == MT_COPRO_PSEUDOREG_MAC_REGNUM)
mt_pseudo_register_write (gdbarch, regcache,
! MT_MAC_PSEUDOREG_REGNUM, buf);
else if (index < MT_NUM_REGS - MT_CPR0_REGNUM)
regcache_raw_write (regcache, index + MT_CPR0_REGNUM, buf);
}
break;
}