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>
This commit is contained in:
@@ -607,9 +607,7 @@ BaseRemoteGDB::incomingData(int revent)
|
||||
}
|
||||
|
||||
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 @@ void
|
||||
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 @@ BaseRemoteGDB::scheduleInstCommitEvent(Event *ev, int delta)
|
||||
} 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 @@ BaseRemoteGDB::cmdSetThread(GdbCommand::Context &ctx)
|
||||
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 {
|
||||
|
||||
@@ -173,7 +173,9 @@ class BaseRemoteGDB
|
||||
|
||||
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 @@ class BaseRemoteGDB
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user