From nobody Sun Feb 8 06:56:25 2026 Delivered-To: importer@patchew.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=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1663687180; cv=none; d=zohomail.com; s=zohoarc; b=W+tAXfIYFMqfDtjXbU0y3rVYpW/JuMfcIlM22oEOmTD7LxT0c5Dy/lX3dFdtyoCqYnKlT4Hbs4//75CG6lWuEvoaYxo0ldtpLfhh4S75smT/GOtfzrqtN9c9PJ7z1BbWdA5dYX2XpmNdOD5JtR8r/+5mspXzNHUBu+AfnyXvkoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663687180; 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; bh=/k0k2L5GGxaU4myI8OACWSyd0K1PwqOyiqKkB2CAC+Q=; b=AwBH2RzVX2JiXLBrDYpsbnx3275NY6huRFJt54iV1rWcAC4aV4AiYqoo+qTFE7bSXBHfXWLMlDqcFgQNjdFThUKiT3958zev3Vx4h+Ng35kA44Do4iYeisrM3lfm9byo4RZk5bMeVt5AXrVSdXpDsIU/3nL2bl5CJaHFo/vu7Wg= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663687180417586.4037921778247; Tue, 20 Sep 2022 08:19:40 -0700 (PDT) Received: from localhost ([::1]:44260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaf28-0004lF-I8 for importer@patchew.org; Tue, 20 Sep 2022 11:19:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oacen-0003IF-Dq for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:29 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:15750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaceg-0004p0-0j for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:16 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28KCbFcp032296; Tue, 20 Sep 2022 12:47:08 GMT Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jq7321mbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:08 +0000 Received: from pps.filterd (NALASPPMTA02.qualcomm.com [127.0.0.1]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 28KCl7f9027106; Tue, 20 Sep 2022 12:47:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3jnqpvh5y7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: from NALASPPMTA02.qualcomm.com (NALASPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28KCl7Ld027099; Tue, 20 Sep 2022 12:47:07 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-mathbern-lv.qualcomm.com [10.47.235.147]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 28KCl6Jd027095 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 4229910) id D51CA4DB5; Tue, 20 Sep 2022 09:47:06 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=/k0k2L5GGxaU4myI8OACWSyd0K1PwqOyiqKkB2CAC+Q=; b=cQD+ziB4Uxda+QtBl3410YKTKM2oWqWYXJGLDDXGke6gW7q1EBbtQFPklsgXtYUikRwc nX+gdLWoWe90f+z1ds6bdOROGUcRgL00TfYDSJgpq7QJQ6aP07BjZNEP8BY8NkiA9OSA i/uJDr1Kt76fLXNRyqHzYUzOJ6L+p5uSVmY5cL3LPFtv6qsynPs+NqV97TRkPmtSmW+D E/YYyczOm1TWhPPpzpIHhZc0HQknw5Pwv55I7+1sVG5kikwubZkN3RPqS6ymKl6k/t7j d48MlJof/8fgqqVYhSnpHYR7DMJc6JvduXyATdbTxhFN2zAQAYASMXgd8O5ha9MMt+aY gQ== From: Matheus Tavares Bernardino To: qemu-devel@nongnu.org Cc: bcain@quicinc.com, alex.bennee@linaro.org, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH v3 1/3] configure: make sure tcg tests can see HAVE_GDB_BIN Date: Tue, 20 Sep 2022 09:47:01 -0300 Message-Id: <99b9352e18fe3cc584a66e740e49a77cdc57494d.1663677789.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: _1bkagb2LTZ6JFnYWpDJTkGqG9662DN_ X-Proofpoint-GUID: _1bkagb2LTZ6JFnYWpDJTkGqG9662DN_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_04,2022-09-20_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 mlxlogscore=781 spamscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200074 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; Received-SPF: pass client-ip=205.220.168.131; envelope-from=mathbern@qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1663687181554100001 Content-Type: text/plain; charset="utf-8" HAVE_GDB_BIN is only used by tests/tcg/* makefiles, but it is currently written at /config-host.mak, which those makefiles don't have access to. Let's instead write it to /tests/tcg/config-host.mak, which is included by the makefiles. Signed-off-by: Matheus Tavares Bernardino --- configure | 13 ++++++------- meson.build | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 575dde1c1f..e9dc766467 100755 --- a/configure +++ b/configure @@ -2474,13 +2474,6 @@ if test "$plugins" =3D "yes" ; then echo "CONFIG_PLUGIN=3Dy" >> $config_host_mak fi =20 -if test -n "$gdb_bin"; then - gdb_version=3D$($gdb_bin --version | head -n 1) - if version_ge ${gdb_version##* } 9.1; then - echo "HAVE_GDB_BIN=3D$gdb_bin" >> $config_host_mak - fi -fi - echo "ROMS=3D$roms" >> $config_host_mak echo "MAKE=3D$make" >> $config_host_mak echo "PYTHON=3D$python" >> $config_host_mak @@ -2561,6 +2554,12 @@ config_host_mak=3Dtests/tcg/config-host.mak echo "# Automatically generated by configure - do not modify" > $config_ho= st_mak echo "SRC_PATH=3D$source_path" >> $config_host_mak echo "HOST_CC=3D$host_cc" >> $config_host_mak +if test -n "$gdb_bin"; then + gdb_version=3D$($gdb_bin --version | head -n 1) + if version_ge ${gdb_version##* } 9.1; then + echo "HAVE_GDB_BIN=3D$gdb_bin" >> $config_host_mak + fi +fi =20 tcg_tests_targets=3D for target in $target_list; do diff --git a/meson.build b/meson.build index c2adb7caf4..1a4ac4bc60 100644 --- a/meson.build +++ b/meson.build @@ -3710,9 +3710,6 @@ summary_info +=3D {'git': config_host['= GIT']} summary_info +=3D {'make': config_host['MAKE']} summary_info +=3D {'python': '@0@ (version: @1@)'.format(python= .full_path(), python.language_version())} summary_info +=3D {'sphinx-build': sphinx_build} -if config_host.has_key('HAVE_GDB_BIN') - summary_info +=3D {'gdb': config_host['HAVE_GDB_BIN']} -endif summary_info +=3D {'iasl': iasl} summary_info +=3D {'genisoimage': config_host['GENISOIMAGE']} if targetos =3D=3D 'windows' and have_ga @@ -3822,6 +3819,9 @@ foreach target: target_dirs summary_info +=3D {config_cross_tcg['TARGET_NAME']: config_cross_tcg= ['CC']} have_cross =3D true endif + if config_cross_tcg.has_key('HAVE_GDB_BIN') + summary_info +=3D {'gdb': config_cross_tcg['HAVE_GDB_BIN= ']} + endif endif endforeach if have_cross --=20 2.37.2 From nobody Sun Feb 8 06:56:25 2026 Delivered-To: importer@patchew.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=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1663687504; cv=none; d=zohomail.com; s=zohoarc; b=TfFtz38A4nPogIHR+yRKAQWVVJqM8ccITxfK9vq/uyuv4SzqoPZMYvMtOQ+lOMdaDb0rCuEJ/1bAsiOzrZXEVCwvbVH2dVf3UPjW3UUf454nBx08jO2iVVkIz84NfpJwPZQXb8+eThM7a/BiAM1YN/eOuxYeTHUOQJRp3/V54v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663687504; 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; bh=y1PTrX/+ADN5lCXMCjx3EmyRLGAjwLfMgEZlgTcOb6Q=; b=d08BzMbxI3MZUD2bnVpNUAJnIozPKfXuHW1XJ8fbOqJY/103KMb+19IUvxBobD8R8R7C5Ay2t3wlla8jGuVLxUbhw2fBzB9KV55CYlxTvT5T34gKxOPQeEhZcDHLVXbzbCZo7piUHBiheloojFeKbhnGK3GwFU302YOoLVAfXwQ= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663687504735996.1509038785582; Tue, 20 Sep 2022 08:25:04 -0700 (PDT) Received: from localhost ([::1]:45588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaf7M-0007NQ-Eq for importer@patchew.org; Tue, 20 Sep 2022 11:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oacej-0003Hb-DC for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:26 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:15748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaceg-0004p1-0d for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:15 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7xkRm003438; Tue, 20 Sep 2022 12:47:08 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jpw78b6tb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:08 +0000 Received: from pps.filterd (NALASPPMTA03.qualcomm.com [127.0.0.1]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 28KCjwkr012348; Tue, 20 Sep 2022 12:47:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 3jnqmj166y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: from NALASPPMTA03.qualcomm.com (NALASPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28KCl74D013271; Tue, 20 Sep 2022 12:47:07 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-mathbern-lv.qualcomm.com [10.47.235.147]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 28KCl6s1013267 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 4229910) id D8B034DD0; Tue, 20 Sep 2022 09:47:06 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=y1PTrX/+ADN5lCXMCjx3EmyRLGAjwLfMgEZlgTcOb6Q=; b=Sz8sQBV104aSlBxdzV9yu+ooDPTumH+9pSsCTrthY4uvBH29FecbQUmcTcLk55NAphE9 9FuQ3RfvPt2P1wWHDYy3Pvy0rAWKA6YxFq55aqSfuP+lcq34xGB2OM6soV4TSVIG61AP 44q80/4KFrTByXduIyG/mdbC079EE4VLPQ/Y9Uk6Za6Kwu4EQr0TLllINsDHqn6DMmhE OrTQIWFOxiuRagKnaS9Ixnss41YchcZGDsIe8Igf2a+zFOqo+jOXQKRvl/NHUmaSQ44m T4rGcR2O4wv5MeGHemb49Uh0fnipzzo8cXp5l4UR/J/yOVN1gUDuLIVLSEtZHUoa6D63 hA== From: Matheus Tavares Bernardino To: qemu-devel@nongnu.org Cc: bcain@quicinc.com, alex.bennee@linaro.org, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH v3 2/3] gdbstub: only send stop-reply packets when allowed to Date: Tue, 20 Sep 2022 09:47:02 -0300 Message-Id: <07bac78c85e9fef6201ec79f552b7267646b42e9.1663677789.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: mX15OK2L1KfaWlD1yLD5QHQVKGbgx8d0 X-Proofpoint-GUID: mX15OK2L1KfaWlD1yLD5QHQVKGbgx8d0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_04,2022-09-20_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=985 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200074 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; Received-SPF: pass client-ip=205.220.168.131; envelope-from=mathbern@qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1663687506152100001 Content-Type: text/plain; charset="utf-8" GDB's remote serial protocol allows stop-reply messages to be sent by the stub either as a notification packet or as a reply to a GDB command (provided that the cmd accepts such a response). QEMU currently does not implement notification packets, so it should only send stop-replies synchronously and when requested. Nevertheless, it may still issue unsolicited stop messages through gdb_vm_state_change(). Although this behavior doesn't seem to cause problems with GDB itself, it does with other debuggers that implement the GDB remote serial protocol, like hexagon-lldb. In this case, the debugger fails upon an unexpected stop-reply message from QEMU when lldb attaches to it. Instead, let's change the gdbstub to send stop messages only as a response to a previous GDB command that accepts such a reply. Signed-off-by: Matheus Tavares Bernardino --- gdbstub.c | 64 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index cf869b10e3..14b4348c18 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -369,6 +369,7 @@ typedef struct GDBState { GByteArray *mem_buf; int sstep_flags; int supported_sstep_flags; + bool allow_stop_reply; } GDBState; =20 static GDBState gdbserver_state; @@ -412,6 +413,7 @@ static void reset_gdbserver_state(void) g_free(gdbserver_state.processes); gdbserver_state.processes =3D NULL; gdbserver_state.process_num =3D 0; + gdbserver_state.allow_stop_reply =3D 0; } #endif =20 @@ -1484,6 +1486,7 @@ typedef struct GdbCmdParseEntry { const char *cmd; bool cmd_startswith; const char *schema; + bool allow_stop_reply; } GdbCmdParseEntry; =20 static inline int startswith(const char *string, const char *pattern) @@ -1517,6 +1520,7 @@ static int process_string_cmd(void *user_ctx, const c= har *data, } } =20 + gdbserver_state.allow_stop_reply =3D cmd->allow_stop_reply; cmd->handler(params, user_ctx); return 0; } @@ -2013,11 +2017,14 @@ static void handle_v_attach(GArray *params, void *u= ser_ctx) gdbserver_state.g_cpu =3D cpu; gdbserver_state.c_cpu =3D cpu; =20 - g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNA= L_TRAP); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdbserver_state.allow_stop_reply =3D 0; cleanup: - put_strbuf(); + put_strbuf(); + } } =20 static void handle_v_kill(GArray *params, void *user_ctx) @@ -2040,12 +2047,14 @@ static const GdbCmdParseEntry gdb_v_commands_table[= ] =3D { .handler =3D handle_v_cont, .cmd =3D "Cont", .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, .schema =3D "s0" }, { .handler =3D handle_v_attach, .cmd =3D "Attach;", .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, .schema =3D "l0" }, { @@ -2546,10 +2555,13 @@ static void handle_gen_set(GArray *params, void *us= er_ctx) =20 static void handle_target_halt(GArray *params, void *user_ctx) { - g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); - gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNA= L_TRAP); + gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_bu= f); + g_string_append_c(gdbserver_state.str_buf, ';'); + put_strbuf(); + gdbserver_state.allow_stop_reply =3D 0; + } /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2573,7 +2585,8 @@ static int gdb_handle_packet(const char *line_buf) static const GdbCmdParseEntry target_halted_cmd_desc =3D { .handler =3D handle_target_halt, .cmd =3D "?", - .cmd_startswith =3D 1 + .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, }; cmd_parser =3D &target_halted_cmd_desc; } @@ -2584,6 +2597,7 @@ static int gdb_handle_packet(const char *line_buf) .handler =3D handle_continue, .cmd =3D "c", .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, .schema =3D "L0" }; cmd_parser =3D &continue_cmd_desc; @@ -2595,6 +2609,7 @@ static int gdb_handle_packet(const char *line_buf) .handler =3D handle_cont_with_sig, .cmd =3D "C", .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, .schema =3D "l0" }; cmd_parser =3D &cont_with_sig_cmd_desc; @@ -2633,6 +2648,7 @@ static int gdb_handle_packet(const char *line_buf) .handler =3D handle_step, .cmd =3D "s", .cmd_startswith =3D 1, + .allow_stop_reply =3D 1, .schema =3D "L0" }; cmd_parser =3D &step_cmd_desc; @@ -2843,6 +2859,10 @@ static void gdb_vm_state_change(void *opaque, bool r= unning, RunState state) return; } =20 + if (!gdbserver_state.allow_stop_reply) { + return; + } + gdb_append_thread_id(cpu, tid); =20 switch (state) { @@ -2908,6 +2928,7 @@ static void gdb_vm_state_change(void *opaque, bool ru= nning, RunState state) =20 send_packet: put_packet(buf->str); + gdbserver_state.allow_stop_reply =3D 0; =20 /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -3000,6 +3021,7 @@ static void gdb_read_byte(uint8_t ch) { uint8_t reply; =20 + gdbserver_state.allow_stop_reply =3D 0; #ifndef CONFIG_USER_ONLY if (gdbserver_state.last_packet->len) { /* Waiting for a response to the last packet. If we see the start @@ -3162,8 +3184,11 @@ void gdb_exit(int code) =20 trace_gdbstub_op_exiting((uint8_t)code); =20 - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(buf); + if (gdbserver_state.allow_stop_reply) { + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + put_packet(buf); + gdbserver_state.allow_stop_reply =3D 0; + } =20 #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&gdbserver_state.chr, true); @@ -3212,11 +3237,14 @@ gdb_handlesig(CPUState *cpu, int sig) =20 if (sig !=3D 0) { gdb_set_stop_cpu(cpu); - g_string_printf(gdbserver_state.str_buf, - "T%02xthread:", target_signal_to_gdb(sig)); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + if (gdbserver_state.allow_stop_reply) { + g_string_printf(gdbserver_state.str_buf, + "T%02xthread:", target_signal_to_gdb(sig)); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + put_strbuf(); + gdbserver_state.allow_stop_reply =3D 0; + } } /* put_packet() might have detected that the peer terminated the connection. */ @@ -3255,12 +3283,14 @@ void gdb_signalled(CPUArchState *env, int sig) { char buf[4]; =20 - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_state.fd < 0 || + !gdbserver_state.allow_stop_reply) { return; } =20 snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); put_packet(buf); + gdbserver_state.allow_stop_reply =3D 0; } =20 static void gdb_accept_init(int fd) --=20 2.37.2 From nobody Sun Feb 8 06:56:25 2026 Delivered-To: importer@patchew.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=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1663687549; cv=none; d=zohomail.com; s=zohoarc; b=kouGd3Lq+qxiTbiTcWHjQfMPiYLVqBmOvcS5E06eNzBpidwYJImZbzRI6jeJaZpd7PSusszNSUUqbXuZVQH3BfThCwHWMYVJkPyO+lWXzXetaD43ODTuWsh5utVLbmC/GE2lbFO2Jwi0Z44g8Jo/GU0CbakuH6SJbKWKd6H6cf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663687549; 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; bh=lGKe4l4O9tCjS4640g8Z4QS+1KRkCseWg0XW4uUq4sg=; b=Kge6/CYFwXLe99pROaySopb726gWZvsYiubMmndC67YoMkDSXUD2TD0wo5gfwqxzWdynTSbhBB/OY6ugZ0akM8z6bvB5asLyB9TKptipxK1kGgHWWCqfKeRIWufrElL8Ymkpg3/JcB+unXKJbCmqu0zRkjKGd44/LghvZj9oEBk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663687549552950.9722036611112; Tue, 20 Sep 2022 08:25:49 -0700 (PDT) Received: from localhost ([::1]:50304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaf86-0008NL-E6 for importer@patchew.org; Tue, 20 Sep 2022 11:25:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oacen-0003IE-6b for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:29 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:16014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaceg-0004pA-0T for qemu-devel@nongnu.org; Tue, 20 Sep 2022 08:47:16 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7xnwB000545; Tue, 20 Sep 2022 12:47:08 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jq7321mbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:08 +0000 Received: from pps.filterd (NALASPPMTA03.qualcomm.com [127.0.0.1]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 28KCl7Aj013281; Tue, 20 Sep 2022 12:47:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 3jnqmj1670-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: from NALASPPMTA03.qualcomm.com (NALASPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28KCl7Yr013272; Tue, 20 Sep 2022 12:47:07 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-mathbern-lv.qualcomm.com [10.47.235.147]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 28KCl6J7013268 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 12:47:07 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 4229910) id DBEFD4DD2; Tue, 20 Sep 2022 09:47:06 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=lGKe4l4O9tCjS4640g8Z4QS+1KRkCseWg0XW4uUq4sg=; b=LXGQidIsqM1oqaJyHZfo3nCBShFBr2V22Ef0HYAUW1/VLExKy2ifXdMQmbZMFtd1p2Jw jA1i4BYy7M6e2k4r11O1p16DTzUzBJlWHK/0sgnaAwBdUrB3qG5rmYe57XescfyZ2Bzp Xyo00bDPyBKPbPHvyrOJQS2a1/kSyu8eQmzNGL5ES26iGdb0UrzkpxOQboagn3Vm4wKR QHEU6Q3EE/QEKnS/xPSn8Jg1MwZhZu3ImMp1e4ANTyqSTVY1Ve3xVGh8ZYv4OFXJ72Dc URH11dP7rWh7Rjv8tvyFTbXwwJlibIeaZk4MLrCzQmBaZZ/0d7GPhhpO/mHQPRe10L3Z nQ== From: Matheus Tavares Bernardino To: qemu-devel@nongnu.org Cc: bcain@quicinc.com, alex.bennee@linaro.org, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH v3 3/3] gdbstub: add test for untimely stop-reply packets Date: Tue, 20 Sep 2022 09:47:03 -0300 Message-Id: <352d1e6a9290ef7eb9a09e9b647f8d48edcd6ad5.1663677789.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 4Y-9uqdaxSJKxlW_3cgwooIQCY5jcmW_ X-Proofpoint-GUID: 4Y-9uqdaxSJKxlW_3cgwooIQCY5jcmW_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_04,2022-09-20_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200074 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; Received-SPF: pass client-ip=205.220.168.131; envelope-from=mathbern@qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1663687550059100001 Content-Type: text/plain; charset="utf-8" In the previous commit, we modified gdbstub.c to only send stop-reply packets as a response to GDB commands that accept it. Now, let's add a test for this intended behavior. Running this test before the fix from the previous commit fails as QEMU sends a stop-reply packet asynchronously, when GDB was in fact waiting an ACK. Signed-off-by: Matheus Tavares Bernardino --- tests/guest-debug/run-test.py | 16 ++++++++++++---- .../tcg/multiarch/system/Makefile.softmmu-target | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index d865e46ecd..de6106a5e5 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -26,11 +26,12 @@ def get_args(): parser.add_argument("--qargs", help=3D"Qemu arguments for test") parser.add_argument("--binary", help=3D"Binary to debug", required=3DTrue) - parser.add_argument("--test", help=3D"GDB test script", - required=3DTrue) + parser.add_argument("--test", help=3D"GDB test script") parser.add_argument("--gdb", help=3D"The gdb binary to use", default=3DNone) + parser.add_argument("--gdb-args", help=3D"Additional gdb arguments") parser.add_argument("--output", help=3D"A file to redirect output to") + parser.add_argument("--stderr", help=3D"A file to redirect stderr to") =20 return parser.parse_args() =20 @@ -58,6 +59,10 @@ def log(output, msg): output =3D open(args.output, "w") else: output =3D None + if args.stderr: + stderr =3D open(args.stderr, "w") + else: + stderr =3D None =20 socket_dir =3D TemporaryDirectory("qemu-gdbstub") socket_name =3D os.path.join(socket_dir.name, "gdbstub.socket") @@ -77,6 +82,8 @@ def log(output, msg): =20 # Now launch gdb with our test and collect the result gdb_cmd =3D "%s %s" % (args.gdb, args.binary) + if args.gdb_args: + gdb_cmd +=3D " %s" % (args.gdb_args) # run quietly and ignore .gdbinit gdb_cmd +=3D " -q -n -batch" # disable prompts in case of crash @@ -84,13 +91,14 @@ def log(output, msg): # connect to remote gdb_cmd +=3D " -ex 'target remote %s'" % (socket_name) # finally the test script itself - gdb_cmd +=3D " -x %s" % (args.test) + if args.test: + gdb_cmd +=3D " -x %s" % (args.test) =20 =20 sleep(1) log(output, "GDB CMD: %s" % (gdb_cmd)) =20 - result =3D subprocess.call(gdb_cmd, shell=3DTrue, stdout=3Doutput) + result =3D subprocess.call(gdb_cmd, shell=3DTrue, stdout=3Doutput, std= err=3Dstderr) =20 # A result of greater than 128 indicates a fatal signal (likely a # crash due to gdb internal failure). That's a problem for GDB and diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg= /multiarch/system/Makefile.softmmu-target index 625ed792c6..1bb6d89097 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -27,9 +27,23 @@ run-gdbstub-memory: memory --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ "softmmu gdbstub support") =20 +run-gdbstub-untimely-packet: hello + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --gdb-args "-ex 'set debug remote 1'" \ + --output untimely-packet.gdb.out \ + --stderr untimely-packet.gdb.err \ + --qemu $(QEMU) \ + --bin $< --qargs \ + "-monitor none -display none -chardev file$(COMMA)path=3Duntimely-packet= .out$(COMMA)id=3Doutput $(QEMU_OPTS)", \ + "softmmu gdbstub untimely packets") + $(call quiet-command, \ + (! grep -Fq 'Packet instead of Ack, ignoring it' untimely-packet.gdb.err= ), \ + "GREP", "file untimely-packet.gdb.err") + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") endif =20 -MULTIARCH_RUNS +=3D run-gdbstub-memory +MULTIARCH_RUNS +=3D run-gdbstub-memory run-gdbstub-untimely-packet --=20 2.37.2