Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/44619 )

Change subject: arch,base,sim: Move GDB stub creation into the arch Workloads.
......................................................................

arch,base,sim: Move GDB stub creation into the arch Workloads.

These classes know what flavor of GDB stub they want, so there's no need
for TheISA:: to multiplex.

Change-Id: Ia428fe391719a3320d865421fc59352a17875bcf
---
M src/arch/arm/fs_workload.hh
M src/arch/arm/se_workload.hh
M src/arch/mips/se_workload.hh
M src/arch/power/se_workload.hh
M src/arch/riscv/bare_metal/fs_workload.hh
M src/arch/riscv/linux/fs_workload.hh
M src/arch/riscv/se_workload.hh
M src/arch/sparc/fs_workload.hh
M src/arch/sparc/se_workload.hh
M src/arch/x86/fs_workload.hh
M src/arch/x86/linux/se_workload.hh
M src/base/remote_gdb.hh
M src/sim/workload.cc
M src/sim/workload.hh
14 files changed, 104 insertions(+), 14 deletions(-)



diff --git a/src/arch/arm/fs_workload.hh b/src/arch/arm/fs_workload.hh
index d14c8bc..c85f867 100644
--- a/src/arch/arm/fs_workload.hh
+++ b/src/arch/arm/fs_workload.hh
@@ -46,6 +46,7 @@

 #include "arch/arm/aapcs32.hh"
 #include "arch/arm/aapcs64.hh"
+#include "arch/arm/remote_gdb.hh"
 #include "kern/linux/events.hh"
 #include "params/ArmFsWorkload.hh"
 #include "sim/kernel_workload.hh"
@@ -143,6 +144,13 @@

     void initState() override;

