diff options
author | Gabe Black <gabeblack@google.com> | 2017-05-11 14:11:28 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2017-05-18 16:48:09 +0000 |
commit | 41ab3e6e7e9b5a5f4427949f9a981cdf2186c88a (patch) | |
tree | 1b02f07e240b6207c83a55cc297dc0ab599ac85a /src/arch | |
parent | 9aadcc797263fc268fdd9f921ddffa473f56d78a (diff) | |
download | gem5-41ab3e6e7e9b5a5f4427949f9a981cdf2186c88a.tar.xz |
base: Refactor the GDB code.
The new version modularizes the implementation of the various commands,
gets rid of dynamic allocation of the register cache, fixes some small
style problems, and uses exceptions to simplify error handling internal to
the GDB stub.
Change-Id: Iff3548373ce4adfb99106a810f5713b769df89b2
Reviewed-on: https://gem5-review.googlesource.com/3280
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Boris Shingarov <shingarov@gmail.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/alpha/remote_gdb.cc | 4 | ||||
-rw-r--r-- | src/arch/alpha/remote_gdb.hh | 2 | ||||
-rw-r--r-- | src/arch/arm/remote_gdb.cc | 6 | ||||
-rw-r--r-- | src/arch/arm/remote_gdb.hh | 15 | ||||
-rw-r--r-- | src/arch/mips/remote_gdb.cc | 4 | ||||
-rw-r--r-- | src/arch/mips/remote_gdb.hh | 7 | ||||
-rw-r--r-- | src/arch/power/remote_gdb.cc | 4 | ||||
-rw-r--r-- | src/arch/power/remote_gdb.hh | 7 | ||||
-rw-r--r-- | src/arch/riscv/remote_gdb.cc | 4 | ||||
-rw-r--r-- | src/arch/riscv/remote_gdb.hh | 1 | ||||
-rw-r--r-- | src/arch/sparc/remote_gdb.cc | 13 | ||||
-rw-r--r-- | src/arch/sparc/remote_gdb.hh | 3 | ||||
-rw-r--r-- | src/arch/x86/remote_gdb.cc | 6 | ||||
-rw-r--r-- | src/arch/x86/remote_gdb.hh | 15 |
14 files changed, 63 insertions, 28 deletions
diff --git a/src/arch/alpha/remote_gdb.cc b/src/arch/alpha/remote_gdb.cc index 8c01005da..a9ec4cf89 100644 --- a/src/arch/alpha/remote_gdb.cc +++ b/src/arch/alpha/remote_gdb.cc @@ -262,12 +262,12 @@ RemoteGDB::write(Addr vaddr, size_t size, const char *data) } -bool +void RemoteGDB::insertHardBreak(Addr addr, size_t len) { warn_once("Breakpoints do not work in Alpha PAL mode.\n" " See PCEventQueue::doService() in cpu/pc_event.cc.\n"); - return BaseRemoteGDB::insertHardBreak(addr, len); + BaseRemoteGDB::insertHardBreak(addr, len); } RemoteGDB::BaseGdbRegCache* diff --git a/src/arch/alpha/remote_gdb.hh b/src/arch/alpha/remote_gdb.hh index 4b71fd23a..38ff91933 100644 --- a/src/arch/alpha/remote_gdb.hh +++ b/src/arch/alpha/remote_gdb.hh @@ -53,7 +53,7 @@ class RemoteGDB : public BaseRemoteGDB bool acc(Addr addr, size_t len); bool write(Addr addr, size_t size, const char *data); - bool insertHardBreak(Addr addr, size_t len); + void insertHardBreak(Addr addr, size_t len) override; class AlphaGdbRegCache : public BaseGdbRegCache { diff --git a/src/arch/arm/remote_gdb.cc b/src/arch/arm/remote_gdb.cc index b0f6d8e5e..eefe62b42 100644 --- a/src/arch/arm/remote_gdb.cc +++ b/src/arch/arm/remote_gdb.cc @@ -165,7 +165,7 @@ using namespace std; using namespace ArmISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc) + : BaseRemoteGDB(_system, tc), regCache32(this), regCache64(this) { } @@ -297,7 +297,7 @@ RemoteGDB::BaseGdbRegCache* RemoteGDB::gdbRegs() { if (inAArch64(context)) - return new AArch64GdbRegCache(this); + return ®Cache32; else - return new AArch32GdbRegCache(this); + return ®Cache64; } diff --git a/src/arch/arm/remote_gdb.hh b/src/arch/arm/remote_gdb.hh index 13ceac17f..acd6f32d2 100644 --- a/src/arch/arm/remote_gdb.hh +++ b/src/arch/arm/remote_gdb.hh @@ -79,7 +79,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() + ".AArch32GdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".AArch32GdbRegCache"; + } }; class AArch64GdbRegCache : public BaseGdbRegCache @@ -98,9 +102,16 @@ 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() + ".AArch64GdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".AArch64GdbRegCache"; + } }; + AArch32GdbRegCache regCache32; + AArch64GdbRegCache regCache64; + public: RemoteGDB(System *_system, ThreadContext *tc); BaseGdbRegCache *gdbRegs(); diff --git a/src/arch/mips/remote_gdb.cc b/src/arch/mips/remote_gdb.cc index 4fa7cac70..2cc2d779b 100644 --- a/src/arch/mips/remote_gdb.cc +++ b/src/arch/mips/remote_gdb.cc @@ -152,7 +152,7 @@ using namespace std; using namespace MipsISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc) + : BaseRemoteGDB(_system, tc), regCache(this) { } @@ -207,5 +207,5 @@ RemoteGDB::MipsGdbRegCache::setRegs(ThreadContext *context) const RemoteGDB::BaseGdbRegCache* RemoteGDB::gdbRegs() { - return new MipsGdbRegCache(this); + return ®Cache; } diff --git a/src/arch/mips/remote_gdb.hh b/src/arch/mips/remote_gdb.hh index fd006e0b6..fba55d84c 100644 --- a/src/arch/mips/remote_gdb.hh +++ b/src/arch/mips/remote_gdb.hh @@ -70,9 +70,14 @@ 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() + ".MipsGdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".MipsGdbRegCache"; + } }; + MipsGdbRegCache regCache; public: RemoteGDB(System *_system, ThreadContext *tc); diff --git a/src/arch/power/remote_gdb.cc b/src/arch/power/remote_gdb.cc index 1ed7afbc0..c85aa38f2 100644 --- a/src/arch/power/remote_gdb.cc +++ b/src/arch/power/remote_gdb.cc @@ -152,7 +152,7 @@ using namespace std; using namespace PowerISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc) + : BaseRemoteGDB(_system, tc), regCache(this) { } @@ -218,6 +218,6 @@ RemoteGDB::PowerGdbRegCache::setRegs(ThreadContext *context) const RemoteGDB::BaseGdbRegCache* RemoteGDB::gdbRegs() { - return new PowerGdbRegCache(this); + return ®Cache; } diff --git a/src/arch/power/remote_gdb.hh b/src/arch/power/remote_gdb.hh index e1c396266..9fefb345b 100644 --- a/src/arch/power/remote_gdb.hh +++ b/src/arch/power/remote_gdb.hh @@ -69,9 +69,14 @@ 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() + ".PowerGdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".PowerGdbRegCache"; + } }; + PowerGdbRegCache regCache; public: RemoteGDB(System *_system, ThreadContext *tc); diff --git a/src/arch/riscv/remote_gdb.cc b/src/arch/riscv/remote_gdb.cc index 2b508762d..3488c8192 100644 --- a/src/arch/riscv/remote_gdb.cc +++ b/src/arch/riscv/remote_gdb.cc @@ -149,7 +149,7 @@ using namespace std; using namespace RiscvISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *tc) - : BaseRemoteGDB(_system, tc) + : BaseRemoteGDB(_system, tc), regCache(this) { } @@ -201,5 +201,5 @@ RemoteGDB::RiscvGdbRegCache::setRegs(ThreadContext *context) const RemoteGDB::BaseGdbRegCache* RemoteGDB::gdbRegs() { - return new RiscvGdbRegCache(this); + return ®Cache; } diff --git a/src/arch/riscv/remote_gdb.hh b/src/arch/riscv/remote_gdb.hh index 735faae02..4b9d6e7f2 100644 --- a/src/arch/riscv/remote_gdb.hh +++ b/src/arch/riscv/remote_gdb.hh @@ -82,6 +82,7 @@ class RemoteGDB : public BaseRemoteGDB } }; + RiscvGdbRegCache regCache; public: RemoteGDB(System *_system, ThreadContext *tc); diff --git a/src/arch/sparc/remote_gdb.cc b/src/arch/sparc/remote_gdb.cc index b7ecd3b7a..3f4df0d3a 100644 --- a/src/arch/sparc/remote_gdb.cc +++ b/src/arch/sparc/remote_gdb.cc @@ -148,7 +148,7 @@ using namespace std; using namespace SparcISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *c) - : BaseRemoteGDB(_system, c) + : BaseRemoteGDB(_system, c), regCache32(this), regCache64(this) {} /////////////////////////////////////////////////////////// @@ -248,10 +248,9 @@ RemoteGDB::BaseGdbRegCache* RemoteGDB::gdbRegs() { PSTATE pstate = context->readMiscReg(MISCREG_PSTATE); - if (pstate.am) - {DPRINTF(GDBRead, "Creating 32-bit GDB\n"); - return new SPARCGdbRegCache(this);} - else - {DPRINTF(GDBRead, "Creating 64-bit GDB\n"); - return new SPARC64GdbRegCache(this);} + if (pstate.am) { + return ®Cache32; + } else { + return ®Cache64; + } } diff --git a/src/arch/sparc/remote_gdb.hh b/src/arch/sparc/remote_gdb.hh index 543683ee8..653f0b113 100644 --- a/src/arch/sparc/remote_gdb.hh +++ b/src/arch/sparc/remote_gdb.hh @@ -94,6 +94,9 @@ class RemoteGDB : public BaseRemoteGDB const std::string name() const { return gdb->name() + ".SPARC64GdbRegCache"; } }; + SPARCGdbRegCache regCache32; + SPARC64GdbRegCache regCache64; + public: RemoteGDB(System *_system, ThreadContext *tc); BaseGdbRegCache *gdbRegs(); diff --git a/src/arch/x86/remote_gdb.cc b/src/arch/x86/remote_gdb.cc index 4a9140e64..79613971a 100644 --- a/src/arch/x86/remote_gdb.cc +++ b/src/arch/x86/remote_gdb.cc @@ -65,7 +65,7 @@ using namespace std; using namespace X86ISA; RemoteGDB::RemoteGDB(System *_system, ThreadContext *c) : - BaseRemoteGDB(_system, c) + BaseRemoteGDB(_system, c), regCache32(this), regCache64(this) {} bool @@ -97,9 +97,9 @@ RemoteGDB::gdbRegs() { HandyM5Reg m5reg = context->readMiscRegNoEffect(MISCREG_M5_REG); if (m5reg.submode == SixtyFourBitMode) - return new AMD64GdbRegCache(this); + return ®Cache64; else - return new X86GdbRegCache(this); + return ®Cache32; } diff --git a/src/arch/x86/remote_gdb.hh b/src/arch/x86/remote_gdb.hh index 5696e3dc7..4a917925e 100644 --- a/src/arch/x86/remote_gdb.hh +++ b/src/arch/x86/remote_gdb.hh @@ -85,7 +85,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() + ".X86GdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".X86GdbRegCache"; + } }; class AMD64GdbRegCache : public BaseGdbRegCache @@ -128,9 +132,16 @@ 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() + ".AMD64GdbRegCache"; } + const std::string + name() const + { + return gdb->name() + ".AMD64GdbRegCache"; + } }; + X86GdbRegCache regCache32; + AMD64GdbRegCache regCache64; + public: RemoteGDB(System *system, ThreadContext *context); BaseGdbRegCache *gdbRegs(); |