From: Mark Mitchell <mark@codesourcery.com>
To: gdb-patches@sources.redhat.com
Subject: PATCH: Fix MT MAC register access
Date: Wed, 12 Apr 2006 03:26:00 -0000 [thread overview]
Message-ID: <200604120326.k3C3QAZN000703@sethra.codesourcery.com> (raw)
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;
}
next reply other threads:[~2006-04-12 3:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-12 3:26 Mark Mitchell [this message]
2006-05-23 0:25 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200604120326.k3C3QAZN000703@sethra.codesourcery.com \
--to=mark@codesourcery.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox