From patchwork Fri Dec 7 09:01:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 1009258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.b="BSbSuxmp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="iKsiv8qd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="iKsiv8qd"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43B6Sv6PQZz9s3q for ; Fri, 7 Dec 2018 20:22:55 +1100 (AEDT) Received: from localhost ([::1]:44959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCLV-0004eN-HZ for incoming@patchwork.ozlabs.org; Fri, 07 Dec 2018 04:22:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1a-0008AL-GI for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1Z-0005g7-If for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:18 -0500 Received: from greensocs.com ([193.104.36.180]:52245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1W-0005Rq-AL; Fri, 07 Dec 2018 04:02:14 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E6A05480018; Fri, 7 Dec 2018 10:01:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173313; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BSbSuxmp8dbH8IVoKBFUmkhO44+fUHu5Pl/MpBR55SjBrN3iU3INaLfz/BsFFqj47 aSj1Q23XPtpYINkjOpYMTVk1deF5AtoM0bVbNrCKmnpvaihrjDzqFR3MzN8uaFYzIF 9TRd2cRwu4D1Y+syi6Djk7Jd4cgUDF8W6B+As3sg= 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=iKsiv8qd; dkim=pass (1024-bit key) header.d=greensocs.com header.b=iKsiv8qd 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 9dfIsUucce24; Fri, 7 Dec 2018 10:01:52 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id B1B2E480037; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iKsiv8qdUoN8RAZrpyjiSwm3Scm1lOPUqsutXpXYq7YkGS72rKXCgh6V2mm3GuvDH IYDHvPsub+V6m8M9Ss1CG1FHAaXdOp7GLTJSz987otbDBgMTtZh5Z/V8ChjvF7N4IN AHjqa5aIJRwMDw2AaoRScKyQNbmKqQBJ8okHvDnM= 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 4C2BA480013; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iKsiv8qdUoN8RAZrpyjiSwm3Scm1lOPUqsutXpXYq7YkGS72rKXCgh6V2mm3GuvDH IYDHvPsub+V6m8M9Ss1CG1FHAaXdOp7GLTJSz987otbDBgMTtZh5Z/V8ChjvF7N4IN AHjqa5aIJRwMDw2AaoRScKyQNbmKqQBJ8okHvDnM= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:31 +0100 Message-Id: <20181207090135.7651-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 8601be533b..81e7742847 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2265,13 +2265,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_default_process(s); + s->processes[0].attached = true; + s->c_cpu = gdb_first_attached_cpu(s); + s->g_cpu = s->c_cpu; s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2353,12 +2354,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_attached_cpu(s); + s->g_cpu = s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml = false; break; default: break; @@ -2543,19 +2555,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;