From 41ab3e6e7e9b5a5f4427949f9a981cdf2186c88a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 11 May 2017 14:11:28 -0700 Subject: 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 Reviewed-by: Boris Shingarov Maintainer: Andreas Sandberg --- src/arch/x86/remote_gdb.cc | 6 +++--- src/arch/x86/remote_gdb.hh | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/arch/x86') 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(); -- cgit v1.2.3