From nobody Mon Nov 10 19:12:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1558433615; cv=none; d=zoho.com; s=zohoarc; b=SIEr7H6TZ+4xBR9CRxbMz+uhyH1jbt4WC4yKLOx/zvzfOXyH4aJgxsos8kfRX2rNuDAsY7ZtrHClIUQ15+z077duItY+JUVvMr9QgWmXS9H1qnYN2fzDRJ5l9uyrns815zCRqtN+OCz2+hoy/994Im8YqCRR2HTO1mrooOIYu0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558433615; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+NF9Yo7d6jp3qeQ6UNfGvcDfxpGOYkZyN8rNP8o5Qo8=; b=V5JAyzViMs1ms5rPKiILbICeeqckI7ySg9OwslrF7vfmQ8OuIvB4jveRu5MhG+2m5A+U0ga8hufgRlMy6eBT7fiELTF1KV9NIvGKgoXi7i1C8hmjdnmfmLx/u6bjVlXM2ANjaG2+DmasSS3XmmN8dHwZ7zo68qWELDx10JyBxh0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558433614997746.8089762852521; Tue, 21 May 2019 03:13:34 -0700 (PDT) Received: from localhost ([127.0.0.1]:50623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT1lN-0006Vj-4P for importer@patchew.org; Tue, 21 May 2019 06:12:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT1ZR-0005yZ-75 for qemu-devel@nongnu.org; Tue, 21 May 2019 06:00:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT1ZQ-0007u7-3g for qemu-devel@nongnu.org; Tue, 21 May 2019 06:00:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:37442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hT1ZP-0007ru-TA for qemu-devel@nongnu.org; Tue, 21 May 2019 06:00:32 -0400 Received: by mail-wr1-x442.google.com with SMTP id e15so17872168wrs.4 for ; Tue, 21 May 2019 03:00:30 -0700 (PDT) Received: from jondnuc.lan ([176.230.64.64]) by smtp.gmail.com with ESMTPSA id 65sm3080257wro.85.2019.05.21.03.00.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2019 03:00:29 -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=VL9b2Xsv/uylVeCYuRqb9dKPxzfF5WehXDN2bOkbi4J1v3j7wWGDBXnAZgv9vPEYkK pG5rU/Ek+8mUGPgxDxKeN6PG50oQiOK4wmV9KKTAzm1qyTmqwLNwZjl0bjcB0xSgr0f0 HetWXbUJHlII75cM3OjPIeRbb0OyCJ91J1RapknfPOSXNOnHmUjClP/C8lTzuyQsKThe agwQKgGbG8i4oaM7hTW3yeQups4XJCA9CeFoKucfZnQUFVH9GRSTTjY+eEPg1OnDEnPN vTZi/h35T/w2d3Ob7LKMdGEcZ6fReqikSGCRUYjjnP33cbcGqTxxAVwqiD4JhIf6PR3/ FLjQ== 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=BRMs0/R4tBwf5JePKd1zmxm5msEWke0GEjRQm6sbQez11F4a2ndmaODL5YKKCSLacg 5wWRSdEU2ykkzyEqWJhaZnhSHFeK/aKpsydK/lHWOkSTz2ilZqVJA8j8ASgzIQZB6LvR 3P8JqwUeEu4XayeXKiExG+i6yjqX/WC9/x6GoM3Zx/gj9jhS5CwApH6iYTL5wGiaAI9W 8Wgam33LuOUONlScUX4/k4itHAeHe3YmWXdS/0owlZzsja0yrrbEwRziIO2hGdab29O7 qHPLs/IB77FSdQbWGmRC74gdhEKzktj+4HJfEfSkYg7d9yMd595mrNyKKQrFS68G6Px7 pRYA== X-Gm-Message-State: APjAAAW2tgkRKR1CqF6dvq94Y1YU8YYpuRLdJph+8xIMn1W8c/Q+tvUZ 6XPIOMwgOKt9DbFGkSgsb2Jcvx7a X-Google-Smtp-Source: APXvYqxBqlYCzfNihFixJF+RzsPjYrlGgUqJQ+Jwik/gYbbkylWtZzQV4ZA364FNng8j4gHDrqZmwQ== X-Received: by 2002:adf:ce0c:: with SMTP id p12mr22873525wrn.19.1558432829914; Tue, 21 May 2019 03:00:29 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Tue, 21 May 2019 12:59:46 +0300 Message-Id: <20190521095948.8204-19-arilou@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190521095948.8204-1-arilou@gmail.com> References: <20190521095948.8204-1-arilou@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v10 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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) } } =20 +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 =3D NULL; =20 trace_gdbstub_io_command(line_buf); @@ -2269,15 +2285,14 @@ static int gdb_handle_packet(GDBState *s, const cha= r *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_i= d))); - put_packet(s, buf); - /* Remove all the breakpoints when this query is issued, - * because gdb is doing and initial connect and the state - * should be cleaned up. - */ - gdb_breakpoint_remove_all(); + { + static const GdbCmdParseEntry target_halted_cmd_desc =3D { + .handler =3D handle_target_halt, + .cmd =3D "?", + .cmd_startswith =3D 1 + }; + cmd_parser =3D &target_halted_cmd_desc; + } break; case 'c': { --=20 2.21.0