From nobody Thu Nov 6 10:36:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540543095079783.800483801756; Fri, 26 Oct 2018 01:38:15 -0700 (PDT) Received: from localhost ([::1]:58847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxdF-0002Bd-Va for importer@patchew.org; Fri, 26 Oct 2018 04:38:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxUI-0002m7-9l for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:29:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFxJE-0004pH-4I for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:17:33 -0400 Received: from greensocs.com ([193.104.36.180]:45409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxJ9-0004lc-GG; Fri, 26 Oct 2018 04:17:29 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C6EEB441B49; Fri, 26 Oct 2018 10:17:20 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wCgoeseR5jE5; Fri, 26 Oct 2018 10:17:20 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 68650441B45; Fri, 26 Oct 2018 10:17:18 +0200 (CEST) Received: from michell-laptop.home.lmichel.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id E4C7F441B47; Fri, 26 Oct 2018 10:17:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541840; bh=BihBqIDZ9GGhR6yGrLTs+q1njikFDNZXrheaOwYcMtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xjhu3rGQyMvmw1AWFtMokInf+aKnKVZ2/j2+SW2PCWoEh0DLYx3p1OdKd9aD64o43 +qkJS4BPedxjUjW2fRlKNvUUdpiL8Lg5TR//7K0PMvhutnb/RHhuXd+iz4JxsOK0nl 4Fs9CYiS28BHMiBdrG0elQjIg3J78PrZ2cTWJ0Y0= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=Lv9BWhGQ; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Lv9BWhGQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541838; bh=BihBqIDZ9GGhR6yGrLTs+q1njikFDNZXrheaOwYcMtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lv9BWhGQLK7ixObPInvQF6iAkzgVIPMmY6Myx6z+KTI8r90j7IXjSU2Nm3WVv7zON /+20HiVlX/bf3eYRdf1y8stEBc5APGQUc7UKhc00toe6Aux4nlCpZykQFMTUJzUUG0 3WyPHxnV/N6Mc+CUxf7KEU94g5FvZ0Ef1Py27qYM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541838; bh=BihBqIDZ9GGhR6yGrLTs+q1njikFDNZXrheaOwYcMtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lv9BWhGQLK7ixObPInvQF6iAkzgVIPMmY6Myx6z+KTI8r90j7IXjSU2Nm3WVv7zON /+20HiVlX/bf3eYRdf1y8stEBc5APGQUc7UKhc00toe6Aux4nlCpZykQFMTUJzUUG0 3WyPHxnV/N6Mc+CUxf7KEU94g5FvZ0Ef1Py27qYM= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 10:16:50 +0200 Message-Id: <20181026081653.24602-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026081653.24602-1-luc.michel@greensocs.com> References: <20181026081653.24602-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v3 13/16] gdbstub: processes initialization on new peer connection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" When a new connection is established, we set the first process to be attached, and the others detached. The first CPU of the first process is selected as the current CPU. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index e5eddd8e2b..b3461eff9e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2242,13 +2242,14 @@ static bool gdb_accept(void) close(fd); return false; } =20 s =3D g_malloc0(sizeof(GDBState)); - s->c_cpu =3D first_cpu; - s->g_cpu =3D first_cpu; create_unique_process(s); + s->processes[0].attached =3D true; + s->c_cpu =3D gdb_first_cpu(s); + s->g_cpu =3D s->c_cpu; s->fd =3D fd; gdb_has_xml =3D false; =20 gdbserver_state =3D s; return true; @@ -2330,12 +2331,23 @@ static void gdb_chr_receive(void *opaque, const uin= t8_t *buf, int size) } } =20 static void gdb_chr_event(void *opaque, int event) { + int i; + GDBState *s =3D (GDBState *) opaque; + switch (event) { case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i =3D 0; i < s->process_num; i++) { + s->processes[i].attached =3D !i; + } + + s->c_cpu =3D gdb_first_cpu(s); + s->g_cpu =3D s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml =3D false; break; default: break; @@ -2509,19 +2521,17 @@ int gdbserver_start(const char *device) mon_chr =3D s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr =3D mon_chr; } - s->c_cpu =3D first_cpu; - s->g_cpu =3D first_cpu; =20 create_processes(s); =20 if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_rec= eive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state =3D chr ? RS_IDLE : RS_INACTIVE; s->mon_chr =3D mon_chr; s->current_syscall_cb =3D NULL; =20 --=20 2.19.1