From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNb5O-0006Fx-L9 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 05:10:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNb5N-0003aO-L9 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 05:10:50 -0500 Date: Fri, 16 Nov 2018 11:10:08 +0100 From: "Edgar E. Iglesias" Message-ID: <20181116101008.GT7447@toto> References: <20181115094207.22846-1-luc.michel@greensocs.com> <20181115094207.22846-11-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20181115094207.22846-11-luc.michel@greensocs.com> Subject: Re: [Qemu-devel] [PATCH v6 10/16] gdbstub: add multiprocess support to 'D' packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luc Michel Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Peter Maydell , saipava@xilinx.com, edgari@xilinx.com, alistair@alistair23.me, Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , mark.burton@greensocs.com, Eduardo Habkost On Thu, Nov 15, 2018 at 10:42:01AM +0100, Luc Michel wrote: > 'D' packets are used by GDB to detach from a process. In multiprocess > mode, the PID to detach from is sent in the request. >=20 > Signed-off-by: Luc Michel > Reviewed-by: Philippe Mathieu-Daud=E9 Reviewed-by: Edgar E. Iglesias > --- > gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 53 insertions(+), 7 deletions(-) >=20 > diff --git a/gdbstub.c b/gdbstub.c > index 5df9929f92..eec1cf0d09 100644 > --- a/gdbstub.c > +++ b/gdbstub.c > @@ -1039,24 +1039,39 @@ static int gdb_breakpoint_remove(target_ulong add= r, target_ulong len, int type) > default: > return -ENOSYS; > } > } > =20 > +static inline void gdb_cpu_breakpoint_remove_all(CPUState *cpu) > +{ > + cpu_breakpoint_remove_all(cpu, BP_GDB); > +#ifndef CONFIG_USER_ONLY > + cpu_watchpoint_remove_all(cpu, BP_GDB); > +#endif > +} > + > +static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProc= ess *p) > +{ > + CPUState *cpu =3D get_first_cpu_in_process(s, p); > + > + while (cpu) { > + gdb_cpu_breakpoint_remove_all(cpu); > + cpu =3D gdb_next_cpu_in_process(s, cpu); > + } > +} > + > static void gdb_breakpoint_remove_all(void) > { > CPUState *cpu; > =20 > if (kvm_enabled()) { > kvm_remove_all_breakpoints(gdbserver_state->c_cpu); > return; > } > =20 > CPU_FOREACH(cpu) { > - cpu_breakpoint_remove_all(cpu, BP_GDB); > -#ifndef CONFIG_USER_ONLY > - cpu_watchpoint_remove_all(cpu, BP_GDB); > -#endif > + gdb_cpu_breakpoint_remove_all(cpu); > } > } > =20 > static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) > { > @@ -1331,13 +1346,44 @@ static int gdb_handle_packet(GDBState *s, const c= har *line_buf) > /* Kill the target */ > error_report("QEMU: Terminated via GDBstub"); > exit(0); > case 'D': > /* Detach packet */ > - gdb_breakpoint_remove_all(); > - gdb_syscall_mode =3D GDB_SYS_DISABLED; > - gdb_continue(s); > + pid =3D 1; > + > + if (s->multiprocess) { > + unsigned long lpid; > + if (*p !=3D ';') { > + put_packet(s, "E22"); > + break; > + } > + > + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { > + put_packet(s, "E22"); > + break; > + } > + > + pid =3D lpid; > + } > + > + process =3D gdb_get_process(s, pid); > + gdb_process_breakpoint_remove_all(s, process); > + process->attached =3D false; > + > + if (pid =3D=3D gdb_get_cpu_pid(s, s->c_cpu)) { > + s->c_cpu =3D gdb_first_cpu(s); > + } > + > + if (pid =3D=3D gdb_get_cpu_pid(s, s->g_cpu)) { > + s->g_cpu =3D gdb_first_cpu(s); > + } > + > + if (s->c_cpu =3D=3D NULL) { > + /* No more process attached */ > + gdb_syscall_mode =3D GDB_SYS_DISABLED; > + gdb_continue(s); > + } > put_packet(s, "OK"); > break; > case 's': > if (*p !=3D '\0') { > addr =3D strtoull(p, (char **)&p, 16); > --=20 > 2.19.1 >=20