qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gdbstub: implement reset in system mode


From: David Malaschonok
Subject: [PATCH] gdbstub: implement reset in system mode
Date: Mon, 16 Dec 2024 14:47:34 +0100
User-agent: Mozilla Thunderbird

Added a handler for RSP reset commands `R` and `r`. In system mode, we
call qemu_system_reset_request. In user mode, no reset is implemented.
An error packet is sent instead.

Signed-off-by: David Malaschonok <david.malaschonok@sit.fraunhofer.de>
---
 gdbstub/gdbstub.c   |  5 +++++
 gdbstub/internals.h |  5 +++++
 gdbstub/system.c    |  9 +++++++++
 gdbstub/user.c      | 13 +++++++++++++
 4 files changed, 32 insertions(+)

diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index b1def7e71d..ce2e2e8291 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -2093,6 +2093,11 @@ static int gdb_handle_packet(const char *line_buf)
         gdb_exit(0);
         gdb_qemu_exit(0);
         break;
+    case 'r':
+    case 'R':
+        /* Reset the target */
+        gdb_reset();
+        break;
     case 'D':
         {
             static const GdbCmdParseEntry detach_cmd_desc = {
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index bf5a5c6302..c5b448e38d 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -154,6 +154,11 @@ void gdb_continue(void);
  */
 int gdb_continue_partial(char *newstates);

+/**
+ * gdb_reset() - reset target in mode specific way.
+ */
+void gdb_reset(void);
+
 /*
  * Helpers with separate system and user implementations
  */
diff --git a/gdbstub/system.c b/gdbstub/system.c
index c9f236e94f..3636502c6d 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -603,6 +603,15 @@ int gdb_continue_partial(char *newstates)
     return res;
 }

+/*
+ * Reset the system.
+ */
+
+void gdb_reset(void)
+{
+    qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
+}
+
 /*
  * Signal Handling - in system mode we only need SIGINT and SIGTRAP; other
  * signals are not yet supported.
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 0b4bfa9c48..6886cbfc20 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -657,6 +657,18 @@ int gdb_continue_partial(char *newstates)
     return res;
 }

+/*
+ * Reset target. (currently not implemented)
+ */
+
+void gdb_reset(void)
+{
+    // Not implemented.
+ // By default, the RSP reset command does not trigger a response. We respond with an + // error code here, so the client does not assume the system has been reset.
+    gdb_put_packet("E00");
+}
+
 /*
  * Memory access helpers
  */
@@ -751,6 +763,7 @@ void gdb_breakpoint_remove_all(CPUState *cs)
     cpu_breakpoint_remove_all(cs, BP_GDB);
 }

+
 /*
  * For user-mode syscall support we send the system call immediately
  * and then return control to gdb for it to process the syscall request.
--
2.43.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]