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 <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Quentin Forcioli
2022-08-12 15:44:54 +02:00
parent eeaeee15aa
commit 2ae9692dfe
5 changed files with 29 additions and 1 deletions

View File

@@ -575,6 +575,16 @@ BaseRemoteGDB::trap(ContextID id, int signum,const std::string& stopReason)
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)
{

View File

@@ -172,6 +172,7 @@ class BaseRemoteGDB
bool selectThreadContext(ContextID id);
void trap(ContextID id, int signum,const std::string& stopReason="");
bool sendMessage(std::string message);
/** @} */ // end of api_remote_gdb

View File

@@ -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 @@ class Workload(SimObject):
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"

View File

@@ -80,6 +80,14 @@ Workload::trapToGdb(int signal, ContextID ctx_id)
}
return false;
};
bool
Workload::sendToGdb(std::string msg){
if (gdb)
return gdb->sendMessage(msg);
else
return false;
}
void
Workload::startup()

View File

@@ -92,6 +92,7 @@ class Workload : public SimObject
// 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);