summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-01-16 01:25:39 -0800
committerGabe Black <gabeblack@google.com>2018-01-20 07:28:42 +0000
commitecec88750729b2c94d5ca9dedbf7a755c46c41a7 (patch)
treecdadcf01c85f622d4c869fb85208c48a2fdb2469 /src/arch
parent372adea6879ac549df4a415b5913d28b6683d535 (diff)
downloadgem5-ecec88750729b2c94d5ca9dedbf7a755c46c41a7.tar.xz
sim, arch, base: Refactor the base remote GDB class.
Fold the GDBListener class into the main BaseRemoteGDB class, move around a bunch of functions, convert a lot of internal functions to be private, move some functions into the .cc, make some functions non-virtual which didn't really need to be overridden. Change-Id: Id0832b730b0fdfb2eababa5067e72c66de1c147d Reviewed-on: https://gem5-review.googlesource.com/7422 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/alpha/remote_gdb.cc39
-rw-r--r--src/arch/alpha/remote_gdb.hh11
-rw-r--r--src/arch/arm/remote_gdb.cc12
-rw-r--r--src/arch/arm/remote_gdb.hh2
-rw-r--r--src/arch/mips/remote_gdb.cc11
-rw-r--r--src/arch/mips/remote_gdb.hh2
-rw-r--r--src/arch/power/remote_gdb.cc11
-rw-r--r--src/arch/power/remote_gdb.hh2
-rw-r--r--src/arch/riscv/remote_gdb.cc11
-rw-r--r--src/arch/riscv/remote_gdb.hh2
-rw-r--r--src/arch/sparc/remote_gdb.cc10
-rw-r--r--src/arch/sparc/remote_gdb.hh14
-rw-r--r--src/arch/x86/remote_gdb.cc16
-rw-r--r--src/arch/x86/remote_gdb.hh2
14 files changed, 69 insertions, 76 deletions
diff --git a/src/arch/alpha/remote_gdb.cc b/src/arch/alpha/remote_gdb.cc
index a9ec4cf89..f3eafc0fe 100644
--- a/src/arch/alpha/remote_gdb.cc
+++ b/src/arch/alpha/remote_gdb.cc
@@ -144,9 +144,11 @@
using namespace std;
using namespace AlphaISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
- : BaseRemoteGDB(_system, tc)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc, int _port)
+ : BaseRemoteGDB(_system, tc, _port)
{
+ warn_once("Breakpoints do not work in Alpha PAL mode.\n"
+ " See PCEventQueue::doService() in cpu/pc_event.cc.\n");
}
/*
@@ -165,7 +167,7 @@ RemoteGDB::acc(Addr va, size_t len)
do {
if (IsK0Seg(va)) {
- if (va < (K0SegBase + system->memSize())) {
+ if (va < (K0SegBase + system()->memSize())) {
DPRINTF(GDBAcc, "acc: Mapping is valid K0SEG <= "
"%#x < K0SEG + size\n", va);
return true;
@@ -187,9 +189,9 @@ RemoteGDB::acc(Addr va, size_t len)
if (PcPAL(va) || va < 0x10000)
return true;
- Addr ptbr = context->readMiscRegNoEffect(IPR_PALtemp20);
+ Addr ptbr = context()->readMiscRegNoEffect(IPR_PALtemp20);
PageTableEntry pte =
- kernel_pte_lookup(context->getPhysProxy(), ptbr, va);
+ kernel_pte_lookup(context()->getPhysProxy(), ptbr, va);
if (!pte.valid()) {
DPRINTF(GDBAcc, "acc: %#x pte is invalid\n", va);
return false;
@@ -247,31 +249,10 @@ RemoteGDB::AlphaGdbRegCache::setRegs(ThreadContext *context) const
context->pcState(r.pc);
}
-// Write bytes to kernel address space for debugger.
-bool
-RemoteGDB::write(Addr vaddr, size_t size, const char *data)
-{
- if (BaseRemoteGDB::write(vaddr, size, data)) {
-#ifdef IMB
- alpha_pal_imb();
-#endif
- return true;
- } else {
- return false;
- }
-}
-
-void
-RemoteGDB::insertHardBreak(Addr addr, size_t len)
+BaseGdbRegCache*
+RemoteGDB::gdbRegs()
{
- warn_once("Breakpoints do not work in Alpha PAL mode.\n"
- " See PCEventQueue::doService() in cpu/pc_event.cc.\n");
- BaseRemoteGDB::insertHardBreak(addr, len);
-}
-
-RemoteGDB::BaseGdbRegCache*
-RemoteGDB::gdbRegs() {
- return new AlphaGdbRegCache(this);
+ return new AlphaGdbRegCache(this);
}
diff --git a/src/arch/alpha/remote_gdb.hh b/src/arch/alpha/remote_gdb.hh
index c8ed709f6..1e99b5fdc 100644
--- a/src/arch/alpha/remote_gdb.hh
+++ b/src/arch/alpha/remote_gdb.hh
@@ -51,9 +51,6 @@ class RemoteGDB : public BaseRemoteGDB
protected:
// Machine memory
bool acc(Addr addr, size_t len) override;
- bool write(Addr addr, size_t size, const char *data) override;
-
- void insertHardBreak(Addr addr, size_t len) override;
class AlphaGdbRegCache : public BaseGdbRegCache
{
@@ -70,11 +67,15 @@ class RemoteGDB : public BaseRemoteGDB
size_t size() const { return sizeof(r); }
void getRegs(ThreadContext*);
void setRegs(ThreadContext*) const;
- const std::string name() const { return gdb->name() + ".AlphaGdbRegCache"; }
+ const std::string
+ name() const
+ {
+ return gdb->name() + ".AlphaGdbRegCache";
+ }
};
public:
- RemoteGDB(System *system, ThreadContext *context);
+ RemoteGDB(System *system, ThreadContext *context, int _port);
BaseGdbRegCache *gdbRegs() override;
};
diff --git a/src/arch/arm/remote_gdb.cc b/src/arch/arm/remote_gdb.cc
index 6dc68b190..f12734182 100644
--- a/src/arch/arm/remote_gdb.cc
+++ b/src/arch/arm/remote_gdb.cc
@@ -164,8 +164,8 @@
using namespace std;
using namespace ArmISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
- : BaseRemoteGDB(_system, tc), regCache32(this), regCache64(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc, int _port)
+ : BaseRemoteGDB(_system, tc, _port), regCache32(this), regCache64(this)
{
}
@@ -177,7 +177,7 @@ RemoteGDB::acc(Addr va, size_t len)
{
if (FullSystem) {
for (ChunkGenerator gen(va, len, PageBytes); !gen.done(); gen.next()) {
- if (!virtvalid(context, gen.addr())) {
+ if (!virtvalid(context(), gen.addr())) {
DPRINTF(GDBAcc, "acc: %#x mapping is invalid\n", va);
return false;
}
@@ -189,7 +189,7 @@ RemoteGDB::acc(Addr va, size_t len)
TlbEntry entry;
//Check to make sure the first byte is mapped into the processes address
//space.
- if (context->getProcessPtr()->pTable->lookup(va, entry))
+ if (context()->getProcessPtr()->pTable->lookup(va, entry))
return true;
return false;
}
@@ -301,10 +301,10 @@ RemoteGDB::AArch32GdbRegCache::setRegs(ThreadContext *context) const
context->setMiscRegNoEffect(MISCREG_CPSR, r.cpsr);
}
-RemoteGDB::BaseGdbRegCache*
+BaseGdbRegCache*
RemoteGDB::gdbRegs()
{
- if (inAArch64(context))
+ if (inAArch64(context()))
return &regCache64;
else
return &regCache32;
diff --git a/src/arch/arm/remote_gdb.hh b/src/arch/arm/remote_gdb.hh
index 328fbadb3..e5d50ee13 100644
--- a/src/arch/arm/remote_gdb.hh
+++ b/src/arch/arm/remote_gdb.hh
@@ -115,7 +115,7 @@ class RemoteGDB : public BaseRemoteGDB
AArch64GdbRegCache regCache64;
public:
- RemoteGDB(System *_system, ThreadContext *tc);
+ RemoteGDB(System *_system, ThreadContext *tc, int _port);
BaseGdbRegCache *gdbRegs();
};
} // namespace ArmISA
diff --git a/src/arch/mips/remote_gdb.cc b/src/arch/mips/remote_gdb.cc
index 2cc2d779b..e17f8fd1d 100644
--- a/src/arch/mips/remote_gdb.cc
+++ b/src/arch/mips/remote_gdb.cc
@@ -151,8 +151,8 @@
using namespace std;
using namespace MipsISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
- : BaseRemoteGDB(_system, tc), regCache(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc, int _port)
+ : BaseRemoteGDB(_system, tc, _port), regCache(this)
{
}
@@ -168,7 +168,7 @@ RemoteGDB::acc(Addr va, size_t len)
if (FullSystem)
panic("acc not implemented for MIPS FS!");
else
- return context->getProcessPtr()->pTable->lookup(va, entry);
+ return context()->getProcessPtr()->pTable->lookup(va, entry);
}
void
@@ -205,7 +205,8 @@ RemoteGDB::MipsGdbRegCache::setRegs(ThreadContext *context) const
context->setFloatRegBits(FLOATREG_FIR, r.fir);
}
-RemoteGDB::BaseGdbRegCache*
-RemoteGDB::gdbRegs() {
+BaseGdbRegCache*
+RemoteGDB::gdbRegs()
+{
return &regCache;
}
diff --git a/src/arch/mips/remote_gdb.hh b/src/arch/mips/remote_gdb.hh
index fba55d84c..169754a53 100644
--- a/src/arch/mips/remote_gdb.hh
+++ b/src/arch/mips/remote_gdb.hh
@@ -80,7 +80,7 @@ class RemoteGDB : public BaseRemoteGDB
MipsGdbRegCache regCache;
public:
- RemoteGDB(System *_system, ThreadContext *tc);
+ RemoteGDB(System *_system, ThreadContext *tc, int _port);
BaseGdbRegCache *gdbRegs();
};
diff --git a/src/arch/power/remote_gdb.cc b/src/arch/power/remote_gdb.cc
index c85aa38f2..7bdd3ba6a 100644
--- a/src/arch/power/remote_gdb.cc
+++ b/src/arch/power/remote_gdb.cc
@@ -151,8 +151,8 @@
using namespace std;
using namespace PowerISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
- : BaseRemoteGDB(_system, tc), regCache(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc, int _port)
+ : BaseRemoteGDB(_system, tc, _port), regCache(this)
{
}
@@ -171,7 +171,7 @@ RemoteGDB::acc(Addr va, size_t len)
if (FullSystem)
panic("acc not implemented for POWER FS!");
else
- return context->getProcessPtr()->pTable->lookup(va, entry);
+ return context()->getProcessPtr()->pTable->lookup(va, entry);
}
void
@@ -216,8 +216,9 @@ RemoteGDB::PowerGdbRegCache::setRegs(ThreadContext *context) const
context->setIntReg(INTREG_XER, betoh(r.xer));
}
-RemoteGDB::BaseGdbRegCache*
-RemoteGDB::gdbRegs() {
+BaseGdbRegCache*
+RemoteGDB::gdbRegs()
+{
return &regCache;
}
diff --git a/src/arch/power/remote_gdb.hh b/src/arch/power/remote_gdb.hh
index 9fefb345b..2894fc124 100644
--- a/src/arch/power/remote_gdb.hh
+++ b/src/arch/power/remote_gdb.hh
@@ -79,7 +79,7 @@ class RemoteGDB : public BaseRemoteGDB
PowerGdbRegCache regCache;
public:
- RemoteGDB(System *_system, ThreadContext *tc);
+ RemoteGDB(System *_system, ThreadContext *tc, int _port);
BaseGdbRegCache *gdbRegs();
};
diff --git a/src/arch/riscv/remote_gdb.cc b/src/arch/riscv/remote_gdb.cc
index 3488c8192..4f423fc01 100644
--- a/src/arch/riscv/remote_gdb.cc
+++ b/src/arch/riscv/remote_gdb.cc
@@ -148,8 +148,8 @@
using namespace std;
using namespace RiscvISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc)
- : BaseRemoteGDB(_system, tc), regCache(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc, int _port)
+ : BaseRemoteGDB(_system, tc, _port), regCache(this)
{
}
@@ -160,7 +160,7 @@ RemoteGDB::acc(Addr va, size_t len)
if (FullSystem)
panic("acc not implemented for RISCV FS!");
else
- return context->getProcessPtr()->pTable->lookup(va, entry);
+ return context()->getProcessPtr()->pTable->lookup(va, entry);
}
void
@@ -199,7 +199,8 @@ RemoteGDB::RiscvGdbRegCache::setRegs(ThreadContext *context) const
context->setMiscReg(i, r.csr[i - ExplicitCSRs]);
}
-RemoteGDB::BaseGdbRegCache*
-RemoteGDB::gdbRegs() {
+BaseGdbRegCache*
+RemoteGDB::gdbRegs()
+{
return &regCache;
}
diff --git a/src/arch/riscv/remote_gdb.hh b/src/arch/riscv/remote_gdb.hh
index 4b9d6e7f2..739cb5a3e 100644
--- a/src/arch/riscv/remote_gdb.hh
+++ b/src/arch/riscv/remote_gdb.hh
@@ -85,7 +85,7 @@ class RemoteGDB : public BaseRemoteGDB
RiscvGdbRegCache regCache;
public:
- RemoteGDB(System *_system, ThreadContext *tc);
+ RemoteGDB(System *_system, ThreadContext *tc, int _port);
BaseGdbRegCache *gdbRegs();
};
diff --git a/src/arch/sparc/remote_gdb.cc b/src/arch/sparc/remote_gdb.cc
index 3f4df0d3a..baec0e7be 100644
--- a/src/arch/sparc/remote_gdb.cc
+++ b/src/arch/sparc/remote_gdb.cc
@@ -147,8 +147,8 @@
using namespace std;
using namespace SparcISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *c)
- : BaseRemoteGDB(_system, c), regCache32(this), regCache64(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *c, int _port)
+ : BaseRemoteGDB(_system, c, _port), regCache32(this), regCache64(this)
{}
///////////////////////////////////////////////////////////
@@ -170,7 +170,7 @@ RemoteGDB::acc(Addr va, size_t len)
TlbEntry entry;
// Check to make sure the first byte is mapped into the processes
// address space.
- if (context->getProcessPtr()->pTable->lookup(va, entry))
+ if (context()->getProcessPtr()->pTable->lookup(va, entry))
return true;
return false;
}
@@ -244,10 +244,10 @@ RemoteGDB::SPARC64GdbRegCache::setRegs(ThreadContext *context) const
}
-RemoteGDB::BaseGdbRegCache*
+BaseGdbRegCache*
RemoteGDB::gdbRegs()
{
- PSTATE pstate = context->readMiscReg(MISCREG_PSTATE);
+ PSTATE pstate = context()->readMiscReg(MISCREG_PSTATE);
if (pstate.am) {
return &regCache32;
} else {
diff --git a/src/arch/sparc/remote_gdb.hh b/src/arch/sparc/remote_gdb.hh
index 653f0b113..f0ddd54e1 100644
--- a/src/arch/sparc/remote_gdb.hh
+++ b/src/arch/sparc/remote_gdb.hh
@@ -69,7 +69,11 @@ class RemoteGDB : public BaseRemoteGDB
size_t size() const { return sizeof(r); }
void getRegs(ThreadContext*);
void setRegs(ThreadContext*) const;
- const std::string name() const { return gdb->name() + ".SPARCGdbRegCache"; }
+ const std::string
+ name() const
+ {
+ return gdb->name() + ".SPARCGdbRegCache";
+ }
};
class SPARC64GdbRegCache : public BaseGdbRegCache
@@ -91,14 +95,18 @@ class RemoteGDB : public BaseRemoteGDB
size_t size() const { return sizeof(r); }
void getRegs(ThreadContext*);
void setRegs(ThreadContext*) const;
- const std::string name() const { return gdb->name() + ".SPARC64GdbRegCache"; }
+ const std::string
+ name() const
+ {
+ return gdb->name() + ".SPARC64GdbRegCache";
+ }
};
SPARCGdbRegCache regCache32;
SPARC64GdbRegCache regCache64;
public:
- RemoteGDB(System *_system, ThreadContext *tc);
+ RemoteGDB(System *_system, ThreadContext *tc, int _port);
BaseGdbRegCache *gdbRegs();
};
} // namespace SparcISA
diff --git a/src/arch/x86/remote_gdb.cc b/src/arch/x86/remote_gdb.cc
index a6fdabd73..175cabba3 100644
--- a/src/arch/x86/remote_gdb.cc
+++ b/src/arch/x86/remote_gdb.cc
@@ -64,8 +64,8 @@
using namespace std;
using namespace X86ISA;
-RemoteGDB::RemoteGDB(System *_system, ThreadContext *c) :
- BaseRemoteGDB(_system, c), regCache32(this), regCache64(this)
+RemoteGDB::RemoteGDB(System *_system, ThreadContext *c, int _port) :
+ BaseRemoteGDB(_system, c, _port), regCache32(this), regCache64(this)
{}
bool
@@ -73,9 +73,9 @@ RemoteGDB::acc(Addr va, size_t len)
{
if (FullSystem) {
Walker *walker = dynamic_cast<TLB *>(
- context->getDTBPtr())->getWalker();
+ context()->getDTBPtr())->getWalker();
unsigned logBytes;
- Fault fault = walker->startFunctional(context, va, logBytes,
+ Fault fault = walker->startFunctional(context(), va, logBytes,
BaseTLB::Read);
if (fault != NoFault)
return false;
@@ -84,19 +84,19 @@ RemoteGDB::acc(Addr va, size_t len)
if ((va & ~mask(logBytes)) == (endVa & ~mask(logBytes)))
return true;
- fault = walker->startFunctional(context, endVa, logBytes,
+ fault = walker->startFunctional(context(), endVa, logBytes,
BaseTLB::Read);
return fault == NoFault;
} else {
TlbEntry entry;
- return context->getProcessPtr()->pTable->lookup(va, entry);
+ return context()->getProcessPtr()->pTable->lookup(va, entry);
}
}
-RemoteGDB::BaseGdbRegCache*
+BaseGdbRegCache*
RemoteGDB::gdbRegs()
{
- HandyM5Reg m5reg = context->readMiscRegNoEffect(MISCREG_M5_REG);
+ HandyM5Reg m5reg = context()->readMiscRegNoEffect(MISCREG_M5_REG);
if (m5reg.submode == SixtyFourBitMode)
return &regCache64;
else
diff --git a/src/arch/x86/remote_gdb.hh b/src/arch/x86/remote_gdb.hh
index f1cbcbe8c..0cae4fe30 100644
--- a/src/arch/x86/remote_gdb.hh
+++ b/src/arch/x86/remote_gdb.hh
@@ -143,7 +143,7 @@ class RemoteGDB : public BaseRemoteGDB
AMD64GdbRegCache regCache64;
public:
- RemoteGDB(System *system, ThreadContext *context);
+ RemoteGDB(System *system, ThreadContext *context, int _port);
BaseGdbRegCache *gdbRegs();
};
} // namespace X86ISA