From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002jq-4Y for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061X-Du for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 From: Luc Michel Date: Mon, 1 Oct 2018 13:57:00 +0200 Message-Id: <20181001115704.701-12-luc.michel@greensocs.com> In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 11/15] gdbstub: add support for vAttach packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Luc Michel , qemu-arm@nongnu.org, Peter Maydell , saipava@xilinx.com, edgari@xilinx.com, alistair@alistair23.me, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , mark.burton@greensocs.com Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel --- gdbstub.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d372972dd3..b6de821025 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1326,10 +1326,42 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach", 6) =3D=3D 0) { + unsigned long pid; + + p +=3D 7; + + qemu_strtoul(p, &p, 16, &pid); + + process =3D gdb_get_process(s, pid); + + if (process =3D=3D NULL) { + put_packet(s, "E22"); + break; + } + + cpu =3D get_first_cpu_in_process(s, process); + + if (cpu =3D=3D NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached =3D true; + + s->g_cpu =3D cpu; + s->c_cpu =3D cpu; + + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRA= P, + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_= id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */ --=20 2.19.0