]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/ukdebug: Add `qAttached` packet to gdb stub
authorThassilo Schulze <thassilo@unikraft.io>
Tue, 27 Aug 2024 09:39:39 +0000 (11:39 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Fri, 13 Sep 2024 20:51:57 +0000 (20:51 +0000)
This packet is not mandatory but gdb will probe for
it. Now we respond properly to the probing. This
packet must be updated to support the multiprocess
features of the gdb remote protocol.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

lib/ukdebug/gdbstub.c

index 5522b448f7aa072cc38a9f3e2e7bb893901b4e61..fde8bc5610e67c91f02f550b7dda35948458b3ec 100644 (file)
@@ -803,9 +803,30 @@ static int gdb_handle_qXfer(char *buf, __sz buf_len,
                offset, length);
 }
 
+/* qAttached */
+static int gdb_handle_qAttached(char *buf __unused, __sz buf_len,
+                               struct gdb_excpt_ctx *g __unused)
+{
+       /* NOTE: If multiprocess extensions are enabled, there's an additional
+        * :pid field at the end of the qAttached packet. Since multiprocess
+        * extensions are not currently supported, we just check that this field
+        * is not present.
+        */
+       if (buf_len) {
+               GDB_CHECK(gdb_send_error_packet(EINVAL));
+               return 0;
+       }
+
+       /* We attached to an existing process */
+       GDB_CHECK(gdb_send_packet(GDB_STR_A_LEN("1")));
+
+       return 0;
+}
+
 static struct gdb_cmd_table_entry gdb_q_cmd_table[] = {
        { gdb_handle_qsupported, GDB_STR_A_LEN("Supported") },
-       { gdb_handle_qXfer, GDB_STR_A_LEN("Xfer") }
+       { gdb_handle_qXfer, GDB_STR_A_LEN("Xfer") },
+       { gdb_handle_qAttached, GDB_STR_A_LEN("Attached") }
 };
 
 #define NUM_GDB_Q_CMDS (sizeof(gdb_q_cmd_table) / \