Quentin Forcioli has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/63532?usp=email )

 (

6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
 )Change subject: base: adding a scheduleTrapEvent
......................................................................

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 <[email protected]>
Tested-by: kokoro <[email protected]>
Maintainer: Bobby Bruce <[email protected]>
---
M src/base/remote_gdb.cc
M src/base/remote_gdb.hh
2 files changed, 41 insertions(+), 10 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




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);


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/63532?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2a5f77da049d140b9ceffd42011fd8a1da59092e
Gerrit-Change-Number: 63532
Gerrit-PatchSet: 10
Gerrit-Owner: Quentin Forcioli <[email protected]>
Gerrit-Reviewer: Bobby Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Quentin Forcioli <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to