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

 (

9 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
 )Change subject: base, sim: Adding support for message to GDB from python
......................................................................

base, sim: Adding support for message to GDB from python

Adding a small python function that allows to display
messages directly in GDB from the python interpreter.
This function is inside the Workload SimObject
(The stub is not a SimObject).
ex:
     system.workload.sendToGdb("message to display")

Change-Id: I46ddae079b10d298743e023f95bf15608f50e358
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63531
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
Maintainer: Bobby Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/remote_gdb.cc
M src/base/remote_gdb.hh
M src/sim/Workload.py
M src/sim/workload.cc
M src/sim/workload.hh
5 files changed, 49 insertions(+), 1 deletion(-)

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




diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 7aafa3d..e02ada0 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -575,6 +575,16 @@
     processCommands(signum);
 }

+bool
+BaseRemoteGDB::sendMessage(std::string message)
+{
+    if (!attached)
+        return false;
+    DPRINTF(GDBMisc, "passing message %s\n", message);
+    sendOPacket(message);
+    return true;
+}
+
 void
 BaseRemoteGDB::incomingConnection(int revent)
 {
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 671ee51..280f12c 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -172,6 +172,7 @@
     bool selectThreadContext(ContextID id);

     void trap(ContextID id, int signum,const std::string& stopReason="");
+    bool sendMessage(std::string message);

     /** @} */ // end of api_remote_gdb

diff --git a/src/sim/Workload.py b/src/sim/Workload.py
index 3fd4f81..b46c32f 100644
--- a/src/sim/Workload.py
+++ b/src/sim/Workload.py
@@ -24,7 +24,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 from m5.params import *
-from m5.SimObject import SimObject
+from m5.SimObject import SimObject, cxxMethod

 from m5.objects.SimpleMemory import *

@@ -37,6 +37,14 @@

wait_for_remote_gdb = Param.Bool(False, "Wait for a remote GDB connection")

+    @cxxMethod
+    def sendToGdb(self, message):
+        """send a message to the GDB client
+        Args:
+            message (str): message to send
+        """
+        pass
+

 class StubWorkload(Workload):
     type = "StubWorkload"
diff --git a/src/sim/workload.cc b/src/sim/workload.cc
index 1f6e072..ca51bbd 100644
--- a/src/sim/workload.cc
+++ b/src/sim/workload.cc
@@ -80,6 +80,14 @@
     }
     return false;
 };
+bool
+Workload::sendToGdb(std::string msg){
+     if (gdb)
+        return gdb->sendMessage(msg);
+    else
+        return false;
+ }
+

 void
 Workload::startup()
diff --git a/src/sim/workload.hh b/src/sim/workload.hh
index 9b3ef04..f9bb8db 100644
--- a/src/sim/workload.hh
+++ b/src/sim/workload.hh
@@ -92,6 +92,7 @@
// Once trapping into GDB is no longer a special case routed through the
     // system object, this helper can be removed.
     bool trapToGdb(int signal, ContextID ctx_id);
+    bool sendToGdb(std::string msg);

     virtual void registerThreadContext(ThreadContext *tc);
     virtual void replaceThreadContext(ThreadContext *tc);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/63531?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: I46ddae079b10d298743e023f95bf15608f50e358
Gerrit-Change-Number: 63531
Gerrit-PatchSet: 11
Gerrit-Owner: Quentin Forcioli <quentin.forci...@telecom-paris.fr>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Quentin Forcioli <quentin.forci...@telecom-paris.fr>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to