From patchwork Sat Nov 10 08:11:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676991 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 80833109C for ; Sat, 10 Nov 2018 08:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70D352DF1C for ; Sat, 10 Nov 2018 08:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 621D42DF19; Sat, 10 Nov 2018 08:26:07 +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 B9E002DF19 for ; Sat, 10 Nov 2018 08:26:06 +0000 (UTC) Received: from localhost ([::1]:37559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOak-0000M8-2u for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:26:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003rH-I4 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000o0-D3 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOY-0000TB-Vc; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E08565D19A6; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=JiC+TmMFd9OLB4+WksacmGkhv9++c1guh9aOUkKjcTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kBRl5ZDX/CyglnRFtf7DPe2vBe4uX7hsAonqGiswXHvHxkhJ7KjJkGZ/UfGpUm3tN 9iXoo7lu2GZK7NPxZ1sM5w43/0MaEJ5MigOXEjczKVq/c8Q/U98bAZRsZchELgpP9d d+4LTeGspLbBSLlaEtar9WEMLwEiDQ/tGwE7Um7c= 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=CMO0sjKH; dkim=pass (1024-bit key) header.d=greensocs.com header.b=gyW4Mjcs 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 Mttch_idWQUd; Sat, 10 Nov 2018 09:13:21 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 08FA45E2E3; Sat, 10 Nov 2018 09:13:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837601; bh=JiC+TmMFd9OLB4+WksacmGkhv9++c1guh9aOUkKjcTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CMO0sjKHOzCYWZasLKPTpbj5K4X9t60XwFEhTXsJ4OZPv66J6VEtZ0dQGnKw6E3Vx u0f27VV5ncfmQuWbghf2vmc5PwcNkVj34p9OrlFmSjkenpzh9G2i4NpHRW3xr3lXu3 L1OYuGgVg/YjDtu0PeoPZc2eWnEHgi4zCzlg8VRQ= 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 7E5746FD81; Sat, 10 Nov 2018 09:13:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837600; bh=JiC+TmMFd9OLB4+WksacmGkhv9++c1guh9aOUkKjcTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gyW4MjcsM76OkwCYLYonZZ9swsUkCoWF9UyYVte2dWUJovrt1y5al3xbAWVoIO9R0 dqJwGoxaUiRy11+w6jzMPfjW5ZqTG5imcgJCoiNpfrt9xuMBJeVp5H845jfNwdi6X2 u22fUTCrxNKPCdBSCbrWHkz24DaKCMTzLDGjDsWI= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:32 +0100 Message-Id: <20181110081147.4027-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 01/16] hw/cpu: introduce CPU clusters 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This commit adds the cpu-cluster type. It aims at gathering CPUs from the same cluster in a machine. For now it only has a `cluster-id` property. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias --- include/hw/cpu/cluster.h | 38 ++++++++++++++++++++++++++ hw/cpu/cluster.c | 59 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 ++ hw/cpu/Makefile.objs | 2 +- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 include/hw/cpu/cluster.h create mode 100644 hw/cpu/cluster.c diff --git a/include/hw/cpu/cluster.h b/include/hw/cpu/cluster.h new file mode 100644 index 0000000000..11f50d5f6b --- /dev/null +++ b/include/hw/cpu/cluster.h @@ -0,0 +1,38 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ +#ifndef HW_CPU_CLUSTER_H +#define HW_CPU_CLUSTER_H + +#include "qemu/osdep.h" +#include "hw/qdev.h" + +#define TYPE_CPU_CLUSTER "cpu-cluster" +#define CPU_CLUSTER(obj) \ + OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) + +typedef struct CPUClusterState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ + uint32_t cluster_id; +} CPUClusterState; + +#endif diff --git a/hw/cpu/cluster.c b/hw/cpu/cluster.c new file mode 100644 index 0000000000..e0ffd76152 --- /dev/null +++ b/hw/cpu/cluster.c @@ -0,0 +1,59 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ + +#include "qemu/osdep.h" +#include "hw/cpu/cluster.h" +#include "qapi/error.h" +#include "qemu/module.h" + +static void cpu_cluster_init(Object *obj) +{ + static uint32_t cluster_id_auto_increment; + CPUClusterState *cluster = CPU_CLUSTER(obj); + + cluster->cluster_id = cluster_id_auto_increment++; +} + +static Property cpu_cluster_properties[] = { + DEFINE_PROP_UINT32("cluster-id", CPUClusterState, cluster_id, 0), + DEFINE_PROP_END_OF_LIST() +}; + +static void cpu_cluster_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->props = cpu_cluster_properties; +} + +static const TypeInfo cpu_cluster_type_info = { + .name = TYPE_CPU_CLUSTER, + .parent = TYPE_DEVICE, + .instance_size = sizeof(CPUClusterState), + .instance_init = cpu_cluster_init, + .class_init = cpu_cluster_class_init, +}; + +static void cpu_cluster_register_types(void) +{ + type_register_static(&cpu_cluster_type_info); +} + +type_init(cpu_cluster_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 126fe0be7e..8e20b0e672 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1022,11 +1022,13 @@ Machine core M: Eduardo Habkost M: Marcel Apfelbaum S: Supported F: hw/core/machine.c F: hw/core/null-machine.c +F: hw/cpu/cluster.c F: include/hw/boards.h +F: include/hw/cpu/cluster.h T: git git://github.com/ehabkost/qemu.git machine-next Xtensa Machines --------------- sim diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs index cd52d20b65..8db9e8a7b3 100644 --- a/hw/cpu/Makefile.objs +++ b/hw/cpu/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o obj-$(CONFIG_REALVIEW) += realview_mpcore.o obj-$(CONFIG_A9MPCORE) += a9mpcore.o obj-$(CONFIG_A15MPCORE) += a15mpcore.o -common-obj-y += core.o +common-obj-y += core.o cluster.o From patchwork Sat Nov 10 08:11:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676971 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 29DA215A6 for ; Sat, 10 Nov 2018 08:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 154692DEB4 for ; Sat, 10 Nov 2018 08:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05D432DEB6; Sat, 10 Nov 2018 08:16:53 +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 5CDB92DEB4 for ; Sat, 10 Nov 2018 08:16:52 +0000 (UTC) Received: from localhost ([::1]:37503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLORn-000632-D3 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:16:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003r7-C0 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000nk-8w for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOX-0000QF-V0; Sat, 10 Nov 2018 03:13:30 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id B96D3441B5D; Sat, 10 Nov 2018 09:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837602; bh=r3G67lVVAUL9k1D9HU6njTCRV6L0gyLUDtK2xzj7t6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R08TxEJsm2f3rir3sIBseSaTiath9n6my5nomooT2+Dr/PAPcXLq3hbCrcO4Fa1S0 gdok+EYGTB/Ds10AgDPOSyy15HAUXI27fErq+cV7LR2BjHXs0tBnJ2bsah+pFfqKQe sMwZD8OvGIdogyNhjSFjuh5GHEyXmbKcp3p0OHvQ= 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=S+o5dd/K; dkim=pass (1024-bit key) header.d=greensocs.com header.b=S+o5dd/K 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 FBZ3a1MFNigQ; Sat, 10 Nov 2018 09:13:21 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id C78ECDFFF5; Sat, 10 Nov 2018 09:13:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837601; bh=r3G67lVVAUL9k1D9HU6njTCRV6L0gyLUDtK2xzj7t6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S+o5dd/K3wlCLhv6HGATAz9kAmbTo4YIxvoqHyikMFZNMqqQsCek5eX//ucjXmP0z Ru0UMWFc7Ae0CugVHeN2vMLCp4HpS3CdTkiutdQ5kQfwkTwgpDlgsmrJGfgrvfcodo GGkLV3x4SdCi5LGrNIlq4i+vCWWsd0eefP/ezqKs= 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 2DBA36FD81; Sat, 10 Nov 2018 09:13:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837601; bh=r3G67lVVAUL9k1D9HU6njTCRV6L0gyLUDtK2xzj7t6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S+o5dd/K3wlCLhv6HGATAz9kAmbTo4YIxvoqHyikMFZNMqqQsCek5eX//ucjXmP0z Ru0UMWFc7Ae0CugVHeN2vMLCp4HpS3CdTkiutdQ5kQfwkTwgpDlgsmrJGfgrvfcodo GGkLV3x4SdCi5LGrNIlq4i+vCWWsd0eefP/ezqKs= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:33 +0100 Message-Id: <20181110081147.4027-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 02/16] gdbstub: introduce GDB processes 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a structure GDBProcess that represent processes from the GDB semantic point of view. CPUs can be split into different processes, by grouping them under different cpu-cluster objects. Each occurrence of a cpu-cluster object implies the existence of the corresponding process in the GDB stub. The GDB process ID is derived from the corresponding cluster ID as follows: GDB PID = cluster ID + 1 This is because PIDs -1 and 0 are reserved in GDB and cannot be used by processes. When no such container are found, all the CPUs are put in a unique GDB process (create_unique_process()). This is also the case when compiled in user mode, where multi-processes do not make much sense for now. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index c4e4f9f082..0d70b89598 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -27,10 +27,11 @@ #include "monitor/monitor.h" #include "chardev/char.h" #include "chardev/char-fe.h" #include "sysemu/sysemu.h" #include "exec/gdbstub.h" +#include "hw/cpu/cluster.h" #endif #define MAX_PACKET_LENGTH 4096 #include "qemu/sockets.h" @@ -294,10 +295,15 @@ typedef struct GDBRegisterState { gdb_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; +typedef struct GDBProcess { + uint32_t pid; + bool attached; +} GDBProcess; + enum RSState { RS_INACTIVE, RS_IDLE, RS_GETLINE, RS_GETLINE_ESC, @@ -322,10 +328,13 @@ typedef struct GDBState { int running_state; #else CharBackend chr; Chardev *mon_chr; #endif + bool multiprocess; + GDBProcess *processes; + int process_num; char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; } GDBState; /* By default use no IRQs and no timers while single stepping so as to @@ -1749,10 +1758,24 @@ void gdb_exit(CPUArchState *env, int code) #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&s->chr, true); #endif } +/* + * Create a unique process containing all the CPUs. + */ +static void create_unique_process(GDBState *s) +{ + GDBProcess *process; + + s->processes = g_malloc0(sizeof(GDBProcess)); + s->process_num = 1; + process = &s->processes[0]; + + process->pid = 1; +} + #ifdef CONFIG_USER_ONLY int gdb_handlesig(CPUState *cpu, int sig) { GDBState *s; @@ -1846,10 +1869,11 @@ static bool gdb_accept(void) } s = g_malloc0(sizeof(GDBState)); s->c_cpu = first_cpu; s->g_cpu = first_cpu; + create_unique_process(s); s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2002,10 +2026,58 @@ static const TypeInfo char_gdb_type_info = { .name = TYPE_CHARDEV_GDB, .parent = TYPE_CHARDEV, .class_init = char_gdb_class_init, }; +static int find_cpu_clusters(Object *child, void *opaque) +{ + if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { + GDBState *s = (GDBState *) opaque; + CPUClusterState *cluster = CPU_CLUSTER(child); + GDBProcess *process; + + s->processes = g_renew(GDBProcess, s->processes, ++s->process_num); + + process = &s->processes[s->process_num - 1]; + + /* GDB process IDs -1 and 0 are reserved */ + process->pid = cluster->cluster_id + 1; + process->attached = false; + return 0; + } + + return object_child_foreach(child, find_cpu_clusters, opaque); +} + +static int pid_order(const void *a, const void *b) +{ + GDBProcess *pa = (GDBProcess *) a; + GDBProcess *pb = (GDBProcess *) b; + + return pa->pid - pb->pid; +} + +static void create_processes(GDBState *s) +{ + object_child_foreach(object_get_root(), find_cpu_clusters, s); + + if (!s->processes) { + /* No CPU cluster specified by the machine */ + create_unique_process(s); + } else { + /* Sort by PID */ + qsort(s->processes, s->process_num, sizeof(s->processes[0]), pid_order); + } +} + +static void cleanup_processes(GDBState *s) +{ + g_free(s->processes); + s->process_num = 0; + s->processes = NULL; +} + int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); GDBState *s; @@ -2058,15 +2130,19 @@ int gdbserver_start(const char *device) NULL, &error_abort); monitor_init(mon_chr, 0); } else { qemu_chr_fe_deinit(&s->chr, true); 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); } From patchwork Sat Nov 10 08:11:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676977 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 9CBD7109C for ; Sat, 10 Nov 2018 08:20:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DD902D9B1 for ; Sat, 10 Nov 2018 08:20:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81F832D9C9; Sat, 10 Nov 2018 08:20:16 +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 043302D9B1 for ; Sat, 10 Nov 2018 08:20:16 +0000 (UTC) Received: from localhost ([::1]:37519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOV5-00026p-6v for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:20:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003qu-5R for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000o6-Cs for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOX-0000QE-Uz; Sat, 10 Nov 2018 03:13:30 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id AB330443259; Sat, 10 Nov 2018 09:13:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=fPhNMVOgnILrdu8vEVGAW8FkOUJiKmx8HxmopOK4UcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cdvsjN8zSxF8dRTvJMXjCDpxi9htagfrccCUzGSLDJp/84BU3Sr5Eq2zKBilrtGMC kD4nWGItT5rDzyidm7/LKRCopRZKDMg+Ujic1RjSEU632gQsVe8xDCAOQoh7K1HDgp WfkreXA/a9xu1a2hmSjGci4Eu2xFKX01Evn5Boac= 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=Q+zXzKTx; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Q+zXzKTx 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 sKOD5PWb-YKF; Sat, 10 Nov 2018 09:13:22 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 5DDAB6FD81; Sat, 10 Nov 2018 09:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837602; bh=fPhNMVOgnILrdu8vEVGAW8FkOUJiKmx8HxmopOK4UcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Q+zXzKTxf+iXlD+RqbWG6CzpBVh2323to5MV434rD6fwXNTpi5ZxCzvGWj/jUNJcG T6S9LnsPKULfrqLBff5XaAUIyVgFKGOgidhxx1BABT4yfffNA20RC892Ra5DEhlUf4 YipkrL59SJ7ERRojS+/614PIPj5WNZ1Ep/wkse+g= 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 BCFB26FD86; Sat, 10 Nov 2018 09:13:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837602; bh=fPhNMVOgnILrdu8vEVGAW8FkOUJiKmx8HxmopOK4UcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Q+zXzKTxf+iXlD+RqbWG6CzpBVh2323to5MV434rD6fwXNTpi5ZxCzvGWj/jUNJcG T6S9LnsPKULfrqLBff5XaAUIyVgFKGOgidhxx1BABT4yfffNA20RC892Ra5DEhlUf4 YipkrL59SJ7ERRojS+/614PIPj5WNZ1Ep/wkse+g= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:34 +0100 Message-Id: <20181110081147.4027-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 03/16] gdbstub: add multiprocess support to '?' packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The gdb_get_cpu_pid() function does the PID lookup for the given CPU. It checks if the CPU is a direct child of a CPU cluster. If it is, the returned PID is the cluster ID plus one (cluster IDs start at 0, GDB PIDs at 1). When the CPU is not a child of such a container, the PID of the first process is returned. The gdb_fmt_thread_id() function generates the string to be used to identify a given thread, in a response packet for the peer. This function supports generating thread IDs when multiprocess mode is enabled (in the form `p.'). Use them in the reply to a '?' request. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 0d70b89598..d26bad4b67 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -638,10 +638,52 @@ static int memtox(char *buf, const char *mem, int len) } } return p - buf; } +static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +{ +#ifndef CONFIG_USER_ONLY + gchar *path, *name; + Object *obj; + CPUClusterState *cluster; + uint32_t ret; + + path = object_get_canonical_path(OBJECT(cpu)); + name = object_get_canonical_path_component(OBJECT(cpu)); + + if (path == NULL) { + ret = s->processes[0].pid; + goto out; + } + + /* + * Retrieve the CPU parent path by removing the last '/' and the CPU name + * from the CPU canonical path. */ + path[strlen(path) - strlen(name) - 1] = '\0'; + + obj = object_resolve_path_type(path, TYPE_CPU_CLUSTER, NULL); + + if (obj == NULL) { + ret = s->processes[0].pid; + goto out; + } + + cluster = CPU_CLUSTER(obj); + ret = cluster->cluster_id + 1; + +out: + g_free(name); + g_free(path); + + return ret; + +#else + return s->processes[0].pid; +#endif +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -907,10 +949,23 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, + char *buf, size_t buf_size) +{ + if (s->multiprocess) { + snprintf(buf, buf_size, "p%02x.%02x", + gdb_get_cpu_pid(s, cpu), cpu_gdb_index(cpu)); + } else { + snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); + } + + return buf; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1018,22 +1073,23 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) const char *p; uint32_t thread; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; + char thread_id[16]; uint8_t *registers; target_ulong addr, len; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { case '?': /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - cpu_gdb_index(s->c_cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state * should be cleaned up. */ From patchwork Sat Nov 10 08:11:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676989 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 84F6614E2 for ; Sat, 10 Nov 2018 08:25:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 704CC2DF19 for ; Sat, 10 Nov 2018 08:25:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FDF22DF1E; Sat, 10 Nov 2018 08:25:44 +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 B6BAF2DF19 for ; Sat, 10 Nov 2018 08:25:43 +0000 (UTC) Received: from localhost ([::1]:37556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOaN-0008TI-1h for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:25:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOw-0003rh-Az for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000oN-D9 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from greensocs.com ([193.104.36.180]:43610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOX-0000QD-V2; Sat, 10 Nov 2018 03:13:30 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 96C336FD81; Sat, 10 Nov 2018 09:13:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837604; bh=oEhtZP/9SjD4dnBg12InDEYfGFug7U6sbGl0KVHhliU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DP6T9ufPD9YO/OQrsa0n+DiME4RwvkSvI+ns/jmYZ50zFVjpthX08ImbQUfNkb6jn Y+P2RWiDvCeaYPTj259wCACpdGCJLRdg7bPBOqb0+j8lvYv4jovyOXAHoXXxaTBY7m Z4UUSUl9FBGmOzY/G3ieTAPvI8gkRuJhRJ4KBwTA= 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=QrQE0JNz; dkim=pass (1024-bit key) header.d=greensocs.com header.b=fVAKxTJj 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 D-NVeqbH9xUG; Sat, 10 Nov 2018 09:13:23 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 132BDDFFF5; Sat, 10 Nov 2018 09:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=oEhtZP/9SjD4dnBg12InDEYfGFug7U6sbGl0KVHhliU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QrQE0JNzsLZx1ufxwIpTVBcVviYSfUlpr1vgNq+JIRxGkMEEHdt7EKmoSoUP6kfsV QcjwVn2hq4R8j0V9miaYHgCqIsSAsLEoT05lkYQLNtTxyTy+ef5K0MQbgUur/mv2w5 q5CCfT/2H+8V5MsC4kdNrZDeitOZSfYy/y8/hfhQ= 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 66AD56FD86; Sat, 10 Nov 2018 09:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837602; bh=oEhtZP/9SjD4dnBg12InDEYfGFug7U6sbGl0KVHhliU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fVAKxTJjoJ2mZudpoFtjisEOAVR1bC47JUbZSqqeoafAEIJFDRKCIMtQba7Miz12O kVtCld6YQhzy2BCkZYjnsuIgh0dDdmGNU3m0ciGNI/MLt5r8SjGruZoY7JNzz2tslE A4lUrDhyLR6QUF4dwBsTzBagSbf7VVVvDvg7b2bQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:35 +0100 Message-Id: <20181110081147.4027-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 04/16] gdbstub: add multiprocess support to 'H' and 'T' packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a couple of helper functions to cope with GDB threads and processes. The gdb_get_process() function looks for a process given a pid. The gdb_get_cpu() function returns the CPU corresponding to the (pid, tid) pair given as parameters. The read_thread_id() function parses the thread-id sent by the peer. This function supports the multiprocess extension thread-id syntax. The return value specifies if the parsing failed, or if a special case was encountered (all processes or all threads). Use them in 'H' and 'T' packets handling to support the multiprocess extension. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 134 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index d26bad4b67..598a89b3ba 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -680,10 +680,73 @@ out: #else return s->processes[0].pid; #endif } +static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid) +{ + int i; + + if (!pid) { + /* 0 means any process, we take the first one */ + return &s->processes[0]; + } + + for (i = 0; i < s->process_num; i++) { + if (s->processes[i].pid == pid) { + return &s->processes[i]; + } + } + + return NULL; +} + +static GDBProcess *gdb_get_cpu_process(const GDBState *s, CPUState *cpu) +{ + return gdb_get_process(s, gdb_get_cpu_pid(s, cpu)); +} + +static CPUState *find_cpu(uint32_t thread_id) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (cpu_gdb_index(cpu) == thread_id) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +{ + GDBProcess *process; + CPUState *cpu = find_cpu(tid); + + if (!tid) { + /* 0 means any thread, we take the first one */ + tid = 1; + } + + if (cpu == NULL) { + return NULL; + } + + process = gdb_get_cpu_process(s, cpu); + + if (process->pid != pid) { + return NULL; + } + + if (!process->attached) { + return NULL; + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -936,23 +999,10 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } -static CPUState *find_cpu(uint32_t thread_id) -{ - CPUState *cpu; - - CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) == thread_id) { - return cpu; - } - } - - return NULL; -} - static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, char *buf, size_t buf_size) { if (s->multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", @@ -962,10 +1012,64 @@ static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, } return buf; } +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD = 0, + GDB_ALL_THREADS, /* One process, all threads */ + GDB_ALL_PROCESSES, + GDB_READ_THREAD_ERR +} GDBThreadIdKind; + +static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, + uint32_t *pid, uint32_t *tid) +{ + unsigned long p, t; + int ret; + + if (*buf == 'p') { + buf++; + ret = qemu_strtoul(buf, &buf, 16, &p); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + /* Skip '.' */ + buf++; + } else { + p = 1; + } + + ret = qemu_strtoul(buf, &buf, 16, &t); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + *end_buf = buf; + + if (p == -1) { + return GDB_ALL_PROCESSES; + } + + if (pid) { + *pid = p; + } + + if (t == -1) { + return GDB_ALL_THREADS; + } + + if (tid) { + *tid = t; + } + + return GDB_ONE_THREAD; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1070,16 +1174,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; CPUClass *cc; const char *p; uint32_t thread; + uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; uint8_t *registers; target_ulong addr, len; + GDBThreadIdKind thread_kind; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; @@ -1283,16 +1389,22 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) else put_packet(s, "E22"); break; case 'H': type = *p++; - thread = strtoull(p, (char **)&p, 16); - if (thread == -1 || thread == 0) { + + thread_kind = read_thread_id(p, &p, &pid, &tid); + if (thread_kind == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + + if (thread_kind != GDB_ONE_THREAD) { put_packet(s, "OK"); break; } - cpu = find_cpu(thread); + cpu = gdb_get_cpu(s, pid, tid); if (cpu == NULL) { put_packet(s, "E22"); break; } switch (type) { @@ -1308,12 +1420,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "E22"); break; } break; case 'T': - thread = strtoull(p, (char **)&p, 16); - cpu = find_cpu(thread); + thread_kind = read_thread_id(p, &p, &pid, &tid); + if (thread_kind == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { put_packet(s, "OK"); } else { put_packet(s, "E22"); From patchwork Sat Nov 10 08:11:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676983 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 55349109C for ; Sat, 10 Nov 2018 08:23:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 432122D9E8 for ; Sat, 10 Nov 2018 08:23:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3587B2D9FF; Sat, 10 Nov 2018 08:23:22 +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 A5C942D9E8 for ; Sat, 10 Nov 2018 08:23:21 +0000 (UTC) Received: from localhost ([::1]:37539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOY4-0005g1-UY for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:23:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003rJ-JI for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000oL-AI for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOX-0000QH-Uy; Sat, 10 Nov 2018 03:13:30 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 95A96521AAD; Sat, 10 Nov 2018 09:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=oIF9dYQDZUKcoiOrfIYnR2/JYabFthPUu6QvgXLquD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kEiIwfgM0Q5SqP9AhsD6TQPpoOWir9q36RHof7sUg72Y6nylOjgdw3HqH0z3oUbcG 98Jn/kQ3CbE14gIfrQZoTQi+bJk2OgdAdZbJUdXo9O3AKYObP/NzvxfpW/xffx46hf +zp6K0LckTYDzK/6Ek8thTywcA3GG9AGeLDQ3RCA= 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=vH1q5Ubo; dkim=pass (1024-bit key) header.d=greensocs.com header.b=vH1q5Ubo 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 CpI0c3P07YhV; Sat, 10 Nov 2018 09:13:24 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 6269F6FD86; Sat, 10 Nov 2018 09:13:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=oIF9dYQDZUKcoiOrfIYnR2/JYabFthPUu6QvgXLquD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vH1q5Ubo95c4tUcos8Yys9hJ3snvJaMDAIwhhZdjhe6Flqk2HkTRjhiHrmg2fPfnB uJmkKK+7m2+xxEF7rRb6dN12+fMqINsRN/fhcMuXrEebvTuPdkxRc5CiziBNBkxFda 3TAuw+tloR5OASxed9rOm5L30fi6JoTDilxiKCSg= 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 D5E37443258; Sat, 10 Nov 2018 09:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=oIF9dYQDZUKcoiOrfIYnR2/JYabFthPUu6QvgXLquD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vH1q5Ubo95c4tUcos8Yys9hJ3snvJaMDAIwhhZdjhe6Flqk2HkTRjhiHrmg2fPfnB uJmkKK+7m2+xxEF7rRb6dN12+fMqINsRN/fhcMuXrEebvTuPdkxRc5CiziBNBkxFda 3TAuw+tloR5OASxed9rOm5L30fi6JoTDilxiKCSg= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:36 +0100 Message-Id: <20181110081147.4027-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 05/16] gdbstub: add multiprocess support to vCont packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add the gdb_first_cpu() and gdb_next_cpu() to iterate over all the CPUs in currently attached processes. Add the gdb_first_cpu_in_process() and gdb_next_cpu_in_process() to iterate over CPUs of a given process. Use them to add multiprocess extension support to vCont packets. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 598a89b3ba..ba8b1a3413 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -716,10 +716,40 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static CPUState *get_first_cpu_in_process(const GDBState *s, + GDBProcess *process) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (gdb_get_cpu_pid(s, cpu) == process->pid) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +{ + uint32_t pid = gdb_get_cpu_pid(s, cpu); + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_pid(s, cpu) == pid) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu = find_cpu(tid); @@ -743,10 +773,41 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) } return cpu; } +/* Return the cpu following @cpu, while ignoring + * unattached processes. + */ +static CPUState *gdb_next_cpu(const GDBState *s, CPUState *cpu) +{ + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_process(s, cpu)->attached) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + +/* Return the first attached cpu */ +static CPUState *gdb_first_cpu(const GDBState *s) +{ + CPUState *cpu = first_cpu; + GDBProcess *process = gdb_get_cpu_process(s, cpu); + + if (!process->attached) { + return gdb_next_cpu(s, cpu); + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -1081,14 +1142,16 @@ static int is_query_packet(const char *p, const char *query, char separator) * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is * a format error, 0 on success. */ static int gdb_handle_vcont(GDBState *s, const char *p) { - int res, idx, signal = 0; + int res, signal = 0; char cur_action; char *newstates; unsigned long tmp; + uint32_t pid, tid; + GDBProcess *process; CPUState *cpu; #ifdef CONFIG_USER_ONLY int max_cpus = 1; /* global variable max_cpus exists only in system mode */ CPU_FOREACH(cpu) { @@ -1127,29 +1190,52 @@ static int gdb_handle_vcont(GDBState *s, const char *p) } else if (cur_action != 'c' && cur_action != 's') { /* unknown/invalid/unsupported command */ res = -ENOTSUP; goto out; } - /* thread specification. special values: (none), -1 = all; 0 = any */ - if ((p[0] == ':' && p[1] == '-' && p[2] == '1') || (p[0] != ':')) { - if (*p == ':') { - p += 3; - } - for (idx = 0; idx < max_cpus; idx++) { - if (newstates[idx] == 1) { - newstates[idx] = cur_action; + + if (*p++ != ':') { + res = -ENOTSUP; + goto out; + } + + switch (read_thread_id(p, &p, &pid, &tid)) { + case GDB_READ_THREAD_ERR: + res = -EINVAL; + goto out; + + case GDB_ALL_PROCESSES: + cpu = gdb_first_cpu(s); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; } + + cpu = gdb_next_cpu(s, cpu); } - } else if (*p == ':') { - p++; - res = qemu_strtoul(p, &p, 16, &tmp); - if (res) { + break; + + case GDB_ALL_THREADS: + process = gdb_get_process(s, pid); + + if (!process->attached) { + res = -EINVAL; goto out; } - /* 0 means any thread, so we pick the first valid CPU */ - cpu = tmp ? find_cpu(tmp) : first_cpu; + cpu = get_first_cpu_in_process(s, process); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; + } + + cpu = gdb_next_cpu_in_process(s, cpu); + } + break; + + case GDB_ONE_THREAD: + cpu = gdb_get_cpu(s, pid, tid); /* invalid CPU/thread specified */ if (!cpu) { res = -EINVAL; goto out; @@ -1157,10 +1243,11 @@ static int gdb_handle_vcont(GDBState *s, const char *p) /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } + break; } } s->signal = signal; gdb_continue_partial(s, newstates); From patchwork Sat Nov 10 08:11:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676969 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 A373315A6 for ; Sat, 10 Nov 2018 08:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9479B2DEB4 for ; Sat, 10 Nov 2018 08:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 862502DEB6; Sat, 10 Nov 2018 08:16:38 +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 2BA152DEB4 for ; Sat, 10 Nov 2018 08:16:38 +0000 (UTC) Received: from localhost ([::1]:37502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLORZ-0005tD-AF for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:16:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003qy-8M for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000ns-BC for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOZ-0000TA-2Q; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 7957F5D19A1; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=p2Mv8ssQ4PExXJBSLWQS/O2C8dspM4cwOB9TCaV84ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I2Kcdxd1DjmBCJLrOaGwgcaEHkaE8dCoky1y7lNV8CFRuao+0BLspoEzDtliF0d2T aB3SRJVxpgGfk5GdDg85OfIPelco8X0XSMmU+3QL7Zyu9OR9oniqvT6A9+GSqhePVd dVKByyqaibrVv0AUwt3ASKl6nOPZ1yJ9P79iqPVI= 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=6DMqK1nL; dkim=pass (1024-bit key) header.d=greensocs.com header.b=6DMqK1nL 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 CRV24ZzVKG7o; Sat, 10 Nov 2018 09:13:25 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id D289144325A; Sat, 10 Nov 2018 09:13:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=p2Mv8ssQ4PExXJBSLWQS/O2C8dspM4cwOB9TCaV84ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6DMqK1nLb1yK9jkXAG4R6lI+0G1MpsHXLpGYwbW/xIWh5FyG2o4YaogNQq7XWMEWz BZrX2N5CJgffvk7acC2Zw8sKl59AiGNEQ7+6ZoySvypOsPygZJRev0CDpeSNiFEbCi LInNTA7/gMGWmtlo9PcmG4c8ywg1jRdAwH0YDyPk= 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 6C6A0443258; Sat, 10 Nov 2018 09:13:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837603; bh=p2Mv8ssQ4PExXJBSLWQS/O2C8dspM4cwOB9TCaV84ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6DMqK1nLb1yK9jkXAG4R6lI+0G1MpsHXLpGYwbW/xIWh5FyG2o4YaogNQq7XWMEWz BZrX2N5CJgffvk7acC2Zw8sKl59AiGNEQ7+6ZoySvypOsPygZJRev0CDpeSNiFEbCi LInNTA7/gMGWmtlo9PcmG4c8ywg1jRdAwH0YDyPk= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:37 +0100 Message-Id: <20181110081147.4027-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 06/16] gdbstub: add multiprocess support to 'sC' packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the sC packet handling to support the multiprocess extension. Instead of returning the first thread, we return the first thread of the current process. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index ba8b1a3413..9be83486f5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1546,13 +1546,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) type = strtoul(p, (char **)&p, 16); sstep_flags = type; put_packet(s, "OK"); break; } else if (strcmp(p,"C") == 0) { - /* "Current thread" remains vague in the spec, so always return - * the first CPU (gdb returns the first thread). */ - put_packet(s, "QC1"); + /* "Current thread" remains vague in the spec, so always return the + * first thread of the current process (gdb returns the first + * thread). + */ + cpu = get_first_cpu_in_process(s, gdb_get_cpu_process(s, s->g_cpu)); + snprintf(buf, sizeof(buf), "QC%s", + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { s->query_cpu = first_cpu; goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { From patchwork Sat Nov 10 08:11:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676981 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 78905109C for ; Sat, 10 Nov 2018 08:22:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65BD72D9E8 for ; Sat, 10 Nov 2018 08:22:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 570262D9FF; Sat, 10 Nov 2018 08:22:52 +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 D7C072D9E8 for ; Sat, 10 Nov 2018 08:22:51 +0000 (UTC) Received: from localhost ([::1]:37535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOXb-0004Yj-3h for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:22:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003r1-9w for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000oA-9B for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOZ-0000TD-3R; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 5F7FD5D19A5; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=8S5wpPVVq90/1QKwmLRWhYH1Jn4czok6NwCnRlvPVDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1Ft+QeNLo30J4J5putTecNnlfQ74BD/arylVH73OyQkBoNopjW1w//BHvY75DV+ZZ N+YOyaQ3459uoIFSZgeXVuWFatLZDCYl9E58XuyIMpW2VYeSRL3XxMjWLDIC55XWrL td+GI1ycIx//A70qVfMIr7xfS4pT220faGf+Ccoo= 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=sLqptJPz; dkim=pass (1024-bit key) header.d=greensocs.com header.b=sLqptJPz 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 fdVdhH2TWFnW; Sat, 10 Nov 2018 09:13:26 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 4808844325B; Sat, 10 Nov 2018 09:13:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837604; bh=8S5wpPVVq90/1QKwmLRWhYH1Jn4czok6NwCnRlvPVDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sLqptJPzs1IEcBlbBHrXqQIbHrgrz7G9CkTpLzKqIbzdhnC03CS3OO8mM0NEyWdmf 2YZ13QTK6GkVkbtp63U5GwD8qiXTe7dPmylrAX6chSamz1EtPM/W0l/cPtAuuyBXLv Qi7nXoT4o0DfdZ7yfYjY9ailTb7BS4mm6IazSgg4= 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 D22D16FD81; Sat, 10 Nov 2018 09:13:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837604; bh=8S5wpPVVq90/1QKwmLRWhYH1Jn4czok6NwCnRlvPVDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sLqptJPzs1IEcBlbBHrXqQIbHrgrz7G9CkTpLzKqIbzdhnC03CS3OO8mM0NEyWdmf 2YZ13QTK6GkVkbtp63U5GwD8qiXTe7dPmylrAX6chSamz1EtPM/W0l/cPtAuuyBXLv Qi7nXoT4o0DfdZ7yfYjY9ailTb7BS4mm6IazSgg4= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:38 +0100 Message-Id: <20181110081147.4027-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 07/16] gdbstub: add multiprocess support to (f|s)ThreadInfo and ThreadExtraInfo 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the thread info related packets handling to support multiprocess extension. Add the CPUs class name in the extra info to help differentiate them in multiprocess mode. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9be83486f5..43c9211bfa 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1260,11 +1260,10 @@ out: static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; CPUClass *cc; const char *p; - uint32_t thread; uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; @@ -1556,30 +1555,46 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "QC%s", gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { - s->query_cpu = first_cpu; + s->query_cpu = gdb_first_cpu(s); goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", cpu_gdb_index(s->query_cpu)); + snprintf(buf, sizeof(buf), "m%s", + gdb_fmt_thread_id(s, s->query_cpu, + thread_id, sizeof(thread_id))); put_packet(s, buf); - s->query_cpu = CPU_NEXT(s->query_cpu); + s->query_cpu = gdb_next_cpu(s, s->query_cpu); } else put_packet(s, "l"); break; } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { - thread = strtoull(p+16, (char **)&p, 16); - cpu = find_cpu(thread); + if (read_thread_id(p + 16, &p, &pid, &tid) == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { cpu_synchronize_state(cpu); - /* memtohex() doubles the required space */ - len = snprintf((char *)mem_buf, sizeof(buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, - cpu->halted ? "halted " : "running"); + + if (s->multiprocess && (s->process_num > 1)) { + /* Print the CPU model in multiprocess mode */ + ObjectClass *oc = object_get_class(OBJECT(cpu)); + const char *cpu_model = object_class_get_name(oc); + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d %s [%s]", cpu->cpu_index, + cpu_model, + cpu->halted ? "halted " : "running"); + } else { + /* memtohex() doubles the required space */ + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d [%s]", cpu->cpu_index, + cpu->halted ? "halted " : "running"); + } trace_gdbstub_op_extra_info((char *)mem_buf); memtohex(buf, mem_buf, len); put_packet(s, buf); } break; From patchwork Sat Nov 10 08:11:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676999 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 4A741139B for ; Sat, 10 Nov 2018 08:30:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ADF32DFC3 for ; Sat, 10 Nov 2018 08:30:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D2F82DFC7; Sat, 10 Nov 2018 08:30:42 +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 9F9A22DFC3 for ; Sat, 10 Nov 2018 08:30:41 +0000 (UTC) Received: from localhost ([::1]:37582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOfA-0005Ua-Up for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:30:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP7-00045J-Pu for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP5-00010J-Jc for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:05 -0500 Received: from greensocs.com ([193.104.36.180]:43681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOy-0000TG-Op; Sat, 10 Nov 2018 03:13:58 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id A80A25D19AA; Sat, 10 Nov 2018 09:13:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837608; bh=cS+N1h1HgsnfQx9Toc/vlaz3Ue7kByeXlQSkWFD48/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D4uIrLpIYxwpMcvcrjaAmH0P6q8W9ABznU9/LVahLbJqlw0y35nwyvuzj0oJ71YO0 NWLRm5l+q6UhCrxncQxV8egrBIHVtju8SfXrEX0+WXch//95ohfj0dtCsvpZA4S0WQ flLQ0oH//uk37uKn0kVmPEof+051eOEwktzsHhGM= 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=MVyM8q+5; dkim=pass (1024-bit key) header.d=greensocs.com header.b=MVyM8q+5 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 8j7DR4EoFtpf; Sat, 10 Nov 2018 09:13:27 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id B2A8D443258; Sat, 10 Nov 2018 09:13:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837604; bh=cS+N1h1HgsnfQx9Toc/vlaz3Ue7kByeXlQSkWFD48/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MVyM8q+56qXRnwbrGeRsAxTIst7djQ+xODaXpOGleg4K9pxe2hjcdZ41SQYmIOM4A IxH1Lrb1EcAxrv8HTew6NChmuuQjSunWQ3Bj/LGk+vSk77jvT85wzJGolAXpSmhUz/ Vhc1OcGUDSth/EvVHoavHueMjCl3d178aYkyJga8= 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 45B78443258; Sat, 10 Nov 2018 09:13:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837604; bh=cS+N1h1HgsnfQx9Toc/vlaz3Ue7kByeXlQSkWFD48/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MVyM8q+56qXRnwbrGeRsAxTIst7djQ+xODaXpOGleg4K9pxe2hjcdZ41SQYmIOM4A IxH1Lrb1EcAxrv8HTew6NChmuuQjSunWQ3Bj/LGk+vSk77jvT85wzJGolAXpSmhUz/ Vhc1OcGUDSth/EvVHoavHueMjCl3d178aYkyJga8= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:39 +0100 Message-Id: <20181110081147.4027-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 08/16] gdbstub: add multiprocess support to Xfer:features:read: 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the Xfer:features:read: packet handling to support the multiprocess extension. This packet is used to request the XML description of the CPU. In multiprocess mode, different descriptions can be sent for different processes. This function now takes the process to send the description for as a parameter, and use a buffer in the process structure to store the generated description. It takes the first CPU of the process to generate the description. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 43c9211bfa..aae3cce01a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -298,10 +298,12 @@ typedef struct GDBRegisterState { } GDBRegisterState; typedef struct GDBProcess { uint32_t pid; bool attached; + + char target_xml[1024]; } GDBProcess; enum RSState { RS_INACTIVE, RS_IDLE, @@ -804,55 +806,57 @@ static CPUState *gdb_first_cpu(const GDBState *s) } return cpu; } -static const char *get_feature_xml(const char *p, const char **newp, - CPUClass *cc) +static const char *get_feature_xml(const GDBState *s, const char *p, + const char **newp, GDBProcess *process) { size_t len; int i; const char *name; - static char target_xml[1024]; + CPUState *cpu = get_first_cpu_in_process(s, process); + CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; while (p[len] && p[len] != ':') len++; *newp = p + len; name = NULL; if (strncmp(p, "target.xml", len) == 0) { + char *buf = process->target_xml; + const size_t buf_sz = sizeof(process->target_xml); + /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { + if (!buf[0]) { GDBRegisterState *r; - CPUState *cpu = first_cpu; - pstrcat(target_xml, sizeof(target_xml), + pstrcat(buf, buf_sz, "" "" ""); if (cc->gdb_arch_name) { gchar *arch = cc->gdb_arch_name(cpu); - pstrcat(target_xml, sizeof(target_xml), ""); - pstrcat(target_xml, sizeof(target_xml), arch); - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); + pstrcat(buf, buf_sz, arch); + pstrcat(buf, buf_sz, ""); g_free(arch); } - pstrcat(target_xml, sizeof(target_xml), "gdb_core_xml_file); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "gdb_core_xml_file); + pstrcat(buf, buf_sz, "\"/>"); for (r = cpu->gdb_regs; r; r = r->next) { - pstrcat(target_xml, sizeof(target_xml), "xml); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "xml); + pstrcat(buf, buf_sz, "\"/>"); } - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); } - return target_xml; + return buf; } if (cc->gdb_get_dynamic_xml) { - CPUState *cpu = first_cpu; char *xmlname = g_strndup(p, len); const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); g_free(xmlname); if (xml) { @@ -1258,10 +1262,11 @@ out: } static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; + GDBProcess *process; CPUClass *cc; const char *p; uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; @@ -1639,18 +1644,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; target_ulong total_len; - cc = CPU_GET_CLASS(first_cpu); + process = gdb_get_cpu_process(s, s->g_cpu); + cc = CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file == NULL) { goto unknown_command; } gdb_has_xml = true; p += 19; - xml = get_feature_xml(p, &p, cc); + xml = get_feature_xml(s, p, &p, process); if (!xml) { snprintf(buf, sizeof(buf), "E00"); put_packet(s, buf); break; } @@ -2319,10 +2325,11 @@ static int find_cpu_clusters(Object *child, void *opaque) process = &s->processes[s->process_num - 1]; /* GDB process IDs -1 and 0 are reserved */ process->pid = cluster->cluster_id + 1; process->attached = false; + process->target_xml[0] = '\0'; return 0; } return object_child_foreach(child, find_cpu_clusters, opaque); } From patchwork Sat Nov 10 08:11:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676993 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 20CE4109C for ; Sat, 10 Nov 2018 08:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EF802DF19 for ; Sat, 10 Nov 2018 08:28:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 009442DF1E; Sat, 10 Nov 2018 08:28:04 +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 6EBFD2DF19 for ; Sat, 10 Nov 2018 08:28:04 +0000 (UTC) Received: from localhost ([::1]:37569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOcd-0002r1-9D for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:28:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP5-00042p-Ng for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP4-0000zS-PE for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:03 -0500 Received: from greensocs.com ([193.104.36.180]:43680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOx-0000TF-5V; Sat, 10 Nov 2018 03:13:56 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id B97F45D19AC; Sat, 10 Nov 2018 09:13:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837608; bh=fC05Ss4NtDnlUcYu1G7ZDk22A00EuZP6bFkSpzrSNxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rRzt18uEDNh3exA2IxRCpe+qMHGGDCmBWodDE+3S26F4g+7xclVKXXiJE4qdVbeg1 wMgUH+dAjpuqEm8/tS+0tLAXU0F9bJ+pCJPDZeHmwjBHjkBUSBf5383injQwSkp6v+ OXz3kgUAGuV6H2P3LRAdX4U7QvxDz9El+olSY/d8= 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=us0jv/hB; dkim=pass (1024-bit key) header.d=greensocs.com header.b=us0jv/hB 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 n3S7m9kyaHn6; Sat, 10 Nov 2018 09:13:28 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 320BB44325F; Sat, 10 Nov 2018 09:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=fC05Ss4NtDnlUcYu1G7ZDk22A00EuZP6bFkSpzrSNxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=us0jv/hBajZAONcD+SwzxZb3njoVD20maKdl+UC2XAxvk/393quQ3xz6s0KGzNEFG BfP+imnQnDh8MSmnPBIxOTgV+ghFX3p65+qlat3wWnULLhji3mkGXZTgzHlmSxCuU3 b2UCHNoMuYZMlRnNk5M95WCVUMJPRf8CaYv5Mnd0= 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 B10CC44325E; Sat, 10 Nov 2018 09:13:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=fC05Ss4NtDnlUcYu1G7ZDk22A00EuZP6bFkSpzrSNxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=us0jv/hBajZAONcD+SwzxZb3njoVD20maKdl+UC2XAxvk/393quQ3xz6s0KGzNEFG BfP+imnQnDh8MSmnPBIxOTgV+ghFX3p65+qlat3wWnULLhji3mkGXZTgzHlmSxCuU3 b2UCHNoMuYZMlRnNk5M95WCVUMJPRf8CaYv5Mnd0= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:40 +0100 Message-Id: <20181110081147.4027-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 09/16] gdbstub: add multiprocess support to gdb_vm_state_change() 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for multiprocess extension in gdb_vm_state_change() function. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index aae3cce01a..decf56c610 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1713,10 +1713,11 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s = gdbserver_state; CPUState *cpu = s->c_cpu; char buf[256]; + char thread_id[16]; const char *type; int ret; if (running || s->state == RS_INACTIVE) { return; @@ -1724,10 +1725,18 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) /* Is there a GDB syscall waiting to be sent? */ if (s->current_syscall_cb) { put_packet(s, s->syscall_buf); return; } + + if (cpu == NULL) { + /* No process attached */ + return; + } + + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + switch (state) { case RUN_STATE_DEBUG: if (cpu->watchpoint_hit) { switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { case BP_MEM_READ: @@ -1741,12 +1750,12 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) break; } trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); snprintf(buf, sizeof(buf), - "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, cpu_gdb_index(cpu), type, + "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", + GDB_SIGNAL_TRAP, thread_id, type, (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit = NULL; goto send_packet; } else { trace_gdbstub_hit_break(); @@ -1784,11 +1793,11 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) trace_gdbstub_hit_unknown(state); ret = GDB_SIGNAL_UNKNOWN; break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_gdb_index(cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); send_packet: put_packet(s, buf); /* disable single step if it was enabled */ From patchwork Sat Nov 10 08:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676967 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 BE86714BA for ; Sat, 10 Nov 2018 08:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B18532DEB4 for ; Sat, 10 Nov 2018 08:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FF612DEC0; Sat, 10 Nov 2018 08:16:12 +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 8F3682DEB4 for ; Sat, 10 Nov 2018 08:16:11 +0000 (UTC) Received: from localhost ([::1]:37500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOR8-0005eA-CR for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:16:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003qz-8V for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000oF-AC for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from greensocs.com ([193.104.36.180]:43682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOZ-0000TI-2w; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 882865D19AD; Sat, 10 Nov 2018 09:13:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837609; bh=cYsacuZtqAvOWvrLvVMrJK7AgZ/b9/60aGrfdT4mrnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Pnfd/RBdLOiXhi161ueCWjw++N3DpE1bTuD8rD34zx6W/Tqu/SBD3c/Yum5Nja9Gf TkxhUW3sScQjY7GMcUYO86+tTlIPrTon9bFiI4jI+2DijpyZYxs/l/bLNaBja1x0bX hTWuXBVeqDK0BcWencfDXM38l6F7qWJA822/YMrA= 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=HqKUD92F; dkim=pass (1024-bit key) header.d=greensocs.com header.b=HqKUD92F 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 DiFfZPx__lsB; Sat, 10 Nov 2018 09:13:28 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 9B68ADFFF5; Sat, 10 Nov 2018 09:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=cYsacuZtqAvOWvrLvVMrJK7AgZ/b9/60aGrfdT4mrnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HqKUD92FDOOeyEXItE0cGLmNuLpXCZ3wOFrLdsEVPk/8/jEGoqCy+eQdAWQS6Xzy3 EE6Y+zDajy1xbXYf63ub9jHafrVrPywQ4Tm0vtnw2/EFFPX3cJV4aDh+44lt+kPRwd af7/WtA7AWO4eHpmhQ/5+GpN5GRvHWMGsBXA/wRY= 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 2E20CDFFF5; Sat, 10 Nov 2018 09:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=cYsacuZtqAvOWvrLvVMrJK7AgZ/b9/60aGrfdT4mrnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HqKUD92FDOOeyEXItE0cGLmNuLpXCZ3wOFrLdsEVPk/8/jEGoqCy+eQdAWQS6Xzy3 EE6Y+zDajy1xbXYf63ub9jHafrVrPywQ4Tm0vtnw2/EFFPX3cJV4aDh+44lt+kPRwd af7/WtA7AWO4eHpmhQ/5+GpN5GRvHWMGsBXA/wRY= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:41 +0100 Message-Id: <20181110081147.4027-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 10/16] gdbstub: add multiprocess support to 'D' packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'D' packets are used by GDB to detach from a process. In multiprocess mode, the PID to detach from is sent in the request. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index decf56c610..bd4895ac0a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1039,24 +1039,39 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type) default: return -ENOSYS; } } +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, GDBProcess *p) +{ + CPUState *cpu = get_first_cpu_in_process(s, p); + + while (cpu) { + gdb_cpu_breakpoint_remove_all(cpu); + cpu = gdb_next_cpu_in_process(s, cpu); + } +} + static void gdb_breakpoint_remove_all(void) { CPUState *cpu; if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } 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); } } static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { @@ -1331,13 +1346,44 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': /* Detach packet */ - gdb_breakpoint_remove_all(); - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + pid = 1; + + if (s->multiprocess) { + unsigned long lpid; + if (*p != ';') { + put_packet(s, "E22"); + break; + } + + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { + put_packet(s, "E22"); + break; + } + + pid = lpid; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_cpu(s); + } + + if (s->c_cpu == NULL) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); From patchwork Sat Nov 10 08:11:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676965 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 AF4E3109C for ; Sat, 10 Nov 2018 08:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9894D2DEB5 for ; Sat, 10 Nov 2018 08:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C8112DEBF; Sat, 10 Nov 2018 08:16:12 +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 8F4302DEB5 for ; Sat, 10 Nov 2018 08:16:11 +0000 (UTC) Received: from localhost ([::1]:37501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOR8-0005eq-6W for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:16:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOu-0003q2-Mc for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000nb-B8 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:52 -0500 Received: from greensocs.com ([193.104.36.180]:43685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOZ-0000TJ-4c; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id AFC5D5D19AE; Sat, 10 Nov 2018 09:13:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837609; bh=rBCCagqSrFOEU0nfuOIRvEJu5ZG6NSRyLpjqwKGgpUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kMBycxR9kXQJI1jZiAiiT0hn6szJXz5lksnaO3FnXRS5cmakz6yHiwlmrIW2FgHtX hgi152CmSpAXiywMehxGOzqOZ9Oz7utn+g7gjBGTa1In3+e4GvL6yFDpZACXaAgbkK pHbVHbG6sFOeAdhKZk6jcc5kQ0GeIFxgILp29fR0= 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=PxK9GhHT; dkim=pass (1024-bit key) header.d=greensocs.com header.b=rVhtYt42 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 3bdH1TijEq9z; Sat, 10 Nov 2018 09:13:29 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 2D0B55D19A0; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=rBCCagqSrFOEU0nfuOIRvEJu5ZG6NSRyLpjqwKGgpUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PxK9GhHTDLQBcvUoxCoi7BPLJgeOUxFVHxHbFt55FVWoOS/dqx4gIlcc+rrARRct0 t9XNJK8PTADGH+h0vzOHfPelm6gT28uyWRgpxttwJFdDHRVLpvFujnKe/rrMQseCeD ZFcnVojRxDZEPEhaSuKoAJT4GVOEfPhkdZEFP0qI= 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 9A2AE5C024C; Sat, 10 Nov 2018 09:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837605; bh=rBCCagqSrFOEU0nfuOIRvEJu5ZG6NSRyLpjqwKGgpUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rVhtYt4289vPTW5i0Ay/KvNWsvFrKw0WFmulMaYBdBGSEbDWxaIkGkSwNUHDb8ELi H1itqpOfWEeGKFU4cbUrZ0c+zxo+5BlHImVDPpLJbQnJM2iPCX2FrYUhcFHI3y3hjs Kp/kz9luajXukCGRdbQ3/vTKfcaRDPpbwX9IyNL4= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:42 +0100 Message-Id: <20181110081147.4027-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 11/16] gdbstub: add support for extended mode packet 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the '!' extended mode packet. This is required for the multiprocess extension. Signed-off-by: Luc Michel --- gdbstub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index bd4895ac0a..4132227092 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1294,10 +1294,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { + case '!': + put_packet(s, "OK"); + break; case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); From patchwork Sat Nov 10 08:11:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676975 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 83D29109C for ; Sat, 10 Nov 2018 08:19:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75E962D9B1 for ; Sat, 10 Nov 2018 08:19:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 679832D9C9; Sat, 10 Nov 2018 08:19:42 +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 16AF62D9B1 for ; Sat, 10 Nov 2018 08:19:42 +0000 (UTC) Received: from localhost ([::1]:37515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOUX-0001iJ-6J for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:19:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOv-0003qc-0G for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOOt-0000nm-Ai for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:13:52 -0500 Received: from greensocs.com ([193.104.36.180]:43686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOZ-0000TH-3g; Sat, 10 Nov 2018 03:13:31 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 647B25D19A0; Sat, 10 Nov 2018 09:13:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837610; bh=o3KJuqJsYNukd/ec4ozLQhf6Dd7aHydQxO2sBiH7PrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OsB1Iq333zJrDHsNHuYugMHTB61Uku+UNd+hKl/9CJGOHi46E+JwP+34ghnhqpSPn WTNrSYQ94UHYB/p1kzbQ1xusfTQe1ACy8ry0+wigdh17PovSe67WRJsYWnz6fQbE09 Q0HViG5xb4kFDoQ5ghBAUYjZd2Y/vaNrtMAcet8E= 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=srQx4qy5; dkim=pass (1024-bit key) header.d=greensocs.com header.b=srQx4qy5 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 JuEp5LoA9k4I; Sat, 10 Nov 2018 09:13:29 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 880AF5D19A2; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=o3KJuqJsYNukd/ec4ozLQhf6Dd7aHydQxO2sBiH7PrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=srQx4qy583OeEKIFPe8ORl4v1mIgROhvRGhz+sH3+YI4CCmHQFG/cX+TmTbOPoB0W lKcna6b/SuPjaZEBw8SSTHZJH04gS+haaGUHrNhom/Y0Q4Y6T4IMU91iYwPTs1a6UA ZtAMGmsT3gVdwBI9k52rEYRW1378PbTJ1Q5ug7rI= 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 14B156FD86; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=o3KJuqJsYNukd/ec4ozLQhf6Dd7aHydQxO2sBiH7PrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=srQx4qy583OeEKIFPe8ORl4v1mIgROhvRGhz+sH3+YI4CCmHQFG/cX+TmTbOPoB0W lKcna6b/SuPjaZEBw8SSTHZJH04gS+haaGUHrNhom/Y0Q4Y6T4IMU91iYwPTs1a6UA ZtAMGmsT3gVdwBI9k52rEYRW1378PbTJ1Q5ug7rI= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:43 +0100 Message-Id: <20181110081147.4027-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 12/16] gdbstub: add support for vAttach packets 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel --- gdbstub.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 4132227092..ba365808db 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1340,10 +1340,45 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach;", 7) == 0) { + unsigned long pid; + + p += 7; + + if (qemu_strtoul(p, &p, 16, &pid)) { + put_packet(s, "E22"); + break; + } + + process = gdb_get_process(s, pid); + + if (process == NULL) { + put_packet(s, "E22"); + break; + } + + cpu = get_first_cpu_in_process(s, process); + + if (cpu == NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached = true; + + s->g_cpu = cpu; + s->c_cpu = cpu; + + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */ From patchwork Sat Nov 10 08:11:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676987 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 BE934109C for ; Sat, 10 Nov 2018 08:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE9A32DF1C for ; Sat, 10 Nov 2018 08:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FB552DF2B; Sat, 10 Nov 2018 08:24:51 +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 426DB2DF1C for ; Sat, 10 Nov 2018 08:24:51 +0000 (UTC) Received: from localhost ([::1]:37543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOZT-0007jQ-9i for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:24:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP7-00045K-Pw for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP5-000102-Ii for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:05 -0500 Received: from greensocs.com ([193.104.36.180]:43688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOy-0000Td-NW; Sat, 10 Nov 2018 03:13:58 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id AA3975D19A2; Sat, 10 Nov 2018 09:13:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837610; bh=gqBhDPpxGlbslzJ48Mohw6BqhBqD+2sU66wHvcW48ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mgUbuZCO2S5ncjOazgjbu1BCuvwDKQpTYduP1EbY3eIi5ixNAmpJDuwYwS88leFG8 uE7mpv6K3L8FvcN1/9qk1ySBMNmtXQeJgZ14YTXM+FYRAdutjDyLNCIbZ62Y4oqFg4 lVjD3wJoxI//88wBgrqehu5UvV2e0WqQWDCkY8hM= 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=hUHvms5r; dkim=pass (1024-bit key) header.d=greensocs.com header.b=hUHvms5r 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 mFpPmQqoF6kk; Sat, 10 Nov 2018 09:13:29 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id F00255D19A4; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=gqBhDPpxGlbslzJ48Mohw6BqhBqD+2sU66wHvcW48ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hUHvms5rxbQPhfKE7X61KIGOfCyh2Tq1LD/Qg9igtxRGJvQtQl9y7++Bww/QA0u6a 5eiN8eemV1+4YoFKeJaRc2WN6w5v54TIF0ciZPjyHkmq9oInZ1Njpvy+jzAxvnNu3u 52zOpElHuu5EsvIJR2EZNRhllFju7k1yLEEfQ7Vw= 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 8ABA15D19A3; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837606; bh=gqBhDPpxGlbslzJ48Mohw6BqhBqD+2sU66wHvcW48ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hUHvms5rxbQPhfKE7X61KIGOfCyh2Tq1LD/Qg9igtxRGJvQtQl9y7++Bww/QA0u6a 5eiN8eemV1+4YoFKeJaRc2WN6w5v54TIF0ciZPjyHkmq9oInZ1Njpvy+jzAxvnNu3u 52zOpElHuu5EsvIJR2EZNRhllFju7k1yLEEfQ7Vw= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:44 +0100 Message-Id: <20181110081147.4027-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 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+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 ba365808db..1a3353ff3c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2245,13 +2245,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; @@ -2333,12 +2334,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; @@ -2513,19 +2525,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; From patchwork Sat Nov 10 08:11:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676979 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 8201B109C for ; Sat, 10 Nov 2018 08:21:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F5232D9E8 for ; Sat, 10 Nov 2018 08:21:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 600E82D9FF; Sat, 10 Nov 2018 08:21:52 +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 B75842D9E8 for ; Sat, 10 Nov 2018 08:21:51 +0000 (UTC) Received: from localhost ([::1]:37531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOWc-0003Ic-CC for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:21:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP7-00045F-P5 for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP5-000105-If for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:05 -0500 Received: from greensocs.com ([193.104.36.180]:43679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOz-0000TB-Bn; Sat, 10 Nov 2018 03:13:58 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 4E95C5D19A4; Sat, 10 Nov 2018 09:13:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837611; bh=WgnMQ5pr+n/ESL8puF7jtpCC/FdzwfDNBDnQ0ACltqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ONxJ/5bODy4hKL0+eazHbh0v3fv0+dzMnA6CuAd5T/o5izwNhYRnx5jW0ywx+sSJu 54vU8wZgerY95of8ohEJ66jMQjaU0CYo/uTS7czvgWrRzGA+zuIFhseq8qaQKK+1LS tFZNuTtfllPX9Fq9IHoCU3XUO2f+jcFmKuawoThg= 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=VnF4Fp1G; dkim=pass (1024-bit key) header.d=greensocs.com header.b=VnF4Fp1G 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 6gh6pPo9W7AB; Sat, 10 Nov 2018 09:13:30 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 6FB9A5D19A3; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=WgnMQ5pr+n/ESL8puF7jtpCC/FdzwfDNBDnQ0ACltqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VnF4Fp1GPMGYOHF4HlqkRbHAPM61HOLBHOeLe1jdoeWTgcmQdLauaxzMGlQa4rXky L9EZ0ma0tp0R3mJ1x0LnPktT4ub1jAs1+zZTv7jsvqUQ3eg17T83wKoo29ONRsTqr3 kBI7HiSsagd6fyvcNCFwyYYliTVz2oFRzRn0AFV8= 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 00E395D19A3; Sat, 10 Nov 2018 09:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=WgnMQ5pr+n/ESL8puF7jtpCC/FdzwfDNBDnQ0ACltqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VnF4Fp1GPMGYOHF4HlqkRbHAPM61HOLBHOeLe1jdoeWTgcmQdLauaxzMGlQa4rXky L9EZ0ma0tp0R3mJ1x0LnPktT4ub1jAs1+zZTv7jsvqUQ3eg17T83wKoo29ONRsTqr3 kBI7HiSsagd6fyvcNCFwyYYliTVz2oFRzRn0AFV8= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:45 +0100 Message-Id: <20181110081147.4027-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 14/16] gdbstub: gdb_set_stop_cpu: ignore request when process is not attached 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When gdb_set_stop_cpu() is called with a CPU associated to a process currently not attached by the GDB client, return without modifying the stop CPU. Otherwise, GDB gets confused if it receives packets with a thread-id it does not know about. Signed-off-by: Luc Michel Acked-by: Alistair Francis --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 1a3353ff3c..c662ada6ff 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1787,10 +1787,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; } void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* Having a stop CPU corresponding to a process that is not attached + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu = cpu; gdbserver_state->g_cpu = cpu; } #ifndef CONFIG_USER_ONLY From patchwork Sat Nov 10 08:11:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676985 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 EE46F15A6 for ; Sat, 10 Nov 2018 08:23:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF9C62D9E8 for ; Sat, 10 Nov 2018 08:23:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D402E2D9FF; Sat, 10 Nov 2018 08:23:24 +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 825F02D9E8 for ; Sat, 10 Nov 2018 08:23:24 +0000 (UTC) Received: from localhost ([::1]:37540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOY7-0005ir-Lx for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:23:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP8-00046D-KQ for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP7-00012E-OI for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:06 -0500 Received: from greensocs.com ([193.104.36.180]:43678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP0-0000TA-Gy; Sat, 10 Nov 2018 03:14:01 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 96A615D19A3; Sat, 10 Nov 2018 09:13:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837611; bh=Th2MJHUdNYEyzy14m2vDNx88f11TUXsyKWgcqpJpXlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dcSxQscIiM1DnKhHJKVX6yEJlmqFSXy4BvEb/dY+iXHGHmvdyWxDx7q8VkYofZA3d f0SRmvYMGoCJ3NAA2qQ+c9X7nzDO6jqKxTZfeiMI7ZOHzr4d4/gGyzaUJI6smalOZ9 H5DpeGbZmJxyH4vg8HGBliDFPgjcXH2dr8JysfgQ= 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=Gip3+pR4; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Gip3+pR4 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 QAKFfCEjxpDd; Sat, 10 Nov 2018 09:13:30 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id D88E85D19A9; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=Th2MJHUdNYEyzy14m2vDNx88f11TUXsyKWgcqpJpXlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gip3+pR4Iz+hKvxvlIHB+W5sHWKJSkHP0T1y/PZ4srs6t/w6Hv7a28jgZ0ZEdCJx6 JiW7kna41+hPTv/2ErE2gOVvoSkAGgQjJLDO2dYMf5eQagwizPDTdTV6v5i/V5+G4g ja1+nZfCmTTYRApafe74L7jQB7WMVORsHCa5aveM= 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 720845D19A6; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837607; bh=Th2MJHUdNYEyzy14m2vDNx88f11TUXsyKWgcqpJpXlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gip3+pR4Iz+hKvxvlIHB+W5sHWKJSkHP0T1y/PZ4srs6t/w6Hv7a28jgZ0ZEdCJx6 JiW7kna41+hPTv/2ErE2gOVvoSkAGgQjJLDO2dYMf5eQagwizPDTdTV6v5i/V5+G4g ja1+nZfCmTTYRApafe74L7jQB7WMVORsHCa5aveM= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:46 +0100 Message-Id: <20181110081147.4027-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 15/16] gdbstub: add multiprocess extension support 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add multiprocess extension support by enabling multiprocess mode when the peer requests it, and by replying that we actually support it in the qSupported reply packet. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Acked-by: Alistair Francis --- gdbstub.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index c662ada6ff..93a7c956c2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1721,10 +1721,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); cc = CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file != NULL) { pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); } + + if (strstr(p, "multiprocess+")) { + s->multiprocess = true; + } + pstrcat(buf, sizeof(buf), ";multiprocess+"); + put_packet(s, buf); break; } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; From patchwork Sat Nov 10 08:11:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10676997 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 CAAF014E2 for ; Sat, 10 Nov 2018 08:29:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBC3D2DF8C for ; Sat, 10 Nov 2018 08:29:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFF572DFA8; Sat, 10 Nov 2018 08:29:31 +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 34D3B2DF8C for ; Sat, 10 Nov 2018 08:29:31 +0000 (UTC) Received: from localhost ([::1]:37574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOe2-0004pu-Is for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Nov 2018 03:29:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOP7-00045I-PZ for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLOP5-00010C-Iv for qemu-devel@nongnu.org; Sat, 10 Nov 2018 03:14:05 -0500 Received: from greensocs.com ([193.104.36.180]:43701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLOOy-0000V7-M7; Sat, 10 Nov 2018 03:13:58 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 3581D5D19A1; Sat, 10 Nov 2018 09:13:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837612; bh=LMxXTTNAWH8AGdUZMYt2021rnq5Xws6PAKfpWkpVZSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ir2Z3oJFXw3GFSXq6F83CJqebtl7evg+QWnJ3RJxeImRo8hTfNUrOKEMwwsF+0K2u HjeEuKByHYY/Xx0G5MJLNjSVzJNkV56p1fZpVQ3eS4aNtIRmue3TX6K5trplfu9Va/ yCELPMN6+g0VbKAQGZ6fQzX78MOjxLPeasvhVGEs= 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=k5N2xuuR; dkim=pass (1024-bit key) header.d=greensocs.com header.b=k5N2xuuR 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 qpWh6bbwxvQp; Sat, 10 Nov 2018 09:13:31 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 8BB315D19AB; Sat, 10 Nov 2018 09:13:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837608; bh=LMxXTTNAWH8AGdUZMYt2021rnq5Xws6PAKfpWkpVZSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k5N2xuuRUN7PydvZ05mNM1fKwpwXpiHiG/d2oiplbeGTkzS7UjVRPA9WHk72JluZ9 f27C+dMUSEwTMX13uIt0qwBKEFQK9wHV3DKy32WYWMJnz2fUKInNK9GombUgqaPYAL 39XlbsGJAq0AFhIHQF1L7xh0yDg+h9C+6u8kPRr8= 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 D8E035D19AA; Sat, 10 Nov 2018 09:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1541837608; bh=LMxXTTNAWH8AGdUZMYt2021rnq5Xws6PAKfpWkpVZSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k5N2xuuRUN7PydvZ05mNM1fKwpwXpiHiG/d2oiplbeGTkzS7UjVRPA9WHk72JluZ9 f27C+dMUSEwTMX13uIt0qwBKEFQK9wHV3DKy32WYWMJnz2fUKInNK9GombUgqaPYAL 39XlbsGJAq0AFhIHQF1L7xh0yDg+h9C+6u8kPRr8= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 10 Nov 2018 09:11:47 +0100 Message-Id: <20181110081147.4027-17-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181110081147.4027-1-luc.michel@greensocs.com> References: <20181110081147.4027-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 v5 16/16] arm/xlnx-zynqmp: put APUs and RPUs in separate CPU clusters 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Create two separate CPU clusters for APUs and RPUs. Signed-off-by: Luc Michel --- include/hw/arm/xlnx-zynqmp.h | 3 +++ hw/arm/xlnx-zynqmp.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h index 98f925ab84..591515c760 100644 --- a/include/hw/arm/xlnx-zynqmp.h +++ b/include/hw/arm/xlnx-zynqmp.h @@ -29,10 +29,11 @@ #include "hw/dma/xlnx_dpdma.h" #include "hw/dma/xlnx-zdma.h" #include "hw/display/xlnx_dp.h" #include "hw/intc/xlnx-zynqmp-ipi.h" #include "hw/timer/xlnx-zynqmp-rtc.h" +#include "hw/cpu/cluster.h" #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \ TYPE_XLNX_ZYNQMP) @@ -75,10 +76,12 @@ typedef struct XlnxZynqMPState { /*< private >*/ DeviceState parent_obj; /*< public >*/ + CPUClusterState apu_cluster; + CPUClusterState rpu_cluster; ARMCPU apu_cpu[XLNX_ZYNQMP_NUM_APU_CPUS]; ARMCPU rpu_cpu[XLNX_ZYNQMP_NUM_RPU_CPUS]; GICState gic; MemoryRegion gic_mr[XLNX_ZYNQMP_GIC_REGIONS][XLNX_ZYNQMP_GIC_ALIASES]; diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index c195040350..42a138074c 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -176,16 +176,22 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, { Error *err = NULL; int i; int num_rpus = MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_NUM_RPU_CPUS); + object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster, + sizeof(s->rpu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + + qdev_init_nofail(DEVICE(&s->rpu_cluster)); + for (i = 0; i < num_rpus; i++) { char *name; object_initialize(&s->rpu_cpu[i], sizeof(s->rpu_cpu[i]), "cortex-r5f-" TYPE_ARM_CPU); - object_property_add_child(OBJECT(s), "rpu-cpu[*]", + object_property_add_child(OBJECT(&s->rpu_cluster), "rpu-cpu[*]", OBJECT(&s->rpu_cpu[i]), &error_abort); name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i])); if (strcmp(name, boot_cpu)) { /* Secondary CPUs start in PSCI powered-down state */ @@ -211,14 +217,19 @@ static void xlnx_zynqmp_init(Object *obj) { XlnxZynqMPState *s = XLNX_ZYNQMP(obj); int i; int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); + object_initialize_child(obj, "apu-cluster", &s->apu_cluster, + sizeof(s->apu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + for (i = 0; i < num_apus; i++) { - object_initialize_child(obj, "apu-cpu[*]", &s->apu_cpu[i], - sizeof(s->apu_cpu[i]), - "cortex-a53-" TYPE_ARM_CPU, &error_abort, NULL); + object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]", + &s->apu_cpu[i], sizeof(s->apu_cpu[i]), + "cortex-a53-" TYPE_ARM_CPU, &error_abort, + NULL); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic), gic_class_name()); @@ -331,10 +342,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus); qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secure); qdev_prop_set_bit(DEVICE(&s->gic), "has-virtualization-extensions", s->virt); + qdev_init_nofail(DEVICE(&s->apu_cluster)); + /* Realize APUs before realizing the GIC. KVM requires this. */ for (i = 0; i < num_apus; i++) { char *name; object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,