misc: Add some utility functions for schedule inst commit events.

These can be used to simplify the implementation of single step in derived
classes.
This commit is contained in:
Gabe Black 2014-12-05 22:35:47 -08:00
parent cddf988bfd
commit 16c9b41616
2 changed files with 31 additions and 8 deletions

View file

@ -141,7 +141,6 @@
#include "sim/system.hh" #include "sim/system.hh"
using namespace std; using namespace std;
using namespace Debug;
using namespace TheISA; using namespace TheISA;
#ifndef NDEBUG #ifndef NDEBUG
@ -248,16 +247,11 @@ BaseRemoteGDB::InputEvent::InputEvent(BaseRemoteGDB *g, int fd, int e)
void void
BaseRemoteGDB::InputEvent::process(int revent) BaseRemoteGDB::InputEvent::process(int revent)
{ {
BaseCPU *cpu = gdb->context->getCpuPtr();
EventQueue *eq = cpu->comInstEventQueue[gdb->context->threadId()];
if (revent & POLLIN) { if (revent & POLLIN) {
gdb->trapEvent.type(SIGILL); gdb->trapEvent.type(SIGILL);
// Here "ticks" aren't simulator ticks which measure time, they're gdb->scheduleInstCommitEvent(&gdb->trapEvent, 0);
// instructions committed by the CPU.
eq->schedule(&gdb->trapEvent, eq->getCurTick());
} else if (revent & POLLNVAL) { } else if (revent & POLLNVAL) {
if (gdb->trapEvent.scheduled()) gdb->descheduleInstCommitEvent(&gdb->trapEvent);
eq->deschedule(&gdb->trapEvent);
gdb->detach(); gdb->detach();
} }
} }
@ -536,6 +530,29 @@ PCEventQueue *BaseRemoteGDB::getPcEventQueue()
return &system->pcEventQueue; return &system->pcEventQueue;
} }
EventQueue *
BaseRemoteGDB::getComInstEventQueue()
{
BaseCPU *cpu = context->getCpuPtr();
return cpu->comInstEventQueue[context->threadId()];
}
void
BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta)
{
EventQueue *eq = getComInstEventQueue();
// Here "ticks" aren't simulator ticks which measure time, they're
// instructions committed by the CPU.
eq->schedule(ev, eq->getCurTick() + delta);
}
void
BaseRemoteGDB::descheduleInstCommitEvent(Event *ev)
{
if (ev->scheduled())
getComInstEventQueue()->deschedule(ev);
}
bool bool
BaseRemoteGDB::checkBpLen(size_t len) BaseRemoteGDB::checkBpLen(size_t len)
{ {

View file

@ -216,6 +216,12 @@ class BaseRemoteGDB
virtual void setSingleStep() = 0; virtual void setSingleStep() = 0;
PCEventQueue *getPcEventQueue(); PCEventQueue *getPcEventQueue();
EventQueue *getComInstEventQueue();
/// Schedule an event which will be triggered "delta" instructions later.
void scheduleInstCommitEvent(Event *ev, int delta);
/// Deschedule an instruction count based event.
void descheduleInstCommitEvent(Event *ev);
protected: protected:
virtual bool checkBpLen(size_t len); virtual bool checkBpLen(size_t len);