base: query now works the same way normal command worked

Query can now return true or false like normal command, to interrupt
execution, it might be needed if a query need to wait for another event.

Change-Id: Ic463287ecd88e6b63a53f2cb9a46c83d3419618c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63537
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:
Quentin Forcioli
2022-08-25 14:52:09 +02:00
parent a49cba9480
commit 6651329cc5
2 changed files with 25 additions and 20 deletions

View File

@@ -1333,13 +1333,14 @@ std::map<std::string, BaseRemoteGDB::QuerySetCommand>
{ "sThreadInfo", { &BaseRemoteGDB::querySThreadInfo } },
};
void
bool
BaseRemoteGDB::queryC(QuerySetCommand::Context &ctx)
{
send("QC%x", encodeThreadId(tc->contextId()));
return true;
}
void
bool
BaseRemoteGDB::querySupported(QuerySetCommand::Context &ctx)
{
std::ostringstream oss;
@@ -1350,9 +1351,10 @@ BaseRemoteGDB::querySupported(QuerySetCommand::Context &ctx)
for (const auto& feature : availableFeatures())
oss << ';' << feature;
send(oss.str());
return true;
}
void
bool
BaseRemoteGDB::queryXfer(QuerySetCommand::Context &ctx)
{
auto split = splitAt(ctx.args.at(0), ":");
@@ -1391,15 +1393,16 @@ BaseRemoteGDB::queryXfer(QuerySetCommand::Context &ctx)
std::string encoded;
encodeXferResponse(content, encoded, offset, length);
send(encoded);
return true;
}
void
bool
BaseRemoteGDB::querySymbol(QuerySetCommand::Context &ctx)
{
//The target does not need to look up any (more) symbols.
send("OK");
return true;
}
void
bool
BaseRemoteGDB::queryAttached(QuerySetCommand::Context &ctx)
{
std::string pid="";
@@ -1409,17 +1412,19 @@ BaseRemoteGDB::queryAttached(QuerySetCommand::Context &ctx)
DPRINTF(GDBMisc, "QAttached : pid=%s\n",pid);
//The remote server is attached to an existing process.
send("1");
return true;
}
void
bool
BaseRemoteGDB::queryFThreadInfo(QuerySetCommand::Context &ctx)
{
threadInfoIdx = 0;
querySThreadInfo(ctx);
return true;
}
void
bool
BaseRemoteGDB::querySThreadInfo(QuerySetCommand::Context &ctx)
{
if (threadInfoIdx >= threads.size()) {
@@ -1430,6 +1435,7 @@ BaseRemoteGDB::querySThreadInfo(QuerySetCommand::Context &ctx)
std::advance(it, threadInfoIdx++);
send("m%x", encodeThreadId(it->second->contextId()));
}
return true;
}
bool
@@ -1461,10 +1467,9 @@ BaseRemoteGDB::cmdQueryVar(GdbCommand::Context &ctx)
remaining = std::move(arg_split.second);
}
}
(this->*(query.func))(qctx);
return true;
//returning true if the query want to pursue GDB command processing
//false means that the command processing stop until it's trigger again.
return (this->*(query.func))(qctx);
}
std::vector<std::string>

View File

@@ -416,7 +416,7 @@ class BaseRemoteGDB
Context(const std::string &_name) : name(_name) {}
};
using Func = void (BaseRemoteGDB::*)(Context &ctx);
using Func = bool (BaseRemoteGDB::*)(Context &ctx);
const char * const argSep;
const Func func;
@@ -428,15 +428,15 @@ class BaseRemoteGDB
static std::map<std::string, QuerySetCommand> queryMap;
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);
bool queryC(QuerySetCommand::Context &ctx);
bool querySupported(QuerySetCommand::Context &ctx);
bool queryXfer(QuerySetCommand::Context &ctx);
bool querySymbol(QuerySetCommand::Context &ctx);
bool queryAttached(QuerySetCommand::Context &ctx);
size_t threadInfoIdx = 0;
void queryFThreadInfo(QuerySetCommand::Context &ctx);
void querySThreadInfo(QuerySetCommand::Context &ctx);
bool queryFThreadInfo(QuerySetCommand::Context &ctx);
bool querySThreadInfo(QuerySetCommand::Context &ctx);
protected:
ThreadContext *context() { return tc; }