From patchwork Mon Oct 1 11:57:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F55B1515 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C85E291D3 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 709632933C; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10FB3291D3 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: from localhost ([::1]:37903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x0B-0005Q4-54 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpv-0002su-CX for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpr-000642-9S for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:58:03 -0400 Received: from greensocs.com ([193.104.36.180]:40137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wph-0005iX-1T; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2A97B511C70; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395035; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SSlA1nADzAFBbpI9Vin7FWurRPOETsokWws0emGuGqaSv8IJsC0v21ntJaLTg6QEI E8sU4a6jd/C96poTlsXbw2pyDC2ipWOt6ZE4hx22GTl9V16FVl90xnD58IFqFiogjs auiHXGfagEBYI7zzCikIYQAbtBg/uMp0C2m3Yw9E= 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=FIilloBC; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FIilloBC 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 UxzaOMl4-Tg1; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E21DC511C75; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FIilloBCap28Cy2p26lBvzRJSn8e++ltAlQ6vpNXl+ZMuSIuxtBQatx6n+Io/MmBA UVBHF0bMmbZImSfwNOcbqFwKv1YLw+3eYL8XQC7Sgvp6qGAj8B0vw4akWXuCc3IG6N PMIvEbTQ000jaLBRWW2X7H1RCX1/eFLQg56I44x0= 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 69E2D511C6F; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FIilloBCap28Cy2p26lBvzRJSn8e++ltAlQ6vpNXl+ZMuSIuxtBQatx6n+Io/MmBA UVBHF0bMmbZImSfwNOcbqFwKv1YLw+3eYL8XQC7Sgvp6qGAj8B0vw4akWXuCc3IG6N PMIvEbTQ000jaLBRWW2X7H1RCX1/eFLQg56I44x0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:01 +0200 Message-Id: <20181001115704.701-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 12/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 b6de821025..c27a3edf1d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2221,13 +2221,14 @@ static bool gdb_accept(void) close(fd); return false; } s = g_malloc0(sizeof(GDBState)); - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_unique_process(s); + s->processes[0].attached = true; + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2309,12 +2310,23 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) } } static void gdb_chr_event(void *opaque, int event) { + int i; + GDBState *s = (GDBState *) opaque; + switch (event) { case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i = 0; i < s->process_num; i++) { + s->processes[i].attached = !i; + } + + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml = false; break; default: break; @@ -2474,19 +2486,17 @@ int gdbserver_start(const char *device) mon_chr = s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_processes(s); if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state = chr ? RS_IDLE : RS_INACTIVE; s->mon_chr = mon_chr; s->current_syscall_cb = NULL;