diff options
author | Gabe Black <gabeblack@google.com> | 2019-10-09 17:47:19 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-10-25 22:42:31 +0000 |
commit | 7bd57d5a94acbdcb64b4927ea6a673cae18adcc0 (patch) | |
tree | 1171079d0af63c62336bc1036e089fff95888e6a /src/cpu | |
parent | 69930afa9b63c25baab86ff5fbe632fc02ce5369 (diff) | |
download | gem5-7bd57d5a94acbdcb64b4927ea6a673cae18adcc0.tar.xz |
cpu: Create a PCEventScope class to abstract the scope of PCEvents.
This abstraction will allow scheduling PCEvents for a particular
ThreadContext, all contexts on a CPU, all contexts in a system, etc.,
and delegates scheduling and removing events to each particular scope.
Right now the PCEventQueue is the only implementor of the PCEventSCope
interface.
Change-Id: I8fb62931511136229915c2e19d36aae7ffdec9df
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22099
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/pc_event.cc | 8 | ||||
-rw-r--r-- | src/cpu/pc_event.hh | 34 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/cpu/pc_event.cc b/src/cpu/pc_event.cc index 60e781ba8..65094f0ad 100644 --- a/src/cpu/pc_event.cc +++ b/src/cpu/pc_event.cc @@ -126,9 +126,9 @@ PCEventQueue::equal_range(Addr pc) return std::equal_range(pcMap.begin(), pcMap.end(), pc, MapCompare()); } -BreakPCEvent::BreakPCEvent(PCEventQueue *q, const std::string &desc, Addr addr, +BreakPCEvent::BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del) - : PCEvent(q, desc, addr), remove(del) + : PCEvent(s, desc, addr), remove(del) { } @@ -142,8 +142,8 @@ BreakPCEvent::process(ThreadContext *tc) delete this; } -PanicPCEvent::PanicPCEvent(PCEventQueue *q, const std::string &desc, Addr pc) - : PCEvent(q, desc, pc) +PanicPCEvent::PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc) + : PCEvent(s, desc, pc) { } diff --git a/src/cpu/pc_event.hh b/src/cpu/pc_event.hh index 2289c876c..0654ca54e 100644 --- a/src/cpu/pc_event.hh +++ b/src/cpu/pc_event.hh @@ -40,18 +40,19 @@ class ThreadContext; class PCEventQueue; class System; +class PCEventScope; class PCEvent { protected: std::string description; - PCEventQueue *queue; + PCEventScope *scope; Addr evpc; public: - PCEvent(PCEventQueue *q, const std::string &desc, Addr pc); + PCEvent(PCEventScope *q, const std::string &desc, Addr pc); - virtual ~PCEvent() { if (queue) remove(); } + virtual ~PCEvent() { if (scope) remove(); } // for DPRINTF virtual const std::string name() const { return description; } @@ -63,7 +64,14 @@ class PCEvent virtual void process(ThreadContext *tc) = 0; }; -class PCEventQueue +class PCEventScope +{ + public: + virtual bool remove(PCEvent *event) = 0; + virtual bool schedule(PCEvent *event) = 0; +}; + +class PCEventQueue : public PCEventScope { protected: class MapCompare { @@ -103,8 +111,8 @@ class PCEventQueue PCEventQueue(); ~PCEventQueue(); - bool remove(PCEvent *event); - bool schedule(PCEvent *event); + bool remove(PCEvent *event) override; + bool schedule(PCEvent *event) override; bool service(ThreadContext *tc) { if (pcMap.empty()) @@ -121,19 +129,19 @@ class PCEventQueue inline -PCEvent::PCEvent(PCEventQueue *q, const std::string &desc, Addr pc) - : description(desc), queue(q), evpc(pc) +PCEvent::PCEvent(PCEventScope *s, const std::string &desc, Addr pc) + : description(desc), scope(s), evpc(pc) { - queue->schedule(this); + scope->schedule(this); } inline bool PCEvent::remove() { - if (!queue) + if (!scope) panic("cannot remove an uninitialized event;"); - return queue->remove(this); + return scope->remove(this); } class BreakPCEvent : public PCEvent @@ -142,7 +150,7 @@ class BreakPCEvent : public PCEvent bool remove; public: - BreakPCEvent(PCEventQueue *q, const std::string &desc, Addr addr, + BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del = false); virtual void process(ThreadContext *tc); }; @@ -150,7 +158,7 @@ class BreakPCEvent : public PCEvent class PanicPCEvent : public PCEvent { public: - PanicPCEvent(PCEventQueue *q, const std::string &desc, Addr pc); + PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc); virtual void process(ThreadContext *tc); }; |