Add support for the vAttach packets. In multiprocess mode, GDB sends
them to attach to additional processes.
Signed-off-by: Luc Michel <luc.michel@greensocs.com>
---
gdbstub.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/gdbstub.c b/gdbstub.c
index 4bed0a85f3..4874d65a30 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1327,10 +1327,42 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
break;
}
goto unknown_command;
}
break;
+ } else if (strncmp(p, "Attach", 6) == 0) {
+ unsigned long pid;
+
+ p += 7;
+
+ qemu_strtoul(p, &p, 16, &pid);
+
+ process = gdb_get_process(s, pid);
+
+ if (process == NULL) {
+ put_packet(s, "E22");
+ break;
+ }
+
+ cpu = get_first_cpu_in_process(s, process);
+
+ if (cpu == NULL) {
+ /* Refuse to attach an empty process */
+ put_packet(s, "E22");
+ break;
+ }
+
+ process->attached = true;
+
+ s->g_cpu = cpu;
+ s->c_cpu = cpu;
+
+ snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP,
+ get_thread_id(s, cpu, thread_id, sizeof(thread_id)));
+
+ put_packet(s, buf);
+ break;
} else {
goto unknown_command;
}
case 'k':
/* Kill the target */
--
2.18.0