From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174791232741.6263366877477; Fri, 7 Dec 2018 01:26:31 -0800 (PST) Received: from localhost ([::1]:44982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCOt-0000dc-08 for importer@patchew.org; Fri, 07 Dec 2018 04:26:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1Z-00089Q-Hg for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1T-0005dG-It for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:17 -0500 Received: from greensocs.com ([193.104.36.180]:52153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1A-0005OJ-CP; Fri, 07 Dec 2018 04:01:52 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 07F01480039; Fri, 7 Dec 2018 10:01:46 +0100 (CET) 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 SSZyeZuSy8Rm; Fri, 7 Dec 2018 10:01:41 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 78044480013; Fri, 7 Dec 2018 10:01:41 +0100 (CET) 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 16102441B53; Fri, 7 Dec 2018 10:01:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=qCbSZN9yqKxMyodHfnn8BcAaMzQztlysADAA2gyzals=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZYAb1SMic60rFTyXEEkxF1GFiB96Tb1W675IS7sp5XRHhw/UO+zlLmREb+/EtiAlA lQgp9ZXUAtKuuFJeR8rkH3e1kP3jgrT56sWl8u5KKdiG8YsbDxTw2Dp08PAHRJAx58 Hs9aJiEfPF0A1Y4Y0j/cjdUDvfhLWDYtX/KDtZVk= 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=FCsSfFsk; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FCsSfFsk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173301; bh=qCbSZN9yqKxMyodHfnn8BcAaMzQztlysADAA2gyzals=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FCsSfFsk1Ytfvy7EISjWW/kMuKhF+SUq3ztnTmr6EsP4Czef5Ib8tk2z2aIzf5QP9 1FAC7wwAbupbmjjqQSy4MQvD76k/HM6Fl8+rL+BNZXAqdHzQWXDgxSbx1spy6WmUPk cFJAfjHOFnV10LUBlOtQwhV5kkhSL4eYen0Z1zp4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173301; bh=qCbSZN9yqKxMyodHfnn8BcAaMzQztlysADAA2gyzals=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FCsSfFsk1Ytfvy7EISjWW/kMuKhF+SUq3ztnTmr6EsP4Czef5Ib8tk2z2aIzf5QP9 1FAC7wwAbupbmjjqQSy4MQvD76k/HM6Fl8+rL+BNZXAqdHzQWXDgxSbx1spy6WmUPk cFJAfjHOFnV10LUBlOtQwhV5kkhSL4eYen0Z1zp4= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:19 +0100 Message-Id: <20181207090135.7651-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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. Documentation in cluster.h written with the help of Peter Maydell. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias --- include/hw/cpu/cluster.h | 58 ++++++++++++++++++++++++++++++++++++++++ hw/cpu/cluster.c | 50 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 ++ hw/cpu/Makefile.objs | 2 +- 4 files changed, 111 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..7381823243 --- /dev/null +++ b/include/hw/cpu/cluster.h @@ -0,0 +1,58 @@ +/* + * 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" + +/* + * CPU Cluster type + * + * A cluster is a group of CPUs which are all identical and have the same = view + * of the rest of the system. It is mainly an internal QEMU representation= and + * does not necessarily match with the notion of clusters on the real hard= ware. + * + * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs = in an + * Arm big.LITTLE system) they should be in different clusters. If the CPU= s do + * not have the same view of memory (for example the main CPU and a manage= ment + * controller processor) they should be in different clusters. + */ + +#define TYPE_CPU_CLUSTER "cpu-cluster" +#define CPU_CLUSTER(obj) \ + OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) + +/** + * CPUClusterState: + * @cluster_id: The cluster ID. This value is for internal use only and sh= ould + * not be exposed directly to the user or to the guest. + * + * State of a 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..9d50a235d5 --- /dev/null +++ b/hw/cpu/cluster.c @@ -0,0 +1,50 @@ +/* + * 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 Property cpu_cluster_properties[] =3D { + 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 =3D DEVICE_CLASS(klass); + + dc->props =3D cpu_cluster_properties; +} + +static const TypeInfo cpu_cluster_type_info =3D { + .name =3D TYPE_CPU_CLUSTER, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(CPUClusterState), + .class_init =3D 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 63effdc473..3a6d22fb07 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1150,11 +1150,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 https://github.com/ehabkost/qemu.git machine-next =20 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) +=3D arm11mpcore.o obj-$(CONFIG_REALVIEW) +=3D realview_mpcore.o obj-$(CONFIG_A9MPCORE) +=3D a9mpcore.o obj-$(CONFIG_A15MPCORE) +=3D a15mpcore.o -common-obj-y +=3D core.o +common-obj-y +=3D core.o cluster.o --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174352848330.4843933853306; Fri, 7 Dec 2018 01:19:12 -0800 (PST) Received: from localhost ([::1]:44938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCHu-0005qU-Vz for importer@patchew.org; Fri, 07 Dec 2018 04:19:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1I-0007vG-29 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1G-0005Wa-QO for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:59 -0500 Received: from greensocs.com ([193.104.36.180]:52154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1A-0005OI-4h; Fri, 07 Dec 2018 04:01:52 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id D2AF9441B53; Fri, 7 Dec 2018 10:01:42 +0100 (CET) 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 sicZ77RD0FE3; Fri, 7 Dec 2018 10:01:42 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id F08EC48001C; Fri, 7 Dec 2018 10:01:41 +0100 (CET) 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 7AFD0441B53; Fri, 7 Dec 2018 10:01:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173302; bh=Td0U/Tjezcs9QOROPPNJsCNzbHguapS0+D1uVLV94LQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0o2dgiSEScVeVn9SVM3+MDYIcXvA8nB0tAtxcnb64Ono4co719PyAmeXeg/l8pZH6 YzYKsEXec5LUWqo9I2DhPCdrJONwPzCdi8Jmg0ge6Wsbee3d4iyF1ETiNJacrp9Ngc WgP/X8Um1ZZO9iENmBCtiR4ZPBOS4YWERdCZDmjc= 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=ktxf9n1u; dkim=pass (1024-bit key) header.d=greensocs.com header.b=ktxf9n1u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173301; bh=Td0U/Tjezcs9QOROPPNJsCNzbHguapS0+D1uVLV94LQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ktxf9n1uJIxxy9ayZqkfQuKZAB6W0QMnuUfk5f9T2cbhilqtaagorU5XJdmSSxST3 0m4P+fHwf78istdzQOR0pPp9bfbZ51YzG8U8i9fAEjDBqsh/MCRvQtl4Qme8c1fPb8 r8KBuwnMnOhkujODj9+G9GKyDBocjrQ/18gNG7Yg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173301; bh=Td0U/Tjezcs9QOROPPNJsCNzbHguapS0+D1uVLV94LQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ktxf9n1uJIxxy9ayZqkfQuKZAB6W0QMnuUfk5f9T2cbhilqtaagorU5XJdmSSxST3 0m4P+fHwf78istdzQOR0pPp9bfbZ51YzG8U8i9fAEjDBqsh/MCRvQtl4Qme8c1fPb8 r8KBuwnMnOhkujODj9+G9GKyDBocjrQ/18gNG7Yg= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:20 +0100 Message-Id: <20181207090135.7651-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" Add a structure GDBProcess that represents 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 =3D cluster ID + 1 This is because PIDs -1 and 0 are reserved in GDB and cannot be used by processes. A default process is created to handle CPUs that are not in a cluster. This process gets the PID of the last process PID + 1. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index c4e4f9f082..2a3aa0f07e 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 =20 #define MAX_PACKET_LENGTH 4096 =20 #include "qemu/sockets.h" @@ -294,10 +295,15 @@ typedef struct GDBRegisterState { gdb_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; =20 +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; =20 /* By default use no IRQs and no timers while single stepping so as to @@ -1749,10 +1758,34 @@ void gdb_exit(CPUArchState *env, int code) #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&s->chr, true); #endif } =20 +/* + * Create the process that will contain all the "orphan" CPUs (that are not + * part of a CPU cluster). Note that if this process contains no CPUs, it = won't + * be attachable and thus will be invisible to the user. + */ +static void create_default_process(GDBState *s) +{ + GDBProcess *process; + int max_pid =3D 0; + + if (s->process_num) { + max_pid =3D s->processes[s->process_num - 1].pid; + } + + s->processes =3D g_renew(GDBProcess, s->processes, ++s->process_num); + process =3D &s->processes[s->process_num - 1]; + + /* We need an available PID slot for this process */ + assert(max_pid < UINT32_MAX); + + process->pid =3D max_pid + 1; + process->attached =3D false; +} + #ifdef CONFIG_USER_ONLY int gdb_handlesig(CPUState *cpu, int sig) { GDBState *s; @@ -1846,10 +1879,11 @@ static bool gdb_accept(void) } =20 s =3D g_malloc0(sizeof(GDBState)); s->c_cpu =3D first_cpu; s->g_cpu =3D first_cpu; + create_default_process(s); s->fd =3D fd; gdb_has_xml =3D false; =20 gdbserver_state =3D s; return true; @@ -2002,10 +2036,68 @@ static const TypeInfo char_gdb_type_info =3D { .name =3D TYPE_CHARDEV_GDB, .parent =3D TYPE_CHARDEV, .class_init =3D char_gdb_class_init, }; =20 +static int find_cpu_clusters(Object *child, void *opaque) +{ + if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { + GDBState *s =3D (GDBState *) opaque; + CPUClusterState *cluster =3D CPU_CLUSTER(child); + GDBProcess *process; + + s->processes =3D g_renew(GDBProcess, s->processes, ++s->process_nu= m); + + process =3D &s->processes[s->process_num - 1]; + + /* + * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at + * runtime, we enforce here that the machine does not use a cluste= r ID + * that would lead to PID 0. */ + assert(cluster->cluster_id !=3D UINT32_MAX); + process->pid =3D cluster->cluster_id + 1; + process->attached =3D false; + + return 0; + } + + return object_child_foreach(child, find_cpu_clusters, opaque); +} + +static int pid_order(const void *a, const void *b) +{ + GDBProcess *pa =3D (GDBProcess *) a; + GDBProcess *pb =3D (GDBProcess *) b; + + if (pa->pid < pb->pid) { + return -1; + } else if (pa->pid > pb->pid) { + return 1; + } else { + return 0; + } +} + +static void create_processes(GDBState *s) +{ + object_child_foreach(object_get_root(), find_cpu_clusters, s); + + if (s->processes) { + /* Sort by PID */ + qsort(s->processes, s->process_num, sizeof(s->processes[0]), pid_o= rder); + } + + create_default_process(s); +} + +static void cleanup_processes(GDBState *s) +{ + g_free(s->processes); + s->process_num =3D 0; + s->processes =3D NULL; +} + int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); =20 GDBState *s; @@ -2058,15 +2150,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 =3D s->mon_chr; + cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr =3D mon_chr; } s->c_cpu =3D first_cpu; s->g_cpu =3D first_cpu; + + 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_rec= eive, gdb_chr_event, NULL, NULL, NULL, true); } --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174215392455.6526414556472; Fri, 7 Dec 2018 01:16:55 -0800 (PST) Received: from localhost ([::1]:44931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCFh-00043a-Rj for importer@patchew.org; Fri, 07 Dec 2018 04:16:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1H-0007vE-Qa for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1G-0005WO-O4 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:59 -0500 Received: from greensocs.com ([193.104.36.180]:52241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rk-86; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 99C7E48002B; Fri, 7 Dec 2018 10:01:48 +0100 (CET) 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 SJt4PgcpJFfG; Fri, 7 Dec 2018 10:01:43 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 70953480024; Fri, 7 Dec 2018 10:01:42 +0100 (CET) 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 F312A441B53; Fri, 7 Dec 2018 10:01:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173308; bh=9VpM4fQSLmCFWhF4lXiU5yzJeMmL84qECiIHELh1Dvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZfIkn23CoITZ7z4C7ozY6oRH7agnksuA+mBdxScy76aJJV19EgKJQ2xDg9zKaIupU alRiqyJPr1lo2e2sex5cTcY/cp2wrpLzWzCkMtsZ7a0GfBOYkXpuQawxWpg7YpIkyX 4p6T/YVp6+FZH4ZsUqTqrTVJT4HToo4WIyOlGWCc= 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=hYiWYwh8; dkim=pass (1024-bit key) header.d=greensocs.com header.b=hYiWYwh8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173302; bh=9VpM4fQSLmCFWhF4lXiU5yzJeMmL84qECiIHELh1Dvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hYiWYwh8HzrjOVZjrOWBgvaezKo9jEVbGzuDz7a6iWzfSRxwQBzTvosu08Rc7vwPm tDWsh2Bb2JwW+zbGHwXTMUPcotiD99DIOPd8hhC7ptZDm9zfl5xILgUoSxvprzoRCI syu+zCBKmlz5tofO5R7GDSHs3qS9Jycm8caTtpEw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173302; bh=9VpM4fQSLmCFWhF4lXiU5yzJeMmL84qECiIHELh1Dvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hYiWYwh8HzrjOVZjrOWBgvaezKo9jEVbGzuDz7a6iWzfSRxwQBzTvosu08Rc7vwPm tDWsh2Bb2JwW+zbGHwXTMUPcotiD99DIOPd8hhC7ptZDm9zfl5xILgUoSxvprzoRCI syu+zCBKmlz5tofO5R7GDSHs3qS9Jycm8caTtpEw= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:21 +0100 Message-Id: <20181207090135.7651-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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 default 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 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 2a3aa0f07e..07508c2e6b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -638,10 +638,57 @@ static int memtox(char *buf, const char *mem, int len) } } return p - buf; } =20 +static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +{ +#ifndef CONFIG_USER_ONLY + gchar *path, *name =3D NULL; + Object *obj; + CPUClusterState *cluster; + uint32_t ret; + + path =3D object_get_canonical_path(OBJECT(cpu)); + + if (path =3D=3D NULL) { + /* Return the default process' PID */ + ret =3D s->processes[s->process_num - 1].pid; + goto out; + } + + name =3D object_get_canonical_path_component(OBJECT(cpu)); + assert(name !=3D NULL); + + /* + * Retrieve the CPU parent path by removing the last '/' and the CPU n= ame + * from the CPU canonical path. */ + path[strlen(path) - strlen(name) - 1] =3D '\0'; + + obj =3D object_resolve_path_type(path, TYPE_CPU_CLUSTER, NULL); + + if (obj =3D=3D NULL) { + /* Return the default process' PID */ + ret =3D s->processes[s->process_num - 1].pid; + goto out; + } + + cluster =3D CPU_CLUSTER(obj); + ret =3D cluster->cluster_id + 1; + +out: + g_free(name); + g_free(path); + + return ret; + +#else + /* TODO: In user mode, we should use the task state PID */ + return s->processes[s->process_num - 1].pid; +#endif +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -907,10 +954,23 @@ static CPUState *find_cpu(uint32_t thread_id) } =20 return NULL; } =20 +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 separato= r) { unsigned int query_len =3D strlen(query); =20 return strncmp(p, query, query_len) =3D=3D 0 && @@ -1018,22 +1078,23 @@ static int gdb_handle_packet(GDBState *s, const cha= r *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; =20 trace_gdbstub_io_command(line_buf); =20 p =3D line_buf; ch =3D *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_i= d))); 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. */ --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173487712143.05880104649975; Fri, 7 Dec 2018 01:04:47 -0800 (PST) Received: from localhost ([::1]:44841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC3y-0002qq-GY for importer@patchew.org; Fri, 07 Dec 2018 04:04:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1P-00083N-MG for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1J-0005YA-BH for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:07 -0500 Received: from greensocs.com ([193.104.36.180]:52160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1A-0005Oc-4i; Fri, 07 Dec 2018 04:01:52 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id F1C8048003B; Fri, 7 Dec 2018 10:01:46 +0100 (CET) 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 IpvKC1QVXw3T; Fri, 7 Dec 2018 10:01:46 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id D880548002B; Fri, 7 Dec 2018 10:01:42 +0100 (CET) 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 6D4F3480011; Fri, 7 Dec 2018 10:01:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=XFlt14LyZxFHZBsj389f0tAG4XXxE9SY9ZpylyKgfps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tbqNVlM09sK7ESVPK3+fDtf+L1FMavVmve0bz+Y+c9a/f2swkyokS8eUgYKebfw6/ Jku264k35fOQyZlzW07d0T72gEzN6jGBg+MRjhSHNDRh1lyHHvuwZIaMtSa7ttkF4O KnZFlDsPCKqakEfv5MDkKxg/g42iQDXBhn0rPbto= 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=1xQ5nNPG; dkim=pass (1024-bit key) header.d=greensocs.com header.b=1xQ5nNPG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173302; bh=XFlt14LyZxFHZBsj389f0tAG4XXxE9SY9ZpylyKgfps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1xQ5nNPGoY9qYfmAdYcIm6TNPLCJ7tql+jiAYNoqXq98PUshR+80s3NgigE2kramc KxhkWzWngB3BQCn7hiaSRTh7nrzxvP5q1zKTzBo72M0FrGg4uNxmUcrSZydcPBRi7a /Xqr1iv9voAL/9xKPIa4Fc8ZuPeVh05V4Iw57K+4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173302; bh=XFlt14LyZxFHZBsj389f0tAG4XXxE9SY9ZpylyKgfps=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1xQ5nNPGoY9qYfmAdYcIm6TNPLCJ7tql+jiAYNoqXq98PUshR+80s3NgigE2kramc KxhkWzWngB3BQCn7hiaSRTh7nrzxvP5q1zKTzBo72M0FrGg4uNxmUcrSZydcPBRi7a /Xqr1iv9voAL/9xKPIa4Fc8ZuPeVh05V4Iw57K+4= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:22 +0100 Message-Id: <20181207090135.7651-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 136 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 07508c2e6b..911faa225a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -685,10 +685,75 @@ out: /* TODO: In user mode, we should use the task state PID */ return s->processes[s->process_num - 1].pid; #endif } =20 +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 =3D 0; i < s->process_num; i++) { + if (s->processes[i].pid =3D=3D 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) =3D=3D thread_id) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +{ + GDBProcess *process; + CPUState *cpu; + + if (!tid) { + /* 0 means any thread, we take the first one */ + tid =3D 1; + } + + cpu =3D find_cpu(tid); + + if (cpu =3D=3D NULL) { + return NULL; + } + + process =3D gdb_get_cpu_process(s, cpu); + + if (process->pid !=3D 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; @@ -941,23 +1006,10 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong= pc) =20 cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } =20 -static CPUState *find_cpu(uint32_t thread_id) -{ - CPUState *cpu; - - CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) =3D=3D 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", @@ -967,10 +1019,64 @@ static char *gdb_fmt_thread_id(const GDBState *s, CP= UState *cpu, } =20 return buf; } =20 +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD =3D 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_bu= f, + uint32_t *pid, uint32_t *tid) +{ + unsigned long p, t; + int ret; + + if (*buf =3D=3D 'p') { + buf++; + ret =3D qemu_strtoul(buf, &buf, 16, &p); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + /* Skip '.' */ + buf++; + } else { + p =3D 1; + } + + ret =3D qemu_strtoul(buf, &buf, 16, &t); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + *end_buf =3D buf; + + if (p =3D=3D -1) { + return GDB_ALL_PROCESSES; + } + + if (pid) { + *pid =3D p; + } + + if (t =3D=3D -1) { + return GDB_ALL_THREADS; + } + + if (tid) { + *tid =3D t; + } + + return GDB_ONE_THREAD; +} + static int is_query_packet(const char *p, const char *query, char separato= r) { unsigned int query_len =3D strlen(query); =20 return strncmp(p, query, query_len) =3D=3D 0 && @@ -1075,16 +1181,18 @@ static int gdb_handle_packet(GDBState *s, const cha= r *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; =20 trace_gdbstub_io_command(line_buf); =20 p =3D line_buf; ch =3D *p++; @@ -1288,16 +1396,22 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) else put_packet(s, "E22"); break; case 'H': type =3D *p++; - thread =3D strtoull(p, (char **)&p, 16); - if (thread =3D=3D -1 || thread =3D=3D 0) { + + thread_kind =3D read_thread_id(p, &p, &pid, &tid); + if (thread_kind =3D=3D GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + + if (thread_kind !=3D GDB_ONE_THREAD) { put_packet(s, "OK"); break; } - cpu =3D find_cpu(thread); + cpu =3D gdb_get_cpu(s, pid, tid); if (cpu =3D=3D NULL) { put_packet(s, "E22"); break; } switch (type) { @@ -1313,12 +1427,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, "E22"); break; } break; case 'T': - thread =3D strtoull(p, (char **)&p, 16); - cpu =3D find_cpu(thread); + thread_kind =3D read_thread_id(p, &p, &pid, &tid); + if (thread_kind =3D=3D GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu =3D gdb_get_cpu(s, pid, tid); =20 if (cpu !=3D NULL) { put_packet(s, "OK"); } else { put_packet(s, "E22"); --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173876783948.5039646858538; Fri, 7 Dec 2018 01:11:16 -0800 (PST) Received: from localhost ([::1]:44890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCAF-0007sx-4N for importer@patchew.org; Fri, 07 Dec 2018 04:11:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1O-00081p-A3 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1K-0005ZB-HV for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:05 -0500 Received: from greensocs.com ([193.104.36.180]:52172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1A-0005P0-4l; Fri, 07 Dec 2018 04:01:52 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id DB5C148003D; Fri, 7 Dec 2018 10:01:47 +0100 (CET) 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-MDqOoO-Gbc; Fri, 7 Dec 2018 10:01:47 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 4A56948001C; Fri, 7 Dec 2018 10:01:43 +0100 (CET) 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 DE25E480011; Fri, 7 Dec 2018 10:01:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=kB56oet04D2MbLCru1kH6fcA5mY1A7C1tONrUo4uOwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zzdD56pACnTP0Z9OCyJSXVSnk5G13h6GHF4aCSrCPc7ZecL8YSiWHNgWhb/KtQWHA fiYQ1Q1jdC1wEI3eznXp7cvEcsjLupqDDViLKq1RGk2/HJ/KrpaRaSfJHmvFMeN7lP kWFRXM8TjG0mFJQHZDVvpulBeZVr4/VCDtthtuPw= 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=yUv96e9O; dkim=pass (1024-bit key) header.d=greensocs.com header.b=yUv96e9O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173303; bh=kB56oet04D2MbLCru1kH6fcA5mY1A7C1tONrUo4uOwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yUv96e9OnmvSlcrqEeN4ndARiSLqZHvkqVjDmSCwiG8srdrSrZy7NAAPTTdWGkwtV bkEzMCvIEdg9JyzowW3MuGThLtiVVdeJH42rfTy/tiNc6DcI0+8U24/zlUfTvbFyn9 32VhFfQewaNc8KyslaGwO5wmJoNub1MmdM1pK83g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173303; bh=kB56oet04D2MbLCru1kH6fcA5mY1A7C1tONrUo4uOwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yUv96e9OnmvSlcrqEeN4ndARiSLqZHvkqVjDmSCwiG8srdrSrZy7NAAPTTdWGkwtV bkEzMCvIEdg9JyzowW3MuGThLtiVVdeJH42rfTy/tiNc6DcI0+8U24/zlUfTvbFyn9 32VhFfQewaNc8KyslaGwO5wmJoNub1MmdM1pK83g= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:23 +0100 Message-Id: <20181207090135.7651-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" Add the gdb_first_attached_cpu() and gdb_next_attached_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=C3=A9 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 911faa225a..77b3dbb2c8 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -721,10 +721,40 @@ static CPUState *find_cpu(uint32_t thread_id) } =20 return NULL; } =20 +static CPUState *get_first_cpu_in_process(const GDBState *s, + GDBProcess *process) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (gdb_get_cpu_pid(s, cpu) =3D=3D process->pid) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +{ + uint32_t pid =3D gdb_get_cpu_pid(s, cpu); + cpu =3D CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_pid(s, cpu) =3D=3D pid) { + break; + } + + cpu =3D CPU_NEXT(cpu); + } + + return cpu; +} + static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu; =20 @@ -750,10 +780,41 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint3= 2_t pid, uint32_t tid) } =20 return cpu; } =20 +/* Return the cpu following @cpu, while ignoring + * unattached processes. + */ +static CPUState *gdb_next_attached_cpu(const GDBState *s, CPUState *cpu) +{ + cpu =3D CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_process(s, cpu)->attached) { + break; + } + + cpu =3D CPU_NEXT(cpu); + } + + return cpu; +} + +/* Return the first attached cpu */ +static CPUState *gdb_first_attached_cpu(const GDBState *s) +{ + CPUState *cpu =3D first_cpu; + GDBProcess *process =3D gdb_get_cpu_process(s, cpu); + + if (!process->attached) { + return gdb_next_attached_cpu(s, cpu); + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -1088,14 +1149,16 @@ static int is_query_packet(const char *p, const cha= r *query, char separator) * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if the= re is * a format error, 0 on success. */ static int gdb_handle_vcont(GDBState *s, const char *p) { - int res, idx, signal =3D 0; + int res, signal =3D 0; char cur_action; char *newstates; unsigned long tmp; + uint32_t pid, tid; + GDBProcess *process; CPUState *cpu; #ifdef CONFIG_USER_ONLY int max_cpus =3D 1; /* global variable max_cpus exists only in system = mode */ =20 CPU_FOREACH(cpu) { @@ -1134,29 +1197,52 @@ static int gdb_handle_vcont(GDBState *s, const char= *p) } else if (cur_action !=3D 'c' && cur_action !=3D 's') { /* unknown/invalid/unsupported command */ res =3D -ENOTSUP; goto out; } - /* thread specification. special values: (none), -1 =3D all; 0 =3D= any */ - if ((p[0] =3D=3D ':' && p[1] =3D=3D '-' && p[2] =3D=3D '1') || (p[= 0] !=3D ':')) { - if (*p =3D=3D ':') { - p +=3D 3; - } - for (idx =3D 0; idx < max_cpus; idx++) { - if (newstates[idx] =3D=3D 1) { - newstates[idx] =3D cur_action; + + if (*p++ !=3D ':') { + res =3D -ENOTSUP; + goto out; + } + + switch (read_thread_id(p, &p, &pid, &tid)) { + case GDB_READ_THREAD_ERR: + res =3D -EINVAL; + goto out; + + case GDB_ALL_PROCESSES: + cpu =3D gdb_first_attached_cpu(s); + while (cpu) { + if (newstates[cpu->cpu_index] =3D=3D 1) { + newstates[cpu->cpu_index] =3D cur_action; } + + cpu =3D gdb_next_attached_cpu(s, cpu); } - } else if (*p =3D=3D ':') { - p++; - res =3D qemu_strtoul(p, &p, 16, &tmp); - if (res) { + break; + + case GDB_ALL_THREADS: + process =3D gdb_get_process(s, pid); + + if (!process->attached) { + res =3D -EINVAL; goto out; } =20 - /* 0 means any thread, so we pick the first valid CPU */ - cpu =3D tmp ? find_cpu(tmp) : first_cpu; + cpu =3D get_first_cpu_in_process(s, process); + while (cpu) { + if (newstates[cpu->cpu_index] =3D=3D 1) { + newstates[cpu->cpu_index] =3D cur_action; + } + + cpu =3D gdb_next_cpu_in_process(s, cpu); + } + break; + + case GDB_ONE_THREAD: + cpu =3D gdb_get_cpu(s, pid, tid); =20 /* invalid CPU/thread specified */ if (!cpu) { res =3D -EINVAL; goto out; @@ -1164,10 +1250,11 @@ static int gdb_handle_vcont(GDBState *s, const char= *p) =20 /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] =3D=3D 1) { newstates[cpu->cpu_index] =3D cur_action; } + break; } } s->signal =3D signal; gdb_continue_partial(s, newstates); =20 --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173645478898.2412511273322; Fri, 7 Dec 2018 01:07:25 -0800 (PST) Received: from localhost ([::1]:44866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC6W-0004kt-7x for importer@patchew.org; Fri, 07 Dec 2018 04:07:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1H-0007vA-D7 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1F-0005VV-FW for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:59 -0500 Received: from greensocs.com ([193.104.36.180]:52244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rl-AB; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 0561C480031; Fri, 7 Dec 2018 10:01:50 +0100 (CET) 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 XKzDi0P6VMwz; Fri, 7 Dec 2018 10:01:48 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id B230148002D; Fri, 7 Dec 2018 10:01:43 +0100 (CET) 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 4E548480011; Fri, 7 Dec 2018 10:01:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173310; bh=LYKjPukkF3jTxCyW8qyvQZFW8og+W5CDquv7hLZS1iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jtB+/SjPn928yoe8XlqtteIBVfR2Y5UK081kFdb5xt4YMHYb7hbnz/NPy+uBBKDZR yuUU7u090YsTs68EXDWAy93CsH0hzPM/ldiSz0xDhyx3Fb0iLXKMUCxS9jCXdLQnuE DUMIyIvhZRrfiYxa/1KQ0atfFsO5CQHzv/NdZRUI= 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=6U9/C7j3; dkim=pass (1024-bit key) header.d=greensocs.com header.b=6U9/C7j3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173303; bh=LYKjPukkF3jTxCyW8qyvQZFW8og+W5CDquv7hLZS1iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6U9/C7j3J02fqbdEdlrnZshWpev16F7mFuL5188LzRi7JMXQeiDqFFrMzpD+OsbMx y7QLbFZAIEXZFtaByfjM2/AzFMPYUX3CxPhrRtawq5d0JBl/jQr71MfijFodTLE4Z0 Lueu6s24wNoPadjSX2qW8djfYbBLHQbXm7sf8eJw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173303; bh=LYKjPukkF3jTxCyW8qyvQZFW8og+W5CDquv7hLZS1iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6U9/C7j3J02fqbdEdlrnZshWpev16F7mFuL5188LzRi7JMXQeiDqFFrMzpD+OsbMx y7QLbFZAIEXZFtaByfjM2/AzFMPYUX3CxPhrRtawq5d0JBl/jQr71MfijFodTLE4Z0 Lueu6s24wNoPadjSX2qW8djfYbBLHQbXm7sf8eJw= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:24 +0100 Message-Id: <20181207090135.7651-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 77b3dbb2c8..bea0215f30 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1553,13 +1553,18 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) type =3D strtoul(p, (char **)&p, 16); sstep_flags =3D type; put_packet(s, "OK"); break; } else if (strcmp(p,"C") =3D=3D 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 retur= n the + * first thread of the current process (gdb returns the first + * thread). + */ + cpu =3D 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") =3D=3D 0) { s->query_cpu =3D first_cpu; goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") =3D=3D 0) { --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173526909558.2458692342786; Fri, 7 Dec 2018 01:05:26 -0800 (PST) Received: from localhost ([::1]:44845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC4b-0003Eg-MG for importer@patchew.org; Fri, 07 Dec 2018 04:05:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1G-0007u8-NF for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1F-0005Vi-MO for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:58 -0500 Received: from greensocs.com ([193.104.36.180]:52242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Ri-5W; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 6F966480024; Fri, 7 Dec 2018 10:01:49 +0100 (CET) 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 XPwl7OEk6fcp; Fri, 7 Dec 2018 10:01:48 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 23FA6480031; Fri, 7 Dec 2018 10:01:44 +0100 (CET) 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 B5632480011; Fri, 7 Dec 2018 10:01:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173309; bh=mzcICz8Hy5oCiIfDs9UxgEljkNS5zKRwZKUGqfLZU4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l5Hk/Qit4GRxQCrPDtxP81t/RCNAsue9jfCDe+DUTMKPvIhkH03KVlMn5FwTVBh19 lfTJphROJsojUZVdgDVbh2DTDT0qeeUlj6mN7sS0Ab3hmdj4a+Z4r4WKQBh31cc62Z /nYDKIEBxctmiJ0qq/lROTGNJSUZWHv3MCwOFIi8= 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=XerEnLX9; dkim=pass (1024-bit key) header.d=greensocs.com header.b=XerEnLX9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=mzcICz8Hy5oCiIfDs9UxgEljkNS5zKRwZKUGqfLZU4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XerEnLX9y1un8Z3/GokSGJl7A9Ot4m0rUaxmDM8A46miHubzOPTNGyvPr+ehP8Wzs 3pBEyG6obVNh2cZ8ViE3mTO/ggsTQhEnccT9Nsuvha4sl+bgcO8S3sePvL/PUlfIVc fvPp7kfXpJ4fgFZD99apVFHBifZjriHZThU42F3E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=mzcICz8Hy5oCiIfDs9UxgEljkNS5zKRwZKUGqfLZU4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XerEnLX9y1un8Z3/GokSGJl7A9Ot4m0rUaxmDM8A46miHubzOPTNGyvPr+ehP8Wzs 3pBEyG6obVNh2cZ8ViE3mTO/ggsTQhEnccT9Nsuvha4sl+bgcO8S3sePvL/PUlfIVc fvPp7kfXpJ4fgFZD99apVFHBifZjriHZThU42F3E= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:25 +0100 Message-Id: <20181207090135.7651-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis --- gdbstub.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index bea0215f30..770915446a 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1267,11 +1267,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]; @@ -1563,30 +1562,48 @@ static int gdb_handle_packet(GDBState *s, const cha= r *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") =3D=3D 0) { - s->query_cpu =3D first_cpu; + s->query_cpu =3D gdb_first_attached_cpu(s); goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") =3D=3D 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", cpu_gdb_index(s->query_c= pu)); + 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 =3D CPU_NEXT(s->query_cpu); + s->query_cpu =3D gdb_next_attached_cpu(s, s->query_cpu); } else put_packet(s, "l"); break; } else if (strncmp(p,"ThreadExtraInfo,", 16) =3D=3D 0) { - thread =3D strtoull(p+16, (char **)&p, 16); - cpu =3D find_cpu(thread); + if (read_thread_id(p + 16, &p, &pid, &tid) =3D=3D GDB_READ_THR= EAD_ERR) { + put_packet(s, "E22"); + break; + } + cpu =3D gdb_get_cpu(s, pid, tid); if (cpu !=3D NULL) { cpu_synchronize_state(cpu); - /* memtohex() doubles the required space */ - len =3D 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 and name in multiprocess mode */ + ObjectClass *oc =3D object_get_class(OBJECT(cpu)); + const char *cpu_model =3D object_class_get_name(oc); + char *cpu_name =3D + object_get_canonical_path_component(OBJECT(cpu)); + len =3D snprintf((char *)mem_buf, sizeof(buf) / 2, + "%s %s [%s]", cpu_model, cpu_name, + cpu->halted ? "halted " : "running"); + g_free(cpu_name); + } else { + /* memtohex() doubles the required space */ + len =3D 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; --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174498588375.09601743255325; Fri, 7 Dec 2018 01:21:38 -0800 (PST) Received: from localhost ([::1]:44954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCKA-0000jq-8V for importer@patchew.org; Fri, 07 Dec 2018 04:21:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1O-00081t-BV for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1J-0005Yl-Tq for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:05 -0500 Received: from greensocs.com ([193.104.36.180]:52243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rp-98; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 4EF5C48002D; Fri, 7 Dec 2018 10:01:50 +0100 (CET) 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 wbCxAoZy5CYN; Fri, 7 Dec 2018 10:01:49 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 8DD72480032; Fri, 7 Dec 2018 10:01:44 +0100 (CET) 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 2A167480011; Fri, 7 Dec 2018 10:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173310; bh=j//0svrnt9OC0lkTyoNN3pWM3w5Yc5T8PcFl79uKj+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GOJk/f81vkt2gbsX2SGtC7tvs0Iha0y4FfY/YwpY5yuTz+NM/ZVdYCx58zbjqPC6I vuaqSm3EC64tC/fkYZkAhj0DuqARN2edvLVE9aIiKs6j6yAvigTSswqF8hC651sQoO 2lL2aarQ2N6MDXzlHiYPYSGqLLGdmTPcZx1iiW/Q= 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=FJqTQLrZ; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FJqTQLrZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=j//0svrnt9OC0lkTyoNN3pWM3w5Yc5T8PcFl79uKj+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FJqTQLrZtgRxI5iPAzWHoCKvimJjiHD/fsp/TvZkirdP1xuAG1URZ+UHKsXTsuMzE G3Ev9T9V9PFwxBybN9Kvo1G6f+AhEPCy1ZgIGLi740qQrPGw44b7l8wbQ0rzRc1s4v 9iZF17oYu4OajdH8S37c/SX1oVFS/lHcNjndeCHY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=j//0svrnt9OC0lkTyoNN3pWM3w5Yc5T8PcFl79uKj+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FJqTQLrZtgRxI5iPAzWHoCKvimJjiHD/fsp/TvZkirdP1xuAG1URZ+UHKsXTsuMzE G3Ev9T9V9PFwxBybN9Kvo1G6f+AhEPCy1ZgIGLi740qQrPGw44b7l8wbQ0rzRc1s4v 9iZF17oYu4OajdH8S37c/SX1oVFS/lHcNjndeCHY= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:26 +0100 Message-Id: <20181207090135.7651-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis --- gdbstub.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 770915446a..c66bf37b49 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -298,10 +298,12 @@ typedef struct GDBRegisterState { } GDBRegisterState; =20 typedef struct GDBProcess { uint32_t pid; bool attached; + + char target_xml[1024]; } GDBProcess; =20 enum RSState { RS_INACTIVE, RS_IDLE, @@ -811,55 +813,57 @@ static CPUState *gdb_first_attached_cpu(const GDBStat= e *s) } =20 return cpu; } =20 -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 =3D get_first_cpu_in_process(s, process); + CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 len =3D 0; while (p[len] && p[len] !=3D ':') len++; *newp =3D p + len; =20 name =3D NULL; if (strncmp(p, "target.xml", len) =3D=3D 0) { + char *buf =3D process->target_xml; + const size_t buf_sz =3D sizeof(process->target_xml); + /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { + if (!buf[0]) { GDBRegisterState *r; - CPUState *cpu =3D first_cpu; =20 - pstrcat(target_xml, sizeof(target_xml), + pstrcat(buf, buf_sz, "" "" ""); if (cc->gdb_arch_name) { gchar *arch =3D 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 =3D cpu->gdb_regs; r; r =3D 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 =3D first_cpu; char *xmlname =3D g_strndup(p, len); const char *xml =3D cc->gdb_get_dynamic_xml(cpu, xmlname); =20 g_free(xmlname); if (xml) { @@ -1265,10 +1269,11 @@ out: } =20 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]; @@ -1648,18 +1653,19 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } if (strncmp(p, "Xfer:features:read:", 19) =3D=3D 0) { const char *xml; target_ulong total_len; =20 - cc =3D CPU_GET_CLASS(first_cpu); + process =3D gdb_get_cpu_process(s, s->g_cpu); + cc =3D CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file =3D=3D NULL) { goto unknown_command; } =20 gdb_has_xml =3D true; p +=3D 19; - xml =3D get_feature_xml(p, &p, cc); + xml =3D get_feature_xml(s, p, &p, process); if (!xml) { snprintf(buf, sizeof(buf), "E00"); put_packet(s, buf); break; } @@ -2068,10 +2074,11 @@ static void create_default_process(GDBState *s) /* We need an available PID slot for this process */ assert(max_pid < UINT32_MAX); =20 process->pid =3D max_pid + 1; process->attached =3D false; + process->target_xml[0] =3D '\0'; } =20 #ifdef CONFIG_USER_ONLY int gdb_handlesig(CPUState *cpu, int sig) @@ -2342,10 +2349,11 @@ static int find_cpu_clusters(Object *child, void *o= paque) * runtime, we enforce here that the machine does not use a cluste= r ID * that would lead to PID 0. */ assert(cluster->cluster_id !=3D UINT32_MAX); process->pid =3D cluster->cluster_id + 1; process->attached =3D false; + process->target_xml[0] =3D '\0'; =20 return 0; } =20 return object_child_foreach(child, find_cpu_clusters, opaque); --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15441740740551005.3749737429902; Fri, 7 Dec 2018 01:14:34 -0800 (PST) Received: from localhost ([::1]:44909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCDQ-0002Bq-HO for importer@patchew.org; Fri, 07 Dec 2018 04:14:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1G-0007tq-EA for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1F-0005VO-E0 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:58 -0500 Received: from greensocs.com ([193.104.36.180]:52245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rq-7p; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id CF85B480032; Fri, 7 Dec 2018 10:01:50 +0100 (CET) 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 ioCa8pdvdKO2; Fri, 7 Dec 2018 10:01:50 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id F3C3C480036; Fri, 7 Dec 2018 10:01:44 +0100 (CET) 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 90EAC480011; Fri, 7 Dec 2018 10:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173310; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a6bjMqJOACVUFsSzdXAkKsw/i3TzFSkrEylKojjkLN7wDl18XDTX1t5bNkTMqIQyc KTNKBKKLw4olG7i+dVJvAv5xpXSXrmPf9fp0hTMcf1NsdpDsPt2kQKEZMsvFFo2UMY QUzmw/yUuDf2IxIL1+ZmQ3zeEfKuOKSAYqG+QUxs= 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=Rp0oTYW1; dkim=pass (1024-bit key) header.d=greensocs.com header.b=V7qNrk6b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rp0oTYW1YokZ8Upw3B1yzdrsqEWaj+baCSPWjwc3+ppLfkLt5huKBzT5JhlvQ/ab4 /K/OeUxkC6NO7Q2K6miujJt0JMGTtFh12wLokfERtP5qKroZ87P26GjcX2f3nfJ1pR kDNgRQuixxzepx3wkb0HzIQniarV4VQTDw/09twI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V7qNrk6bhJmpuqeFLnMygVGYg74RMKYmesP6exDjwaKCP8EfYpUSf69zd9jioPZEC 1wqsX+d1YgyPWlTW2upx4wFlpTmAlTIfwfgABV6dYSqB8IgL0fpcSHp1ckvJucbwT/ 5ujCXTBihaYqQWhK5gMNvB1waH4nA4EnbPhwatvA= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:27 +0100 Message-Id: <20181207090135.7651-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) Content-Type: text/plain; charset="utf-8" Add support for multiprocess extension in gdb_vm_state_change() function. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c66bf37b49..4645d59d8c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1722,10 +1722,11 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s =3D gdbserver_state; CPUState *cpu =3D s->c_cpu; char buf[256]; + char thread_id[16]; const char *type; int ret; =20 if (running || s->state =3D=3D RS_INACTIVE) { return; @@ -1733,10 +1734,18 @@ static void gdb_vm_state_change(void *opaque, int r= unning, 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 =3D=3D 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: @@ -1750,12 +1759,12 @@ static void gdb_vm_state_change(void *opaque, int r= unning, 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 =3D NULL; goto send_packet; } else { trace_gdbstub_hit_break(); @@ -1793,11 +1802,11 @@ static void gdb_vm_state_change(void *opaque, int r= unning, RunState state) trace_gdbstub_hit_unknown(state); ret =3D 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); =20 send_packet: put_packet(s, buf); =20 /* disable single step if it was enabled */ --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173909614816.2530574772292; Fri, 7 Dec 2018 01:11:49 -0800 (PST) Received: from localhost ([::1]:44893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCAm-0008Op-0z for importer@patchew.org; Fri, 07 Dec 2018 04:11:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1a-00089q-02 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1Z-0005fj-4p for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:17 -0500 Received: from greensocs.com ([193.104.36.180]:52246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1V-0005Rs-A7; Fri, 07 Dec 2018 04:02:13 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2E513480036; Fri, 7 Dec 2018 10:01:51 +0100 (CET) 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 o7Yf1L6AME2X; Fri, 7 Dec 2018 10:01:50 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 698F1480038; Fri, 7 Dec 2018 10:01:45 +0100 (CET) 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 0328C480011; Fri, 7 Dec 2018 10:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173311; bh=fTLojJdToljvuaXR6Y5DUo7NPRDCtUsKLEk8/1L5s4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qGMnhw3V5VbeAJJgjH5w8UfEdINWNpVwVvARFFIzY3Wrd+bFrnDl2oOdSZkGK9uiH CCXG3t+GFhrh8l2Ii02514xSH2bgwV8pXUnaLQgz3HimhUlXGdZStAgml9JmUfXMgX C5rd6N+9VXHyzEWEE5B82q70Z7SYi10SckIx9NyM= 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=LAFz6sz5; dkim=pass (1024-bit key) header.d=greensocs.com header.b=LAFz6sz5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=fTLojJdToljvuaXR6Y5DUo7NPRDCtUsKLEk8/1L5s4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LAFz6sz5j9L5LiIpDtvvLm/kCN6LE6VMYsr3OApcGA8feVzeGVdxXGTfMaTp3T/Nx 851WSxpwV26fvRq+Y4sLJSghf7p0ZynC9m/l6vfqMBTBLTYG3F0X1ahwykVcffGJgc yuPAQ7E+AbRL2CJrzmDBvZviXzhDMaVQLv5/u4ts= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=fTLojJdToljvuaXR6Y5DUo7NPRDCtUsKLEk8/1L5s4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LAFz6sz5j9L5LiIpDtvvLm/kCN6LE6VMYsr3OApcGA8feVzeGVdxXGTfMaTp3T/Nx 851WSxpwV26fvRq+Y4sLJSghf7p0ZynC9m/l6vfqMBTBLTYG3F0X1ahwykVcffGJgc yuPAQ7E+AbRL2CJrzmDBvZviXzhDMaVQLv5/u4ts= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:28 +0100 Message-Id: <20181207090135.7651-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" '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=C3=A9 Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4645d59d8c..48c2571ebe 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1046,24 +1046,39 @@ static int gdb_breakpoint_remove(target_ulong addr,= target_ulong len, int type) default: return -ENOSYS; } } =20 +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, GDBProces= s *p) +{ + CPUState *cpu =3D get_first_cpu_in_process(s, p); + + while (cpu) { + gdb_cpu_breakpoint_remove_all(cpu); + cpu =3D gdb_next_cpu_in_process(s, cpu); + } +} + static void gdb_breakpoint_remove_all(void) { CPUState *cpu; =20 if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } =20 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); } } =20 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { @@ -1338,13 +1353,44 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': /* Detach packet */ - gdb_breakpoint_remove_all(); - gdb_syscall_mode =3D GDB_SYS_DISABLED; - gdb_continue(s); + pid =3D 1; + + if (s->multiprocess) { + unsigned long lpid; + if (*p !=3D ';') { + put_packet(s, "E22"); + break; + } + + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { + put_packet(s, "E22"); + break; + } + + pid =3D lpid; + } + + process =3D gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached =3D false; + + if (pid =3D=3D gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu =3D gdb_first_attached_cpu(s); + } + + if (pid =3D=3D gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu =3D gdb_first_attached_cpu(s); + } + + if (s->c_cpu =3D=3D NULL) { + /* No more process attached */ + gdb_syscall_mode =3D GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': if (*p !=3D '\0') { addr =3D strtoull(p, (char **)&p, 16); --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544175047696563.1323641985998; Fri, 7 Dec 2018 01:30:47 -0800 (PST) Received: from localhost ([::1]:45009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCSz-0005s3-23 for importer@patchew.org; Fri, 07 Dec 2018 04:30:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1o-0008NO-Oq for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1j-0005ob-7t for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:32 -0500 Received: from greensocs.com ([193.104.36.180]:52249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1V-0005S1-DU; Fri, 07 Dec 2018 04:02:13 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C8BC9441B53; Fri, 7 Dec 2018 10:01:52 +0100 (CET) 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 e9nQ_L8uwgL8; Fri, 7 Dec 2018 10:01:51 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id D00DA480011; Fri, 7 Dec 2018 10:01:45 +0100 (CET) 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 697FA480037; Fri, 7 Dec 2018 10:01:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173312; bh=5fEHqqrKfs547kfy2tsAp8GlZdfkwG8rdzXh46VRHEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ydwxVgvcYPKh/dfgme/Pzvwl3pKTHgRUrurRGzXse8pUnctp7pBw+lomAisg6TDSj wjAB5dRMAa7cX9lFuiEX5pmKjQSvZSLCTkjksxwgBotFfammJKAbOUe/9UQrz6Vary +q28g3Lla/djtm4hx8fl3upw9v3t6qS0QfJpW9xY= 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=WVDci8yj; dkim=pass (1024-bit key) header.d=greensocs.com header.b=WVDci8yj DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=5fEHqqrKfs547kfy2tsAp8GlZdfkwG8rdzXh46VRHEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WVDci8yjvsQAqJ4HHuwQXzWAtx+wfL7EGh0dQI195pNE8qxmUF3AorHJ5F4KsU+ie rGdZyAxP6cLqgdhDbwIhGsvWjE4/SFJMbz8v2BIOQcjD0PRvSz/vflOrScN7oVFOeb RvaYjfpz9lLf+MChkRj7Cd1d1ZqiuHyTp3a6TCmI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=5fEHqqrKfs547kfy2tsAp8GlZdfkwG8rdzXh46VRHEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WVDci8yjvsQAqJ4HHuwQXzWAtx+wfL7EGh0dQI195pNE8qxmUF3AorHJ5F4KsU+ie rGdZyAxP6cLqgdhDbwIhGsvWjE4/SFJMbz8v2BIOQcjD0PRvSz/vflOrScN7oVFOeb RvaYjfpz9lLf+MChkRj7Cd1d1ZqiuHyTp3a6TCmI= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:29 +0100 Message-Id: <20181207090135.7651-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" Add support for the '!' extended mode packet. This is required for the multiprocess extension. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 48c2571ebe..1cf1bea428 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1301,10 +1301,13 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) trace_gdbstub_io_command(line_buf); =20 p =3D line_buf; ch =3D *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_i= d))); put_packet(s, buf); --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174031447608.377305228023; Fri, 7 Dec 2018 01:13:51 -0800 (PST) Received: from localhost ([::1]:44908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCCj-0001gX-Pq for importer@patchew.org; Fri, 07 Dec 2018 04:13:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1O-00081q-A2 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1H-0005Wz-DJ for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:05 -0500 Received: from greensocs.com ([193.104.36.180]:52247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rt-Ax; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 10E7B511C5F; Fri, 7 Dec 2018 10:01:52 +0100 (CET) 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 YOZfpkmDVJnh; Fri, 7 Dec 2018 10:01:51 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 4DD4A48003A; Fri, 7 Dec 2018 10:01:46 +0100 (CET) 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 D31C4480037; Fri, 7 Dec 2018 10:01:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173312; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Pi5DYeNaSgvXp87NaMdAhQ2JpNkSboV6FiIEOXJ5JAfEDuRSMcVYathp/HIIU23ur LLES74ZBZDKmh0p+1jSsxjdCGZTz2N/jj4Knto7YXWUarNY9jEoySHsqQY/tceL3Oh HGs5IJQq4eZRN5XShyFhpzONVyNfzbo6cgOQ/LSo= 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=nZyw/Xah; dkim=pass (1024-bit key) header.d=greensocs.com header.b=nZyw/Xah DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nZyw/XahwVzHrG7ZGAbNtnnd7P1onfGeibw1RiutgNeRpff4WRvFiwRp/I28HUobo gEo8/BVCTqL5Q4liXjfuPr7qinzMm9TFr4r4AP2WSnCb+ffvYqEyjl6sYj7CwOUEQ8 ZUXlT/kmBIuqIrLAzKh0yx8bVEjrkby29iRL5kmQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=1YfOa6KOFz7+7vzadhdXswLweJ5s+84SUWufA2FeAHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nZyw/XahwVzHrG7ZGAbNtnnd7P1onfGeibw1RiutgNeRpff4WRvFiwRp/I28HUobo gEo8/BVCTqL5Q4liXjfuPr7qinzMm9TFr4r4AP2WSnCb+ffvYqEyjl6sYj7CwOUEQ8 ZUXlT/kmBIuqIrLAzKh0yx8bVEjrkby29iRL5kmQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:30 +0100 Message-Id: <20181207090135.7651-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 1cf1bea428..8601be533b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1347,10 +1347,45 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach;", 7) =3D=3D 0) { + unsigned long pid; + + p +=3D 7; + + if (qemu_strtoul(p, &p, 16, &pid)) { + put_packet(s, "E22"); + break; + } + + process =3D gdb_get_process(s, pid); + + if (process =3D=3D NULL) { + put_packet(s, "E22"); + break; + } + + cpu =3D get_first_cpu_in_process(s, process); + + if (cpu =3D=3D NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached =3D true; + + s->g_cpu =3D cpu; + s->c_cpu =3D 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 */ --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174631795926.2033158086549; Fri, 7 Dec 2018 01:23:51 -0800 (PST) Received: from localhost ([::1]:44968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCML-0006v6-L6 for importer@patchew.org; Fri, 07 Dec 2018 04:23:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1a-0008AL-GI for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1Z-0005g7-If for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:18 -0500 Received: from greensocs.com ([193.104.36.180]:52245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1W-0005Rq-AL; Fri, 07 Dec 2018 04:02:14 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E6A05480018; Fri, 7 Dec 2018 10:01:53 +0100 (CET) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9dfIsUucce24; Fri, 7 Dec 2018 10:01:52 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id B1B2E480037; Fri, 7 Dec 2018 10:01:46 +0100 (CET) Received: from michell-laptop.home.lmichel.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 4C2BA480013; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173313; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BSbSuxmp8dbH8IVoKBFUmkhO44+fUHu5Pl/MpBR55SjBrN3iU3INaLfz/BsFFqj47 aSj1Q23XPtpYINkjOpYMTVk1deF5AtoM0bVbNrCKmnpvaihrjDzqFR3MzN8uaFYzIF 9TRd2cRwu4D1Y+syi6Djk7Jd4cgUDF8W6B+As3sg= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=iKsiv8qd; dkim=pass (1024-bit key) header.d=greensocs.com header.b=iKsiv8qd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iKsiv8qdUoN8RAZrpyjiSwm3Scm1lOPUqsutXpXYq7YkGS72rKXCgh6V2mm3GuvDH IYDHvPsub+V6m8M9Ss1CG1FHAaXdOp7GLTJSz987otbDBgMTtZh5Z/V8ChjvF7N4IN AHjqa5aIJRwMDw2AaoRScKyQNbmKqQBJ8okHvDnM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173306; bh=NtClXFPIxg1OArVuKPjWf7LBj/Mk+I6aQK/rvdYFu8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iKsiv8qdUoN8RAZrpyjiSwm3Scm1lOPUqsutXpXYq7YkGS72rKXCgh6V2mm3GuvDH IYDHvPsub+V6m8M9Ss1CG1FHAaXdOp7GLTJSz987otbDBgMTtZh5Z/V8ChjvF7N4IN AHjqa5aIJRwMDw2AaoRScKyQNbmKqQBJ8okHvDnM= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:31 +0100 Message-Id: <20181207090135.7651-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 13/16] gdbstub: processes initialization on new peer connection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" When a new connection is established, we set the first process to be attached, and the others detached. The first CPU of the first process is selected as the current CPU. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 8601be533b..81e7742847 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2265,13 +2265,14 @@ static bool gdb_accept(void) close(fd); return false; } =20 s =3D g_malloc0(sizeof(GDBState)); - s->c_cpu =3D first_cpu; - s->g_cpu =3D first_cpu; create_default_process(s); + s->processes[0].attached =3D true; + s->c_cpu =3D gdb_first_attached_cpu(s); + s->g_cpu =3D s->c_cpu; s->fd =3D fd; gdb_has_xml =3D false; =20 gdbserver_state =3D s; return true; @@ -2353,12 +2354,23 @@ static void gdb_chr_receive(void *opaque, const uin= t8_t *buf, int size) } } =20 static void gdb_chr_event(void *opaque, int event) { + int i; + GDBState *s =3D (GDBState *) opaque; + switch (event) { case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i =3D 0; i < s->process_num; i++) { + s->processes[i].attached =3D !i; + } + + s->c_cpu =3D gdb_first_attached_cpu(s); + s->g_cpu =3D s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml =3D false; break; default: break; @@ -2543,19 +2555,17 @@ int gdbserver_start(const char *device) mon_chr =3D s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr =3D mon_chr; } - s->c_cpu =3D first_cpu; - s->g_cpu =3D first_cpu; =20 create_processes(s); =20 if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_rec= eive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state =3D chr ? RS_IDLE : RS_INACTIVE; s->mon_chr =3D mon_chr; s->current_syscall_cb =3D NULL; =20 --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174960978164.1467928835774; Fri, 7 Dec 2018 01:29:20 -0800 (PST) Received: from localhost ([::1]:44996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCRj-0004zT-H9 for importer@patchew.org; Fri, 07 Dec 2018 04:29:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1g-0008HO-Oe for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1g-0005jB-1C for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:24 -0500 Received: from greensocs.com ([193.104.36.180]:52242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1V-0005Ri-Ty; Fri, 07 Dec 2018 04:02:14 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9820F480011; Fri, 7 Dec 2018 10:01:53 +0100 (CET) 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 JcsXwgtsNnOg; Fri, 7 Dec 2018 10:01:52 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 337B248003C; Fri, 7 Dec 2018 10:01:47 +0100 (CET) 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 B5077480013; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173313; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rA56IWwgBHr9j59Zek0LLjpcfD5GLTWuwhG3i876jGpEqfW0heTiLt7PiiIColDDI X4qpNQghpRT/9h1ak8PQ4sIUfN80GusUcGmvOAKRlIxybhrrg2PVXQOAfiBrIeXa37 reYn8eh/fZ+ojqr6lZaRMfSQjw3XS7AwWMlUd2X8= 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=WIXn2w0l; dkim=pass (1024-bit key) header.d=greensocs.com header.b=WIXn2w0l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WIXn2w0lWY5USmn6nfhFCZ9WYVZQ2DlB03KTTF/9puLw1BXdvMiPpGTycDBznDynu F7Y8EdBOWg7l6btgUcUnL2zz+ZcObfcmZTNf6lLOaBhVCHEa+N2rH0q39QU7m0Uve6 55O+MKNu6m3tIkMCpSkJc3pB3TULuRpjiEfgrH24= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WIXn2w0lWY5USmn6nfhFCZ9WYVZQ2DlB03KTTF/9puLw1BXdvMiPpGTycDBznDynu F7Y8EdBOWg7l6btgUcUnL2zz+ZcObfcmZTNf6lLOaBhVCHEa+N2rH0q39QU7m0Uve6 55O+MKNu6m3tIkMCpSkJc3pB3TULuRpjiEfgrH24= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:32 +0100 Message-Id: <20181207090135.7651-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" When 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 Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 81e7742847..48b49195f7 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1796,10 +1796,19 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) return RS_IDLE; } =20 void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p =3D gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* Having a stop CPU corresponding to a process that is not attach= ed + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu =3D cpu; gdbserver_state->g_cpu =3D cpu; } =20 #ifndef CONFIG_USER_ONLY --=20 2.19.2 From nobody Thu May 2 02:37:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544174210563514.3421045380492; Fri, 7 Dec 2018 01:16:50 -0800 (PST) Received: from localhost ([::1]:44929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCFZ-0003v9-3R for importer@patchew.org; Fri, 07 Dec 2018 04:16:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1q-0008OY-G3 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1n-0005sQ-5H for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:34 -0500 Received: from greensocs.com ([193.104.36.180]:52276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1b-0005XD-Ro; Fri, 07 Dec 2018 04:02:20 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 4645248001C; Fri, 7 Dec 2018 10:01:59 +0100 (CET) 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 yp5BzxRFgf90; Fri, 7 Dec 2018 10:01:53 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 93A4C480013; Fri, 7 Dec 2018 10:01:47 +0100 (CET) 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 29AB748002B; Fri, 7 Dec 2018 10:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173319; bh=IP6jRQoZE0XKPG4iiMFfY8vpzGwLJrBjjivKVJr6bTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hgdGBwgTxbBPns+RRVz2aI1MVgFXssHXgD4Uqe7t+gyBzqEaodrRE86qJTHICk2MH 9EcZdA3tq9i2Wwp+ySUNSnuTyeJ2Adt7AM8kSxcaIBhplDYyveRBQc2XqHugC2Jbv5 GGatb3D8A4S2JCdR1O51BvAG+KQz9uocxWjAHLp4= 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=lhRD4wyT; dkim=pass (1024-bit key) header.d=greensocs.com header.b=lhRD4wyT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=IP6jRQoZE0XKPG4iiMFfY8vpzGwLJrBjjivKVJr6bTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lhRD4wyTVgj6/nrZ9qJK2bCrNjDkD5R+ADdGJmPfO5hKJnNPud7Qzx65rJEtNtupX g4l34bdMt+VCjWDFirKhrx9gxxKLE8Jb14NCCzAmpl15kwpmEVsedTSF2NNanhiUNE 8PnyqeIL/oB/lkusHIYPBJTMHFQ7CXHapjOitsP8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=IP6jRQoZE0XKPG4iiMFfY8vpzGwLJrBjjivKVJr6bTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lhRD4wyTVgj6/nrZ9qJK2bCrNjDkD5R+ADdGJmPfO5hKJnNPud7Qzx65rJEtNtupX g4l34bdMt+VCjWDFirKhrx9gxxKLE8Jb14NCCzAmpl15kwpmEVsedTSF2NNanhiUNE 8PnyqeIL/oB/lkusHIYPBJTMHFQ7CXHapjOitsP8= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:33 +0100 Message-Id: <20181207090135.7651-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" 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=C3=A9 Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- gdbstub.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 48b49195f7..bb82d97c5c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1730,10 +1730,16 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) snprintf(buf, sizeof(buf), "PacketSize=3D%x", MAX_PACKET_LENGT= H); cc =3D CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file !=3D NULL) { pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); } + + if (strstr(p, "multiprocess+")) { + s->multiprocess =3D true; + } + pstrcat(buf, sizeof(buf), ";multiprocess+"); + put_packet(s, buf); break; } if (strncmp(p, "Xfer:features:read:", 19) =3D=3D 0) { const char *xml; --=20 2.19.2 From nobody Thu May 2 02:37:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544173741837376.12976338707983; Fri, 7 Dec 2018 01:09:01 -0800 (PST) Received: from localhost ([::1]:44869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC7r-0005wt-Q2 for importer@patchew.org; Fri, 07 Dec 2018 04:08:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1b-0008Bd-GS for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1a-0005gi-J4 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:19 -0500 Received: from greensocs.com ([193.104.36.180]:52241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1X-0005Rk-SR; Fri, 07 Dec 2018 04:02:16 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id D1507480024; Fri, 7 Dec 2018 10:01:54 +0100 (CET) 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 ujpnGvA8f5ez; Fri, 7 Dec 2018 10:01:54 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 1392B48001C; Fri, 7 Dec 2018 10:01:48 +0100 (CET) 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 951C148002B; Fri, 7 Dec 2018 10:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173314; bh=qT1myRY8+72bGIoRFHUkl0awqFWddD9vzwxt3H9ioig=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XV3yCyGGd0WS0n1cMj5WbEVVR6kLqWlHB28ZE8eIyX07DhHC/Jhv5Zi4+nU40p5ui 8JkYoZpF6QbIABL8P5xBHqnDSU0HRlF7QuJNVerKsvkgly6Fe6cL3a8IyCbTSwRLRo koeegQLyZ4zovW3vOER6UrLsx447md3lxcJWbeUc= 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=Ajz1vfMD; dkim=pass (1024-bit key) header.d=greensocs.com header.b=z1+UaR0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173308; bh=qT1myRY8+72bGIoRFHUkl0awqFWddD9vzwxt3H9ioig=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ajz1vfMD1cGgZcb1RCzF36aXePccBemPugnW32OXkolXLuLddBkzYYN2Qxm3h4Cgb SMksIasQIMWSLOcbUPyizfbHQFKkYwcSdibZrpzujOXqGOjWZO7Arxhl3oRcR2ptSn OyUldMBSf0ySIXJsfsdKjji+j6nvRfwM3r6XQMkk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=qT1myRY8+72bGIoRFHUkl0awqFWddD9vzwxt3H9ioig=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=z1+UaR0Eprn37p6DyL9pDiL4dR2JSVrLyMmzZpvRNCBpfgmtOThg1LP87zhlvdEf7 CKRZzpx1SNH6wMe2W1ic/h63eAkmO8Ut1RjSBw6S3I2wuKi2Y0mg1e234XVHX3m6cD DuP0Q9ECdX78xBNf5W5xI3NqDDItgZVrxifz+VNg= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:34 +0100 Message-Id: <20181207090135.7651-17-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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=20Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) Content-Type: text/plain; charset="utf-8" Create two separate CPU clusters for APUs and RPUs. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- include/hw/arm/xlnx-zynqmp.h | 3 +++ hw/arm/xlnx-zynqmp.c | 23 +++++++++++++++++++---- 2 files changed, 22 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" =20 #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \ TYPE_XLNX_ZYNQMP) =20 @@ -75,10 +76,12 @@ typedef struct XlnxZynqMPState { /*< private >*/ DeviceState parent_obj; =20 /*< 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]; =20 diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index c195040350..c67ac2e64a 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -176,16 +176,23 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s= , const char *boot_cpu, { Error *err =3D NULL; int i; int num_rpus =3D MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_= NUM_RPU_CPUS); =20 + object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster, + sizeof(s->rpu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + qdev_prop_set_uint32(DEVICE(&s->rpu_cluster), "cluster-id", 1); + + qdev_init_nofail(DEVICE(&s->rpu_cluster)); + for (i =3D 0; i < num_rpus; i++) { char *name; =20 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); =20 name =3D 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 +218,20 @@ static void xlnx_zynqmp_init(Object *obj) { XlnxZynqMPState *s =3D XLNX_ZYNQMP(obj); int i; int num_apus =3D MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); =20 + object_initialize_child(obj, "apu-cluster", &s->apu_cluster, + sizeof(s->apu_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + qdev_prop_set_uint32(DEVICE(&s->apu_cluster), "cluster-id", 0); + for (i =3D 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); } =20 sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic), gic_class_name()); =20 @@ -331,10 +344,12 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Err= or **errp) qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus); qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secur= e); qdev_prop_set_bit(DEVICE(&s->gic), "has-virtualization-extensions", s->virt); =20 + qdev_init_nofail(DEVICE(&s->apu_cluster)); + /* Realize APUs before realizing the GIC. KVM requires this. */ for (i =3D 0; i < num_apus; i++) { char *name; =20 object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_= SMC, --=20 2.19.2