}
void
-BaseRemoteGDB::SingleStepEvent::process()
+BaseRemoteGDB::processSingleStepEvent()
{
- if (!gdb->singleStepEvent.scheduled())
- gdb->scheduleInstCommitEvent(&gdb->singleStepEvent, 1);
- gdb->trap(SIGTRAP);
+ if (!singleStepEvent.scheduled())
+ scheduleInstCommitEvent(&singleStepEvent, 1);
+ trap(SIGTRAP);
}
BaseRemoteGDB::BaseRemoteGDB(System *_system, ThreadContext *c) :
- inputEvent(NULL), trapEvent(this), listener(NULL),
- number(-1), fd(-1), active(false), attached(false), system(_system),
- context(c), singleStepEvent(this)
+ inputEvent(NULL), trapEvent(this), listener(NULL), number(-1),
+ fd(-1), active(false), attached(false), system(_system),
+ context(c),
+ singleStepEvent([this]{ processSingleStepEvent(); }, name())
{
}
*srcp = src;
return r;
}
-
return trap(SIGTRAP);
}
- protected:
- class SingleStepEvent : public Event
- {
- protected:
- BaseRemoteGDB *gdb;
-
- public:
- SingleStepEvent(BaseRemoteGDB *g) : gdb(g)
- {}
-
- void process();
- };
-
- SingleStepEvent singleStepEvent;
+ void processSingleStepEvent();
+ EventFunctionWrapper singleStepEvent;
void clearSingleStep();
void setSingleStep();
Stats::Scalar *imported_num_cycles,
Event::Priority priority) :
object(object_),
- event(*this, priority),
+ event([this]{ processClockEvent(); }, name(), false, priority),
running(false),
lastStopped(0),
/* Allocate numCycles if an external stat wasn't passed in */
*numCyclesLocal))
{ }
+void
+Ticked::processClockEvent() {
+ ++tickCycles;
+ ++numCycles;
+ countCycles(Cycles(1));
+ evaluate();
+ if (running)
+ object.schedule(event, object.clockEdge(Cycles(1)));
+}
+
void
Ticked::regStats()
{
class Ticked : public Serializable
{
protected:
- /** An event to call process periodically */
- class ClockEvent : public Event
- {
- public:
- Ticked &owner;
-
- ClockEvent(Ticked &owner_, Priority priority) :
- Event(priority),
- owner(owner_)
- { }
-
- /** Evaluate and reschedule */
- void
- process()
- {
- ++owner.tickCycles;
- ++owner.numCycles;
- owner.countCycles(Cycles(1));
- owner.evaluate();
- if (owner.running) {
- owner.object.schedule(this,
- owner.object.clockEdge(Cycles(1)));
- }
- }
- };
-
- friend class ClockEvent;
-
/** ClockedObject who is responsible for this Ticked's actions/stats */
ClockedObject &object;
- /** The single instance of ClockEvent used */
- ClockEvent event;
+ /** The wrapper for processClockEvent */
+ EventFunctionWrapper event;
+
+ /** Evaluate and reschedule */
+ void processClockEvent();
/** Have I been started? and am not stopped */
bool running;