From patchwork Fri Dec 7 09:01:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10717709 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 82A4214E2 for ; Fri, 7 Dec 2018 09:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD452BC27 for ; Fri, 7 Dec 2018 09:14:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C6462BD49; Fri, 7 Dec 2018 09:14:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5A302BC27 for ; Fri, 7 Dec 2018 09:14:01 +0000 (UTC) Received: from localhost ([::1]:44909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCCu-0002Bq-Eg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Dec 2018 04:14:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1G-0007tq-EA for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1F-0005VO-E0 for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:01:58 -0500 Received: from greensocs.com ([193.104.36.180]:52245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1B-0005Rq-7p; Fri, 07 Dec 2018 04:01:53 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id CF85B480032; Fri, 7 Dec 2018 10:01:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173310; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a6bjMqJOACVUFsSzdXAkKsw/i3TzFSkrEylKojjkLN7wDl18XDTX1t5bNkTMqIQyc KTNKBKKLw4olG7i+dVJvAv5xpXSXrmPf9fp0hTMcf1NsdpDsPt2kQKEZMsvFFo2UMY QUzmw/yUuDf2IxIL1+ZmQ3zeEfKuOKSAYqG+QUxs= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=Rp0oTYW1; dkim=pass (1024-bit key) header.d=greensocs.com header.b=V7qNrk6b Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ioCa8pdvdKO2; Fri, 7 Dec 2018 10:01:50 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id F3C3C480036; Fri, 7 Dec 2018 10:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173305; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rp0oTYW1YokZ8Upw3B1yzdrsqEWaj+baCSPWjwc3+ppLfkLt5huKBzT5JhlvQ/ab4 /K/OeUxkC6NO7Q2K6miujJt0JMGTtFh12wLokfERtP5qKroZ87P26GjcX2f3nfJ1pR kDNgRQuixxzepx3wkb0HzIQniarV4VQTDw/09twI= Received: from michell-laptop.home.lmichel.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 90EAC480011; Fri, 7 Dec 2018 10:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173304; bh=p6jKllSk1N89qZ5kxsijOyj3jCEF8rBu8QqbfZyaa78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V7qNrk6bhJmpuqeFLnMygVGYg74RMKYmesP6exDjwaKCP8EfYpUSf69zd9jioPZEC 1wqsX+d1YgyPWlTW2upx4wFlpTmAlTIfwfgABV6dYSqB8IgL0fpcSHp1ckvJucbwT/ 5ujCXTBihaYqQWhK5gMNvB1waH4nA4EnbPhwatvA= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:27 +0100 Message-Id: <20181207090135.7651-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 09/16] gdbstub: add multiprocess support to gdb_vm_state_change() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for multiprocess extension in gdb_vm_state_change() function. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Acked-by: Alistair Francis --- gdbstub.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index c66bf37b49..4645d59d8c 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1722,10 +1722,11 @@ void gdb_set_stop_cpu(CPUState *cpu) static void gdb_vm_state_change(void *opaque, int running, RunState state) { GDBState *s = 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; @@ -1733,10 +1734,18 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) /* Is there a GDB syscall waiting to be sent? */ if (s->current_syscall_cb) { put_packet(s, s->syscall_buf); return; } + + if (cpu == NULL) { + /* No process attached */ + return; + } + + gdb_fmt_thread_id(s, cpu, thread_id, sizeof(thread_id)); + switch (state) { case RUN_STATE_DEBUG: if (cpu->watchpoint_hit) { switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { case BP_MEM_READ: @@ -1750,12 +1759,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(); @@ -1793,11 +1802,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 */