From patchwork Mon Oct 1 11:56:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D4D415E8 for ; Mon, 1 Oct 2018 12:08:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4FE29223 for ; Mon, 1 Oct 2018 12:08:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F718293D1; Mon, 1 Oct 2018 12:08:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36DC629223 for ; Mon, 1 Oct 2018 12:08:38 +0000 (UTC) Received: from localhost ([::1]:37902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x08-0005O7-WF for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:08:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RA-Ac for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005oJ-Lu for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005gV-PN; Mon, 01 Oct 2018 07:57:29 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2BBF2511C7A; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395032; bh=hzryMaDN826qZv17hcBHWGh1oUXnmV+3gYFiqx3y/A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HFtilpIgZ34nUP+6TxGNLA1gKT0iR2/LY8PFx1M3uMAVLJx0YN6VQRKyPhRp9npYE 1gf6tDM3sZlToEL9B3eDcdfx1SmLlBbYa5vPofgWotLINauukBfMQfBLHX4Ki4Y5IA ISqO3sa+yl+6MMnUzmL4iqSs/8xGkp+6K3MXCV80= 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=msNoUMsc; dkim=pass (1024-bit key) header.d=greensocs.com header.b=msNoUMsc 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 VAD6mHau484w; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 807EC511C51; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395026; bh=hzryMaDN826qZv17hcBHWGh1oUXnmV+3gYFiqx3y/A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=msNoUMscEPj/dVyefRvWE89dCVIfYRDDOiivPs1M0z3fnwbo3i5fjSkuJ3BVy92lp gRi1ETQQ2aFQlbQAJgRL2eexaxqYIGZhQr1uezlwUwRnKLsIhuRU+/IYGGHQi9NmxH ncTX5VUNQ6Pozhto0s3x9NGFc7DPIPiwhHCtbHhA= 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 1FA14511C65; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395026; bh=hzryMaDN826qZv17hcBHWGh1oUXnmV+3gYFiqx3y/A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=msNoUMscEPj/dVyefRvWE89dCVIfYRDDOiivPs1M0z3fnwbo3i5fjSkuJ3BVy92lp gRi1ETQQ2aFQlbQAJgRL2eexaxqYIGZhQr1uezlwUwRnKLsIhuRU+/IYGGHQi9NmxH ncTX5VUNQ6Pozhto0s3x9NGFc7DPIPiwhHCtbHhA= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:50 +0200 Message-Id: <20181001115704.701-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 01/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a structure GDBProcess that represent processes from the GDB semantic point of view. CPUs can be split into different processes, by grouping them under a QOM container named after the GDB_CPU_GROUP_NAME macro (`gdb-group[*]'). Each occurrence of such a container implies the existence of the corresponding process in the GDB stub. The gdb_cpu_group_container_get() function can be used to create a new container. When no such container are found, all the CPUs are put in a unique GDB process (create_unique_process()). This is also the case when compiled in user mode, where multi-processes do not make much sense for now. Signed-off-by: Luc Michel --- include/exec/gdbstub.h | 8 +++++ gdbstub.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 08363969c1..a3e4159bf4 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -1,8 +1,10 @@ #ifndef GDBSTUB_H #define GDBSTUB_H +#include "qom/object.h" + #define DEFAULT_GDBSTUB_PORT "1234" /* GDB breakpoint/watchpoint types */ #define GDB_BREAKPOINT_SW 0 #define GDB_BREAKPOINT_HW 1 @@ -129,6 +131,12 @@ void gdbserver_cleanup(void); extern bool gdb_has_xml; /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ extern const char *const xml_builtin[][2]; +#define GDB_CPU_GROUP_NAME "gdb-group" + +static inline Object *gdb_cpu_group_container_get(Object *parent) +{ + return container_get(parent, "/" GDB_CPU_GROUP_NAME "[*]"); +} #endif diff --git a/gdbstub.c b/gdbstub.c index d6ab95006c..5c86218f49 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -295,10 +295,17 @@ typedef struct GDBRegisterState { gdb_reg_cb set_reg; const char *xml; struct GDBRegisterState *next; } GDBRegisterState; +typedef struct GDBProcess { + uint32_t pid; + bool attached; + + char target_xml[1024]; +} GDBProcess; + enum RSState { RS_INACTIVE, RS_IDLE, RS_GETLINE, RS_GETLINE_ESC, @@ -323,10 +330,13 @@ typedef struct GDBState { int running_state; #else CharBackend chr; Chardev *mon_chr; #endif + bool multiprocess; + GDBProcess *processes; + int process_num; char syscall_buf[256]; gdb_syscall_complete_cb current_syscall_cb; } GDBState; /* By default use no IRQs and no timers while single stepping so as to @@ -1750,10 +1760,24 @@ void gdb_exit(CPUArchState *env, int code) #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&s->chr, true); #endif } +/* + * Create a unique process containing all the CPUs. + */ +static void create_unique_process(GDBState *s) +{ + GDBProcess *process; + + s->processes = g_malloc0(sizeof(GDBProcess)); + s->process_num = 1; + process = &s->processes[0]; + + process->pid = 1; +} + #ifdef CONFIG_USER_ONLY int gdb_handlesig(CPUState *cpu, int sig) { GDBState *s; @@ -1847,10 +1871,11 @@ static bool gdb_accept(void) } s = g_malloc0(sizeof(GDBState)); s->c_cpu = first_cpu; s->g_cpu = first_cpu; + create_unique_process(s); s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2003,10 +2028,48 @@ static const TypeInfo char_gdb_type_info = { .name = TYPE_CHARDEV_GDB, .parent = TYPE_CHARDEV, .class_init = char_gdb_class_init, }; +static void create_processes(GDBState *s) +{ + Object *container; + int i = 0; + char process_str[16]; + + container = object_resolve_path(GDB_CPU_GROUP_NAME "[0]", NULL); + + while (container) { + s->processes = g_renew(GDBProcess, s->processes, i + 1); + + GDBProcess *process = &s->processes[i]; + + /* GDB process IDs -1 and 0 are reserved */ + process->pid = i + 1; + process->attached = false; + process->target_xml[0] = '\0'; + + i++; + snprintf(process_str, sizeof(process_str), GDB_CPU_GROUP_NAME "[%d]", i); + container = object_resolve_path(process_str, NULL); + } + + if (!s->processes) { + /* No CPU group specified by the machine */ + create_unique_process(s); + } else { + s->process_num = i; + } +} + +static void cleanup_processes(GDBState *s) +{ + g_free(s->processes); + s->process_num = 0; + s->processes = NULL; +} + int gdbserver_start(const char *device) { trace_gdbstub_op_start(device); GDBState *s; @@ -2055,15 +2118,19 @@ int gdbserver_start(const char *device) NULL, &error_abort); monitor_init(mon_chr, 0); } else { qemu_chr_fe_deinit(&s->chr, true); mon_chr = s->mon_chr; + cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } s->c_cpu = first_cpu; s->g_cpu = first_cpu; + + create_processes(s); + if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL, NULL, NULL, true); } From patchwork Mon Oct 1 11:56:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FE4A15E8 for ; Mon, 1 Oct 2018 12:03:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D3CD28113 for ; Mon, 1 Oct 2018 12:03:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 613E028178; Mon, 1 Oct 2018 12:03:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF1B128113 for ; Mon, 1 Oct 2018 12:03:29 +0000 (UTC) Received: from localhost ([::1]:37832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wvB-0000r4-5A for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:03:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RF-B0 for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005nt-LH for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpG-0005SR-2s; Mon, 01 Oct 2018 07:57:26 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C20E0511C74; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395028; bh=CZDV+nwNooxk+V+II5p/pzKlDVhCtkeY4U7VPDETTBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D3ecuqbHWKf8D+1LPrpBLuxE2C8OAmjaAavOYp3wA8LBNcv7x4Vw2KQQxLy6q0ZzO HArFRVlG7vwOdEAaYwKTH7aJPIqQHxM3SyMYmtY9bQ3sq5Udrr0vB2SFOSpmbPqyfz B4C8ds1vukWGc2FCPu/NEGoVT6qOILsCSBs/8lV0= 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=N6pDGiDj; dkim=pass (1024-bit key) header.d=greensocs.com header.b=N6pDGiDj 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 EhjVCXGYCR9b; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E0D47511C65; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395026; bh=CZDV+nwNooxk+V+II5p/pzKlDVhCtkeY4U7VPDETTBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N6pDGiDjsemAxATb7juswwz8L8QbZ4LFP7faEfJ5/4CU+vViYshtPyJfK0mlWLU2V AU5VEDqum+9/3AfitV8aZAaWjHmCyTBHiLT+XZVD74ilXEANskw1BqZyqaBFkqtMrK LqmaCBSnKoAllOBpOqnVWR3QpAwPbPuyFAsQJSRY= 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 84613511C69; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395026; bh=CZDV+nwNooxk+V+II5p/pzKlDVhCtkeY4U7VPDETTBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N6pDGiDjsemAxATb7juswwz8L8QbZ4LFP7faEfJ5/4CU+vViYshtPyJfK0mlWLU2V AU5VEDqum+9/3AfitV8aZAaWjHmCyTBHiLT+XZVD74ilXEANskw1BqZyqaBFkqtMrK LqmaCBSnKoAllOBpOqnVWR3QpAwPbPuyFAsQJSRY= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:51 +0200 Message-Id: <20181001115704.701-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 02/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The gdb_get_cpu_pid() function does the PID lookup for the given CPU. It checks if the CPU is in a QOM container named after the GDB_CPU_GROUP_NAME macro. If found, it returns the correponding PID, which is the group ID plus one (group IDs start at 0, GDB PIDs at 1). When the CPU is not a child of such a container, PID 1 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 it in the reply to a '?' request. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 5c86218f49..ac9d540fda 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -640,10 +640,37 @@ static int memtox(char *buf, const char *mem, int len) } } return p - buf; } +static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) +{ + gchar *path; + gchar *cont; + const char *left; + unsigned long pid; + + if (!s->multiprocess || (s->process_num == 1)) { + return 1; + } + + path = object_get_canonical_path(OBJECT(cpu)); + cont = g_strrstr(path, "/" GDB_CPU_GROUP_NAME "["); + + if (cont == NULL) { + return 1; + } + + cont += strlen("/" GDB_CPU_GROUP_NAME "["); + + if (qemu_strtoul(cont, &left, 10, &pid)) { + return 1; + } + + return pid + 1; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -909,10 +936,23 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, + char *buf, size_t buf_size) +{ + if (s->multiprocess) { + snprintf(buf, buf_size, "p%02x.%02x", + gdb_get_cpu_pid(s, cpu), cpu_gdb_index(cpu)); + } else { + snprintf(buf, buf_size, "%02x", cpu_gdb_index(cpu)); + } + + return buf; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1020,22 +1060,23 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) const char *p; uint32_t thread; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; + char thread_id[16]; uint8_t *registers; target_ulong addr, len; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { case '?': /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - cpu_gdb_index(s->c_cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state * should be cleaned up. */ From patchwork Mon Oct 1 11:56:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A94C6CB for ; Mon, 1 Oct 2018 11:59:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46899294A8 for ; Mon, 1 Oct 2018 11:59:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 383A5294B2; Mon, 1 Oct 2018 11:59:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D08A294A8 for ; Mon, 1 Oct 2018 11:59:40 +0000 (UTC) Received: from localhost ([::1]:37810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wrT-0004M5-QR for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 07:59:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RD-B2 for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005nd-Lu for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005SS-EH; Mon, 01 Oct 2018 07:57:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C1D07511C76; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=R42etYwRSrVcvW4xJWx/ZO7fMF+ds6WK3e7k/NVNk1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bU5X5yuIb0i7yinhcxk2aDIdYwle8tof0SHh+REi2vgW0cJn1hfCc8gefXg+cp/Xa nTMDVMFVs+6RopH32jtGmqV3nMC5c8jpmqrlxm+mPqcagSvjBsL6tAbXXnMvWOcJWC aC5xyhUyXS8BLKlUpnpHXvnWnX79u/keQI+Xdy60= 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=UWUjcBFg; dkim=pass (1024-bit key) header.d=greensocs.com header.b=UWUjcBFg 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 6I_qrpbX8Vjg; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 5F000511C69; Mon, 1 Oct 2018 13:57:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395027; bh=R42etYwRSrVcvW4xJWx/ZO7fMF+ds6WK3e7k/NVNk1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UWUjcBFgX4P6tFHngH+bbeAZpa829Vv/pyufgvw4GURQ+qFFfHmhq24AgPEcZ98e1 dxDMvrEukFYmNXf3sOlaveEbE5iBtUv4EyypuMVeC/3O00Iem6szQ/wmyLVzlW5sXH X707BE70dhRgq8UT2ty5Zg+S+Iylpl8ufYtGTc5w= 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 E7DE3511C6E; Mon, 1 Oct 2018 13:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395027; bh=R42etYwRSrVcvW4xJWx/ZO7fMF+ds6WK3e7k/NVNk1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UWUjcBFgX4P6tFHngH+bbeAZpa829Vv/pyufgvw4GURQ+qFFfHmhq24AgPEcZ98e1 dxDMvrEukFYmNXf3sOlaveEbE5iBtUv4EyypuMVeC/3O00Iem6szQ/wmyLVzlW5sXH X707BE70dhRgq8UT2ty5Zg+S+Iylpl8ufYtGTc5w= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:52 +0200 Message-Id: <20181001115704.701-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 03/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a couple of helper functions to cope with GDB threads and processes. The gdb_get_process() function looks for a process given a pid. The gdb_get_cpu() function returns the CPU corresponding to the (pid, tid) pair given as parameters. The read_thread_id() function parses the thread-id sent by the peer. This function supports the multiprocess extension thread-id syntax. The return value specifies if the parsing failed, or if a special case was encountered (all processes or all threads). Use them in 'H' and 'T' packets handling to support the multiprocess extension. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index ac9d540fda..a21ce3ca18 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -667,10 +667,74 @@ static uint32_t gdb_get_cpu_pid(const GDBState *s, CPUState *cpu) } return pid + 1; } +static GDBProcess *gdb_get_process(const GDBState *s, uint32_t pid) +{ + uint32_t process_idx; + + if (!pid) { + /* 0 means any process, we take the first one */ + pid = 1; + } + + /* GDB PIDs are in the range [1;n] */ + process_idx = pid - 1; + + if (process_idx >= s->process_num) { + return NULL; + } + + return &s->processes[process_idx]; +} + +static GDBProcess *gdb_get_cpu_process(const GDBState *s, CPUState *cpu) +{ + return gdb_get_process(s, gdb_get_cpu_pid(s, cpu)); +} + +static CPUState *find_cpu(uint32_t thread_id) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (cpu_gdb_index(cpu) == thread_id) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) +{ + GDBProcess *process; + CPUState *cpu = find_cpu(tid); + + if (!tid) { + /* 0 means any thread, we take the first one */ + tid = 1; + } + + if (cpu == NULL) { + return NULL; + } + + process = gdb_get_cpu_process(s, cpu); + + if (process->pid != pid) { + return NULL; + } + + if (!process->attached) { + return NULL; + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -923,23 +987,10 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) cpu_synchronize_state(cpu); cpu_set_pc(cpu, pc); } -static CPUState *find_cpu(uint32_t thread_id) -{ - CPUState *cpu; - - CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) == thread_id) { - return cpu; - } - } - - return NULL; -} - static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, char *buf, size_t buf_size) { if (s->multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", @@ -949,10 +1000,64 @@ static char *gdb_fmt_thread_id(const GDBState *s, CPUState *cpu, } return buf; } +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD = 0, + GDB_ALL_THREADS, /* One process, all threads */ + GDB_ALL_PROCESSES, + GDB_READ_THREAD_ERR +} GDBThreadIdKind; + +static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, + uint32_t *pid, uint32_t *tid) +{ + unsigned long p, t; + int ret; + + if (*buf == 'p') { + buf++; + ret = qemu_strtoul(buf, &buf, 16, &p); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + /* Skip '.' */ + buf++; + } else { + p = 1; + } + + ret = qemu_strtoul(buf, &buf, 16, &t); + + if (ret) { + return GDB_READ_THREAD_ERR; + } + + *end_buf = buf; + + if (p == -1) { + return GDB_ALL_PROCESSES; + } + + if (pid) { + *pid = p; + } + + if (t == -1) { + return GDB_ALL_THREADS; + } + + if (tid) { + *tid = t; + } + + return GDB_ONE_THREAD; +} + static int is_query_packet(const char *p, const char *query, char separator) { unsigned int query_len = strlen(query); return strncmp(p, query, query_len) == 0 && @@ -1057,16 +1162,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; CPUClass *cc; const char *p; uint32_t thread; + uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; char thread_id[16]; uint8_t *registers; target_ulong addr, len; + GDBThreadIdKind thread_kind; trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; @@ -1270,16 +1377,22 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) else put_packet(s, "E22"); break; case 'H': type = *p++; - thread = strtoull(p, (char **)&p, 16); - if (thread == -1 || thread == 0) { + + thread_kind = read_thread_id(p, &p, &pid, &tid); + if (thread_kind == GDB_READ_THREAD_ERR) { + put_packet(s, "E22"); + break; + } + + if (thread_kind != GDB_ONE_THREAD) { put_packet(s, "OK"); break; } - cpu = find_cpu(thread); + cpu = gdb_get_cpu(s, pid, tid); if (cpu == NULL) { put_packet(s, "E22"); break; } switch (type) { @@ -1295,12 +1408,12 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "E22"); break; } break; case 'T': - thread = strtoull(p, (char **)&p, 16); - cpu = find_cpu(thread); + read_thread_id(p, &p, &pid, &tid); + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { put_packet(s, "OK"); } else { put_packet(s, "E22"); From patchwork Mon Oct 1 11:56:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 073721515 for ; Mon, 1 Oct 2018 12:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EADB32946E for ; Mon, 1 Oct 2018 12:10:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E91D529563; Mon, 1 Oct 2018 12:10:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43D4C2946E for ; Mon, 1 Oct 2018 12:10:58 +0000 (UTC) Received: from localhost ([::1]:37985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x2P-000088-HI for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:10:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002R8-Aa for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005oN-NK for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpK-0005SU-9z; Mon, 01 Oct 2018 07:57:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id A1CEF511C77; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395030; bh=meV9yOzJ7Ab2hCvUI3L602DaBOj/Pe+XBQYESc/Rovw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MXrj+6cc9+e8jIhXs5t/KS93l51xghRMT+VoJ6INLBvoYaDWVKrgX/tK4TI2iJ0dg QntnjbPML6EOLwLQVZveTmGW77UMgXq8Ggw+GN8tJ43/JiOc1CqAZuAv9hEARZnMUG 8lfURGyKaKpxfmivTMyayGhoZBtF0GMod1aXrE/k= 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=02g0XcS/; dkim=pass (1024-bit key) header.d=greensocs.com header.b=02g0XcS/ 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 pKa9U5-h-JZl; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id CA5CD511C6F; Mon, 1 Oct 2018 13:57:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395027; bh=meV9yOzJ7Ab2hCvUI3L602DaBOj/Pe+XBQYESc/Rovw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=02g0XcS/FZ5dvGHBElmyqWGdagym2ANJJlNuqv3MyIxywZjjy23qLVpreCJ/tBVRv g4zPzcyLZYnFYrWW1qLuevawrzodENNAOmHCD/sFwvY5vGmgjR5uHmPrOdSObwOnnI hXIOXam9kTr1K5X3QdJvrIQvHMwuucHMCFeXWxJw= 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 64B7E511C6E; Mon, 1 Oct 2018 13:57:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395027; bh=meV9yOzJ7Ab2hCvUI3L602DaBOj/Pe+XBQYESc/Rovw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=02g0XcS/FZ5dvGHBElmyqWGdagym2ANJJlNuqv3MyIxywZjjy23qLVpreCJ/tBVRv g4zPzcyLZYnFYrWW1qLuevawrzodENNAOmHCD/sFwvY5vGmgjR5uHmPrOdSObwOnnI hXIOXam9kTr1K5X3QdJvrIQvHMwuucHMCFeXWxJw= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:53 +0200 Message-Id: <20181001115704.701-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 04/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add the gdb_first_cpu() and gdb_next_cpu() to iterate over all the CPUs in currently attached processes. Add the gdb_first_cpu_in_process() and gdb_next_cpu_in_process() to iterate over CPUs of a given process. Use them to add multiprocess extension support to vCont packets. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a21ce3ca18..779cc8b241 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -704,10 +704,40 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static CPUState *get_first_cpu_in_process(const GDBState *s, + GDBProcess *process) +{ + CPUState *cpu; + + CPU_FOREACH(cpu) { + if (gdb_get_cpu_pid(s, cpu) == process->pid) { + return cpu; + } + } + + return NULL; +} + +static CPUState *gdb_next_cpu_in_process(const GDBState *s, CPUState *cpu) +{ + uint32_t pid = gdb_get_cpu_pid(s, cpu); + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_pid(s, cpu) == pid) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) { GDBProcess *process; CPUState *cpu = find_cpu(tid); @@ -731,10 +761,41 @@ static CPUState *gdb_get_cpu(const GDBState *s, uint32_t pid, uint32_t tid) } return cpu; } +/* Return the cpu following @cpu, while ignoring + * unattached processes. + */ +static CPUState *gdb_next_cpu(const GDBState *s, CPUState *cpu) +{ + cpu = CPU_NEXT(cpu); + + while (cpu) { + if (gdb_get_cpu_process(s, cpu)->attached) { + break; + } + + cpu = CPU_NEXT(cpu); + } + + return cpu; +} + +/* Return the first attached cpu */ +static CPUState *gdb_first_cpu(const GDBState *s) +{ + CPUState *cpu = first_cpu; + GDBProcess *process = gdb_get_cpu_process(s, cpu); + + if (!process->attached) { + return gdb_next_cpu(s, cpu); + } + + return cpu; +} + static const char *get_feature_xml(const char *p, const char **newp, CPUClass *cc) { size_t len; int i; @@ -1069,14 +1130,16 @@ static int is_query_packet(const char *p, const char *query, char separator) * returns -ENOTSUP if a command is unsupported, -EINVAL or -ERANGE if there is * a format error, 0 on success. */ static int gdb_handle_vcont(GDBState *s, const char *p) { - int res, idx, signal = 0; + int res, signal = 0; char cur_action; char *newstates; unsigned long tmp; + uint32_t pid, tid; + GDBProcess *process; CPUState *cpu; #ifdef CONFIG_USER_ONLY int max_cpus = 1; /* global variable max_cpus exists only in system mode */ CPU_FOREACH(cpu) { @@ -1115,29 +1178,52 @@ static int gdb_handle_vcont(GDBState *s, const char *p) } else if (cur_action != 'c' && cur_action != 's') { /* unknown/invalid/unsupported command */ res = -ENOTSUP; goto out; } - /* thread specification. special values: (none), -1 = all; 0 = any */ - if ((p[0] == ':' && p[1] == '-' && p[2] == '1') || (p[0] != ':')) { - if (*p == ':') { - p += 3; - } - for (idx = 0; idx < max_cpus; idx++) { - if (newstates[idx] == 1) { - newstates[idx] = cur_action; + + if (*p++ != ':') { + res = -ENOTSUP; + goto out; + } + + switch (read_thread_id(p, &p, &pid, &tid)) { + case GDB_READ_THREAD_ERR: + res = -EINVAL; + goto out; + + case GDB_ALL_PROCESSES: + cpu = gdb_first_cpu(s); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; } + + cpu = gdb_next_cpu(s, cpu); } - } else if (*p == ':') { - p++; - res = qemu_strtoul(p, &p, 16, &tmp); - if (res) { + break; + + case GDB_ALL_THREADS: + process = gdb_get_process(s, pid); + + if (!process->attached) { + res = -EINVAL; goto out; } - /* 0 means any thread, so we pick the first valid CPU */ - cpu = tmp ? find_cpu(tmp) : first_cpu; + cpu = get_first_cpu_in_process(s, process); + while (cpu) { + if (newstates[cpu->cpu_index] == 1) { + newstates[cpu->cpu_index] = cur_action; + } + + cpu = gdb_next_cpu_in_process(s, cpu); + } + break; + + case GDB_ONE_THREAD: + cpu = gdb_get_cpu(s, pid, tid); /* invalid CPU/thread specified */ if (!cpu) { res = -EINVAL; goto out; @@ -1145,10 +1231,11 @@ static int gdb_handle_vcont(GDBState *s, const char *p) /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } + break; } } s->signal = signal; gdb_continue_partial(s, newstates); From patchwork Mon Oct 1 11:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A520B6CB for ; Mon, 1 Oct 2018 11:59:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 930EB294A8 for ; Mon, 1 Oct 2018 11:59:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86CB4294B2; Mon, 1 Oct 2018 11:59:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 877C6294A8 for ; Mon, 1 Oct 2018 11:59:16 +0000 (UTC) Received: from localhost ([::1]:37806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wr4-00041A-TY for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 07:59:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RG-B7 for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005nn-Ld for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpF-0005SV-W2; Mon, 01 Oct 2018 07:57:24 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 74D85511C79; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=PnGrRRbiD++Gs8LrhEYq/EHRNpXoblJ2ZYiJIwiIGEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vekiIom0JfZn6L8I3bGollRHvMp6Ak495ktLYvixAKb3t7xFF0KHmEpDGveZSdWDb 9PKfbrAUBZ8YmtrFmwpPjFdwyxKEbqZRvgUy4rpyoTaKgyjOXARl967ofhEGUWCObe jxpGEvhgpBAR89RwIKHemYs0bivAkFQgiWGI1muQ= 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=tNHvpBTB; dkim=pass (1024-bit key) header.d=greensocs.com header.b=tNHvpBTB 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 995cjeUtqhgG; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 5C8D3511C6E; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395028; bh=PnGrRRbiD++Gs8LrhEYq/EHRNpXoblJ2ZYiJIwiIGEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tNHvpBTB/6TBGRnMxgWPP6bYjgOdUwAx503L7bHe5n8h/EE5yfDguMhkWFCGuoeAJ B8yDIWuNuwBzFG2mmhhYH9PhkDKLEtJtaLOmPYwfqWDQZjXS/A0RF2HpFb0b3RQcE0 TZVe27fiP6HC6plzog6RYKbjb1CTR2R0QozaX1x0= 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 CB6B0511C70; Mon, 1 Oct 2018 13:57:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395028; bh=PnGrRRbiD++Gs8LrhEYq/EHRNpXoblJ2ZYiJIwiIGEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tNHvpBTB/6TBGRnMxgWPP6bYjgOdUwAx503L7bHe5n8h/EE5yfDguMhkWFCGuoeAJ B8yDIWuNuwBzFG2mmhhYH9PhkDKLEtJtaLOmPYwfqWDQZjXS/A0RF2HpFb0b3RQcE0 TZVe27fiP6HC6plzog6RYKbjb1CTR2R0QozaX1x0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:54 +0200 Message-Id: <20181001115704.701-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 05/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the sC packet handling to support the multiprocess extension. Instead of returning the first thread, we return the first thread of the current process. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 779cc8b241..3242f0d261 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1530,13 +1530,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) type = strtoul(p, (char **)&p, 16); sstep_flags = type; put_packet(s, "OK"); break; } else if (strcmp(p,"C") == 0) { - /* "Current thread" remains vague in the spec, so always return - * the first CPU (gdb returns the first thread). */ - put_packet(s, "QC1"); + /* "Current thread" remains vague in the spec, so always return the + * first thread of the current process (gdb returns the first + * thread). + */ + cpu = get_first_cpu_in_process(s, gdb_get_cpu_process(s, s->g_cpu)); + snprintf(buf, sizeof(buf), "QC%s", + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { s->query_cpu = first_cpu; goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { From patchwork Mon Oct 1 11:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6438415E8 for ; Mon, 1 Oct 2018 12:01:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50CDE2952D for ; Mon, 1 Oct 2018 12:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4524E29531; Mon, 1 Oct 2018 12:01:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95FE52952D for ; Mon, 1 Oct 2018 12:01:08 +0000 (UTC) Received: from localhost ([::1]:37821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wst-0005fb-Sc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:01:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RE-Ax for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005o9-OL for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005gU-HV; Mon, 01 Oct 2018 07:57:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 789C9511C7B; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395032; bh=u9mBA29Uy7CeTohlrONoiEzan2f3Z3lvgNj7vWz+qbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=01QMJ5a16bbM8B6jaJcW0dzKjijcXTRC+Vie2Ovq6yE/vlT799c2nWi3e5haUKKAo bGMEzW+lvV8hOZXjcTFC2ABa9pv8TtZuwquBlzKfyl7HdmWLyxWKYYKkUlsidu4sqS glI9A6tZGMzCNtn7Iq0OkEcQBbQL9sqB7Mh1GlNA= 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=cVUEd9a9; dkim=pass (1024-bit key) header.d=greensocs.com header.b=cVUEd9a9 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 v-Jp0GMdIrCi; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id B2305511C70; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395028; bh=u9mBA29Uy7CeTohlrONoiEzan2f3Z3lvgNj7vWz+qbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cVUEd9a9sjwACAjH6LWJA0zP37TVqbNf/5tx0V/KU96Z0zRC9UzNFYzEBxLXyEOw5 mVr/6ZqVne675/90EzSMYggLHM6tj/ao9kOb2TKSt63iYKAFtraGCYWIiv1k/t+iIy saCObSh1QI03nkGt3bPl1TbO6g3JZShRuWTtKCuY= 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 582A7511C59; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395028; bh=u9mBA29Uy7CeTohlrONoiEzan2f3Z3lvgNj7vWz+qbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cVUEd9a9sjwACAjH6LWJA0zP37TVqbNf/5tx0V/KU96Z0zRC9UzNFYzEBxLXyEOw5 mVr/6ZqVne675/90EzSMYggLHM6tj/ao9kOb2TKSt63iYKAFtraGCYWIiv1k/t+iIy saCObSh1QI03nkGt3bPl1TbO6g3JZShRuWTtKCuY= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:55 +0200 Message-Id: <20181001115704.701-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 06/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the thread info related packets handling to support multiprocess extension. Add the CPUs class name in the extra info to help differentiate them in multiprocess mode. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3242f0d261..63d7913269 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1248,11 +1248,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]; @@ -1540,30 +1539,43 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "QC%s", gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { - s->query_cpu = first_cpu; + s->query_cpu = gdb_first_cpu(s); goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", cpu_gdb_index(s->query_cpu)); + snprintf(buf, sizeof(buf), "m%s", + gdb_fmt_thread_id(s, s->query_cpu, + thread_id, sizeof(thread_id))); put_packet(s, buf); - s->query_cpu = CPU_NEXT(s->query_cpu); + s->query_cpu = gdb_next_cpu(s, s->query_cpu); } else put_packet(s, "l"); break; } else if (strncmp(p,"ThreadExtraInfo,", 16) == 0) { - thread = strtoull(p+16, (char **)&p, 16); - cpu = find_cpu(thread); + read_thread_id(p + 16, &p, &pid, &tid); + cpu = gdb_get_cpu(s, pid, tid); if (cpu != NULL) { cpu_synchronize_state(cpu); - /* memtohex() doubles the required space */ - len = snprintf((char *)mem_buf, sizeof(buf) / 2, - "CPU#%d [%s]", cpu->cpu_index, - cpu->halted ? "halted " : "running"); + + if (s->multiprocess && (s->process_num > 1)) { + /* Print the CPU model in multiprocess mode */ + ObjectClass *oc = object_get_class(OBJECT(cpu)); + const char *cpu_model = object_class_get_name(oc); + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d %s [%s]", cpu->cpu_index, + cpu_model, + cpu->halted ? "halted " : "running"); + } else { + /* memtohex() doubles the required space */ + len = snprintf((char *)mem_buf, sizeof(buf) / 2, + "CPU#%d [%s]", cpu->cpu_index, + cpu->halted ? "halted " : "running"); + } trace_gdbstub_op_extra_info((char *)mem_buf); memtohex(buf, mem_buf, len); put_packet(s, buf); } break; From patchwork Mon Oct 1 11:56:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 751EC1515 for ; Mon, 1 Oct 2018 12:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6486C29545 for ; Mon, 1 Oct 2018 12:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57F4E29551; Mon, 1 Oct 2018 12:12:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CDBB029545 for ; Mon, 1 Oct 2018 12:12:44 +0000 (UTC) Received: from localhost ([::1]:38092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x48-00021W-3W for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:12:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RJ-BI for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005o4-Lp for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005gb-OX; Mon, 01 Oct 2018 07:57:29 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 37ACB511C7C; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395033; bh=fORHhLW7x9Y7LTXpgI9o9P9dnprhSOMLu1KN81BZNF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=diNV62kyiPczjGY3px/Q0aSTgQAGVroN6qN3CDlSXY+/nitEHYk9KG84oDrWcppJ/ ChbJBPBO40krBWmWnQqD/WaN5AFC3XGAOb8t8H6a7qifvqKejny2cRfp4bSWY8W+4o VAplp+X34w24C5+iCWDApqwz93DtUvJ8FKsUslNk= 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=b3lED2LQ; dkim=pass (1024-bit key) header.d=greensocs.com header.b=b3lED2LQ 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 MQduy6hdZ78v; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 59CEF511C65; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=fORHhLW7x9Y7LTXpgI9o9P9dnprhSOMLu1KN81BZNF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b3lED2LQhx9L7Dr3b1fThrEgBWb7WbVDj5w2ZVVEml8Ef7HubDTVDKTnBpPV2ZyZO Yeg56ZHJ3p2EZStgNzg+BR4J4l7nhFvR52J1oluumhDBDPC5eawQh3LBFmrvhvzeYZ B1zOTpPr3Wk+hy2X10t4kxwis8Fes3ckDnhhl5xE= 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 B8AA9511C71; Mon, 1 Oct 2018 13:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=fORHhLW7x9Y7LTXpgI9o9P9dnprhSOMLu1KN81BZNF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b3lED2LQhx9L7Dr3b1fThrEgBWb7WbVDj5w2ZVVEml8Ef7HubDTVDKTnBpPV2ZyZO Yeg56ZHJ3p2EZStgNzg+BR4J4l7nhFvR52J1oluumhDBDPC5eawQh3LBFmrvhvzeYZ B1zOTpPr3Wk+hy2X10t4kxwis8Fes3ckDnhhl5xE= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:56 +0200 Message-Id: <20181001115704.701-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 07/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the Xfer:features:read: packet handling to support the multiprocess extension. This packet is used to request the XML description of the CPU. In multiprocess mode, different descriptions can be sent for different processes. This function now takes the process to send the description for as a parameter, and use a buffer in the process structure to store the generated description. It takes the first CPU of the process to generate the description. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 63d7913269..9065e8e140 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -792,55 +792,57 @@ static CPUState *gdb_first_cpu(const GDBState *s) } return cpu; } -static const char *get_feature_xml(const char *p, const char **newp, - CPUClass *cc) +static const char *get_feature_xml(const GDBState *s, const char *p, + const char **newp, GDBProcess *process) { size_t len; int i; const char *name; - static char target_xml[1024]; + CPUState *cpu = get_first_cpu_in_process(s, process); + CPUClass *cc = CPU_GET_CLASS(cpu); len = 0; while (p[len] && p[len] != ':') len++; *newp = p + len; name = NULL; if (strncmp(p, "target.xml", len) == 0) { + char *buf = process->target_xml; + const size_t buf_sz = sizeof(process->target_xml); + /* Generate the XML description for this CPU. */ - if (!target_xml[0]) { + if (!buf[0]) { GDBRegisterState *r; - CPUState *cpu = first_cpu; - pstrcat(target_xml, sizeof(target_xml), + pstrcat(buf, buf_sz, "" "" ""); if (cc->gdb_arch_name) { gchar *arch = cc->gdb_arch_name(cpu); - pstrcat(target_xml, sizeof(target_xml), ""); - pstrcat(target_xml, sizeof(target_xml), arch); - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); + pstrcat(buf, buf_sz, arch); + pstrcat(buf, buf_sz, ""); g_free(arch); } - pstrcat(target_xml, sizeof(target_xml), "gdb_core_xml_file); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "gdb_core_xml_file); + pstrcat(buf, buf_sz, "\"/>"); for (r = cpu->gdb_regs; r; r = r->next) { - pstrcat(target_xml, sizeof(target_xml), "xml); - pstrcat(target_xml, sizeof(target_xml), "\"/>"); + pstrcat(buf, buf_sz, "xml); + pstrcat(buf, buf_sz, "\"/>"); } - pstrcat(target_xml, sizeof(target_xml), ""); + pstrcat(buf, buf_sz, ""); } - return target_xml; + return buf; } if (cc->gdb_get_dynamic_xml) { - CPUState *cpu = first_cpu; char *xmlname = g_strndup(p, len); const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname); g_free(xmlname); if (xml) { @@ -1246,10 +1248,11 @@ out: } static int gdb_handle_packet(GDBState *s, const char *line_buf) { CPUState *cpu; + GDBProcess *process; CPUClass *cc; const char *p; uint32_t pid, tid; int ch, reg_size, type, res; uint8_t mem_buf[MAX_PACKET_LENGTH]; @@ -1620,18 +1623,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; target_ulong total_len; - cc = CPU_GET_CLASS(first_cpu); + process = gdb_get_cpu_process(s, s->g_cpu); + cc = CPU_GET_CLASS(s->g_cpu); if (cc->gdb_core_xml_file == NULL) { goto unknown_command; } gdb_has_xml = true; p += 19; - xml = get_feature_xml(p, &p, cc); + xml = get_feature_xml(s, p, &p, process); if (!xml) { snprintf(buf, sizeof(buf), "E00"); put_packet(s, buf); break; } From patchwork Mon Oct 1 11:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DDCD1515 for ; Mon, 1 Oct 2018 12:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C36F28FB9 for ; Mon, 1 Oct 2018 12:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 807AA29106; Mon, 1 Oct 2018 12:06:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21EFC28FB9 for ; Mon, 1 Oct 2018 12:06:04 +0000 (UTC) Received: from localhost ([::1]:37888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wxf-0002qJ-DG for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:06:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RB-Ak for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005oQ-Ms for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005gZ-Gm; Mon, 01 Oct 2018 07:57:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 81212511C78; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395033; bh=M8REKNwH4qFmyvROFKIcRtEkSK+Yf801vnRgI3pzY/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l+66bg53Qucf36Iuozr4p9qrLHroZUTcEyFqbLMLKhnvQ3mnSw5om4yxNc5cV9g0L cJa4fXdPlLdvkJWcvEvFN886bv4j/BecHItGl4cc71xQaEokKUx6v7wF9kG7W7dOD+ RNMXXr+PWcnY7dQF0pt0Q9+JxZ1WB/CcmSAHxkLI= 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=OWq0iBM0; dkim=pass (1024-bit key) header.d=greensocs.com header.b=OWq0iBM0 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 tfxcJ3NWPSMk; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id A54E1511C73; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=M8REKNwH4qFmyvROFKIcRtEkSK+Yf801vnRgI3pzY/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OWq0iBM0ZUZTLTGAxVgL8xDHzmijtcmFxhrIkLOgFYekv3uKYfwPbgcUmdtjkuMRh 5C1BbftgIrHf4vkj6uBSHJSXlKJu2ZWZT7IPvw35H73jgoUbvypmx0cqE3z9pMkH5r 4hzQ+Ns2rNXqeVUae2GpscOyndcA/u3FPRXf/+ZQ= 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 3ED12511C59; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=M8REKNwH4qFmyvROFKIcRtEkSK+Yf801vnRgI3pzY/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OWq0iBM0ZUZTLTGAxVgL8xDHzmijtcmFxhrIkLOgFYekv3uKYfwPbgcUmdtjkuMRh 5C1BbftgIrHf4vkj6uBSHJSXlKJu2ZWZT7IPvw35H73jgoUbvypmx0cqE3z9pMkH5r 4hzQ+Ns2rNXqeVUae2GpscOyndcA/u3FPRXf/+ZQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:57 +0200 Message-Id: <20181001115704.701-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 08/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for multiprocess extension in gdb_vm_state_change() function. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9065e8e140..c1a02c34cd 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1692,10 +1692,11 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s = gdbserver_state; CPUState *cpu = s->c_cpu; char buf[256]; + char thread_id[16]; const char *type; int ret; if (running || s->state == RS_INACTIVE) { return; @@ -1703,10 +1704,18 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) /* Is there a GDB syscall waiting to be sent? */ if (s->current_syscall_cb) { put_packet(s, s->syscall_buf); return; } + + if (cpu == NULL) { + /* No process attached */ + return; + } + + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + switch (state) { case RUN_STATE_DEBUG: if (cpu->watchpoint_hit) { switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { case BP_MEM_READ: @@ -1720,12 +1729,12 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) break; } trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); snprintf(buf, sizeof(buf), - "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, cpu_gdb_index(cpu), type, + "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", + GDB_SIGNAL_TRAP, thread_id, type, (target_ulong)cpu->watchpoint_hit->vaddr); cpu->watchpoint_hit = NULL; goto send_packet; } else { trace_gdbstub_hit_break(); @@ -1763,11 +1772,11 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) trace_gdbstub_hit_unknown(state); ret = GDB_SIGNAL_UNKNOWN; break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_gdb_index(cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); send_packet: put_packet(s, buf); /* disable single step if it was enabled */ From patchwork Mon Oct 1 11:56:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83B481515 for ; Mon, 1 Oct 2018 12:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7107D294FA for ; Mon, 1 Oct 2018 12:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64E9E2952C; Mon, 1 Oct 2018 12:02:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04D91294FA for ; Mon, 1 Oct 2018 12:02:45 +0000 (UTC) Received: from localhost ([::1]:37828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wuT-0008A3-3k for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:02:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002RC-BN for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005o2-LZ for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005gc-NE; Mon, 01 Oct 2018 07:57:29 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 0ADA7511C6E; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395034; bh=UFouwvELHl9JcuGuuuxFHBpyox2Fhsgl1OaPcur/BDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xSc1INM1xfYRsUd0Io8JEnYVw+9qPPmehjEzdlT+ZR7CN8Q641ps1m1rSSe3bn9jd VokPQkV2ykacyoSreoCnLVxnfUV4jo/0XdgbZFyUDuiRj5sO/73Ezr8X4OkW3zMPAy mDAkjkBQN3EkgKbwwOXfxdOSnj0SGe3RpcONgaCg= 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=LxrlIO0Z; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Z1llqlIS 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 sVtfJdSWOOVA; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 8AF0F511C69; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395030; bh=UFouwvELHl9JcuGuuuxFHBpyox2Fhsgl1OaPcur/BDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LxrlIO0ZrUztb4VPRKf10Qm7md8269GpWKNC0Rrc/r8p5SFg7upoweQWZvlwix+Xz tgjzV6noJiFrVdHFSzn4+VL/t6WZPsRFK2Gu+7tghPz53T0Unx6DSHwn8NuUwwRqzD h3FjPGC1KRuOq4tQNrlZMPZNw4asFShRRxYobKds= 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 9E703511C71; Mon, 1 Oct 2018 13:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395029; bh=UFouwvELHl9JcuGuuuxFHBpyox2Fhsgl1OaPcur/BDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z1llqlISCAFj9PyswMyvEMZ+P5R++7QF7LpwoYMkn9Cr+BVHBfqUjr1GWcpGXE2Sp a4LVcObp28aX5RDH901qUoI+c5sH9LmyICjM8qQ6aWkaxzgT2LChos01eagLRbR74d QSU2OmkUfHXV52Lq1iEISh/ChCXU9JlHVpIpVLHo= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:58 +0200 Message-Id: <20181001115704.701-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 09/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'D' packets are used by GDB to detach from a process. In multiprocess mode, the PID to detach from is sent in the request. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c1a02c34cd..299783b3b8 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1025,24 +1025,39 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type) default: return -ENOSYS; } } +static inline void gdb_cpu_breakpoint_remove_all(CPUState *cpu) +{ + cpu_breakpoint_remove_all(cpu, BP_GDB); +#ifndef CONFIG_USER_ONLY + cpu_watchpoint_remove_all(cpu, BP_GDB); +#endif +} + +static void gdb_process_breakpoint_remove_all(const GDBState *s, GDBProcess *p) +{ + CPUState *cpu = get_first_cpu_in_process(s, p); + + while (cpu) { + gdb_cpu_breakpoint_remove_all(cpu); + cpu = gdb_next_cpu_in_process(s, cpu); + } +} + static void gdb_breakpoint_remove_all(void) { CPUState *cpu; if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); return; } CPU_FOREACH(cpu) { - cpu_breakpoint_remove_all(cpu, BP_GDB); -#ifndef CONFIG_USER_ONLY - cpu_watchpoint_remove_all(cpu, BP_GDB); -#endif + gdb_cpu_breakpoint_remove_all(cpu); } } static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { @@ -1317,13 +1332,44 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); exit(0); case 'D': /* Detach packet */ - gdb_breakpoint_remove_all(); - gdb_syscall_mode = GDB_SYS_DISABLED; - gdb_continue(s); + pid = 1; + + if (s->multiprocess) { + unsigned long lpid; + if (*p != ';') { + put_packet(s, "E22"); + break; + } + + if (qemu_strtoul(p + 1, &p, 16, &lpid)) { + put_packet(s, "E22"); + break; + } + + pid = lpid; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_cpu(s); + } + + if (s->c_cpu == NULL) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); From patchwork Mon Oct 1 11:56:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF3B16CB for ; Mon, 1 Oct 2018 11:59:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC3CB294A8 for ; Mon, 1 Oct 2018 11:59:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FA37294B2; Mon, 1 Oct 2018 11:59:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53E9D294A8 for ; Mon, 1 Oct 2018 11:59:54 +0000 (UTC) Received: from localhost ([::1]:37811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wrh-0004Xd-Hv for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 07:59:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpT-0002R4-8W for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpQ-0005oB-PG for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:35 -0400 Received: from greensocs.com ([193.104.36.180]:40120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpM-0005ga-Jx; Mon, 01 Oct 2018 07:57:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 57F6F511C73; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395034; bh=sGpdDHnh6UkEpab7HOOlprckQf+/+DmBBAJDYJ7oNXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ODoDAjvwk7yRfdPWRSdA35lCvt40g2kD52UCtiffhDH1CkJzONR4zp9SMzD0ddTsQ fkmWqAJ/F+zisHEAOV3J0e3UHcKETGtQRyFmrbCwIFisTw81dWA4xOah6fTeC/SSqR N/mr2oX2SnnZsbXdGHLEi9oBD1D8WEKuW5eVxb2c= 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=I5Fi/0n0; dkim=pass (1024-bit key) header.d=greensocs.com header.b=I5Fi/0n0 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 Ktq2mU35kMaA; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id F0E13511C71; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395030; bh=sGpdDHnh6UkEpab7HOOlprckQf+/+DmBBAJDYJ7oNXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I5Fi/0n0fWy8A43hHgFNh/zJ+jNPhozWmosNy97lXL8Nccv3hFXk/ScySj8uB4z6l GSpH4jct18gq6Iv2ownW36MUKQ9drDQGd8ORjt0Pu5CUE+OXxHB5YvhRqzfL6p2F4T e45LaB9ZerfhHknhiJp/d8wnTC+RxPzsjALgWLRE= 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 7CF27511C59; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395030; bh=sGpdDHnh6UkEpab7HOOlprckQf+/+DmBBAJDYJ7oNXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I5Fi/0n0fWy8A43hHgFNh/zJ+jNPhozWmosNy97lXL8Nccv3hFXk/ScySj8uB4z6l GSpH4jct18gq6Iv2ownW36MUKQ9drDQGd8ORjt0Pu5CUE+OXxHB5YvhRqzfL6p2F4T e45LaB9ZerfhHknhiJp/d8wnTC+RxPzsjALgWLRE= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:56:59 +0200 Message-Id: <20181001115704.701-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 10/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the '!' extended mode packet. This is required for the multiprocess extension. Signed-off-by: Luc Michel --- gdbstub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 299783b3b8..d372972dd3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1280,10 +1280,13 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) trace_gdbstub_io_command(line_buf); p = line_buf; ch = *p++; switch(ch) { + case '!': + put_packet(s, "OK"); + break; case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); From patchwork Mon Oct 1 11:57:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E50F71515 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D280828FB9 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C69AA29106; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7666428FB9 for ; Mon, 1 Oct 2018 12:07:30 +0000 (UTC) Received: from localhost ([::1]:37901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wz3-00048X-P5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:07:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002jq-4Y for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061X-Du for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from greensocs.com ([193.104.36.180]:40136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpg-0005iY-St; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C91C8511C71; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395034; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SZaFWYkiOsu4oPrvC2yB8M2R6Ass2w2aWnQC4b4DqjE11Mi+L1scaeMfy55CgFJ0a VXDFj6gXRbNRWpkVKqkNUHyrUvlIRgR+aNw7yne3zBd4O4Vf3Uqm8nyFav/JSVofXJ gu+SWaausqmnN/p3mLcViOT+TQYx4h34TRNsL7KE= 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=W7Yx0Td2; dkim=pass (1024-bit key) header.d=greensocs.com header.b=W7Yx0Td2 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 XwQY7GnSPX3z; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 5501E511C59; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W7Yx0Td2RjuHMYcaYWI7RdT9g+qcHZ4n6JYYDOeQB8vUvAsGtsTCkClj+l05/8VyA X8JXwSx9MWMdcqq1NzFyt8OVi5ze4jBeY6sNgE9LY9Mq2Mwp54BG+ct4Gy11INZjm/ 6cWV9C5JQIlGyfJDE1u0Mk9HP/+5QCRXeO2nNIBg= 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 E7EDB511C6F; Mon, 1 Oct 2018 13:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=9C/gIEA3NZLS7VnTV3RQTiDgLuN+c06HAC6nEZRMMAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W7Yx0Td2RjuHMYcaYWI7RdT9g+qcHZ4n6JYYDOeQB8vUvAsGtsTCkClj+l05/8VyA X8JXwSx9MWMdcqq1NzFyt8OVi5ze4jBeY6sNgE9LY9Mq2Mwp54BG+ct4Gy11INZjm/ 6cWV9C5JQIlGyfJDE1u0Mk9HP/+5QCRXeO2nNIBg= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:00 +0200 Message-Id: <20181001115704.701-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 11/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for the vAttach packets. In multiprocess mode, GDB sends them to attach to additional processes. Signed-off-by: Luc Michel --- gdbstub.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index d372972dd3..b6de821025 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1326,10 +1326,42 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) break; } goto unknown_command; } break; + } else if (strncmp(p, "Attach", 6) == 0) { + unsigned long pid; + + p += 7; + + qemu_strtoul(p, &p, 16, &pid); + + process = gdb_get_process(s, pid); + + if (process == NULL) { + put_packet(s, "E22"); + break; + } + + cpu = get_first_cpu_in_process(s, process); + + if (cpu == NULL) { + /* Refuse to attach an empty process */ + put_packet(s, "E22"); + break; + } + + process->attached = true; + + s->g_cpu = cpu; + s->c_cpu = cpu; + + snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */ From patchwork Mon Oct 1 11:57:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F55B1515 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C85E291D3 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 709632933C; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10FB3291D3 for ; Mon, 1 Oct 2018 12:08:40 +0000 (UTC) Received: from localhost ([::1]:37903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x0B-0005Q4-54 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpv-0002su-CX for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpr-000642-9S for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:58:03 -0400 Received: from greensocs.com ([193.104.36.180]:40137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wph-0005iX-1T; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2A97B511C70; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395035; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SSlA1nADzAFBbpI9Vin7FWurRPOETsokWws0emGuGqaSv8IJsC0v21ntJaLTg6QEI E8sU4a6jd/C96poTlsXbw2pyDC2ipWOt6ZE4hx22GTl9V16FVl90xnD58IFqFiogjs auiHXGfagEBYI7zzCikIYQAbtBg/uMp0C2m3Yw9E= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=FIilloBC; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FIilloBC Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UxzaOMl4-Tg1; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E21DC511C75; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FIilloBCap28Cy2p26lBvzRJSn8e++ltAlQ6vpNXl+ZMuSIuxtBQatx6n+Io/MmBA UVBHF0bMmbZImSfwNOcbqFwKv1YLw+3eYL8XQC7Sgvp6qGAj8B0vw4akWXuCc3IG6N PMIvEbTQ000jaLBRWW2X7H1RCX1/eFLQg56I44x0= Received: from michell-laptop.home.lmichel.fr (LFbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 69E2D511C6F; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395031; bh=OBMgwVCanW8NF8EnxIwMHmdqrAqfS5WPbtNyVCqqbbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FIilloBCap28Cy2p26lBvzRJSn8e++ltAlQ6vpNXl+ZMuSIuxtBQatx6n+Io/MmBA UVBHF0bMmbZImSfwNOcbqFwKv1YLw+3eYL8XQC7Sgvp6qGAj8B0vw4akWXuCc3IG6N PMIvEbTQ000jaLBRWW2X7H1RCX1/eFLQg56I44x0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:01 +0200 Message-Id: <20181001115704.701-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 12/15] gdbstub: processes initialization on new peer connection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When a new connection is established, we set the first process to be attached, and the others detached. The first CPU of the first process is selected as the current CPU. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index b6de821025..c27a3edf1d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2221,13 +2221,14 @@ static bool gdb_accept(void) close(fd); return false; } s = g_malloc0(sizeof(GDBState)); - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_unique_process(s); + s->processes[0].attached = true; + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; s->fd = fd; gdb_has_xml = false; gdbserver_state = s; return true; @@ -2309,12 +2310,23 @@ static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) } } static void gdb_chr_event(void *opaque, int event) { + int i; + GDBState *s = (GDBState *) opaque; + switch (event) { case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i = 0; i < s->process_num; i++) { + s->processes[i].attached = !i; + } + + s->c_cpu = gdb_first_cpu(s); + s->g_cpu = s->c_cpu; + vm_stop(RUN_STATE_PAUSED); gdb_has_xml = false; break; default: break; @@ -2474,19 +2486,17 @@ int gdbserver_start(const char *device) mon_chr = s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_processes(s); if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state = chr ? RS_IDLE : RS_INACTIVE; s->mon_chr = mon_chr; s->current_syscall_cb = NULL; From patchwork Mon Oct 1 11:57:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5FAD1515 for ; Mon, 1 Oct 2018 12:13:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D46DE29545 for ; Mon, 1 Oct 2018 12:13:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8AFC29551; Mon, 1 Oct 2018 12:13:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76C7829545 for ; Mon, 1 Oct 2018 12:13:59 +0000 (UTC) Received: from localhost ([::1]:38120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x5K-00034O-No for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:13:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002kQ-GZ for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061o-Lp for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from greensocs.com ([193.104.36.180]:40140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wph-0005jS-Br; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 96BD2511C75; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395035; bh=11JYwxGBPnuaFsCIuYEBJZlUexokehWYmRnK8HTFNQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zimx3OPgd5eoBTf2RjQ2/wM65v757qYOtB4h4PhbP0wT3AGBzII6Kez1niqE6Dfgu zpA9eFEfOiSnoqVJgrjoQ84+4i2XstJoz3hdBNwWY3riIzTNzfTEZPu6NWR3/EiFm7 6hK2OSyEgEGXZi+puxgAu5q3GE6EP9ohgmxvdiHU= 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=IuaE7kuN; dkim=pass (1024-bit key) header.d=greensocs.com header.b=IuaE7kuN 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 vMZ17Cc9RQtU; Mon, 1 Oct 2018 13:57:14 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 88852511C6F; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395032; bh=11JYwxGBPnuaFsCIuYEBJZlUexokehWYmRnK8HTFNQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IuaE7kuNWo5Q6HtBzpaiX8dBVgdySaJQ98nEWraYzCByKmiFsq+uea9wL8182oCQg MdFqLeNSWvXxprnSHOHmPpf7rAI2IsvRzrdijJTx0k1J2Jk+nY9ThogHNtbHKFOjd4 9Xh19zQcqfsrmSnnh4Ru3u/LTUM8+/uJAq5X2q28= 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 DFFD4511C6E; Mon, 1 Oct 2018 13:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395032; bh=11JYwxGBPnuaFsCIuYEBJZlUexokehWYmRnK8HTFNQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IuaE7kuNWo5Q6HtBzpaiX8dBVgdySaJQ98nEWraYzCByKmiFsq+uea9wL8182oCQg MdFqLeNSWvXxprnSHOHmPpf7rAI2IsvRzrdijJTx0k1J2Jk+nY9ThogHNtbHKFOjd4 9Xh19zQcqfsrmSnnh4Ru3u/LTUM8+/uJAq5X2q28= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:02 +0200 Message-Id: <20181001115704.701-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 13/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When gdb_set_stop_cpu() is called with a CPU associated to a process currently not attached by the GDB client, return without modifying the stop CPU. Otherwise, GDB get confused if it receives packets with a thread-id it does not know about. Signed-off-by: Luc Michel --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index c27a3edf1d..51cc11981e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1763,10 +1763,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; } void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* Having a stop CPU corresponding to a process that is not attached + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu = cpu; gdbserver_state->g_cpu = cpu; } #ifndef CONFIG_USER_ONLY From patchwork Mon Oct 1 11:57:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8098015A7 for ; Mon, 1 Oct 2018 12:10:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C50F2946E for ; Mon, 1 Oct 2018 12:10:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ECD62948B; Mon, 1 Oct 2018 12:10:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF4E72946E for ; Mon, 1 Oct 2018 12:10:01 +0000 (UTC) Received: from localhost ([::1]:37936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6x1U-0006vE-NC for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:10:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002kP-Fc for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061p-Lp for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from greensocs.com ([193.104.36.180]:40141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wph-0005jR-AE; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E72B1511C6F; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395035; bh=KdNu9QGOUCYSzJWzlap/9zyYoowEZ7QOtkLhorspP1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Vpnme4Hcwp6+JXnt6V/2++4iIw1OlipkiM8ty678X8b9pqUSrQZzzOEc49Q3yuG5/ ulzU9dReuMiLhHXwzlDCler0evfQt7W28H5ITaXg9tOe6FBdm8uIoZlwtXaic4Gkap e3PMKEmm6bJKWIob/U0bTXuo86Qqpf6joSFsoFfU= 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=nD+spMeP; dkim=pass (1024-bit key) header.d=greensocs.com header.b=tuO/KFn9 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 4MNwaX5qi0Fh; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 2820D511C51; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395033; bh=KdNu9QGOUCYSzJWzlap/9zyYoowEZ7QOtkLhorspP1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nD+spMePMBQqIfGHevLYYAXfsZKbFSINbD8Itpu54ZE+kg+ku5zh0fAM9ZLlbfObR I4O55rQQnIUiGxS0Y+DQwKNSpGLpGbHPudZu0gVbv4I/8hyftm1JIHSCie7bl0CVxA 6hNoCQd6cj6m8bZFE/ehEjXTGo/oktUe2feH24xg= 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 8A7C7511C78; Mon, 1 Oct 2018 13:57:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395032; bh=KdNu9QGOUCYSzJWzlap/9zyYoowEZ7QOtkLhorspP1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tuO/KFn9GagAZrQ4kFQ/J5vtpcyzaeFJC4HSG4u7qo3UVVQcTlwqgLHCIrvjdwT7u 3r5q1kMWf+Emyx4KbhbX23zt5ARSETjpqF66+0XYBt3p6X+eEuXroISod0XKSy5HbF CkX2srPKuzPDEt9EILPRr4OvSuj2k3vigca2lUd0= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:03 +0200 Message-Id: <20181001115704.701-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 14/15] 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 , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add multiprocess extension support by enabling multiprocess mode when the peer requests it, and by replying that we actually support it in the qSupported reply packet. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé --- gdbstub.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 51cc11981e..89f6803533 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1692,15 +1692,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; } #endif /* !CONFIG_USER_ONLY */ if (is_query_packet(p, "Supported", ':')) { + if (strstr(p, "multiprocess+")) { + s->multiprocess = true; + } snprintf(buf, sizeof(buf), "PacketSize=%x", MAX_PACKET_LENGTH); cc = CPU_GET_CLASS(first_cpu); if (cc->gdb_core_xml_file != NULL) { pstrcat(buf, sizeof(buf), ";qXfer:features:read+"); } + pstrcat(buf, sizeof(buf), ";multiprocess+"); put_packet(s, buf); break; } if (strncmp(p, "Xfer:features:read:", 19) == 0) { const char *xml; From patchwork Mon Oct 1 11:57:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10621913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CA4F1515 for ; Mon, 1 Oct 2018 12:03:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F1428066 for ; Mon, 1 Oct 2018 12:03:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DD5A28161; Mon, 1 Oct 2018 12:03:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21D1028066 for ; Mon, 1 Oct 2018 12:03:17 +0000 (UTC) Received: from localhost ([::1]:37831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wuy-0000i8-CX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Oct 2018 08:03:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wpn-0002kT-I6 for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6wpm-00061i-Kx for qemu-devel@nongnu.org; Mon, 01 Oct 2018 07:57:55 -0400 Received: from greensocs.com ([193.104.36.180]:40120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6wph-0005ga-8D; Mon, 01 Oct 2018 07:57:49 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 66BDB511C69; Mon, 1 Oct 2018 13:57:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395036; bh=SEwONAKUPLnQvPdqyDN0j2bLhYtpzo2X4JReEAVA59g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f5iH1x1K+f/EFFA9FEUGPqRTGZoGuyPvxP3tcz9Ruawi20K5xWzAYviqMXhVmNKG0 1TpU4paB3GnvIO8Cd0ns8OjSH9FEXCmumwDfnwo8hwmGbLvf5r8sxIRcMoyZU629B3 H10uydDoMbAcdg4VDxQWmGRXl8tSmHVY90QHkcxg= 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=PPeLhYLy; dkim=pass (1024-bit key) header.d=greensocs.com header.b=PPeLhYLy 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 yPJ7BXt9M8FJ; Mon, 1 Oct 2018 13:57:15 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id A488C511C65; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395033; bh=SEwONAKUPLnQvPdqyDN0j2bLhYtpzo2X4JReEAVA59g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PPeLhYLyxkjHLgys7VvFdUj1hRUmhndO68jRRh5o2JAxSgD2ybAOt4Epjwc4r6L5f 9XBERQTP4KY7I99Puxt7gO5da+lSk5SHBtWZ9jbhbJXpsWVXDSV9Vn/tOzUTe1WluM Ej+PlyEfTK0Qg8aYiqugcD74X5HIPgqjdUBiH04g= 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 2A6C3511C6E; Mon, 1 Oct 2018 13:57:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1538395033; bh=SEwONAKUPLnQvPdqyDN0j2bLhYtpzo2X4JReEAVA59g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PPeLhYLyxkjHLgys7VvFdUj1hRUmhndO68jRRh5o2JAxSgD2ybAOt4Epjwc4r6L5f 9XBERQTP4KY7I99Puxt7gO5da+lSk5SHBtWZ9jbhbJXpsWVXDSV9Vn/tOzUTe1WluM Ej+PlyEfTK0Qg8aYiqugcD74X5HIPgqjdUBiH04g= From: Luc Michel To: qemu-devel@nongnu.org Date: Mon, 1 Oct 2018 13:57:04 +0200 Message-Id: <20181001115704.701-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001115704.701-1-luc.michel@greensocs.com> References: <20181001115704.701-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v2 15/15] arm/xlnx-zynqmp: put APUs and RPUs in separate GDB groups X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Create two separate QOM containers for APUs and RPUs to indicate to the GDB stub that those CPUs should be put in different processes. Signed-off-by: Luc Michel --- hw/arm/xlnx-zynqmp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index c195040350..5e92adbc71 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -22,10 +22,11 @@ #include "hw/arm/xlnx-zynqmp.h" #include "hw/intc/arm_gic_common.h" #include "exec/address-spaces.h" #include "sysemu/kvm.h" #include "kvm_arm.h" +#include "exec/gdbstub.h" #define GIC_NUM_SPI_INTR 160 #define ARM_PHYS_TIMER_PPI 30 #define ARM_VIRT_TIMER_PPI 27 @@ -175,17 +176,18 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, Error **errp) { Error *err = NULL; int i; int num_rpus = MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_NUM_RPU_CPUS); + Object *rpu_group = gdb_cpu_group_container_get(OBJECT(s)); for (i = 0; i < num_rpus; i++) { char *name; object_initialize(&s->rpu_cpu[i], sizeof(s->rpu_cpu[i]), "cortex-r5f-" TYPE_ARM_CPU); - object_property_add_child(OBJECT(s), "rpu-cpu[*]", + object_property_add_child(rpu_group, "rpu-cpu[*]", OBJECT(&s->rpu_cpu[i]), &error_abort); name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i])); if (strcmp(name, boot_cpu)) { /* Secondary CPUs start in PSCI powered-down state */ @@ -210,13 +212,14 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, static void xlnx_zynqmp_init(Object *obj) { XlnxZynqMPState *s = XLNX_ZYNQMP(obj); int i; int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); + Object *apu_group = gdb_cpu_group_container_get(obj); for (i = 0; i < num_apus; i++) { - object_initialize_child(obj, "apu-cpu[*]", &s->apu_cpu[i], + object_initialize_child(apu_group, "apu-cpu[*]", &s->apu_cpu[i], sizeof(s->apu_cpu[i]), "cortex-a53-" TYPE_ARM_CPU, &error_abort, NULL); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic),