summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2014-12-05 22:35:47 -0800
committerGabe Black <gabeblack@google.com>2014-12-05 22:35:47 -0800
commit16c9b41616312bfef0b5859f7cebe24e8c17d9da (patch)
tree66e2724fb6ec416c38a35413463ce0bdf362dc6f /src
parentcddf988bfdb60bbf2e77aa23d98ee7ea8d12f072 (diff)
downloadgem5-16c9b41616312bfef0b5859f7cebe24e8c17d9da.tar.xz
misc: Add some utility functions for schedule inst commit events.
These can be used to simplify the implementation of single step in derived classes.
Diffstat (limited to 'src')
-rw-r--r--src/base/remote_gdb.cc33
-rw-r--r--src/base/remote_gdb.hh6
2 files changed, 31 insertions, 8 deletions
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 50bb78259..97d763803 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -141,7 +141,6 @@
#include "sim/system.hh"
using namespace std;
-using namespace Debug;
using namespace TheISA;
#ifndef NDEBUG
@@ -248,16 +247,11 @@ BaseRemoteGDB::InputEvent::InputEvent(BaseRemoteGDB *g, int fd, int e)
void
BaseRemoteGDB::InputEvent::process(int revent)
{
- BaseCPU *cpu = gdb->context->getCpuPtr();
- EventQueue *eq = cpu->comInstEventQueue[gdb->context->threadId()];
if (revent & POLLIN) {
gdb->trapEvent.type(SIGILL);
- // Here "ticks" aren't simulator ticks which measure time, they're
- // instructions committed by the CPU.
- eq->schedule(&gdb->trapEvent, eq->getCurTick());
+ gdb->scheduleInstCommitEvent(&gdb->trapEvent, 0);
} else if (revent & POLLNVAL) {
- if (gdb->trapEvent.scheduled())
- eq->deschedule(&gdb->trapEvent);
+ gdb->descheduleInstCommitEvent(&gdb->trapEvent);
gdb->detach();
}
}
@@ -536,6 +530,29 @@ PCEventQueue *BaseRemoteGDB::getPcEventQueue()
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
BaseRemoteGDB::checkBpLen(size_t len)
{
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 373f05343..62f98f29a 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -216,6 +216,12 @@ class BaseRemoteGDB
virtual void setSingleStep() = 0;
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:
virtual bool checkBpLen(size_t len);