From patchwork Mon Dec 14 15:30:07 2020 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: 1416013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=mAkzLs9U; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CvlnH0b73z9sSf for ; Tue, 15 Dec 2020 02:34:43 +1100 (AEDT) Received: from localhost ([::1]:47840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kops1-0003ey-3V for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:34:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopnz-0007pf-LW for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:32 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopnm-000658-Qf for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:31 -0500 Received: by mail-wm1-x343.google.com with SMTP id v14so14110312wml.1 for ; Mon, 14 Dec 2020 07:30:18 -0800 (PST) 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=c3huyqy8+fYU69WXa9m/cHIDpA578AI7lcvIx56XNmM=; b=mAkzLs9UgdBoP7RQNc66cLgZeHIiesJ1CyiaOdGMwCIu4wAnDOtRV9xD9XmZJ+j+Rz 1uOG/ZgnMOMUJd8UDuUeXRdZXs4lhmekKW0QlPKFg8bmJEv9J78QhHcU1xyYPG2UNE7e 5/O2/8bsSOsa4YK0hNafayu9IG6dMIj2tJ0yP9/Ru6bOpTd4sEZ3Ho4GVG3ULhtlAJpc jhwwgOmkueht0AuOe1eHbIq78iz/CjEsukIQ8dE9y8kb2gOcM4Ks2g7RwWIrJxHT7Ak4 OvOquxQkyjVDnbQipjxFPwtGDmrZtN3JMvS1aY89kaO2wr24IracbCEGAqUKuvpXPTXg Mrlg== 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=c3huyqy8+fYU69WXa9m/cHIDpA578AI7lcvIx56XNmM=; b=b5ApZ+AGeTrDbfd2GrsDY/caNZZtCZA4z3TF58DJOZNIhEfdMlsJS1YrMdWw1D5bse UwtGoXFzHa+92/CHQvgNWv7sbcQ+w7x0/e6ZJRio7+XIzN4g/cXomRUXNs3RBHAxmfMi j4YJz+GmoSesbdql+DyJQNjqkmkie4BzUHAoxq7fjAaXZzoLde3r4bmTjLtbIiDPgDK8 7QGg0N/9toOB41KK1hRLlv6YBq3HVGv3R/T7fCJoW+hyHkuFzKdxJtziRnkTUTmjaVpq Cgi34bEb5Zk6BdKKJRqqnybKvJ4/xpyWNoORig0gnkqg5KVIN2or3fg1RXv3k3rLk1G0 FcEA== X-Gm-Message-State: AOAM530EzwH+d1i65wF6Bist8bAwq5domSqoBjLtwQ9NGXG/TrP/yjEE JydknHXNyIOPDDD8QwR6NWIuZA== X-Google-Smtp-Source: ABdhPJy/gX5sf4+E19Mf8KbplJeO2QvK1rK38ZXBESSosj0CismXNjxglrSz25kTKS4j8Dv02LcY1A== X-Received: by 2002:a1c:b3c3:: with SMTP id c186mr9286236wmf.169.1607959815940; Mon, 14 Dec 2020 07:30:15 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z22sm29482877wml.1.2020.12.14.07.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:13 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BFFEE1FF87; Mon, 14 Dec 2020 15:30:12 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 1/6] test/guest-debug: echo QEMU command as well Date: Mon, 14 Dec 2020 15:30:07 +0000 Message-Id: <20201214153012.12723-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This helps with debugging. Signed-off-by: Alex Bennée --- tests/guest-debug/run-test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 71c5569054..0c4f5c3808 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -53,6 +53,7 @@ if __name__ == '__main__': cmd = "%s %s -g %s %s" % (args.qemu, args.qargs, socket_name, args.binary) + print("QEMU CMD: %s" % (cmd)) inferior = subprocess.Popen(shlex.split(cmd)) # Now launch gdb with our test and collect the result From patchwork Mon Dec 14 15:30:08 2020 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: 1416012 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=AgTJa4H2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cvln45bl1z9sSf for ; Tue, 15 Dec 2020 02:34:30 +1100 (AEDT) Received: from localhost ([::1]:46038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koprm-0002wR-St for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:34:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopnp-0007gs-BL for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:21 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:35008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopnn-000667-LW for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:21 -0500 Received: by mail-wr1-x42e.google.com with SMTP id r3so16865381wrt.2 for ; Mon, 14 Dec 2020 07:30:19 -0800 (PST) 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=tRKsmU0qEAtPOv4DujHsfCCXKQEIa7oRhg2frJNfMMw=; b=AgTJa4H2j87RYqtKV4o6KTnuDtE01uatIL8Yb/x2iMIpRe7PPcjiGuUst/jXT9juwZ GPZYXtNL2QF1+Mc89t8RgjYlEyMclVWP2JhdrJZ5gr8wFHjHQvLvTF0QI/f/tx2Uods/ UaTw8AVd5sKfrGrDmGgRIUqR+fUrpWlYOWsBnNYVz6FovS6/Fxd7i1rRMSfvkniU50ED mZ76IFXg1nowN/Nc1tV/+iOA7d7XaUxLeaXYPydrUEXsz2mdL0ciKDAw20E4PrAcLm0s kuct9Ib2Av1hItHOkFE/8J5wJUzflDXGjSYXCpGDX7hNlv8vXZQr3C60nQHeWRXlwJhv jnUw== 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=tRKsmU0qEAtPOv4DujHsfCCXKQEIa7oRhg2frJNfMMw=; b=Mu5AC3px/qihKUxPGlk1Z3n8oZzXOQr9PAJF6M3/kOb8m1Ugu+/oT7KoVk9LVHMfsk HE3iuayENJOpGjZTUk2HhLco3fBILT3MYj8MvCUnMU1yRxkpADNmJnbY7xQocs627Yfe dpf4rBex/GRcX584UJZG+6G2WzHPpPXr7JN8EUCG+Fbhm3fN7vGmfSCD/iCa/QTPBEk2 6qiQYwrLO51nA8zmC+aYCroeQJrAfDAQzeihhUEOdqGOp/9kYPMl9xHbfcdi2M7FenuM jAjyUAm+pbcu8oOMwDY8jHP5njhyfCtiIjk6K3uSlPM+ezvVonVVEBlrQ8tPBfTVgkLH r5IA== X-Gm-Message-State: AOAM530tyOU7pw8IaoM0EzQLatp8JWFQNvZ5rIczSo9IgY5kEC8JjuSS T1jWHstimcdhPSxdJStRM/NuRE3rxKtEVQ== X-Google-Smtp-Source: ABdhPJxB0H8zV5opZvOPXInKOsZc2Byz2qeGgEMLJLrdloZenk8LbA/7W0lKyuD4CIrgIRDy1muxgw== X-Received: by 2002:adf:fd42:: with SMTP id h2mr15513769wrs.142.1607959817966; Mon, 14 Dec 2020 07:30:17 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q15sm31706534wrw.75.2020.12.14.07.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:13 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D45CE1FF8C; Mon, 14 Dec 2020 15:30:12 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 2/6] configure: gate our use of GDB to 8.3.1 or above Date: Mon, 14 Dec 2020 15:30:08 +0000 Message-Id: <20201214153012.12723-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Certain earlier versions of GDB have (possibly distro) derived issues when running against multiarch guests. Also given the problem of clashing ports it is preferable to use socket comms rather than TCP ports for testing. Signed-off-by: Alex Bennée --- configure | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 11f5878a59..f6347382e9 100755 --- a/configure +++ b/configure @@ -6721,8 +6721,11 @@ if test "$plugins" = "yes" ; then fi fi -if test -n "$gdb_bin" ; then - echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak +if test -n "$gdb_bin"; then + gdb_version=$($gdb_bin --version | head -n 1) + if version_ge ${gdb_version##* } 8.3.1; then + echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak + fi fi if test "$secret_keyring" = "yes" ; then From patchwork Mon Dec 14 15:30:09 2020 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: 1416007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=dVi7Pbbk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cvljj2Wq6z9sS8 for ; Tue, 15 Dec 2020 02:31:37 +1100 (AEDT) Received: from localhost ([::1]:37604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kopp1-0007mf-9Q for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:31:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopnr-0007kb-MF for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:23 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:35013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopno-00066e-UP for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:23 -0500 Received: by mail-wr1-x433.google.com with SMTP id r3so16865450wrt.2 for ; Mon, 14 Dec 2020 07:30:20 -0800 (PST) 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=bXB03b69IRRD0RMhlaFUm5Vdm4BgZtmItrqWS1AnHsY=; b=dVi7PbbkiKDb1HjXH6UjjVarCGWe4nKSZyGrcWMJe/VTXfJtjQB/V6TrPj2j2hSGnu 4YfhnwOur0SSDNsMgIOlBSP0RKhz1XQm+ZtWN/lmKuSjBu3qJOaTjuIN5FtDqXCvWKtv B0rtlp8kgP3e6C7F0u9sUEqtD1i8umnCEcuViRhaYlEWKojRU/c+mvsIw2dsmvD/b/tC 5Dc1VMIY3yr+/rPpmZVZZnfkSCo+xQUx11IFw/sW9Ale5egYV3sJlYUrQCRvA369DpNw IIt2soRTYU+BqsO4no/dsPDkz9W4fy7BrhH30UeoK9EcmyLVjn5M/Ryv1ZEHSlXKAM9x 1Mgw== 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=bXB03b69IRRD0RMhlaFUm5Vdm4BgZtmItrqWS1AnHsY=; b=GYP5lkaRowa9ZzNCqmQ1u6RvQqt4bQDRLbo6nLjOeyQwGtav5tutI4A/ylITMV4IS2 9PLedMdxeclB9NdHN0lbhNOasOwAzHD4ajLQ5J8dnPy0e8EdWZfk7nP2klWrJeFaKvh4 OvSO2hejngnnEAJOhFnarsarazXYHDrrtkJdh8QzFuHTk7gy1kJQabBpwwT2p/CLdyIQ ACrK3aFecaxTHT/oqEtMYJIkCMYrqYM7BCqAK1yPjCue5PhTh1/2Yq81iTx0rOSCsSM3 DAG+tvWMFyNu03M6Gq0VJlNfAV75DF9y7IkMUpkvEySrirLMSzDYximl/haPG6/sFBoe oYwg== X-Gm-Message-State: AOAM531C74OoUNz3W4KJAPzHCs7gfISxzyPHuAzBiOlpB6GyGAmp7BT6 RPyvQD6ZwvpgO7cRf8pRi550lXaZghkQUg== X-Google-Smtp-Source: ABdhPJxdIpHLalPs1uM2w/z8LK20MklZ6BE4jdaAm6nzYFqWooN46gFUTNF5n5464IbTudVCVEoWrQ== X-Received: by 2002:adf:aa4a:: with SMTP id q10mr28768816wrd.276.1607959819442; Mon, 14 Dec 2020 07:30:19 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h98sm35454468wrh.69.2020.12.14.07.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EE9141FF8F; Mon, 14 Dec 2020 15:30:12 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 3/6] gdbstub: add support to Xfer:auxv:read: packet Date: Mon, 14 Dec 2020 15:30:09 +0000 Message-Id: <20201214153012.12723-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Lirong Yuan Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Lirong Yuan This allows gdb to access the target’s auxiliary vector, which can be helpful for telling system libraries important details about the hardware, operating system, and process. Signed-off-by: Lirong Yuan [AJB: minor tweaks to test case, update MAINTAINERS] Signed-off-by: Alex Bennée Message-Id: <20200730193932.3654677-1-yuanzi@google.com> Reviewed-by: Richard Henderson --- gdbstub.c | 54 ++++++++++++++++++ MAINTAINERS | 1 + tests/tcg/multiarch/Makefile.target | 9 ++- .../multiarch/gdbstub/test-qxfer-auxv-read.py | 57 +++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py diff --git a/gdbstub.c b/gdbstub.c index f19f98ab1a..ec8daa002b 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2172,6 +2172,12 @@ static void handle_query_supported(GdbCmdContext *gdb_ctx, void *user_ctx) ";ReverseStep+;ReverseContinue+"); } +#ifdef CONFIG_USER_ONLY + if (gdbserver_state.c_cpu->opaque) { + g_string_append(gdbserver_state.str_buf, ";qXfer:auxv:read+"); + } +#endif + if (gdb_ctx->num_params && strstr(gdb_ctx->params[0].data, "multiprocess+")) { gdbserver_state.multiprocess = true; @@ -2233,6 +2239,46 @@ static void handle_query_xfer_features(GdbCmdContext *gdb_ctx, void *user_ctx) gdbserver_state.str_buf->len, true); } +#ifdef CONFIG_USER_ONLY +static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + TaskState *ts; + unsigned long offset, len, saved_auxv, auxv_len; + const char *mem; + + if (gdb_ctx->num_params < 2) { + put_packet("E22"); + return; + } + + offset = gdb_ctx->params[0].val_ul; + len = gdb_ctx->params[1].val_ul; + ts = gdbserver_state.c_cpu->opaque; + saved_auxv = ts->info->saved_auxv; + auxv_len = ts->info->auxv_len; + mem = (const char *)(saved_auxv + offset); + if (offset > auxv_len) { + put_packet("E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len = (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < auxv_len - offset) { + g_string_assign(gdbserver_state.str_buf, "m"); + memtox(gdbserver_state.str_buf, mem, len); + } else { + g_string_assign(gdbserver_state.str_buf, "l"); + memtox(gdbserver_state.str_buf, mem, auxv_len - offset); + } + + put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} +#endif + static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) { put_packet(GDB_ATTACHED); @@ -2338,6 +2384,14 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "s:l,l0" }, +#ifdef CONFIG_USER_ONLY + { + .handler = handle_query_xfer_auxv, + .cmd = "Xfer:auxv:read::", + .cmd_startswith = 1, + .schema = "l,l0" + }, +#endif { .handler = handle_query_attached, .cmd = "Attached:", diff --git a/MAINTAINERS b/MAINTAINERS index a83416d54c..9dedc37be4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2295,6 +2295,7 @@ R: Philippe Mathieu-Daudé S: Maintained F: gdbstub* F: gdb-xml/ +F: tests/tcg/multiarch/gdbstub/ Memory API M: Paolo Bonzini diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index cb49cc9ccb..c8cdb1e04d 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -54,7 +54,14 @@ run-gdbstub-sha1: sha1 --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ "basic gdbstub support") -EXTRA_RUNS += run-gdbstub-sha1 +run-gdbstub-qxfer-auxv-read: sha1 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ + "basic gdbstub qXfer:auxv:read support") + +EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read endif diff --git a/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py new file mode 100644 index 0000000000..d91e8fdf19 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/test-qxfer-auxv-read.py @@ -0,0 +1,57 @@ +from __future__ import print_function +# +# Test auxiliary vector is loaded via gdbstub +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +failcount = 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print ("PASS: %s" % (msg)) + else: + print ("FAIL: %s" % (msg)) + global failcount + failcount += 1 + +def run_test(): + "Run through the tests one by one" + + auxv = gdb.execute("info auxv", False, True) + report(isinstance(auxv, str), "Fetched auxv from inferior") + report(auxv.find("sha1"), "Found test binary name in auxv") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + arch = inferior.architecture() + print("ATTACHED: %s" % arch.name()) +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +if gdb.parse_and_eval('$pc') == 0: + print("SKIP: PC not set") + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except (gdb.error): + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + pass + +print("All tests complete: %d failures" % failcount) +exit(failcount) From patchwork Mon Dec 14 15:30:10 2020 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: 1416021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=JzYtmShz; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cvlqj3dDXz9sTK for ; Tue, 15 Dec 2020 02:36:49 +1100 (AEDT) Received: from localhost ([::1]:52922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kopu3-0005nK-FT for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:36:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopnt-0007ml-1d for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:25 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:36972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopnr-000684-3c for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:24 -0500 Received: by mail-wm1-x344.google.com with SMTP id q75so15640892wme.2 for ; Mon, 14 Dec 2020 07:30:22 -0800 (PST) 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=dATvnSiNbzH3IwDni97PXBq4aN519xmIXNmYmOWL0lM=; b=JzYtmShzwL9A2ZTyH1kSjm5gGQN7L8LcRZt46y1GQnuOZACxjN28FtToulywsIbnXm dvsh/t1tR1VA0squD/FqRbjKpoe2Gf0Zti8WBNmE9zYUeqAOnXjMNKgvLQFZO/d3CvhA hDaofg0/rZqhioWsROOmx+CeeEQl9BXGQkKamjvzlP0Vuvu9v/xQ+lcui1le5yU2E6li rYTB8ffpET0lI7jjSUrMtZriNgoobsyY94y72/ijMDD9xZP2e8kA9gw3oJkL3RjTiIox j4MFwd/Ir0WJmI4/pjTKJxDjvabl3s1j9uEEthr5XvRXxr4E1if1lgPGfVBzCHzWacHz i6Wg== 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=dATvnSiNbzH3IwDni97PXBq4aN519xmIXNmYmOWL0lM=; b=B+NmgVT+3DlZP1v20lpwFmDpnz/jHV7ELoCHFB+9bWGzzG4oSYUCeTIpNfPBXiAnEG 9KPBWqxpyo0bdIMe7fvQeOLnHSYziHcK/c+NuzcqEsz0naVt4KVEAC3+WIdxqPfFKyp7 TjR/QtH7jer9Z6qqCDM3D2y9Dw06IjkJmo6PFeMPm3twKv9X/uX5OMfWwN8LjIBxpJp3 6MBaN8BB6a514f6fT3VN2zv+frxQiHF87mD6CoGhl5PTVx9ttLIDqp+i/STSWCRLMsG/ ximFtazqyu4bbMxww/by5crDoJdVvwLP/FeMDDoJ+Vb+HQWFZA/JM+deqZZK+stsouim mU1Q== X-Gm-Message-State: AOAM5320eTGYywohfIBAGkmt+Fxb7JFDDdMT5G2tB0y7/InNhST3K2sj +zD0yk+8QFYnDibV/nnqG+rS/mbyDPbMOw== X-Google-Smtp-Source: ABdhPJwiuC6LSFF2lkY1be7Xfs4N0LTBAVB0PrzO2H07I7WiRrfV5uxzmu+2Q/jgEh2avFVjx1eIAQ== X-Received: by 2002:a1c:2c4:: with SMTP id 187mr28998203wmc.187.1607959821625; Mon, 14 Dec 2020 07:30:21 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e15sm27711843wrx.86.2020.12.14.07.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B1131FF90; Mon, 14 Dec 2020 15:30:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 4/6] gdbstub: drop CPUEnv from gdb_exit() Date: Mon, 14 Dec 2020 15:30:10 +0000 Message-Id: <20201214153012.12723-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Marek Vasut , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Chris Wulff , Laurent Vivier , "open list:ARM TCG CPUs" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" gdb_exit() has never needed anything from env and I doubt we are going to start now. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 2 +- bsd-user/syscall.c | 6 +++--- gdbstub.c | 2 +- linux-user/exit.c | 2 +- target/arm/arm-semi.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 94d8f83e92..492db0f512 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -46,7 +46,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); int use_gdb_syscalls(void); void gdb_set_stop_cpu(CPUState *cpu); -void gdb_exit(CPUArchState *, int); +void gdb_exit(int); #ifdef CONFIG_USER_ONLY /** * gdb_handlesig: yield control to gdb diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index d38ec7a162..adc3d21b54 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -333,7 +333,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef CONFIG_GPROF _mcleanup(); #endif - gdb_exit(cpu_env, arg1); + gdb_exit(arg1); qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); @@ -435,7 +435,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef CONFIG_GPROF _mcleanup(); #endif - gdb_exit(cpu_env, arg1); + gdb_exit(arg1); qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); @@ -514,7 +514,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1, #ifdef CONFIG_GPROF _mcleanup(); #endif - gdb_exit(cpu_env, arg1); + gdb_exit(arg1); qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); diff --git a/gdbstub.c b/gdbstub.c index ec8daa002b..f6566c7b82 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3068,7 +3068,7 @@ static void gdb_read_byte(uint8_t ch) } /* Tell the remote gdb that the process has exited. */ -void gdb_exit(CPUArchState *env, int code) +void gdb_exit(int code) { char buf[4]; diff --git a/linux-user/exit.c b/linux-user/exit.c index 1594015444..70b344048c 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -34,6 +34,6 @@ void preexit_cleanup(CPUArchState *env, int code) #ifdef CONFIG_GCOV __gcov_dump(); #endif - gdb_exit(env, code); + gdb_exit(code); qemu_plugin_atexit_cb(); } diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index c892e0e674..5d5654bec0 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -1100,7 +1100,7 @@ target_ulong do_arm_semihosting(CPUARMState *env) */ ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1; } - gdb_exit(env, ret); + gdb_exit(ret); exit(ret); case TARGET_SYS_SYNCCACHE: /* diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 8e5fbfc8fa..6230a789b6 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -194,7 +194,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) args = env->dregs[1]; switch (nr) { case HOSTED_EXIT: - gdb_exit(env, env->dregs[0]); + gdb_exit(env->dregs[0]); exit(env->dregs[0]); case HOSTED_OPEN: GET_ARG(0); diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index d7a80dd303..e508b2fafc 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -215,7 +215,7 @@ void do_nios2_semihosting(CPUNios2State *env) args = env->regs[R_ARG1]; switch (nr) { case HOSTED_EXIT: - gdb_exit(env, env->regs[R_ARG0]); + gdb_exit(env->regs[R_ARG0]); exit(env->regs[R_ARG0]); case HOSTED_OPEN: GET_ARG(0); From patchwork Mon Dec 14 15:30:11 2020 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: 1416011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qyFFzz0a; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CvlmP1sWYz9sS8 for ; Tue, 15 Dec 2020 02:33:57 +1100 (AEDT) Received: from localhost ([::1]:44000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koprH-00026W-81 for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:33:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopnu-0007nh-Fp for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:29 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:37083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopnr-00068K-US for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:26 -0500 Received: by mail-wr1-x443.google.com with SMTP id i9so16845314wrc.4 for ; Mon, 14 Dec 2020 07:30:23 -0800 (PST) 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=AyTGjsVZ1hUFkxFr4OcBIz/5XjlUR5r506a9Y66UF4g=; b=qyFFzz0a2jZAVVfg+/cRN9uXPbnwXylhX4jyu7Xct4OEJj01h4Dn5HT8mzmZT4x2T/ 24OFOR/ZzTVmpjZeyXb4Qnl/aTyS9jLRP4/MM1oahnMmTO3+9/l1bKho/mp36fAT8Gx7 W8gZtIAr+0uu1rzH3zhw0G8iCYid7poMQaNE0pqn3eMiMYAxjQj/UK474UKyFXO3fW3L wnkPudjXV3ZMOKSw273e17xB1VJE020m24s6t0nNmeNv1bi+phW6OQ/s8AqK3ea1rljA 6YAv75Lfpvn2dLmklC5DwNzmydBD2vpMrN6KN/nPLB+oMUOcWr2SEnQ4NizxJbD7epef N2UA== 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=AyTGjsVZ1hUFkxFr4OcBIz/5XjlUR5r506a9Y66UF4g=; b=M5fMjByRQUyMex7EajteE2zxh9a9FYIvyZx698BeaAFu/r45f5DI8HvJ+cde9CTTfk VyrXD0QROZ/9xZeOf3tHq5SFc5zh6V76t1qEFOmygM4bbJSeoGVaAsZpsA09QR5OiGXn 59oUcNwg7qtKX1FEQ/ZJ5RlgLiXC692kPgN23OkipKKrvlMMocHBZHE7kp5Eri14EmD7 qGck1ppEP+GZSlApkXvb8tEJrDPYddqlreOZFaPXgAll5nRD0sYWhkGxRWXIquMLlcZG 3zauzf4dAzs0uxhv1cdIWGBmpLW//9iK0eOZGMxjX5Apu4zPeOcd6QENbp4weF10sAkN B/1A== X-Gm-Message-State: AOAM5309OajbRy+NIQqJWr1qui8dQRSpRcLuxRG/FCLAE+7u1OvNW4Xu aGmUL/R2eb3pOOB0GTJSMt9voA== X-Google-Smtp-Source: ABdhPJzyi2/dW8Ij2uzdJ7M6K2eoWkn39q0G35bC6oGXtfnPyAauG7N75l0+XKgfie/YuWSwxfiaig== X-Received: by 2002:adf:df03:: with SMTP id y3mr22786495wrl.102.1607959822548; Mon, 14 Dec 2020 07:30:22 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u66sm32040538wmg.30.2020.12.14.07.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 340FE1FF91; Mon, 14 Dec 2020 15:30:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 5/6] gdbstub: drop gdbserver_cleanup in favour of gdb_exit Date: Mon, 14 Dec 2020 15:30:11 +0000 Message-Id: <20201214153012.12723-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Despite it's name it didn't actually clean-up so let us document gdb_exit() better and use that. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- include/exec/gdbstub.h | 14 +++++++++++--- gdbstub.c | 7 ------- softmmu/vl.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 492db0f512..ff0b7bc45e 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -46,7 +46,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); int use_gdb_syscalls(void); void gdb_set_stop_cpu(CPUState *cpu); -void gdb_exit(int); + +/** + * gdb_exit: exit gdb session, reporting inferior status + * @code: exit code reported + * + * This closes the session and sends a final packet to GDB reporting + * the exit status of the program. It also cleans up any connections + * detritus before returning. + */ +void gdb_exit(int code); + #ifdef CONFIG_USER_ONLY /** * gdb_handlesig: yield control to gdb @@ -187,8 +197,6 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len) */ int gdbserver_start(const char *port_or_device); -void gdbserver_cleanup(void); - /** * gdb_has_xml: * This is an ugly hack to cope with both new and old gdb. diff --git a/gdbstub.c b/gdbstub.c index f6566c7b82..7172f063a1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3547,13 +3547,6 @@ int gdbserver_start(const char *device) return 0; } -void gdbserver_cleanup(void) -{ - if (gdbserver_state.init) { - put_packet("W00"); - } -} - static void register_types(void) { type_register_static(&char_gdb_type_info); diff --git a/softmmu/vl.c b/softmmu/vl.c index e6e0ad5a92..0694a1d602 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4509,7 +4509,7 @@ void qemu_init(int argc, char **argv, char **envp) void qemu_cleanup(void) { - gdbserver_cleanup(); + gdb_exit(0); /* * cleaning up the migration object cancels any existing migration From patchwork Mon Dec 14 15:30:12 2020 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: 1416020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=QVkwCJ/j; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cvlq81PlKz9sS8 for ; Tue, 15 Dec 2020 02:36:20 +1100 (AEDT) Received: from localhost ([::1]:51096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kopta-0004xL-70 for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2020 10:36:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kopny-0007o2-Iu for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:30 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:52520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kopnu-00068a-2I for qemu-devel@nongnu.org; Mon, 14 Dec 2020 10:30:30 -0500 Received: by mail-wm1-x343.google.com with SMTP id a6so14110861wmc.2 for ; Mon, 14 Dec 2020 07:30:25 -0800 (PST) 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=mswVJ8W6L1K/A6VuFf51dF/y+gVp/RoCPsfkvo9QLzE=; b=QVkwCJ/j3zPIV4YA1tBPzveprpEbQjG+cxzTzsAUbIdpiDQPZfCdu27TyzapPAHyK6 x8VglSx26Z+Qh1nF8zqljmNUOYv5gSGDgIbjQ56qOZIRCvS3oSHHFj/a5naNNeoDaw3T nXVj7Q2xp4wtpts9rqBOxK+zvS0GyCDq0nNewRodU+1k2fPx0K4Yk/L1RchsyzF8kBxD aqtJFG+UdvWUvJRU7wKpyICezroRgzPUN5ie56b+84xxOc4+R9tByTx7+EtZcO+sF+2c Rig2ZmvKtHji14K2+x25p5e0+bo0rkjtWC+kfiGm5/7AXWqqsusEMoLPtFZDLbAcKvmg gk1w== 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=mswVJ8W6L1K/A6VuFf51dF/y+gVp/RoCPsfkvo9QLzE=; b=MmPUBWrr+T+m+9/aFuJr/7aWl9Hv/Wh+D+GiPAIZ79yYz42J20Lq14OQGdD5sNbA79 O7lSNTGhWukevbgQHEiXBVtMsPcHVXHvflZjc2n9iwU9+fwKj/KAcnK53N1cMvGeDpa8 3JhN3lz8hakrqHHUoV02eKopvC/Es1AemL3qdQeme9qU3UeYbqi5qD5kn+wj8O6pxop6 XX+skAyF74WLNUtNGwlU0Hby6sQerDNC7hIaihcpB87fQAToBAaTRkTupfIwpoBnNovB rDMEgSiI9oJKVZ7KwcrWUJc7xeEAh1iB0/jIcBUCCrqMJYEefKA9Mp7YCAsDsoDjSUHX zIUw== X-Gm-Message-State: AOAM530sNQsMvyToiZj6+qM1X09nC/XQo6Aevn3M+ryzN88ok3u8NUTr sdrtQ0O7A0jF1BIwhaAKzYDXfg== X-Google-Smtp-Source: ABdhPJwonk04q+wMmGuxNV4GL6KGT9uZoVdun8MW0QA6mbXtO3SiN6ZAIvgNYRCdNRILWGMYNtfh8A== X-Received: by 2002:a1c:a785:: with SMTP id q127mr23794528wme.25.1607959824657; Mon, 14 Dec 2020 07:30:24 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a144sm31463691wmd.47.2020.12.14.07.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 07:30:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 494341FF92; Mon, 14 Dec 2020 15:30:13 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 6/6] gdbstub: ensure we clean-up when terminated Date: Mon, 14 Dec 2020 15:30:12 +0000 Message-Id: <20201214153012.12723-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201214153012.12723-1-alex.bennee@linaro.org> References: <20201214153012.12723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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?A?= =?utf-8?q?lex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If you kill the inferior from GDB we end up leaving our socket lying around. Fix this by calling gdb_exit() first. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- gdbstub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 7172f063a1..61fe2360e3 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1978,6 +1978,7 @@ static void handle_v_kill(GdbCmdContext *gdb_ctx, void *user_ctx) /* Kill the target */ put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); + gdb_exit(0); exit(0); } @@ -2539,6 +2540,7 @@ static int gdb_handle_packet(const char *line_buf) case 'k': /* Kill the target */ error_report("QEMU: Terminated via GDBstub"); + gdb_exit(0); exit(0); case 'D': {