+    void
+    setSystem(System *sys) override
+    {
+        KernelWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     Addr
     fixFuncEventAddr(Addr addr) const override
     {
diff --git a/src/arch/arm/se_workload.hh b/src/arch/arm/se_workload.hh
index 70a85b0..b14f949 100644
--- a/src/arch/arm/se_workload.hh
+++ b/src/arch/arm/se_workload.hh
@@ -29,6 +29,7 @@
 #define __ARCH_ARM_SE_WORKLOAD_HH__

 #include "arch/arm/reg_abi.hh"
+#include "arch/arm/remote_gdb.hh"
 #include "params/ArmSEWorkload.hh"
 #include "sim/se_workload.hh"

@@ -42,6 +43,13 @@

     SEWorkload(const Params &p) : ::SEWorkload(p) {}

+    void
+    setSystem(System *sys) override
+    {
+        ::SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     ::Loader::Arch getArch() const override { return ::Loader::Arm64; }

     using SyscallABI32 = RegABI32;
diff --git a/src/arch/mips/se_workload.hh b/src/arch/mips/se_workload.hh
index 63eba3c..e1dd03f 100644
--- a/src/arch/mips/se_workload.hh
+++ b/src/arch/mips/se_workload.hh
@@ -29,6 +29,7 @@
 #define __ARCH_MIPS_SE_WORKLOAD_HH__

 #include "arch/mips/regs/int.hh"
+#include "arch/mips/remote_gdb.hh"
 #include "params/MipsSEWorkload.hh"
 #include "sim/se_workload.hh"
 #include "sim/syscall_abi.hh"
@@ -44,6 +45,13 @@

     SEWorkload(const Params &p) : ::SEWorkload(p) {}

+    void
+    setSystem(System *sys) override
+    {
+        ::SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     ::Loader::Arch getArch() const override { return ::Loader::Mips; }

     struct SyscallABI : public GenericSyscallABI64
diff --git a/src/arch/power/se_workload.hh b/src/arch/power/se_workload.hh
index ac79151..2305538 100644
--- a/src/arch/power/se_workload.hh
+++ b/src/arch/power/se_workload.hh
@@ -30,6 +30,7 @@

 #include "arch/power/regs/int.hh"
 #include "arch/power/regs/misc.hh"
+#include "arch/power/remote_gdb.hh"
 #include "params/PowerSEWorkload.hh"
 #include "sim/se_workload.hh"
 #include "sim/syscall_abi.hh"
@@ -44,6 +45,13 @@
     using Params = PowerSEWorkloadParams;
     SEWorkload(const Params &p) : ::SEWorkload(p) {}

+    void
+    setSystem(System *sys) override
+    {
+        ::SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     ::Loader::Arch getArch() const override { return ::Loader::Power; }

     struct SyscallABI : public GenericSyscallABI64
diff --git a/src/arch/riscv/bare_metal/fs_workload.hh b/src/arch/riscv/bare_metal/fs_workload.hh
index aa86cca..d7545f2 100644
--- a/src/arch/riscv/bare_metal/fs_workload.hh
+++ b/src/arch/riscv/bare_metal/fs_workload.hh
@@ -29,6 +29,7 @@
 #ifndef __ARCH_RISCV_BARE_METAL_SYSTEM_HH__
 #define __ARCH_RISCV_BARE_METAL_SYSTEM_HH__

+#include "arch/riscv/remote_gdb.hh"
 #include "params/RiscvBareMetal.hh"
 #include "sim/workload.hh"

@@ -52,6 +53,13 @@

     void initState() override;

+    void
+    setSystem(System *sys) override
+    {
+        Workload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     Loader::Arch getArch() const override { return bootloader->getArch(); }
     const Loader::SymbolTable &
     symtab(ThreadContext *tc) override
diff --git a/src/arch/riscv/linux/fs_workload.hh b/src/arch/riscv/linux/fs_workload.hh
index 84b0e1d..d891349 100644
--- a/src/arch/riscv/linux/fs_workload.hh
+++ b/src/arch/riscv/linux/fs_workload.hh
@@ -29,6 +29,7 @@
 #ifndef __ARCH_RISCV_LINUX_SYSTEM_HH__
 #define __ARCH_RISCV_LINUX_SYSTEM_HH__

+#include "arch/riscv/remote_gdb.hh"
 #include "params/RiscvLinux.hh"
 #include "sim/kernel_workload.hh"

@@ -42,6 +43,13 @@
     FsLinux(const Params &p) : KernelWorkload(p) {}

     void initState() override;
+
+    void
+    setSystem(System *sys) override
+    {
+        KernelWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
 };

 } // namespace RiscvISA
diff --git a/src/arch/riscv/se_workload.hh b/src/arch/riscv/se_workload.hh
index fcb79e8..8f5f895 100644
--- a/src/arch/riscv/se_workload.hh
+++ b/src/arch/riscv/se_workload.hh
@@ -30,6 +30,7 @@

 #include "arch/riscv/reg_abi.hh"
 #include "arch/riscv/registers.hh"
+#include "arch/riscv/remote_gdb.hh"
 #include "params/RiscvSEWorkload.hh"
 #include "sim/se_workload.hh"
 #include "sim/syscall_abi.hh"
@@ -44,6 +45,13 @@

     SEWorkload(const Params &p) : ::SEWorkload(p) {}

+    void
+    setSystem(System *sys) override
+    {
+        ::SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     ::Loader::Arch getArch() const override { return ::Loader::Riscv64; }

     //FIXME RISCV needs to handle 64 bit arguments in its 32 bit ISA.
diff --git a/src/arch/sparc/fs_workload.hh b/src/arch/sparc/fs_workload.hh
index 96fea4c..8eae7cd 100644
--- a/src/arch/sparc/fs_workload.hh
+++ b/src/arch/sparc/fs_workload.hh
@@ -30,6 +30,7 @@
 #define __ARCH_SPARC_FS_WORKLOAD_HH__

 #include "arch/sparc/faults.hh"
+#include "arch/sparc/remote_gdb.hh"
 #include "params/SparcFsWorkload.hh"
 #include "sim/workload.hh"

@@ -45,6 +46,13 @@
     FsWorkload(const SparcFsWorkloadParams &params) : Workload(params) {}
     void initState() override;

+    void
+    setSystem(System *sys) override
+    {
+        Workload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     Addr
     getEntry() const override
     {
diff --git a/src/arch/sparc/se_workload.hh b/src/arch/sparc/se_workload.hh
index 0ad572a..8edb9b5 100644
--- a/src/arch/sparc/se_workload.hh
+++ b/src/arch/sparc/se_workload.hh
@@ -32,6 +32,7 @@

 #include "arch/sparc/regs/int.hh"
 #include "arch/sparc/regs/misc.hh"
+#include "arch/sparc/remote_gdb.hh"
 #include "base/loader/object_file.hh"
 #include "cpu/thread_context.hh"
 #include "sim/se_workload.hh"
@@ -45,6 +46,13 @@
   public:
     using ::SEWorkload::SEWorkload;

+    void
+    setSystem(System *sys) override
+    {
+        ::SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     virtual void handleTrap(ThreadContext *tc, int trapNum);
     virtual void flushWindows(ThreadContext *tc);

diff --git a/src/arch/x86/fs_workload.hh b/src/arch/x86/fs_workload.hh
index f926dce..e88b715 100644
--- a/src/arch/x86/fs_workload.hh
+++ b/src/arch/x86/fs_workload.hh
@@ -43,6 +43,7 @@

 #include "arch/x86/regs/misc.hh"
 #include "arch/x86/regs/segment.hh"
+#include "arch/x86/remote_gdb.hh"
 #include "base/types.hh"
 #include "cpu/thread_context.hh"
 #include "params/X86FsWorkload.hh"
@@ -77,6 +78,13 @@
   public:
     void initState() override;

+    void
+    setSystem(System *sys) override
+    {
+        KernelWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
   protected:

     SMBios::SMBiosTable *smbiosTable;
diff --git a/src/arch/x86/linux/se_workload.hh b/src/arch/x86/linux/se_workload.hh
index b8d1774..1b0ec50 100644
--- a/src/arch/x86/linux/se_workload.hh
+++ b/src/arch/x86/linux/se_workload.hh
@@ -40,6 +40,7 @@
 #define __ARCH_X86_LINUX_SE_WORKLOAD_HH__

 #include "arch/x86/linux/linux.hh"
+#include "arch/x86/remote_gdb.hh"
 #include "params/X86EmuLinux.hh"
 #include "sim/process.hh"
 #include "sim/se_workload.hh"
@@ -56,6 +57,13 @@

     EmuLinux(const Params &p);

+    void
+    setSystem(System *sys) override
+    {
+        SEWorkload::setSystem(sys);
+        gdb = BaseRemoteGDB::build<RemoteGDB>(system);
+    }
+
     ::Loader::Arch getArch() const override { return ::Loader::X86_64; }

     void syscall(ThreadContext *tc) override;
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index edc81ed..197d7fa 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -56,6 +56,7 @@
 #include "base/socket.hh"
 #include "base/types.hh"
 #include "cpu/pc_event.hh"
+#include "sim/debug.hh"
 #include "sim/eventq.hh"

 /*
@@ -171,6 +172,17 @@

     /** @} */ // end of api_remote_gdb

+    template <class GDBStub, class ...Args>
+    static BaseRemoteGDB *
+    build(Args... args)
+    {
+        int port = getRemoteGDBPort();
+        if (port)
+            return new GDBStub(args..., port);
+        else
+            return nullptr;
+    }
+
   private:
     /*
      * Connection to the external GDB.
diff --git a/src/sim/workload.cc b/src/sim/workload.cc
index 962c60a..a1864ed 100644
--- a/src/sim/workload.cc
+++ b/src/sim/workload.cc
@@ -27,23 +27,11 @@

 #include "sim/workload.hh"

-#include "arch/remote_gdb.hh"
+#include "base/remote_gdb.hh"
 #include "cpu/thread_context.hh"
 #include "sim/debug.hh"

 void
-Workload::setSystem(System *sys)
-{
-    system = sys;
-
-#   if THE_ISA != NULL_ISA
-    int port = getRemoteGDBPort();
-    if (port)
-        gdb = new TheISA::RemoteGDB(system, port);
-#   endif
-}
-
-void
 Workload::registerThreadContext(ThreadContext *tc)
 {
     std::set<ThreadContext *>::iterator it;
@@ -74,8 +62,10 @@
         panic_if(!success,
                 "Failed to insert replacement thread context %d.", id);

+#       if THE_ISA != NULL_ISA
         if (gdb)
             gdb->replaceThreadContext(tc);
+#       endif

         return;
     }
diff --git a/src/sim/workload.hh b/src/sim/workload.hh
index 3a63838..37faf97 100644
--- a/src/sim/workload.hh
+++ b/src/sim/workload.hh
@@ -78,7 +78,7 @@
             waitForRemoteGDB(params.wait_for_remote_gdb)
     {}

-    void setSystem(System *sys);
+    virtual void setSystem(System *sys) { system = sys; }

     void recordQuiesce() { stats.instStats.quiesce++; }
     void recordArm() { stats.instStats.arm++; }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44619
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ia428fe391719a3320d865421fc59352a17875bcf
Gerrit-Change-Number: 44619
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to