Jan Vrany has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/48181 )
Change subject: base: Extract GDB command processing into separate function
......................................................................
base: Extract GDB command processing into separate function
Change-Id: I1f090285f92752d6907044b9ee6ade1869a2cb9f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48181
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/remote_gdb.cc
M src/base/remote_gdb.hh
2 files changed, 58 insertions(+), 44 deletions(-)
Approvals:
Gabe Black: 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 ad95046..b53cbc0 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -519,50 +519,7 @@
send("S%02x", signum);
}
- // Stick frame regs into our reg cache.
- regCachePtr = gdbRegs();
- regCachePtr->getRegs(tc);
-
- GdbCommand::Context cmd_ctx;
- cmd_ctx.type = signum;
- std::vector<char> data;
-
- for (;;) {
- try {
- recv(data);
- if (data.size() == 1)
- throw BadClient();
- cmd_ctx.cmdByte = data[0];
- cmd_ctx.data = data.data() + 1;
- // One for sentinel, one for cmdByte.
- cmd_ctx.len = data.size() - 2;
-
- auto cmd_it = commandMap.find(cmd_ctx.cmdByte);
- if (cmd_it == commandMap.end()) {
- DPRINTF(GDBMisc, "Unknown command: %c(%#x)\n",
- cmd_ctx.cmdByte, cmd_ctx.cmdByte);
- throw Unsupported();
- }
- cmd_ctx.cmd = &(cmd_it->second);
-
- if (!(this->*(cmd_ctx.cmd->func))(cmd_ctx))
- break;
-
- } catch (BadClient &e) {
- if (e.warning)
- warn(e.warning);
- detach();
- break;
- } catch (Unsupported &e) {
- send("");
- } catch (CmdError &e) {
- send(e.error);
- } catch (std::exception &e) {
- panic("Unrecognzied GDB exception: %s", e.what());
- } catch (...) {
- panic("Unrecognzied GDB exception.");
- }
- }
+ processCommands(signum);
}
void
@@ -683,6 +640,55 @@
} while ((c & 0x7f) == GDBBadP);
}
+void
+BaseRemoteGDB::processCommands(int signum)
+{
+ // Stick frame regs into our reg cache.
+ regCachePtr = gdbRegs();
+ regCachePtr->getRegs(tc);
+
+ GdbCommand::Context cmd_ctx;
+ cmd_ctx.type = signum;
+ std::vector<char> data;
+
+ for (;;) {
+ try {
+ recv(data);
+ if (data.size() == 1)
+ throw BadClient();
+ cmd_ctx.cmdByte = data[0];
+ cmd_ctx.data = data.data() + 1;
+ // One for sentinel, one for cmdByte.
+ cmd_ctx.len = data.size() - 2;
+
+ auto cmd_it = commandMap.find(cmd_ctx.cmdByte);
+ if (cmd_it == commandMap.end()) {
+ DPRINTF(GDBMisc, "Unknown command: %c(%#x)\n",
+ cmd_ctx.cmdByte, cmd_ctx.cmdByte);
+ throw Unsupported();
+ }
+ cmd_ctx.cmd = &(cmd_it->second);
+
+ if (!(this->*(cmd_ctx.cmd->func))(cmd_ctx))
+ break;
+
+ } catch (BadClient &e) {
+ if (e.warning)
+ warn(e.warning);
+ detach();
+ break;
+ } catch (Unsupported &e) {
+ send("");
+ } catch (CmdError &e) {
+ send(e.error);
+ } catch (std::exception &e) {
+ panic("Unrecognized GDB exception: %s", e.what());
+ } catch (...) {
+ panic("Unrecognized GDB exception.");
+ }
+ }
+}
+
// Read bytes from kernel address space for debugger.
bool
BaseRemoteGDB::read(Addr vaddr, size_t size, char *data)
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 7d8305b..f04bc9d 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -238,6 +238,14 @@
}
/*
+ * Process commands from remote GDB. If simulation has been
+ * stopped because of some kind of fault (as segmentation violation,
+ * or SW trap), 'signum' is the signal value reported back to GDB
+ * in "S" packet (this is done in trap()).
+ */
+ void processCommands(int signum=0);
+
+ /*
* Simulator side debugger state.
*/
bool active = false;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48181
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: I1f090285f92752d6907044b9ee6ade1869a2cb9f
Gerrit-Change-Number: 48181
Gerrit-PatchSet: 5
Gerrit-Owner: Jan Vrany <jan.vr...@labware.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Boris Shingarov <shinga...@labware.com>
Gerrit-Reviewer: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jan Vrany <jan.vr...@labware.com>
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
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s