base: adding a scheduleTrapEvent
This function centralize setting up a new trapEvent making sure that
the contextId match with the ThreadContext use for the Event.
Change-Id: I2a5f77da049d140b9ceffd42011fd8a1da59092e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63532
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index e02ada0..2c74aa0 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -607,9 +607,7 @@
}
if (revent & POLLIN) {
- trapEvent.type(SIGILL);
- trapEvent.id(tc->contextId());
- scheduleInstCommitEvent(&trapEvent, 0);
+ scheduleTrapEvent(tc->contextId(),SIGILL,0,"");
} else if (revent & POLLNVAL) {
descheduleInstCommitEvent(&trapEvent);
scheduleInstCommitEvent(&disconnectEvent, 0);
@@ -964,10 +962,23 @@
BaseRemoteGDB::sendOPacket(const std::string message){
send("O" + string2hexS(message));
}
+
void
-BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta)
+BaseRemoteGDB::scheduleTrapEvent(ContextID id,int type,int delta,
+ std::string stopReason){
+ ThreadContext* _tc = threads[id];
+ panic_if(_tc == nullptr, "Unknown context id :%i",id);
+ trapEvent.id(id);
+ trapEvent.type(type);
+ trapEvent.stopReason(stopReason);
+ if (!trapEvent.scheduled())
+ scheduleInstCommitEvent(&trapEvent,delta,_tc);
+}
+
+void
+BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta,ThreadContext* _tc)
{
- if (delta == 0 && tc->status() != ThreadContext::Active) {
+ if (delta == 0 && _tc->status() != ThreadContext::Active) {
// If delta is zero, we're just trying to wait for an instruction
// boundary. If the CPU is not active, assume we're already at a
// boundary without waiting for the CPU to eventually wake up.
@@ -975,7 +986,7 @@
} else {
// Here "ticks" aren't simulator ticks which measure time, they're
// instructions committed by the CPU.
- tc->scheduleInstCountEvent(ev, tc->getCurrentInstCount() + delta);
+ _tc->scheduleInstCountEvent(ev, _tc->getCurrentInstCount() + delta);
}
}
@@ -1154,8 +1165,7 @@
throw CmdError("E04");
// Line up on an instruction boundary in the new thread.
threadSwitching = true;
- trapEvent.id(tid);
- scheduleInstCommitEvent(&trapEvent, 0);
+ scheduleTrapEvent(tid,0,0,"");
return false;
}
} else {
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 280f12c..d4a8a5b 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -173,7 +173,9 @@
void trap(ContextID id, int signum,const std::string& stopReason="");
bool sendMessage(std::string message);
-
+ //schedule a trap event with these properties
+ void scheduleTrapEvent(ContextID id,int type, int delta,
+ std::string stopReason);
/** @} */ // end of api_remote_gdb
template <class GDBStub, class ...Args>
@@ -313,7 +315,10 @@
void setSingleStep();
/// Schedule an event which will be triggered "delta" instructions later.
- void scheduleInstCommitEvent(Event *ev, int delta);
+ void scheduleInstCommitEvent(Event *ev, int delta,ThreadContext* _tc);
+ void scheduleInstCommitEvent(Event *ev, int delta){
+ scheduleInstCommitEvent(ev, delta,tc);
+ };
/// Deschedule an instruction count based event.
void descheduleInstCommitEvent(Event *ev);