From patchwork Fri Jun 7 09:05:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 166129 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp448684ili; Fri, 7 Jun 2019 03:22:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+/BzCL6H5yMzZfuNv0NaS5OidjXgqhLbUN9FYGT/Ep/sUR0YN6JbSzOhufuSDvcNheIYG X-Received: by 2002:ac8:124c:: with SMTP id g12mr16375703qtj.57.1559902965319; Fri, 07 Jun 2019 03:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559902965; cv=none; d=google.com; s=arc-20160816; b=YQrszI7eUN8ZGf2JoP6LsQreLI60Tp7+7ZlZlo1X84RV9VLwnGNnb4nZQdMaZTicDV dEJE0z2iqfk6tG5iCULrV6ukXj15SGQLKNjafZsaIEwEzzuYg1rWP27B97DE2tQaYl1G gAzLQOqfDUWej46+prpaF4AAFGRgaC6AZdVzw6siVTU5KqsDvvUFjVryaCMAnxP/G49F rWZn91ntWnHdk55Oc+DpulxrokJqcWqRp0Dtcf6HbLAQpbsTM+vpbQ5dcz5X9mFt4xxO dpDozAkbJJdYOunqzIZLQt8VCKgACPtLsg8CjKNoa8YLOAmSoSo8eE0yNDDcFnoXChhM CYVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6p4AOuc6tSqUtkly1124rR3i8VzgPPw2QQg37+GiwQw=; b=rQb++TAgU5/4ih8Y5vsMrGDM16Q3w6+GcL140jnEMyAEFkyXBK1e8xeTGbmZw2zCjm EXWJ8QDL8ypvuZXm/uL7A06lEQ/aW6pa/cJ7xDxe1mPCnY2GUdhLo4nMHaT8ANR1XUOE O/IAm8TKTOfbirjL2NHZXXsCmVFdEEdaJCncXW/U0fV35F8Lx7pVnwBoNFbnp1RExOK8 6mJlW/tOo5EM4FsKTv6k+PH7eItw6XBC/9IjATgGucc9ecsed6IYzyfiF+Rpnq2t87Ky TgFP+GcmTMey1iq32RAm4IOm2RBseQBNLT5BE7XE1FH25KxJO8dwxAErY+FA+671Eo7q MnAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LGGWbPMP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.47]) by mx.google.com with ESMTPS id f17si877908qkm.270.2019.06.07.03.22.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 03:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LGGWbPMP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZC1E-00084Z-79 for patch@linaro.org; Fri, 07 Jun 2019 06:22:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44947) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZB4z-00084G-76 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZB4y-0005oO-2c for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hZB4w-0005hl-3g for qemu-devel@nongnu.org; Fri, 07 Jun 2019 05:22:30 -0400 Received: by mail-wr1-x442.google.com with SMTP id m3so1422062wrv.2 for ; Fri, 07 Jun 2019 02:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6p4AOuc6tSqUtkly1124rR3i8VzgPPw2QQg37+GiwQw=; b=LGGWbPMPy8kvNxxFhLdei3Ebzjt4NHqzX2b2XzS7za1J/oD6Tk4l+OzLzOQsiguEpG JOwErwhTsNXNb2C1PjsdqZ1/+4Y6FULvLUuXS4uIZ5JLtS1azzUfxedKJ4Sk0CMPaTr3 8DQHLLpI2CY/6ssbU3Rk3UPJ/agK5pi3hWS5dEvHnMZMDvm/DQB7wtTqFGJgPsk7K9Rj ZyUwGLf0vfBzOj5JRljOVGnraSjHGQoAhBSk0BIdV9cEf6Oy/CCIwAIC97V4D/wFoGed zYPUyCbZGFQM85si4qZg0HTP8dLtnySezCHjHO6CE5Fh933s8btVADuPircn7aIlKBSw W5Xw== 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=6p4AOuc6tSqUtkly1124rR3i8VzgPPw2QQg37+GiwQw=; b=HTBvGzcT1fwczs3qyzGn8YywKf15Tpalyxht/AvK4oyccvzY587H8HB2R/u2vd8m5O lGU9/CKStkWErepgFpxx6586kh7gsgiraoLuFbKcmgQRQ0xof243dIi6OUoAlZC3Br3t hyRpXIwZHLaXsfo7nb9BZ205ZTU5SfhgPaxWfcbp2JjXOpHrbMHF07EikkUYukUa9DDi lUBKdawKyII1f+2hDNLQY1A8FDrhinNBuzCBwHaZxSk4iJp3/JPBW5z+P07SEWaS6UgK EDzS83jLWZ0XgcdqH9Tqrscj5tbNOP2BA6RDMleF0QKNlNz0AC9RoYtB9ZHcp7Tlxo1N //Dg== X-Gm-Message-State: APjAAAVkIAQPMkSAOcEQaYW/xWqS2HizJFTFv3XAqnBzcG4JIqj+rq0i SuyNVEG+UGd4mKYSfdeje1IBDA== X-Received: by 2002:adf:dc43:: with SMTP id m3mr15729283wrj.279.1559899347429; Fri, 07 Jun 2019 02:22:27 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q20sm4023504wra.36.2019.06.07.02.22.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 02:22:26 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 02AF11FFC9; Fri, 7 Jun 2019 10:05:56 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 7 Jun 2019 10:05:49 +0100 Message-Id: <20190607090552.12434-51-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190607090552.12434-1-alex.bennee@linaro.org> References: <20190607090552.12434-1-alex.bennee@linaro.org> 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::442 Subject: [Qemu-devel] [PULL 50/52] gdbstub: Implement target halted (? pkt) with new infra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Jon Doron Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jon Doron Note: The user-mode thread-id has been correctly reported since bd88c780e6 Signed-off-by: Jon Doron Message-Id: <20190529064148.19856-19-arilou@gmail.com> Signed-off-by: Alex Bennée -- 2.20.1 diff --git a/gdbstub.c b/gdbstub.c index c45cefd721..26c0c30682 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2265,13 +2265,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); @@ -2283,15 +2299,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': {