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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44619 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -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 @@ class FsWorkload : public KernelWorkload
|
||||
|
||||
void initState() override;
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
{
|
||||
KernelWorkload::setSystem(sys);
|
||||
gdb = BaseRemoteGDB::build<RemoteGDB>(system);
|
||||
}
|
||||
|
||||
Addr
|
||||
fixFuncEventAddr(Addr addr) const override
|
||||
{
|
||||
|
||||
@@ -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 @@ class SEWorkload : public ::SEWorkload
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 @@ class SEWorkload : public ::SEWorkload
|
||||
|
||||
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
|
||||
|
||||
@@ -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 @@ class SEWorkload : public ::SEWorkload
|
||||
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
|
||||
|
||||
@@ -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 @@ class BareMetal : public Workload
|
||||
|
||||
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
|
||||
|
||||
@@ -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 @@ class FsLinux : public KernelWorkload
|
||||
FsLinux(const Params &p) : KernelWorkload(p) {}
|
||||
|
||||
void initState() override;
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
{
|
||||
KernelWorkload::setSystem(sys);
|
||||
gdb = BaseRemoteGDB::build<RemoteGDB>(system);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace RiscvISA
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "arch/riscv/reg_abi.hh"
|
||||
#include "arch/riscv/regs/int.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 @@ class SEWorkload : public ::SEWorkload
|
||||
|
||||
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.
|
||||
|
||||
@@ -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 @@ class FsWorkload : public Workload
|
||||
FsWorkload(const SparcFsWorkloadParams ¶ms) : Workload(params) {}
|
||||
void initState() override;
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
{
|
||||
Workload::setSystem(sys);
|
||||
gdb = BaseRemoteGDB::build<RemoteGDB>(system);
|
||||
}
|
||||
|
||||
Addr
|
||||
getEntry() const override
|
||||
{
|
||||
|
||||
@@ -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 @@ class SEWorkload : public ::SEWorkload
|
||||
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);
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -80,6 +81,13 @@ class FsWorkload : public KernelWorkload
|
||||
public:
|
||||
void initState() override;
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
{
|
||||
KernelWorkload::setSystem(sys);
|
||||
gdb = BaseRemoteGDB::build<RemoteGDB>(system);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
smbios::SMBiosTable *smbiosTable;
|
||||
|
||||
@@ -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 @@ class EmuLinux : public SEWorkload
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 @@ class BaseRemoteGDB
|
||||
|
||||
/** @} */ // 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.
|
||||
|
||||
@@ -27,23 +27,11 @@
|
||||
|
||||
#include "sim/workload.hh"
|
||||
|
||||
#include "arch/remote_gdb.hh"
|
||||
#include "base/remote_gdb.hh"
|
||||
#include "config/the_isa.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)
|
||||
{
|
||||
@@ -75,8 +63,10 @@ Workload::replaceThreadContext(ThreadContext *tc)
|
||||
panic_if(!success,
|
||||
"Failed to insert replacement thread context %d.", id);
|
||||
|
||||
# if THE_ISA != NULL_ISA
|
||||
if (gdb)
|
||||
gdb->replaceThreadContext(tc);
|
||||
# endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class Workload : public SimObject
|
||||
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++; }
|
||||
|
||||
Reference in New Issue
Block a user