diff options
author | Boris Shingarov <shingarov@labware.com> | 2015-12-18 15:12:07 -0600 |
---|---|---|
committer | Boris Shingarov <shingarov@labware.com> | 2015-12-18 15:12:07 -0600 |
commit | d765dbf22cb3242c055b19b797b0f4cb39a43aae (patch) | |
tree | 55fade43c664a78e55823cdc43f7bcec1bf663a9 /src/arch/alpha/remote_gdb.cc | |
parent | b5a54eb64ebce9c217c1d44cc93aebb7cb508c6d (diff) | |
download | gem5-d765dbf22cb3242c055b19b797b0f4cb39a43aae.tar.xz |
arm: remote GDB: rationalize structure of register offsets
Currently, the wire format of register values in g- and G-packets is
modelled using a union of uint8/16/32/64 arrays. The offset positions
of each register are expressed as a "register count" scaled according
to the width of the register in question. This results in counter-
intuitive and error-prone "register count arithmetic", and some
formats would even be altogether unrepresentable in such model, e.g.
a 64-bit register following a 32-bit one would have a fractional index
in the regs64 array.
Another difficulty is that the array is allocated before the actual
architecture of the workload is known (and therefore before the correct
size for the array can be calculated).
With this patch I propose a simpler mechanism for expressing the
register set structure. In the new code, GdbRegCache is an abstract
class; its subclasses contain straightforward structs reflecting the
register representation. The determination whether to use e.g. the
AArch32 vs. AArch64 register set (or SPARCv8 vs SPARCv9, etc.) is made
by polymorphically dispatching getregs() to the concrete subclass.
The subclass is not instantiated until it is needed for actual
g-/G-packet processing, when the mode is already known.
This patch is not meant to be merged in on its own, because it changes
the contract between src/base/remote_gdb.* and src/arch/*/remote_gdb.*,
so as it stands right now, it would break the other architectures.
In this patch only the base and the ARM code are provided for review;
once we agree on the structure, I will provide src/arch/*/remote_gdb.*
for the other architectures; those patches could then be merged in
together.
Review Request: http://reviews.gem5.org/r/3207/
Pushed by Joel Hestness <jthestness@gmail.com>
Diffstat (limited to 'src/arch/alpha/remote_gdb.cc')
-rw-r--r-- | src/arch/alpha/remote_gdb.cc | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/arch/alpha/remote_gdb.cc b/src/arch/alpha/remote_gdb.cc index a3fcf6136..f32d49e97 100644 --- a/src/arch/alpha/remote_gdb.cc +++ b/src/arch/alpha/remote_gdb.cc @@ -124,7 +124,6 @@ #include "arch/alpha/decoder.hh" -#include "arch/alpha/kgdb.h" #include "arch/alpha/regredir.hh" #include "arch/alpha/remote_gdb.hh" #include "arch/alpha/utility.hh" @@ -146,9 +145,8 @@ using namespace std; using namespace AlphaISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc, KGDB_NUMREGS * sizeof(uint64_t)) + : BaseRemoteGDB(_system, tc) { - memset(gdbregs.regs, 0, gdbregs.bytes()); } /* @@ -203,47 +201,41 @@ RemoteGDB::acc(Addr va, size_t len) return true; } -/* - * Translate the kernel debugger register format into the GDB register - * format. - */ void -RemoteGDB::getregs() +RemoteGDB::AlphaGdbRegCache::getRegs(ThreadContext *context) { - memset(gdbregs.regs, 0, gdbregs.bytes()); + DPRINTF(GDBAcc, "getRegs in remotegdb \n"); - gdbregs.regs64[KGDB_REG_PC] = context->pcState().pc(); + r.pc = context->pcState().pc(); - // @todo: Currently this is very Alpha specific. - if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) { - for (int i = 0; i < NumIntArchRegs; ++i) - gdbregs.regs64[i] = context->readIntReg(reg_redir[i]); + if (PcPAL(r.pc)) { + for (int i = 0; i < 32; ++i) + r.gpr[i] = context->readIntReg(reg_redir[i]); } else { - for (int i = 0; i < NumIntArchRegs; ++i) - gdbregs.regs64[i] = context->readIntReg(i); + for (int i = 0; i < 32; ++i) + r.gpr[i] = context->readIntReg(i); } + for (int i = 0; i < 32; ++i) #ifdef KGDB_FP_REGS - for (int i = 0; i < NumFloatArchRegs; ++i) - gdbregs.regs64[i + KGDB_REG_F0] = context->readFloatRegBits(i); + r.fpr[i] = context->readFloatRegBits(i); +#else + r.fpr[i] = 0; #endif } -/* - * Translate the GDB register format into the kernel debugger register - * format. - */ void -RemoteGDB::setregs() +RemoteGDB::AlphaGdbRegCache::setRegs(ThreadContext *context) const { - // @todo: Currently this is very Alpha specific. - if (PcPAL(gdbregs.regs64[KGDB_REG_PC])) { - for (int i = 0; i < NumIntArchRegs; ++i) { - context->setIntReg(reg_redir[i], gdbregs.regs64[i]); + DPRINTF(GDBAcc, "setRegs in remotegdb \n"); + + if (PcPAL(r.pc)) { + for (int i = 0; i < 32; ++i) { + context->setIntReg(reg_redir[i], r.gpr[i]); } } else { - for (int i = 0; i < NumIntArchRegs; ++i) { - context->setIntReg(i, gdbregs.regs64[i]); + for (int i = 0; i < 32; ++i) { + context->setIntReg(i, r.gpr[i]); } } @@ -252,7 +244,7 @@ RemoteGDB::setregs() context->setFloatRegBits(i, gdbregs.regs64[i + KGDB_REG_F0]); } #endif - context->pcState(gdbregs.regs64[KGDB_REG_PC]); + context->pcState(r.pc); } // Write bytes to kernel address space for debugger. @@ -277,3 +269,9 @@ RemoteGDB::insertHardBreak(Addr addr, size_t len) " See PCEventQueue::doService() in cpu/pc_event.cc.\n"); return BaseRemoteGDB::insertHardBreak(addr, len); } + +RemoteGDB::BaseGdbRegCache* +RemoteGDB::gdbRegs() { + return new AlphaGdbRegCache(this); +} + |