From nobody Wed May 8 04:37:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1582244831; cv=none; d=zohomail.com; s=zohoarc; b=Jvb9qHffvo33M2Oqz1fkt6+PoN6GspgX03utxUs13bfo+R2RW8nw+JXmGNB4bcN6UH8Z2zRAoiry0FqoHKtmkgp7VPpxYuxf3j3ymmHJegqdpkaehNRx3v0uACtdLhCoLr8oNBHm+zpd27V+hB99TyqjYaLaG4t5sT69gW9BYxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582244831; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2RsVayiSQuQhZNhepkVxMmWRfo73hY+d4lGJZW6mBLA=; b=n4mEtCG3DH1rFHrLD4WMI2Fm9YUgfmfHEcSFjqremFuvj+jAogWASi8HXSzf/uUon3jx8wHPvlMGBDQYaM7G6Wdyr7yC+rk/Lh3Zyw391zXD1WLSOWssshKlgeEXnM6u8eOXgZG7IpBe2ACgRdoYdcE/SHHqDX1JkPTQeRcnx4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582244831096553.0525318873301; Thu, 20 Feb 2020 16:27:11 -0800 (PST) Received: from localhost ([::1]:50808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4w9t-0004z1-Br for importer@patchew.org; Thu, 20 Feb 2020 19:27:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34157) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4w92-0004Ws-CU for qemu-devel@nongnu.org; Thu, 20 Feb 2020 19:26:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4w91-0006zU-Bs for qemu-devel@nongnu.org; Thu, 20 Feb 2020 19:26:16 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:37584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j4w91-0006z8-6L for qemu-devel@nongnu.org; Thu, 20 Feb 2020 19:26:15 -0500 Received: by mail-pl1-x644.google.com with SMTP id c23so111734plz.4 for ; Thu, 20 Feb 2020 16:26:15 -0800 (PST) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id i3sm717181pfg.94.2020.02.20.16.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 16:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2RsVayiSQuQhZNhepkVxMmWRfo73hY+d4lGJZW6mBLA=; b=BkKwg1c1x436ItoanfTrT3GXebMLlDzFczhOAn5w3QD14V/M/RveURxG7LKEZgVAMb k8DVu+9s2oEIHAPaRowLoU0KQjo2ZNS6G7SiwWyFYn+DjZ2arZrsZhcQ1fIJsfl94RNS 3sh+wggcbeKPM7kE1dDAQ6mjkzXGJ5dVcRrxRUTW51/MQ51jwoRYPH0+ZS0XBv2O0qxU EiNQ3oY43MysHNgGrDarjShsB4DZ1PAuJFUrtyjNq4RkE25jGOYrQ6YpssdmZUoQ0/qM NtPcUOJXQnZ2HMd9v4xjK7GzIXldDPvT6UpYHjie1yS4a4PrwqMP1vpSHGUODW/NyjWl Jgmg== 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:mime-version :content-transfer-encoding; bh=2RsVayiSQuQhZNhepkVxMmWRfo73hY+d4lGJZW6mBLA=; b=UxJgCK1ftaRFbnI3TcvELppBzPM4tUtGD3hGzdv7VcpAvaWVn5RqeVcpeokE5vubHM vWmdnlV5HCn8ht5tiiEo97KJmlECnghQzuqRPk7q0HUKCxe1MWIihLzVbFq2Emo83YEv GFO+aO07cp9WrNiIrb1c2T9WVTh4fIYdHucHDdVH9nYmpirdyDwt5j2SprX3OPsGbM0l UltXIzBQ2/kWm6T8QVyH8/YQY1ES441fp6hT9hAes/ga2lYFGeirnQGvUd1gankpbMvz hi6oWjsRfbYmMwcgqdo1ijzi/0Kh8n9SDYE3Lk0Ibxhdi6XP2Fix//XsWoAbHOc54O8k aUqw== X-Gm-Message-State: APjAAAXq0CIWW+xOH/4YiOwgG1g/Ngjz7ldvzlsMhX6HBreBrtNQUtSm S+3UuC+20aaPkY+F57+lCsw= X-Google-Smtp-Source: APXvYqwlF5QLObK7IJ6YVc7SlXFaYZnN+60iFXfHa668hwz4D34nU6bSvVeS+Ydt6i0eDrFvi74E5A== X-Received: by 2002:a17:90a:f84:: with SMTP id 4mr6748701pjz.74.1582244773951; Thu, 20 Feb 2020 16:26:13 -0800 (PST) From: Changbin Du To: alex.bennee@linaro.org, philmd@redhat.com Subject: [PATCH v2] gdbstub: Fix single-step issue by confirming 'vContSupported+' feature to gdb Date: Fri, 21 Feb 2020 08:25:59 +0800 Message-Id: <20200221002559.6768-1-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 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: qemu-devel@nongnu.org, Changbin Du Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Recently when debugging an arm32 system on qemu, I found sometimes the single-step command (stepi) is not working. This can be reproduced by below steps: 1) start qemu-system-arm -s -S .. and wait for gdb connection. 2) start gdb and connect to qemu. In my case, gdb gets a wrong value (0x60) for PC, which is an another bug. 3) After connected, type 'stepi' and expect it will stop at next ins. But, it has never stopped. This because: 1) We doesn't report =E2=80=98vContSupported=E2=80=99 feature to gdb expli= citly and gdb think we do not support it. In this case, gdb use a software breakpoint to emulate single-step. 2) Since gdb gets a wrong initial value of PC, then gdb inserts a breakpoint to wrong place (PC+4). Not only for the arm target, Philippe has also encountered this on MIPS. Probably gdb has different assumption for different architectures. Since we do support =E2=80=98vContSupported=E2=80=99 query command, so let'= s tell gdb that we support it. Before this change, gdb send below 'Z0' packet to implement single-step: gdb_handle_packet: Z0,4,4 After this change, gdb send "vCont;s.." which is expected: gdb_handle_packet: vCont? put_packet: vCont;c;C;s;S gdb_handle_packet: vCont;s:p1.1;c:p1.-1 Signed-off-by: Changbin Du Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Luc Michel --- v2: polish commit message. --- gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index ce304ff482..adccd938e2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2111,7 +2111,7 @@ static void handle_query_supported(GdbCmdContext *gdb= _ctx, void *user_ctx) gdb_ctx->s->multiprocess =3D true; } =20 - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";multiprocess+"); + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";vContSupported+;= multiprocess+"); put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 --=20 2.25.0