base: adding queryAttached and querySymbol to GDB

In some cases/version these queries might be needed
to make the remote GDB connect correctly to the stub.

Change-Id: I98cdc9b4a952b4dc64f9357e6148af6e3351ef92
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63530
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 4835f00..7aafa3d 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -1299,8 +1299,10 @@
 std::map<std::string, BaseRemoteGDB::QuerySetCommand>
         BaseRemoteGDB::queryMap = {
     { "C", { &BaseRemoteGDB::queryC } },
+    { "Attached", { &BaseRemoteGDB::queryAttached} },
     { "Supported", { &BaseRemoteGDB::querySupported, ";" } },
     { "Xfer", { &BaseRemoteGDB::queryXfer } },
+    { "Symbol", { &BaseRemoteGDB::querySymbol  ,":" } },
     { "fThreadInfo", { &BaseRemoteGDB::queryFThreadInfo } },
     { "sThreadInfo", { &BaseRemoteGDB::querySThreadInfo } },
 };
@@ -1364,6 +1366,25 @@
     encodeXferResponse(content, encoded, offset, length);
     send(encoded);
 }
+void
+BaseRemoteGDB::querySymbol(QuerySetCommand::Context &ctx)
+{
+    //The target does not need to look up any (more) symbols.
+    send("OK");
+}
+
+void
+BaseRemoteGDB::queryAttached(QuerySetCommand::Context &ctx)
+{
+    std::string pid="";
+    if (!ctx.args.empty() && !ctx.args[0].empty()){
+         pid=ctx.args[0];
+    }
+    DPRINTF(GDBMisc, "QAttached : pid=%s\n",pid);
+    //The remote server is attached to an existing process.
+    send("1");
+}
+
 
 void
 BaseRemoteGDB::queryFThreadInfo(QuerySetCommand::Context &ctx)
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index d51268a..671ee51 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -426,6 +426,8 @@
     void queryC(QuerySetCommand::Context &ctx);
     void querySupported(QuerySetCommand::Context &ctx);
     void queryXfer(QuerySetCommand::Context &ctx);
+    void querySymbol(QuerySetCommand::Context &ctx);
+    void queryAttached(QuerySetCommand::Context &ctx);
 
     size_t threadInfoIdx = 0;
     void queryFThreadInfo(QuerySetCommand::Context &ctx);