From patchwork Sat Sep 1 12:46:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584743 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 D055A139B for ; Sat, 1 Sep 2018 12:58:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDC292A4E8 for ; Sat, 1 Sep 2018 12:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF8932A53F; Sat, 1 Sep 2018 12:58:26 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 268FC2A4E8 for ; Sat, 1 Sep 2018 12:58:26 +0000 (UTC) Received: from localhost ([::1]:37096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5Tt-00021m-H0 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:58:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JF-0004yK-8I for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JD-0007p0-5l for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from greensocs.com ([193.104.36.180]:40589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J5-0007hT-Lt; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 6B322521AB2; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806025; bh=S3RvbnEJeKZevYe1NCxR6EjkHmlP1FmDR8Tccz1ttr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukfkQy+3OY9W+98/J3MDhWIbrGD0AvUyjQuFRsX9pqNsjfnv07MKckSpU5RVyTJMp +p3hWOZR3FFC4+BVyRCh5Tw3r2cmiUsq8qC8Qy38TOP/LLgZ19YtS7qrjTG5/PG1u/ yMQ9VtFxnvcQNlvn61of3iyke2ePns252i3x3USs= 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=soEe7dTI; dkim=pass (1024-bit key) header.d=greensocs.com header.b=soEe7dTI 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 PRceOI6kuAXx; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 93C21521A9F; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806024; bh=S3RvbnEJeKZevYe1NCxR6EjkHmlP1FmDR8Tccz1ttr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=soEe7dTIRuJcyVxDujFEPjZrnGxPM9LXGherWa0qrUHd2+k3fz7UAzL4UsS6betCc VZTa4kJUnapclrffWIAQ3hvXl9mrwB/MxR05V5cG4hwCrf9yWiNxfRidADUvHCsXJK uCbKPiboVsfSAAuxdBx4u+VIVk3mZOjWE2VqA4/k= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 424AF521AAA; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806024; bh=S3RvbnEJeKZevYe1NCxR6EjkHmlP1FmDR8Tccz1ttr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=soEe7dTIRuJcyVxDujFEPjZrnGxPM9LXGherWa0qrUHd2+k3fz7UAzL4UsS6betCc VZTa4kJUnapclrffWIAQ3hvXl9mrwB/MxR05V5cG4hwCrf9yWiNxfRidADUvHCsXJK uCbKPiboVsfSAAuxdBx4u+VIVk3mZOjWE2VqA4/k= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:25 +0200 Message-Id: <20180901124639.19735-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 Sat Sep 1 12:46:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584737 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 2645B139B for ; Sat, 1 Sep 2018 12:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C1E29C75 for ; Sat, 1 Sep 2018 12:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08DD229D8B; Sat, 1 Sep 2018 12:55:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9ACA529C75 for ; Sat, 1 Sep 2018 12:55:50 +0000 (UTC) Received: from localhost ([::1]:37084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5RN-0006Tc-T0 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:55:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JF-0004xS-3w for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JD-0007pV-RN for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from greensocs.com ([193.104.36.180]:40586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J5-0007hQ-Lv; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id EF598521AB5; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=T5Qf/ncLIV1hRTTx9h9gQWecUf91vnvMwkOiWtNcGIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nMklebHuq4vZLI5SulHvxEPAqS3RMPSGjQI9cZArj1imOQtr80/NXniSACX0esw5z g9gsVUo4BuSUvtI8WD4mSOZ1VdjLtELpeS5faZ4cZCHEb6fSD5rrso2hL5YaJ+fE9V fXQQOboNsHl1VE4g35N0hkAsPDLVnPt/s17VMKtY= 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=W5Jkye6U; dkim=pass (1024-bit key) header.d=greensocs.com header.b=W5Jkye6U 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 MHk2tiE9aaOx; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id F1668521AAF; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806024; bh=T5Qf/ncLIV1hRTTx9h9gQWecUf91vnvMwkOiWtNcGIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W5Jkye6Uj3ekwWO47VP0Hupt94gZloPdbYPYzHpfZ1sJ6OBeMbWAtKClWwxCNNgxR MOfPaWKkS8EAbsFIYobG230xyCSJS6zxNRRiEQhgckfBRgmnx03vmOvEzpMM9ZfN9d aDVuQ34VZks4ox81693hM4gzjHjDzfdMaFrfczCI= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 99C74521AAA; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806024; bh=T5Qf/ncLIV1hRTTx9h9gQWecUf91vnvMwkOiWtNcGIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W5Jkye6Uj3ekwWO47VP0Hupt94gZloPdbYPYzHpfZ1sJ6OBeMbWAtKClWwxCNNgxR MOfPaWKkS8EAbsFIYobG230xyCSJS6zxNRRiEQhgckfBRgmnx03vmOvEzpMM9ZfN9d aDVuQ34VZks4ox81693hM4gzjHjDzfdMaFrfczCI= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:26 +0200 Message-Id: <20180901124639.19735-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 get_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 --- gdbstub.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 5c86218f49..ec3105dbc1 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,24 @@ static CPUState *find_cpu(uint32_t thread_id) } return NULL; } +static char *get_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 +1061,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, + get_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state * should be cleaned up. */ From patchwork Sat Sep 1 12:46:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584715 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 66739174C for ; Sat, 1 Sep 2018 12:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562502A8DC for ; Sat, 1 Sep 2018 12:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49E502A8FC; Sat, 1 Sep 2018 12:49:35 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B63002A8DC for ; Sat, 1 Sep 2018 12:49:34 +0000 (UTC) Received: from localhost ([::1]:37044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5LJ-0007pn-Vg for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:49:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JE-0004wq-WD for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JD-0007p9-9o for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from greensocs.com ([193.104.36.180]:40588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J5-0007hR-Ls; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 907B3521ABA; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=EP9OAu1dvp26opCYuwAgh8bOW65TUfqskncyeeJ9KUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ePMOPlCyFyvkMmimtfEnYHAboKPBDKy2Ab4C3Mg2b6ifDx+DzmsDNm4ueLAkq+mle d6ZNFx2vkC6E1qoYBbG+upD4DkJ8LxS7BJvCIfx3eAoIkC/Qr9tXad7IETkMph4fz6 t+rF81CRHVwbdZQdyfd5jp/pA0yBkAXuSMM59D3k= 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=d4c3Ecvr; dkim=pass (1024-bit key) header.d=greensocs.com header.b=d4c3Ecvr 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 Io8QM9d6O92H; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id A6644521A9F; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806025; bh=EP9OAu1dvp26opCYuwAgh8bOW65TUfqskncyeeJ9KUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d4c3EcvrWPm67ASwBwXVa4y2OZFaT1QqAMij6RO2E4lEaQEEZhwBQ/LAgBpnHX2o/ B/YAhTIU3iCeAByEGWSuJjI+4NlRKWyic6ohwNy2HYgwzlzjOrzBgehTlVOFge8hmA SuMH/8wjhwYdRA3/znRCKVs8w0JtxRg2tnv/G4hk= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 F3DF8521AB0; Sat, 1 Sep 2018 14:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806025; bh=EP9OAu1dvp26opCYuwAgh8bOW65TUfqskncyeeJ9KUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d4c3EcvrWPm67ASwBwXVa4y2OZFaT1QqAMij6RO2E4lEaQEEZhwBQ/LAgBpnHX2o/ B/YAhTIU3iCeAByEGWSuJjI+4NlRKWyic6ohwNy2HYgwzlzjOrzBgehTlVOFge8hmA SuMH/8wjhwYdRA3/znRCKVs8w0JtxRg2tnv/G4hk= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:27 +0200 Message-Id: <20180901124639.19735-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 131 insertions(+), 18 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index ec3105dbc1..33fa1b9c5f 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 *get_thread_id(const GDBState *s, CPUState *cpu, char *buf, size_t buf_size) { if (s->multiprocess) { snprintf(buf, buf_size, "p%02x.%02x", @@ -950,10 +1001,64 @@ static char *get_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 && @@ -1058,16 +1163,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++; @@ -1271,16 +1378,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) { @@ -1296,12 +1409,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 Sat Sep 1 12:46:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584741 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 1E5A6174C for ; Sat, 1 Sep 2018 12:58:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0563A298B2 for ; Sat, 1 Sep 2018 12:58:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAA3D298BC; Sat, 1 Sep 2018 12:58:00 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6823F298B2 for ; Sat, 1 Sep 2018 12:58:00 +0000 (UTC) Received: from localhost ([::1]:37094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5TT-0001LB-PO for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:57:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JE-0004ve-LX for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JD-0007ov-3e for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from greensocs.com ([193.104.36.180]:40590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J5-0007hU-Lu; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id E9F2D521AAD; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=TMmbprC/XeV+12usXTjnmKvjOgFUUNWeCg1c+GGHkvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fxecv5Lt8OufdrgnRnB1Y4kZgTU1+fWJXLmDXJ4LIKzomwoZ6pOy7rOQErKoQqVhX eO/VYkY8BQWEEPXzzMAm/E4PMCSJxTvffPm4F69QiPHMuoMB4JLx8yJLJ4k3IYjv4D zeH9JqqDpclevMgNuc0XtNnSMxuTlsxX38g6jpzg= 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=yhecBxlm; dkim=pass (1024-bit key) header.d=greensocs.com header.b=yhecBxlm 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 BbR0I4vZEEcs; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E1E94521AAA; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806025; bh=TMmbprC/XeV+12usXTjnmKvjOgFUUNWeCg1c+GGHkvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yhecBxlmvid1/8vOBqyWTQW4fB6A8Aka0JwAIm5J2luKMc8Uz5UZwP1WBdmqrXJhI lhhLTaa2sqgMNAM472yQNaTrgXjLPOVDGTrbKynnor06XWoOGvW1eghzJVL9jSvzEt 7hEU4AXcYLvcwWMsI/bFl5/dDWnDgBTJaal3yLSE= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 6F6AB521AB5; Sat, 1 Sep 2018 14:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806025; bh=TMmbprC/XeV+12usXTjnmKvjOgFUUNWeCg1c+GGHkvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yhecBxlmvid1/8vOBqyWTQW4fB6A8Aka0JwAIm5J2luKMc8Uz5UZwP1WBdmqrXJhI lhhLTaa2sqgMNAM472yQNaTrgXjLPOVDGTrbKynnor06XWoOGvW1eghzJVL9jSvzEt 7hEU4AXcYLvcwWMsI/bFl5/dDWnDgBTJaal3yLSE= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:28 +0200 Message-Id: <20180901124639.19735-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 33fa1b9c5f..2cb9cb6d97 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; @@ -1070,14 +1131,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) { @@ -1116,29 +1179,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; @@ -1146,10 +1232,11 @@ static int gdb_handle_vcont(GDBState *s, const char *p) /* only use if no previous match occourred */ if (newstates[cpu->cpu_index] == 1) { newstates[cpu->cpu_index] = cur_action; } + break; } } s->signal = signal; gdb_continue_partial(s, newstates); From patchwork Sat Sep 1 12:46:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584723 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 BEC4D175A for ; Sat, 1 Sep 2018 12:52:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACDFC2A83F for ; Sat, 1 Sep 2018 12:52:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0CAA2A913; Sat, 1 Sep 2018 12:52:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 53C162A83F for ; Sat, 1 Sep 2018 12:52:28 +0000 (UTC) Received: from localhost ([::1]:37063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5O7-0002SY-Ji for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:52:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JD-0004rK-W6 for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007oI-M4 for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:23 -0400 Received: from greensocs.com ([193.104.36.180]:40635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kE-Rc; Sat, 01 Sep 2018 08:47:17 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id B7CAD521ABF; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806027; bh=WzVolxSjdch3Ooe617kmhtvstqYL1EBIaH5T3ZzYLP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wMOLCfhwZLAvJeopfy/W072j8jZg5vV66n5w1mj2ehfCZEiU64UlXtOe3w5B1hoHw 6SSWeeniNcYhrlPrDtmgMCUTtELBnMqurBs7P7fS0dtEmCyxmAu7Sk4KPJn90sEc1U ZJRDXBgwz147aOk7aKdGlnprTh5niLCWi1pg/9fk= 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=zDj8ohtD; dkim=pass (1024-bit key) header.d=greensocs.com header.b=zDj8ohtD 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 hiIPGLW6qyBO; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id C625E521AB0; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=WzVolxSjdch3Ooe617kmhtvstqYL1EBIaH5T3ZzYLP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zDj8ohtD8T0ZNNY6IdZvYGOsCm860BjWIQndVLF8wefUp+C5ZI93olqKzbNfez9I3 pfpLmW/gcVnlbCHOQlWmOd0Oabz7KFipBoi3hH4aB2gs+7A5tUI3yI8M8t/in4IHpY xa8/FxxpY5NMbxBMTGp4W+DNCex9c8nVMysiGMxs= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 114AA521AAD; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=WzVolxSjdch3Ooe617kmhtvstqYL1EBIaH5T3ZzYLP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zDj8ohtD8T0ZNNY6IdZvYGOsCm860BjWIQndVLF8wefUp+C5ZI93olqKzbNfez9I3 pfpLmW/gcVnlbCHOQlWmOd0Oabz7KFipBoi3hH4aB2gs+7A5tUI3yI8M8t/in4IHpY xa8/FxxpY5NMbxBMTGp4W+DNCex9c8nVMysiGMxs= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:29 +0200 Message-Id: <20180901124639.19735-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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é --- gdbstub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 2cb9cb6d97..c15250ce65 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1531,13 +1531,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", + get_thread_id(s, cpu, thread_id, sizeof(thread_id))); + put_packet(s, buf); break; } else if (strcmp(p,"fThreadInfo") == 0) { s->query_cpu = first_cpu; goto report_cpuinfo; } else if (strcmp(p,"sThreadInfo") == 0) { From patchwork Sat Sep 1 12:46:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584729 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 6421F139B for ; Sat, 1 Sep 2018 12:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52EA029B18 for ; Sat, 1 Sep 2018 12:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 471C229C0F; Sat, 1 Sep 2018 12:53:06 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 E0FB329B18 for ; Sat, 1 Sep 2018 12:53:05 +0000 (UTC) Received: from localhost ([::1]:37066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5Oj-0003Gu-89 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:53:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JZ-00068Q-7N for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JY-0007yF-6J for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from greensocs.com ([193.104.36.180]:40639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JQ-0007kI-PS; Sat, 01 Sep 2018 08:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 826DAC7AF6; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806028; bh=enKqiXZ0cDdY2cDIYNFZB12+BPC+N/hVVcWV4c8b8TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cMyushgZPeS9s11V9IuJmePdXYlGqvwzxNzydaFEh7zqn+Uhimr4NSjuc6ZOsHkyT 7h8CNmvNiRsm1z9Vurb2TTSy4R1rdxlA35II8leHYkfWkg8AYEFOyoFKWt9B8hWiUQ lMF1I0XpUIGYh/Ycko4yz+T5ng7Mm2U+298meUks= 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=ucgxJoDk; dkim=pass (1024-bit key) header.d=greensocs.com header.b=0lJ0hqSO 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 b8nZ9Nww8v9M; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 53E86521AAA; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806027; bh=enKqiXZ0cDdY2cDIYNFZB12+BPC+N/hVVcWV4c8b8TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ucgxJoDk3mtGw4c95Q+g7Lrx3xybK/+tjUSDChFCtAC0XlMIeN7EWzcRlxWJk2p9l 3hAMhwE8AKWPzcBYsS5c3uUVXnFArGkxnSQObvXZ+DLWlhVa6khuyQ1FFv9uOb6dig smhc3ubrXYmqLxCfeP+KzL54NQINLhxYHUKfXO+0= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 A7511521AAF; Sat, 1 Sep 2018 14:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806026; bh=enKqiXZ0cDdY2cDIYNFZB12+BPC+N/hVVcWV4c8b8TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0lJ0hqSO5qrjUJ0rNbbfJklcRTIhlgkgItZMTf9p3jIg1zw4liKCJyazYFGCod9lG 10ieGjH/dEz7TltTuHAAo7oabSsY8xFbbiUsD7IkcxtcGRBhDXpHSA8V3ZH8H8PJKI HrXPC2gzq+8KdgZq1yy5z2JouzRutOWcTWhmgjwI= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:30 +0200 Message-Id: <20180901124639.19735-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c15250ce65..43015f7792 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1249,11 +1249,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]; @@ -1541,30 +1540,43 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) snprintf(buf, sizeof(buf), "QC%s", get_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", + get_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 Sat Sep 1 12:46:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584725 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 42A25174C for ; Sat, 1 Sep 2018 12:52:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 335132A83F for ; Sat, 1 Sep 2018 12:52:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25EDF2A913; Sat, 1 Sep 2018 12:52: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 996292A83F for ; Sat, 1 Sep 2018 12:52:39 +0000 (UTC) Received: from localhost ([::1]:37064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5OI-0002px-UY for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JE-0004tP-Ab for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007oo-VW for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from greensocs.com ([193.104.36.180]:40637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kF-L0; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id EAD14DFFE0; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806029; bh=NjQ3rZmHdKpW6ybJVivC+BqNnipQ91j4rFLMZTWMRpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A4MAELlUi82zMmuRpmk9TI8YY/i9lM3BCLb2dOY4wPG8ndFUzz8l7cjy9p8dhsOiF L0sHqcCx/43h4GX0yzR+7xR5+w4R1O3LbRbJ5UCEfytPmSvs/+3gJxnaBM54R07Zn9 Xwut7Rea5bpnxDxl67HJk8WlAx1KDfwIU9hCPza4= 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=R/I/GS9n; dkim=pass (1024-bit key) header.d=greensocs.com header.b=GTF9pr7M 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 Iq_ycgfIiixv; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 028EC521AAF; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806028; bh=NjQ3rZmHdKpW6ybJVivC+BqNnipQ91j4rFLMZTWMRpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R/I/GS9n2qz/NhMwvMb8k55TZCoNDq7IwtMnezCZrahzQgC4vEMFwy8kuGDJg92WI iOF6FRjgfTn2q8N2pMXCix83p/vB6OuPGV1VsVGyHV9X7rJHgJ7nIkaeGtKWxPdb0S sFFEt9U42bTC+orhQvQDcslWQ01kTWgQesvw03h4= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 43F3D521A9F; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806027; bh=NjQ3rZmHdKpW6ybJVivC+BqNnipQ91j4rFLMZTWMRpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GTF9pr7Mcnj7WUoRE2pZ26keWA/xzMN1Fm5Pc96X6iAaHAti7ekJqLH4DZZLmKH5O I2X4yiqX18J4MGE0JgW9Gyr4pmT5dwdyCEjSp1PrfBS0BL6oyyzd9Z0+Z4a0ecY58p ywdADreSauykDdPFhJ6fDKf34QphgiyVk82NwdyA= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:31 +0200 Message-Id: <20180901124639.19735-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 43015f7792..761cb051c8 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) { @@ -1247,10 +1249,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]; @@ -1621,18 +1624,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 Sat Sep 1 12:46:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584717 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 E1A89174C for ; Sat, 1 Sep 2018 12:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1B872A8DC for ; Sat, 1 Sep 2018 12:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C61D12A8FC; Sat, 1 Sep 2018 12:49: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 731BE2A8DC for ; Sat, 1 Sep 2018 12:49:40 +0000 (UTC) Received: from localhost ([::1]:37045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5LP-0007vD-Ly for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:49:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JE-0004sH-6A for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007oj-U3 for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from greensocs.com ([193.104.36.180]:40636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kD-OE; Sat, 01 Sep 2018 08:47:17 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id A45A8C7AC5; Sat, 1 Sep 2018 14:47:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806029; bh=YEe+bSOHxip03b/mKVTpeg3rx6MLOFwKQBwCoNaRXg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2MVsRv3vJckeHMKmdxLzRYINYlDd2h9FSWp/ht+a0HNslNG/eCdl89oADVMfy1TQo 3uLaIxSxBagcp/YBxDXTXh5Xs+e8rvEp7ry1q3YioA1Z1TvTiBo2Xaw7tamaeD6sMG Lg8PV8hJM/6KwsRVqpMuspzxMXq8KJDcBWa+zqcw= 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=houbh2g0; dkim=pass (1024-bit key) header.d=greensocs.com header.b=houbh2g0 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 LZcCImLprE-h; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id AA919521A9F; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806028; bh=YEe+bSOHxip03b/mKVTpeg3rx6MLOFwKQBwCoNaRXg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=houbh2g08bpcgk2ZVmw6SE71WN2gGseH88hM5pK0lPkUEAhgPPNaTw+6fqjp9Tg0D SkeNqwsVQboTkQonWzm/RtIZB4OtFt5yhY7JhgeDIIRHKVur6s1WE527cK6w2oLM4a TceQhRsU+vf/PzR90koGb8P0KMpmUHTYheS6bOck= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 B9474C7AC5; Sat, 1 Sep 2018 14:47:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806028; bh=YEe+bSOHxip03b/mKVTpeg3rx6MLOFwKQBwCoNaRXg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=houbh2g08bpcgk2ZVmw6SE71WN2gGseH88hM5pK0lPkUEAhgPPNaTw+6fqjp9Tg0D SkeNqwsVQboTkQonWzm/RtIZB4OtFt5yhY7JhgeDIIRHKVur6s1WE527cK6w2oLM4a TceQhRsU+vf/PzR90koGb8P0KMpmUHTYheS6bOck= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:32 +0200 Message-Id: <20180901124639.19735-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 761cb051c8..4ccd1153ce 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1693,10 +1693,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; @@ -1704,10 +1705,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; + } + + get_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: @@ -1721,12 +1730,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(); @@ -1764,11 +1773,11 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) trace_gdbstub_hit_unknown(state); ret = GDB_SIGNAL_UNKNOWN; break; } gdb_set_stop_cpu(cpu); - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_gdb_index(cpu)); + snprintf(buf, sizeof(buf), "T%02xthread:%s;", ret, thread_id); send_packet: put_packet(s, buf); /* disable single step if it was enabled */ From patchwork Sat Sep 1 12:46:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584749 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 DE127174C for ; Sat, 1 Sep 2018 13:01:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAA922A576 for ; Sat, 1 Sep 2018 13:01:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCFFC2A589; Sat, 1 Sep 2018 13:01:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 296332A576 for ; Sat, 1 Sep 2018 13:01:27 +0000 (UTC) Received: from localhost ([::1]:37129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5Wp-0003sr-1q for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 09:01:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JZ-00068M-5u for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JY-0007y9-6i for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from greensocs.com ([193.104.36.180]:40638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JQ-0007kG-Q3; Sat, 01 Sep 2018 08:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 021CF521ABB; Sat, 1 Sep 2018 14:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806030; bh=U7y+z5X4f9EQxSzlOdGa0ZG0HeuqrrIUt9MwzUb7h4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DySiNmK21+iTbx5wpRYICPysJC8g6XFp9Dm00FE4xvRaHvW1khwHJP6OdBn/gUpVl yXMW/e61KjcrStGiiaUnw/3rn+IkYsEtwd4xdaKLbS1wGgaUMmIRTn6HkTrypk8elf Z41C2iAljUIwgCUyRPHdXzBbjhjaAK2M8Tg4nCaQ= 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=GSxCpWW0; dkim=pass (1024-bit key) header.d=greensocs.com header.b=MlM0jRIH 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 xiPcfbqhMoO3; Sat, 1 Sep 2018 14:47:09 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 19B8D521AAA; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806029; bh=U7y+z5X4f9EQxSzlOdGa0ZG0HeuqrrIUt9MwzUb7h4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GSxCpWW0MlgFXy8OO+3eCtyt+jorz/E4EXtKC8OGEdhS3yOnxj/dArtQgW7gqjBpS FgaYarLLPziSW48QuyoOcDOKUIQ0p8oweQlvxYmal0hAqz7tMV8p4sCGqyo2DFeAJ0 Wn3xO3PkDBAYOEu+L6QcJwFMP5JPPW8OyOdozuYw= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 3D31F521AB0; Sat, 1 Sep 2018 14:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806028; bh=U7y+z5X4f9EQxSzlOdGa0ZG0HeuqrrIUt9MwzUb7h4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MlM0jRIHHOPlPez4Nd3/gangVsXx8AxWRNp/f6gvSms1ZYVsY2ULq/17BCb4w3qhv ghXzTmhIIFlJL00GoTEOVoiVOyXhbA7km5Asqu4kVOYwbE+JZRRnRTWEpkq4tcB1ZX gzLmhNNmgzjYaTJat4FXoG3ZAsHVUOrYmtcLJXE0= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:33 +0200 Message-Id: <20180901124639.19735-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4ccd1153ce..af8864e251 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) { @@ -1318,13 +1333,39 @@ 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; + } + qemu_strtoul(p + 1, &p, 16, &lpid); + pid = lpid; + } + + process = gdb_get_process(s, pid); + gdb_process_breakpoint_remove_all(s, process); + process->attached = false; + + if (pid == gdb_get_cpu_pid(s, s->c_cpu)) { + s->c_cpu = gdb_first_cpu(s); + } + + if (pid == gdb_get_cpu_pid(s, s->g_cpu)) { + s->g_cpu = gdb_first_cpu(s); + } + + if (s->c_cpu == NULL) { + /* No more process attached */ + gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_continue(s); + } put_packet(s, "OK"); break; case 's': if (*p != '\0') { addr = strtoull(p, (char **)&p, 16); From patchwork Sat Sep 1 12:46:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584713 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 61515139B for ; Sat, 1 Sep 2018 12:49:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47A8A2A8DC for ; Sat, 1 Sep 2018 12:49:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AEE22A8FC; Sat, 1 Sep 2018 12:49:32 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 384B32A8DC for ; Sat, 1 Sep 2018 12:49:31 +0000 (UTC) Received: from localhost ([::1]:37043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5LF-0007lo-R3 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:49:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JD-0004r1-UX for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007oN-Nw for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:23 -0400 Received: from greensocs.com ([193.104.36.180]:40641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kH-OT; Sat, 01 Sep 2018 08:47:16 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 1D5C3DFFE4; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806031; bh=bmU4wXE3iudYwFRME/0Zuv4lzXHnqtQIFY1W31Fc69k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i+PtOHcmZTqBzegY1nuaG0x8pO3HrjBDi2mB46tsXYxOjjaDPfp9ImNH67VGMSYw1 sx5j687Isp97rAT3GtKdYUvSvJUBPNLFt5Sd1RpJ+O54/mcPOZOp9NIS62+/Yj7ypj DDEEDbdnzot04fbnD+kQiTO8woQRjBD1j7v8RC4w= 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=MhlVda1I; dkim=pass (1024-bit key) header.d=greensocs.com header.b=BuumqQyo 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 eGld-iZN1yMQ; Sat, 1 Sep 2018 14:47:10 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 64315521A9F; Sat, 1 Sep 2018 14:47:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806030; bh=bmU4wXE3iudYwFRME/0Zuv4lzXHnqtQIFY1W31Fc69k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MhlVda1I61UrtfDJTxZ6Qo+MwaSn7kdtt8nBy+cXmBO4lfR+h0FV7WlFji5jUcdFD /uX8epcEnxTrwa+jBVG0378OJUmu4EceN8hjmC842862dLyI31fOFovi7Ua5xCGo8J kO4CE+hsEOPlWff6tNYsfXllXlrI2cmtrH3jbhNY= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 22F4E521AB0; Sat, 1 Sep 2018 14:47:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806029; bh=bmU4wXE3iudYwFRME/0Zuv4lzXHnqtQIFY1W31Fc69k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BuumqQyokVo3TxLs1sS2fqIpJget3tIVY3lPPA5s5/bjQtpsBr+JAykClAMxaNEm5 Wq4wUzV6c74sRG/YR60C629NoSqnB2+7LYcQHj6dDWEBeviHbec7Jfp7MTClO68nI7 fHuBXqsWZyN/lVf+YxrLoG635F6Hpqrve/BjogZ0= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:34 +0200 Message-Id: <20180901124639.19735-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 af8864e251..4bed0a85f3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1281,10 +1281,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, get_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); put_packet(s, buf); From patchwork Sat Sep 1 12:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584719 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 1C5FD139B for ; Sat, 1 Sep 2018 12:50:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B6182A8FC for ; Sat, 1 Sep 2018 12:50:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1D8E2A903; Sat, 1 Sep 2018 12:50: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9FE252A8FC for ; Sat, 1 Sep 2018 12:50:04 +0000 (UTC) Received: from localhost ([::1]:37047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5Ln-0008C9-TS for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:50:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JD-0004pE-J0 for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007o6-GA for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:23 -0400 Received: from greensocs.com ([193.104.36.180]:40643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kR-QZ; Sat, 01 Sep 2018 08:47:17 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 7F297DFFE5; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806031; bh=YreZeTrW0Sv/0CWPHMxl5hdbM1k5LPGRr5JMFnrvDaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lIqRu3vv2TmQDGlX/cYIWtGT5J0gfJneMHlGjr9kpGhIsrcEfBJMkbgf2t3PCHGAl 6bp5Vsv7Wb4oT6BQHZCinbyaaUTHPStK4fnTEGe7Slt9EOD9SUtlvyTE27GwQvi5ii PLXCNUGhFFCQ/XCcTRFBJVHy2OMuKE3ywI/pqVAU= 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=uVJY3dJU; dkim=pass (1024-bit key) header.d=greensocs.com header.b=uVJY3dJU 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 cqsO6YAXV2_D; Sat, 1 Sep 2018 14:47:10 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id A562F521AAA; Sat, 1 Sep 2018 14:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806030; bh=YreZeTrW0Sv/0CWPHMxl5hdbM1k5LPGRr5JMFnrvDaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uVJY3dJUHN/8JVXPGlEdChmD1YR4ARASr8kdn4kRzZL+vEjZM1+RswbmI1GJIksDe 1tMfcUulADBlR67Ub2pVlIoevP1G2G92S5aD4LLLyeO965bgegOWYu4/D1se8mHpA5 wQwSBnHEiUcTv7/8JK0oGQwNvwl+NhrulE9aj488= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 EA8FE521AAF; Sat, 1 Sep 2018 14:47:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806030; bh=YreZeTrW0Sv/0CWPHMxl5hdbM1k5LPGRr5JMFnrvDaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uVJY3dJUHN/8JVXPGlEdChmD1YR4ARASr8kdn4kRzZL+vEjZM1+RswbmI1GJIksDe 1tMfcUulADBlR67Ub2pVlIoevP1G2G92S5aD4LLLyeO965bgegOWYu4/D1se8mHpA5 wQwSBnHEiUcTv7/8JK0oGQwNvwl+NhrulE9aj488= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:35 +0200 Message-Id: <20180901124639.19735-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 4bed0a85f3..4874d65a30 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1327,10 +1327,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, + get_thread_id(s, cpu, thread_id, sizeof(thread_id))); + + put_packet(s, buf); + break; } else { goto unknown_command; } case 'k': /* Kill the target */ From patchwork Sat Sep 1 12:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584727 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 A6AF6139B for ; Sat, 1 Sep 2018 12:53:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94E6F29BC0 for ; Sat, 1 Sep 2018 12:53:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86DD329C3C; Sat, 1 Sep 2018 12:53:03 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 32BB929BC0 for ; Sat, 1 Sep 2018 12:53:03 +0000 (UTC) Received: from localhost ([::1]:37065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5Og-0003El-Fa for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:53:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JD-0004r5-Uo for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JC-0007oT-OV for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:23 -0400 Received: from greensocs.com ([193.104.36.180]:40642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5J6-0007kQ-UU; Sat, 01 Sep 2018 08:47:17 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 457B8DFFE9; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=KAY+hWMxatC8pmfXSdjygTJWll949e3yUyuZVOI52lM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hg9pbPVkWmf+zn5vpZ0zmruzJEBUBWJU3nio27MXYgQj89nnMjkwOAbgXxi//kUzK t8ivYRJS7NUmtWOaFmBZThosY6sE249Y5uWvKx0+uRqAEuZ0YlLakU1WLcsvbg4QPl b0SnYwYqg/IUQvvxvEfG/Wc5HGNFOB1SHJAnrt5I= 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=nYCSzsnw; dkim=pass (1024-bit key) header.d=greensocs.com header.b=nYCSzsnw 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 jATZo9TXSgjj; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 70AD9521AB0; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806031; bh=KAY+hWMxatC8pmfXSdjygTJWll949e3yUyuZVOI52lM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nYCSzsnw6lbKqt9134oAhYVA9rK7gec0R1FTOHcf4xGEiZ8kbn8cpVPdkKZ2UQ9ft cX1KLOUozd5gRdjNJ2upaVsRAB1ojlaofg0oQKTP135hssA57rkPisFhbsvF3NkYFZ 8zbQNTCKhxN7Ncbb9IWV8XjFelb0lnPpvr4grBMY= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 BEA45521AAF; Sat, 1 Sep 2018 14:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806031; bh=KAY+hWMxatC8pmfXSdjygTJWll949e3yUyuZVOI52lM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nYCSzsnw6lbKqt9134oAhYVA9rK7gec0R1FTOHcf4xGEiZ8kbn8cpVPdkKZ2UQ9ft cX1KLOUozd5gRdjNJ2upaVsRAB1ojlaofg0oQKTP135hssA57rkPisFhbsvF3NkYFZ 8zbQNTCKhxN7Ncbb9IWV8XjFelb0lnPpvr4grBMY= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:36 +0200 Message-Id: <20180901124639.19735-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4874d65a30..36ed7081ea 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2217,13 +2217,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; @@ -2305,12 +2306,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; @@ -2470,19 +2482,17 @@ int gdbserver_start(const char *device) mon_chr = s->mon_chr; cleanup_processes(s); memset(s, 0, sizeof(GDBState)); s->mon_chr = mon_chr; } - s->c_cpu = first_cpu; - s->g_cpu = first_cpu; create_processes(s); if (chr) { qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, gdb_chr_can_receive, gdb_chr_receive, - gdb_chr_event, NULL, NULL, NULL, true); + gdb_chr_event, NULL, s, NULL, true); } s->state = chr ? RS_IDLE : RS_INACTIVE; s->mon_chr = mon_chr; s->current_syscall_cb = NULL; From patchwork Sat Sep 1 12:46:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584739 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 D770B139B for ; Sat, 1 Sep 2018 12:55:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C67E629C75 for ; Sat, 1 Sep 2018 12:55:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA5D229D8B; Sat, 1 Sep 2018 12:55:55 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7167F29C75 for ; Sat, 1 Sep 2018 12:55:55 +0000 (UTC) Received: from localhost ([::1]:37085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5RS-0006Wy-LW for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:55:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JZ-00068L-5v for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JY-0007y3-5S for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from greensocs.com ([193.104.36.180]:40645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JQ-0007kS-RO; Sat, 01 Sep 2018 08:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id C1D60DFFED; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=H1BEeWZcXbhpNd6Me1rhtl3y8JK99Adxfg+psjia9g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukYnZFYp/m8aMitDU5I110umm6Sq3g4kVo+CS6vmkfZw3VjmApC4misij0J2D8isf HTMr+DmPX5BPwLMS8EtmuMZIvo12uvHIwvwN966LHHunCDmekyYs+Ws/pgUslyb4w8 PQWDAqYzqbOcy65DKS1rtwArmkaRXOz7a4Ev8row= 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=ukYnZFYp; dkim=pass (1024-bit key) header.d=greensocs.com header.b=gp8rMuTe 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 IcFmYGyFwRrk; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 02DF0521AAF; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=H1BEeWZcXbhpNd6Me1rhtl3y8JK99Adxfg+psjia9g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukYnZFYp/m8aMitDU5I110umm6Sq3g4kVo+CS6vmkfZw3VjmApC4misij0J2D8isf HTMr+DmPX5BPwLMS8EtmuMZIvo12uvHIwvwN966LHHunCDmekyYs+Ws/pgUslyb4w8 PQWDAqYzqbOcy65DKS1rtwArmkaRXOz7a4Ev8row= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 6075A521A9F; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806031; bh=H1BEeWZcXbhpNd6Me1rhtl3y8JK99Adxfg+psjia9g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gp8rMuTeJuLIoqJuROxNAfp1M4KSTljWUBQixpGux9BCAiOKracORZl8uGZlBVEWs BwWVDtLbyuHANmkNZxdcCx7WujxHfpxn0Htw70bkBXGxCDeupqeB5vZQXhI5t7J/Uj i+c6rPxO8ntYxCMPLWwL7G5b2nbp5V1+ejXv29bA= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:37 +0200 Message-Id: <20180901124639.19735-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 36ed7081ea..6a55bf2785 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1759,10 +1759,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; } void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* Having a stop CPU corresponding to a process that is not attached + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu = cpu; gdbserver_state->g_cpu = cpu; } #ifndef CONFIG_USER_ONLY From patchwork Sat Sep 1 12:46:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584745 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 A9686174C for ; Sat, 1 Sep 2018 13:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962972A540 for ; Sat, 1 Sep 2018 13:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A2AF2A573; Sat, 1 Sep 2018 13:00:03 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6DEF92A540 for ; Sat, 1 Sep 2018 13:00:02 +0000 (UTC) Received: from localhost ([::1]:37103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5VR-00038M-RB for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 09:00:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JZ-00068N-5y for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JY-0007yD-6O for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from greensocs.com ([193.104.36.180]:40644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JQ-0007kT-Uv; Sat, 01 Sep 2018 08:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 5C0D0DFFE1; Sat, 1 Sep 2018 14:47:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806033; bh=53E2KYfvzxY3RVepuu8hlX4xIk1DTU1T0gbwnQ2ryxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C8e2rf1rIosFDm5rsHIJ7nkjXWhsLyDLiwP699M/ksRKCwK/iyI2dEX6xpgm18phs k6rUP5K0kYf9Dn0VUZrKAEnvUpiqvmH7W7NkSWXPwBkReEBuejQKyubTudLaURyi15 jmW/RhfB7X103l+/mfBnbOM8NzBOsYJ4yEsg6Sws= 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=IIfmdgVK; dkim=pass (1024-bit key) header.d=greensocs.com header.b=IIfmdgVK 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 2voZMw0TAPth; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 89377521AB0; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=53E2KYfvzxY3RVepuu8hlX4xIk1DTU1T0gbwnQ2ryxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IIfmdgVKUNmLbcmjk6aGujGgsj2NjLGLfgmuMBLkYrtKNGe5YlfwpzG6ZEGIfzuPT kuR3KYA5OdhRPpQkjdGBLMthe7eoSt+Vb24NQp1jTBFl8lcJaBm6oRJIs1SFBQWjcm wlIiQb588186vXhnq0XhKnoPnH6Ulamo8Pv00KAk= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 EB636521AAA; Sat, 1 Sep 2018 14:47:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=53E2KYfvzxY3RVepuu8hlX4xIk1DTU1T0gbwnQ2ryxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IIfmdgVKUNmLbcmjk6aGujGgsj2NjLGLfgmuMBLkYrtKNGe5YlfwpzG6ZEGIfzuPT kuR3KYA5OdhRPpQkjdGBLMthe7eoSt+Vb24NQp1jTBFl8lcJaBm6oRJIs1SFBQWjcm wlIiQb588186vXhnq0XhKnoPnH6Ulamo8Pv00KAk= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:38 +0200 Message-Id: <20180901124639.19735-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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 --- gdbstub.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 6a55bf2785..d249803c8e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1688,15 +1688,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 Sat Sep 1 12:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10584735 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 9B053139B for ; Sat, 1 Sep 2018 12:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8787629C75 for ; Sat, 1 Sep 2018 12:55:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 792B029D8B; Sat, 1 Sep 2018 12:55: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 17E7929C75 for ; Sat, 1 Sep 2018 12:55:46 +0000 (UTC) Received: from localhost ([::1]:37083 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5RJ-0006PV-DJ for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Sep 2018 08:55:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JZ-00068K-5B for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw5JY-0007yN-73 for qemu-devel@nongnu.org; Sat, 01 Sep 2018 08:47:45 -0400 Received: from greensocs.com ([193.104.36.180]:40637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw5JR-0007kF-9t; Sat, 01 Sep 2018 08:47:37 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id DCA78521AB0; Sat, 1 Sep 2018 14:47:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806033; bh=5/2DOvtpiZV5P2ENECTDH5wFSujNGyE0gLpN3XvmQ5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6uhL0YVGIRSMmkFE6RY8YTIeY5ZMonvc19p/YwOZ9JUIDhOqtW7ZrpHyoWKVOKDuJ IeU5agzqHsT2ZHDmqmq2VWXeUcxhHMI3ad94xkNWZUdrP8rcj6YRcOvG3khmyJ+jNz Qj4fm7zO7HzJTSbMu93Yjr58f+xzKXM3z27QmeIo= 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=6uhL0YVG; dkim=pass (1024-bit key) header.d=greensocs.com header.b=5nTiMUE1 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 caxCHvjHpHDg; Sat, 1 Sep 2018 14:47:13 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 129FA521AAA; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806033; bh=5/2DOvtpiZV5P2ENECTDH5wFSujNGyE0gLpN3XvmQ5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=6uhL0YVGIRSMmkFE6RY8YTIeY5ZMonvc19p/YwOZ9JUIDhOqtW7ZrpHyoWKVOKDuJ IeU5agzqHsT2ZHDmqmq2VWXeUcxhHMI3ad94xkNWZUdrP8rcj6YRcOvG3khmyJ+jNz Qj4fm7zO7HzJTSbMu93Yjr58f+xzKXM3z27QmeIo= Received: from michell-laptop.home.lmichel.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 5E55F521A9F; Sat, 1 Sep 2018 14:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1535806032; bh=5/2DOvtpiZV5P2ENECTDH5wFSujNGyE0gLpN3XvmQ5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=5nTiMUE11pDB2HFZhB5i0pydVr8AhhRfiF72dghKNkNv8l8cmqhTRZzMAjS+P12Ro DRLmEiUFfMmeX0dR01qs4rYsbH2Usl+ddCj7s5m3bCcrYXni23hyfEQewC9wdo9VHa LgjsxAX0vL8xQqW3cVR6Un060Z5CwZw4h7MNB66c= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 1 Sep 2018 14:46:39 +0200 Message-Id: <20180901124639.19735-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180901124639.19735-1-luc.michel@greensocs.com> References: <20180901124639.19735-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH 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, 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),