From patchwork Fri May 24 16:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1105017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dgh72pA7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 459Wfr2Hx4z9s9N for ; Sat, 25 May 2019 02:15:00 +1000 (AEST) Received: from localhost ([127.0.0.1]:57047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUCqQ-0006hR-8n for incoming@patchwork.ozlabs.org; Fri, 24 May 2019 12:14:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUCds-0004I1-1C for qemu-devel@nongnu.org; Fri, 24 May 2019 12:02:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUCdq-0002Hu-2d for qemu-devel@nongnu.org; Fri, 24 May 2019 12:01:59 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUCdp-0002DJ-RA for qemu-devel@nongnu.org; Fri, 24 May 2019 12:01:57 -0400 Received: by mail-wm1-x344.google.com with SMTP id z23so5685756wma.4 for ; Fri, 24 May 2019 09:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+NF9Yo7d6jp3qeQ6UNfGvcDfxpGOYkZyN8rNP8o5Qo8=; b=Dgh72pA7oISYq7pA8dc4iwSQaKR1MkJiMuAOvEuDiFl12N70c8FVzOe/uowyB+k8H1 a/3OvDHFxMjMmdR5GTK3Tz/YQPsZEv4Q6RGsqZXlmJWPMivZdH6/usqIcDi1/ioTI/A+ hOkkHD1ByDpQ2n6TKTKUkDXBCanENaYzzq0v26zhR3xGKwYhOp0A8XHUke7P2+VyFIXN +VusM7iE3i6rT3olxG+B64oFuuHoYalPKYVqKZFukIdVrqG6uCL5G2cQfNG2uCrmk2aV tDS+mwMRRmM1Y2MyiUbdBY7egxSmoeuLAaZ5grMmdaw2iaiT6bGkAzY0Zhm0IT3ZBpbi Dd7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+NF9Yo7d6jp3qeQ6UNfGvcDfxpGOYkZyN8rNP8o5Qo8=; b=kRhd0aeDMB7EPuH3h7euLcpdgjraAcnHrNFJIjb6eA+038JOSGgpC3NPZecNe9DBqv stCGLXI3qKIegQ+oe0lDfffOqaW3PCe0RVAqCfqmy1NNpMOmBSxBfZm+HP3zyMXn1WSe ntOERnRbanmxvDY5IRWyDBhXtDb9X0WjEy2itWH5O82a9UBCZRWl5fIuhALuxES7k6Qw DL6mHo56C8nDTeu/P7EaxBHgNomZZG2AE+OiUP7htDox6f1VjWtKr/LRWDWQNMApg9oA XRbKqb4qBwD2qnlATLCuwRIyG94WSBCApo0YsejflPmNfSuExOEVOgWMkZRjX3x1+CHz ICNA== X-Gm-Message-State: APjAAAUVgk75qjfTHkQjOVJBxucZ43QE7BDgC0jwU6BQCCYKfeEfLjNX 9J8D74FkIOhIWDw6A5dcsKhpqd9B X-Google-Smtp-Source: APXvYqwcPlCCPZvVEPQpIo4dPs+YYXfSp7eORfiWC8pjxZKbXNW0Ke3HjqlFn5ArJ4lchXqCPafDCA== X-Received: by 2002:a1c:c016:: with SMTP id q22mr15816329wmf.6.1558713713214; Fri, 24 May 2019 09:01:53 -0700 (PDT) Received: from jondnuc.lan ([176.230.64.37]) by smtp.gmail.com with ESMTPSA id s11sm370863wro.17.2019.05.24.09.01.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:01:52 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Fri, 24 May 2019 19:01:16 +0300 Message-Id: <20190524160118.31134-19-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190524160118.31134-1-arilou@gmail.com> References: <20190524160118.31134-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v11 18/20] gdbstub: Implement target halted (? pkt) with new infra 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: alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Note: The user-mode thread-id has been correctly reported since bd88c780e6 Signed-off-by: Jon Doron --- gdbstub.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 57a05fd6a4..097b7d1231 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2251,13 +2251,29 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) } } +static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + char thread_id[16]; + + gdb_fmt_thread_id(gdb_ctx->s, gdb_ctx->s->c_cpu, thread_id, + sizeof(thread_id)); + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "T%02xthread:%s;", + GDB_SIGNAL_TRAP, thread_id); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); + /* + * Remove all the breakpoints when this query is issued, + * because gdb is doing an initial connect and the state + * should be cleaned up. + */ + gdb_breakpoint_remove_all(); +} + static int gdb_handle_packet(GDBState *s, const char *line_buf) { const char *p; int ch; uint8_t mem_buf[MAX_PACKET_LENGTH]; char buf[sizeof(mem_buf) + 1 /* trailing NUL */]; - char thread_id[16]; const GdbCmdParseEntry *cmd_parser = NULL; trace_gdbstub_io_command(line_buf); @@ -2269,15 +2285,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, "OK"); break; case '?': - /* TODO: Make this return the correct value for user-mode. */ - snprintf(buf, sizeof(buf), "T%02xthread:%s;", GDB_SIGNAL_TRAP, - gdb_fmt_thread_id(s, s->c_cpu, thread_id, sizeof(thread_id))); - put_packet(s, buf); - /* Remove all the breakpoints when this query is issued, - * because gdb is doing and initial connect and the state - * should be cleaned up. - */ - gdb_breakpoint_remove_all(); + { + static const GdbCmdParseEntry target_halted_cmd_desc = { + .handler = handle_target_halt, + .cmd = "?", + .cmd_startswith = 1 + }; + cmd_parser = &target_halted_cmd_desc; + } break; case 'c': {