From nobody Tue Apr 15 14:47:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546879048791664.6805656208983; Mon, 7 Jan 2019 08:37:28 -0800 (PST) Received: from localhost ([127.0.0.1]:43635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXtx-0000UA-Gd for importer@patchew.org; Mon, 07 Jan 2019 11:37:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXoa-00050L-8a for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoY-00024s-BB for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:48 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:56147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXoX-0001w9-V9 for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:46 -0500 Received: by mail-wm1-x331.google.com with SMTP id y139so1436454wmc.5 for ; Mon, 07 Jan 2019 08:31:40 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=u312PotEuQpWHq94BwRphO7NoGBKFDJhyMDW9Wc9sAM=; b=eGZVl4DTVdUWVa/yZ6b4cpf1yKwJE5zq2lfOTw5TtzjAnHWSu5lxWC/RqJbmVuLTE2 DcSLAdAnUKGGBnR41xEuA0rXYJIS8nYSSi8IEMl7UgSuHZtVxnaXc+jFKF7M/Y3wbeso iRTQHuPpi+gHuaFbCjAY1iuMCRFr1OVelxoDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u312PotEuQpWHq94BwRphO7NoGBKFDJhyMDW9Wc9sAM=; b=mc+lPA1frYxpreXM3iDbblL+M+2mdmWsTSdpkuwjm36UAnaN3vBRmDJsuUfMy7jYbJ QAwK0iCyB0bfs5RCChP4PjfsbcRN26UcPg5CTmtRHZkF8JlK9wCuwJDawqg7SPNMnKtW I7/RKbowklqLD4exHnXmL26e3YSYnfrGoAu+UAdiNm20eh4AZkdWfo3iBUDV/tJDNBT/ +iB7cVo0/sWGT+crpqtBlqND05JseiQjca1J5VWvcO4UkDfzPGv3eVZi/IoCiUa10vmr qhJtufpYVCfWnVQmu/fHQOVTI+wGq4zUq/HrtYvhcf7TlG8hyOteZ9dDRbDcz47/gwrZ 6JmA== X-Gm-Message-State: AJcUukcoAC18udNy71+NJ46IA8NDNO+DljebG5PIysnwOirZbkNoC6Pz 2UVRwyE+Mf32ZKS7OpjP+vC618QqrIoT7g== X-Google-Smtp-Source: ALg8bN4YeRRUVMr4I6IRmvlkx3OTuNSI78f2da3GkBuUWQXkWyyOBKi5NhXMzSgsV2Ot5sN9WNpjbw== X-Received: by 2002:a1c:2408:: with SMTP id k8mr8833662wmk.110.1546878698989; Mon, 07 Jan 2019 08:31:38 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2019 16:30:55 +0000 Message-Id: <20190107163117.16269-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 15/37] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Luc Michel 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 Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20181207090135.7651-14-luc.michel@greensocs.com Signed-off-by: Peter Maydell --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d80af955cea..432e7d2f7da 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2267,9 +2267,10 @@ static bool gdb_accept(void) } =20 s =3D g_malloc0(sizeof(GDBState)); - s->c_cpu =3D first_cpu; - s->g_cpu =3D first_cpu; create_default_process(s); + s->processes[0].attached =3D true; + s->c_cpu =3D gdb_first_attached_cpu(s); + s->g_cpu =3D s->c_cpu; s->fd =3D fd; gdb_has_xml =3D false; =20 @@ -2355,8 +2356,19 @@ static void gdb_chr_receive(void *opaque, const uint= 8_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_attached_cpu(s); + s->g_cpu =3D s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml =3D false; break; @@ -2546,15 +2558,13 @@ int gdbserver_start(const char *device) 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; --=20 2.19.2