From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.80]) by sourceware.org (Postfix) with ESMTPS id E46A53858C50 for ; Tue, 13 Feb 2024 15:19:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E46A53858C50 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E46A53858C50 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.94.80 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707837579; cv=pass; b=XzqUiDiXr5YCg0lQrQ8coryK8wY1TEbonbeU8mJBy4Ow94RfgeZbMzhQB5TyfNRCu2GdTNQT60TvxWcSeKPMXY6POYA2TjaPoW5VRC3T354xlL8kVDB6MddBgXaMzSq01c6iyZrrMWfZkcG+dPHxNJYOPJsxIoSr2xj0D0VLH6w= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707837579; c=relaxed/simple; bh=m5RNX6/daktXm7nhibQet5Ta68OyT5G7uFdf/tW3UBY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xYQUH3RR/sp7iGnAh7KrxnkxhhBo+VBJNgJpki5QYg20F65RMmYACGr9+/AoXLUszwLIagxvQusElMCSS23mMDnpNzQQQ7GV5RWwcbaav8sRie78F002h65sSOVxiz6k6LpHU01duG5AFOtaJSOpTlztYz+WnPwxLpmBNiQhOw8= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i2OC8NDRfV4pY9f3x7YBbLO5IE7hTZj+RjQqEMVzfh9MJkLONNdjJYYDP6NSKJy4TDhyf/rYzmqE+FEA6WnA6lKAPSO8xmAON9GNYBkOrIcT5vAHpQ2oO4q5kddiCy8wLgygC0hb4Sv9grBRwHzZEm/gkL74BM1l0kPJIzrZjDkAyJrjDCn/hmKGJMjg6JlXj8mFLCPk8aJrr8I9LoosAZTcvRqadYIfx6X2YGfgz1iTVLhK23mBwzmimsPBSXdV5gB/1bBrEEskof4NC42kXlkT7A0ei76wGJIjeaAbt/5cQ+3LFDVdCIhWENTc7MKZwTUWfgvN+vzPYRqh4k0Vxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Km9ewzjDLMGVUlIa87XZJuFp0EZ3N47ZTKfP9jm2Lb0=; b=mvYViKUwd5KKfvEMi4OJfSXuXCUWnif0I9nctQqA3lN13qBjr3DsRUNOQG6eOTpYjLbd8M878FVfsgRDle3/yXXah5QFdBkRqfkdew0gHd0AlXsStaIxY+F1UI0cjMGdzd57NTLGWdRBMi0cv9bdmKIvmbnUQF3hCoHUYh8sXDig5Kx0B31jaep81dOwrISx4JoLjUwffjjBbmGdhvvdMf7YdpNGZs+XgxZOzqCa3/36ip2tSPGXUqe8+jboeTnBaf1vlvu0j7h3ujaxPa5jrtNZiIDU9NpLBWIiDEytvifS6ZqyRNpJC3xGZsBZDSLqYNAyovUYR8J1PPlmCMbFbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=palves.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Km9ewzjDLMGVUlIa87XZJuFp0EZ3N47ZTKfP9jm2Lb0=; b=ow/7EQ7A8K5hjbXosHmX6n0qr1htR8PcVhUrFZlVGdpObMN0FtpdZla8Zr9fZ/dxZ10mKGcoSjrrImXaYzonTKY2zmfp3GT95T2SIR1g0eMVoMLytyHKXmVRiVbgHQEsrNb8/362lqGlrB82qdI+95FFiVCj6mG8E3FJDos5k0E= Received: from CH5PR04CA0021.namprd04.prod.outlook.com (2603:10b6:610:1f4::14) by CH3PR12MB9195.namprd12.prod.outlook.com (2603:10b6:610:1a3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.24; Tue, 13 Feb 2024 15:19:31 +0000 Received: from CH2PEPF0000009E.namprd02.prod.outlook.com (2603:10b6:610:1f4:cafe::e3) by CH5PR04CA0021.outlook.office365.com (2603:10b6:610:1f4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.41 via Frontend Transport; Tue, 13 Feb 2024 15:19:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000009E.mail.protection.outlook.com (10.167.244.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Tue, 13 Feb 2024 15:19:31 +0000 Received: from khazad-dum (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 13 Feb 2024 09:19:29 -0600 Date: Tue, 13 Feb 2024 15:19:16 +0000 From: Lancelot SIX To: Pedro Alves CC: Subject: Re: [PATCH 1/3] Fix "run" failure with GDBserver Message-ID: <20240213151701.lomtqogce7tuceu5@khazad-dum> References: <20240212200153.882582-1-pedro@palves.net> <20240212200153.882582-2-pedro@palves.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240212200153.882582-2-pedro@palves.net> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000009E:EE_|CH3PR12MB9195:EE_ X-MS-Office365-Filtering-Correlation-Id: a04aa7d7-320f-469b-ee97-08dc2ca72d7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BkTnNXWaFQoEbJ/tRwl8wpUqkefwabaK23PsVnmBxGGeZ83m28jO9Ol6Ln8xH0aDBNAEvfyGT1ttpflHiIG8SO+XMcaBhXcMzOs0gvMlM2nI9CMsn4O3YBdoti/7Ua7AG9fyh/BQX5DUDmTlV9TWpxBcV8VhArtah0iOFUvnJteOFh4gfXglq575QCqgkzi28boT+s9dfXgyLEEZSpSfilGI8nLztyG57iXCYylCmyrWXo1bREkD9ZJnlSy3aVPwoVW3UOB/YDNCN/1mTCAVW1L0u4tLqmOICHa9uUgZowVlDS1qkD4NAjLq2BQ7m3kfAN37OPQza4LtV3U1Lj6a2QclR4YgoRBq6OPV2dN4LgJCKr+to8KDxgBALJOPwqHL4vvcozE4tSxa80RzyzK9n7v5C6xxYff1+OGT1pN+ARQreRMFUeaXwV1OmVel/zjvPtbVVSCwyS9v49MO8DWwI6nGuAJrX949xBgTdz6Dn8pBF61bELf+anZsDycQjLhvfxgq6l3e+zFgJgFuka/IlSo0GwDd/2H0a0sLGOB7i5Xebaixi8mIXGRz7Q24Cqu05OBQAubZPzDRiIsuDAEeHg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(39860400002)(396003)(136003)(346002)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(46966006)(36840700001)(40470700004)(41300700001)(426003)(478600001)(83380400001)(70206006)(336012)(70586007)(26005)(5660300002)(8936002)(6916009)(4326008)(16526019)(8676002)(1076003)(316002)(9686003)(86362001)(82740400003)(356005)(6666004)(81166007)(2906002)(55016003)(33716001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 15:19:31.3662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a04aa7d7-320f-469b-ee97-08dc2ca72d7f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000009E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9195 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Pedro, On Mon, Feb 12, 2024 at 08:01:51PM +0000, Pedro Alves wrote: > If starting the inferior process with "run" (vRun packet) fails, > GDBserver throws an error that escapes all the way to the top level. > When an error escapes all the way like that, GDBserver interprets it > as a disconnection, and either goes back to waiting for a new GDB > connection, or exits, if --once was specified. > > E.g., with the testcase program added by this commit, we see: > > On GDB side: > > ... > (gdb) tar extended-remote :999 > ... > Remote debugging using :9999 > (gdb) r > Starting program: > Running ".../gdb.base/run-fail-twice/run-fail-twice.nox" on the remote target failed > (gdb) > > On GDBserver side: > > $ gdbserver --once --multi :9999 > Remote debugging from host 127.0.0.1, port 34344 > bash: line 1: .../gdb.base/run-fail-twice/run-fail-twice.nox: Permission denied > bash: line 1: exec: .../gdb.base/run-fail-twice/run-fail-twice.nox: cannot execute: Permission denied > gdbserver: During startup program exited with code 126. > $ # gdbserver exited > > This is wrong, as we've connected with extended-remote/--multi. > GDBserver should just report an error to vCont, and continue connected > to GDB, waiting for other commands. > > This commit fixes GDBserver by catching the error locally in > handle_v_run. > > Change-Id: Ib386f267522603f554b52a885b15229c9639e870 > --- > gdb/testsuite/gdb.base/run-fail-twice.exp | 67 +++++++++++++++++++++++ > gdbserver/server.cc | 10 +++- > 2 files changed, 76 insertions(+), 1 deletion(-) > create mode 100644 gdb/testsuite/gdb.base/run-fail-twice.exp > Looks like you forgot the gdb/testsuite/gdb.base/run-fail-twice.c file? > diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp > new file mode 100644 > index 00000000000..2fda5c9fde5 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/run-fail-twice.exp > @@ -0,0 +1,67 @@ > +# Copyright 2024 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# Test doing a "run" that fails, and then another "run". > + > +# The purpose of this testcase is to test the "run" command. If we > +# cannot use it, then there is no point in running this testcase. > +require !use_gdb_stub > + > +standard_testfile > + > +if {[build_executable "failed to build" $testfile $srcfile {debug}]} { > + return -1 > +} > + > +proc test_run {testname} { > + gdb_run_cmd > + gdb_test_multiple "" $testname { > + -re -wrap "During startup program exited with code 126\\." { > + # What we get on GNU/Linux. > + pass $gdb_test_name > + } > + -re -wrap "Error creating process.*" { > + # What we get on Windows. > + pass $gdb_test_name > + } > + -re -wrap "Running .* on the remote target failed" { > + # What we get with older GDBserver and other remote > + # targets. > + pass $gdb_test_name > + } > + } > +} > + > +proc_with_prefix test {} { > + global gdb_prompt binfile > + > + clean_restart $binfile > + > + gdb_test_no_output "set confirm off" > + > + gdb_remote_download host $binfile $binfile.nox > + remote_exec target "chmod \"a-x\" $binfile.nox" > + gdb_test "exec-file $binfile.nox" \ Couldn't you use gdb_test_no_output and remove the 2nd argument? > + "" \ > + "exec-file \$binfile.nox" > + gdb_test "set remote exec-file $binfile.nox" \ > + "" \ Same here. > + "set remote exec-file \$binfile.nox" > + > + test_run "bad run 1" > + test_run "bad run 2" > +} > + > +test > diff --git a/gdbserver/server.cc b/gdbserver/server.cc > index e02cdb83b51..0967b194376 100644 > --- a/gdbserver/server.cc > +++ b/gdbserver/server.cc > @@ -3025,7 +3025,15 @@ handle_v_run (char *own_buf) > free_vector_argv (program_args); > program_args = new_argv; > > - target_create_inferior (program_path.get (), program_args); > + try > + { > + target_create_inferior (program_path.get (), program_args); > + } > + catch (const gdb_exception_error &exception) > + { > + sprintf (own_buf, "E.%s", exception.what ()); > + return; > + } > > if (cs.last_status.kind () == TARGET_WAITKIND_STOPPED) > { > > -- > 2.43.0 > Best, Lancelot