From 6f42417144fe1a2e3ca37a3b419a57fc825030e2 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 9 Oct 2019 19:22:37 -0700 Subject: [PATCH] sim: Make the System object a PCEventScope. This abstracts away the raw PCEventQueue managed by the System. Change-Id: I04d773e6be90a891884a76841f15c3eecd5796ed Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22101 Reviewed-by: Andreas Sandberg Maintainer: Gabe Black Tested-by: kokoro --- src/arch/alpha/linux/system.cc | 2 +- src/base/remote_gdb.cc | 2 +- src/sim/system.cc | 14 ++++++++++++++ src/sim/system.hh | 15 +++++++++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/arch/alpha/linux/system.cc b/src/arch/alpha/linux/system.cc index ae9e5ef07..89d18f6f6 100644 --- a/src/arch/alpha/linux/system.cc +++ b/src/arch/alpha/linux/system.cc @@ -149,7 +149,7 @@ LinuxAlphaSystem::setupFuncEvents() // leads to non-intuitive behavior with --trace-start. Addr addr = 0; if (false && kernelSymtab->findAddress("alpha_switch_to", addr)) { - printThreadEvent = new PrintThreadInfo(&pcEventQueue, "threadinfo", + printThreadEvent = new PrintThreadInfo(this, "threadinfo", addr + sizeof(MachInst) * 6); } else { printThreadEvent = NULL; diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index d0ccde566..3dde235f0 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -717,7 +717,7 @@ BaseRemoteGDB::insertHardBreak(Addr addr, size_t len) HardBreakpoint *&bkpt = hardBreakMap[addr]; if (bkpt == 0) - bkpt = new HardBreakpoint(this, &sys->pcEventQueue, addr); + bkpt = new HardBreakpoint(this, sys, addr); bkpt->refcount++; } diff --git a/src/sim/system.cc b/src/sim/system.cc index 3868f57b8..7b8ca87e3 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -292,6 +292,20 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned) return id; } +#if THE_ISA != NULL_ISA +bool +System::schedule(PCEvent *event) +{ + return pcEventQueue.schedule(event); +} + +bool +System::remove(PCEvent *event) +{ + return pcEventQueue.remove(event); +} +#endif + int System::numRunningContexts() { diff --git a/src/sim/system.hh b/src/sim/system.hh index 852bc21a2..c2b841107 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -74,7 +74,8 @@ */ #if THE_ISA != NULL_ISA #include "cpu/pc_event.hh" - +#else +class PCEvent; #endif class BaseRemoteGDB; @@ -83,6 +84,9 @@ class ObjectFile; class ThreadContext; class System : public SimObject +#if THE_ISA != NULL_ISA + , public PCEventScope +#endif { private: @@ -201,6 +205,13 @@ class System : public SimObject std::vector threadContexts; const bool multiThread; + using SimObject::schedule; + +#if THE_ISA != NULL_ISA + bool schedule(PCEvent *event) override; + bool remove(PCEvent *event) override; +#endif + ThreadContext *getThreadContext(ContextID tid) const { return threadContexts[tid]; @@ -493,7 +504,7 @@ class System : public SimObject #if THE_ISA != NULL_ISA if (symtab->findAddress(lbl, addr)) { - T *ev = new T(&pcEventQueue, desc, fixFuncEventAddr(addr), + T *ev = new T(this, desc, fixFuncEventAddr(addr), std::forward(args)...); return ev; } -- 2.30.2