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/power/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/power/remote_gdb.cc')
-rw-r--r-- | src/arch/power/remote_gdb.cc | 72 |
1 files changed, 28 insertions, 44 deletions
diff --git a/src/arch/power/remote_gdb.cc b/src/arch/power/remote_gdb.cc index b8a1592b6..ef10efc18 100644 --- a/src/arch/power/remote_gdb.cc +++ b/src/arch/power/remote_gdb.cc @@ -1,4 +1,5 @@ /* + * Copyright 2015 LabWare * Copyright 2014 Google, Inc. * Copyright (c) 2010 ARM Limited * All rights reserved @@ -149,7 +150,7 @@ using namespace std; using namespace PowerISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc, GDB_REG_BYTES) + : BaseRemoteGDB(_system, tc) { } @@ -171,67 +172,50 @@ RemoteGDB::acc(Addr va, size_t len) return context->getProcessPtr()->pTable->lookup(va, entry); } -/* - * Translate the kernel debugger register format into the GDB register - * format. - * - * The PowerPC ISA is quite flexible in what register sets may be present - * depending on the features implemented by the particular CPU; - * GDB addresses this by describing the format of how register contents - * are transferred on the wire, in XML files such as 'power-core.xml'. - * Ideally, we should be reading these files instead of hardcoding this - * information, but for now the following implementation is enough to - * serve as the RSP backend for the out-of-the-box, default GDB. - */ void -RemoteGDB::getregs() +RemoteGDB::PowerGdbRegCache::getRegs(ThreadContext *context) { - DPRINTF(GDBAcc, "getregs in remotegdb \n"); - memset(gdbregs.regs, 0, gdbregs.bytes()); + DPRINTF(GDBAcc, "getRegs in remotegdb \n"); // Default order on 32-bit PowerPC: // R0-R31 (32-bit each), F0-F31 (64-bit IEEE754 double), // PC, MSR, CR, LR, CTR, XER (32-bit each) - // INTREG: R0~R31 for (int i = 0; i < NumIntArchRegs; i++) - gdbregs.regs32[GdbFirstGPRIndex + i] = htobe((uint32_t)context->readIntReg(i)); + r.gpr[i] = htobe((uint32_t)context->readIntReg(i)); - // FLOATREG: F0~F31 for (int i = 0; i < NumFloatArchRegs; i++) - gdbregs.regs32[GdbFirstFPRIndex + i] = context->readFloatRegBits(i); - - // PC, MSR, CR, LR, CTR, XER - gdbregs.regs32[GdbPCIndex] = htobe((uint32_t)context->pcState().pc()); - gdbregs.regs32[GdbMSRIndex] = 0; // Is MSR modeled? - gdbregs.regs32[GdbCRIndex] = htobe((uint32_t)context->readIntReg(INTREG_CR)); - gdbregs.regs32[GdbLRIndex] = htobe((uint32_t)context->readIntReg(INTREG_LR)); - gdbregs.regs32[GdbCTRIndex] = htobe((uint32_t)context->readIntReg(INTREG_CTR)); - gdbregs.regs32[GdbXERIndex] = htobe((uint32_t)context->readIntReg(INTREG_XER)); + r.fpr[i] = context->readFloatRegBits(i); + + r.pc = htobe((uint32_t)context->pcState().pc()); + r.msr = 0; // Is MSR modeled? + r.cr = htobe((uint32_t)context->readIntReg(INTREG_CR)); + r.lr = htobe((uint32_t)context->readIntReg(INTREG_LR)); + r.ctr = htobe((uint32_t)context->readIntReg(INTREG_CTR)); + r.xer = htobe((uint32_t)context->readIntReg(INTREG_XER)); } -/* - * Translate the GDB register format into the kernel debugger register - * format. - */ void -RemoteGDB::setregs() +RemoteGDB::PowerGdbRegCache::setRegs(ThreadContext *context) const { - DPRINTF(GDBAcc, "setregs in remotegdb \n"); + DPRINTF(GDBAcc, "setRegs in remotegdb \n"); - // INTREG: R0~R31 for (int i = 0; i < NumIntArchRegs; i++) - context->setIntReg(i, betoh(gdbregs.regs32[GdbFirstGPRIndex + i])); + context->setIntReg(i, betoh(r.gpr[i])); - // FLOATREG: F0~F31 for (int i = 0; i < NumFloatArchRegs; i++) - context->setFloatRegBits(i, gdbregs.regs64[GdbFirstFPRIndex + i]); + context->setFloatRegBits(i, r.fpr[i]); - // PC, MSR, CR, LR, CTR, XER - context->pcState(betoh(gdbregs.regs32[GdbPCIndex])); + context->pcState(betoh(r.pc)); // Is MSR modeled? - context->setIntReg(INTREG_CR, betoh(gdbregs.regs32[GdbCRIndex])); - context->setIntReg(INTREG_LR, betoh(gdbregs.regs32[GdbLRIndex])); - context->setIntReg(INTREG_CTR, betoh(gdbregs.regs32[GdbCTRIndex])); - context->setIntReg(INTREG_XER, betoh(gdbregs.regs32[GdbXERIndex])); + context->setIntReg(INTREG_CR, betoh(r.cr)); + context->setIntReg(INTREG_LR, betoh(r.lr)); + context->setIntReg(INTREG_CTR, betoh(r.ctr)); + context->setIntReg(INTREG_XER, betoh(r.xer)); +} + +RemoteGDB::BaseGdbRegCache* +RemoteGDB::gdbRegs() { + return new PowerGdbRegCache(this); } + |