From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YR1mDapdE2kAljYAWB0awg (envelope-from ) for ; Tue, 11 Nov 2025 11:00:42 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XU4ms/ne; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 34D231E057; Tue, 11 Nov 2025 11:00:42 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5D66E1E057 for ; Tue, 11 Nov 2025 11:00:41 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9E3D3858C51 for ; Tue, 11 Nov 2025 16:00:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9E3D3858C51 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XU4ms/ne Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 1E6333858D20 for ; Tue, 11 Nov 2025 16:00:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E6333858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E6333858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762876803; cv=none; b=ut/1d3HsPn5Yvyk0e/wDN+gStiRzb2/VytjVhg6qR0gttJ+cLQIYoLMmZR5VHDsvaHwqqBdt3qtEJoJDKF0SLOUKFkcsC678xT5LreggIULf/D/yocbZLA4acJFoLKGG7KHkVNNj1OcAQxZziifc2ZvGzuy/1PuOkXCF6Kw/fxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762876803; c=relaxed/simple; bh=l6DYu7EBf/IJhVlhq1p5eN5f/LoCWUNKNmau6MgQmts=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lGqqOko8jeCu5semg3VSmz253u4Y9c09MjJRh9Dtnoh2hWdTEz9oX8JDcb/PikplZLZbCuZYcIqok/MrXfJqOE+2cz53V49YaD1Zu9l6UhzmrS02DrQIAZD342gZps1oH1ZwggQInmGNzx2Yyrt4fZeSHB0kcHMdQHT9CF9+dcU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E6333858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762876802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=StCejkdkk0kq9QAvI6zHquRHPbysrvyJ4vGoAjDIZH8=; b=XU4ms/neNGX+ndW4GNIad8XzAiIXFxlrRLALys6NdPo/Ua1fz9alT9DP9cuFKdHHYZAVhr O+0t9a5rDvV+AYYRGC8uHo2nHMJVBRh+HEyT+gn0WE1cJ6WqBbG6Hty1awlFYHOxN60g7f iLMg8U2Y4RyQ6/cr9KPw0Oq8msfuG3c= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-R_TG6LbhM_KtEfluB7OP0Q-1; Tue, 11 Nov 2025 11:00:01 -0500 X-MC-Unique: R_TG6LbhM_KtEfluB7OP0Q-1 X-Mimecast-MFC-AGG-ID: R_TG6LbhM_KtEfluB7OP0Q_1762876800 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4777885a071so14892545e9.3 for ; Tue, 11 Nov 2025 08:00:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762876800; x=1763481600; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=StCejkdkk0kq9QAvI6zHquRHPbysrvyJ4vGoAjDIZH8=; b=Bkv7CNRsqkZy6kmYkujxLHi0pWjuLECxWKFn20XrrpfSqfGeWG9BYRFpH06I4DcRDM sYOtuuKE436iVdqnezM5wEvaHlwsDi8sWgk/UaNOn/f4d569nkIEjf3KiPYAlgRGWddV gZY2rl71UksXszAgXdGzOGGSN9xPn6vElL5g+rFTGDqshgBu/vRGBKHxV98m+36hBnip T46ushoh6FDFkXxGUofcW41slPO3UA2m+vYI5cKQrSwFBYHumZRJYtospas0euUcRWO/ 1q7BRL0D/Li2Goscq5CkUMFTWvgQ52gbAx1oOdhJpY3p8Xhc5BFB3dF0mJlF347e4JLT wXmw== X-Forwarded-Encrypted: i=1; AJvYcCXDbZw8Cg8hgVJsas+kbewkchqt/Anapk3EOuFXZQI4WjM4JZLeclGmtFRlWLdbDbjBdU9maz8CQIUVFw==@sourceware.org X-Gm-Message-State: AOJu0YxorZeDN+rTK/QeM/23iZpGLD1d5q0D+f1rBEyO+7UPoI0zwSwR Dp8frIK36jvZ8pBSeAE8MpS84A7BBs7wDV+URNDPn0YDgH11ouHG6FcrWNDi4zue3VmiNB5xX37 Z875emuSDCzT+G0NQtPXOvuY9FUyHBywAbJp8pE3E7os6UEx14AyWBq7annDE+3E+X2fIRZE= X-Gm-Gg: ASbGncsUY1s1ptdbkzEfO7FLRLpDs5fqBYVH4yntxMN6WY/e4Mxu0TeP7wxciq62yqS mFkl8uuiT5N2ldwlyM2c0GjfAj83yGK2qbLZZ1HwdMAjZgJsBpAvDR4gQ7rNeDUiF8BQIEI//80 Vo1K52ke3UwWgBxj+kO9KaTx9iQWhENRfY+Tq6JuUx9ZyaNg8Zi1obhEgNWbyDZ5kUSAP//gaim beG9ZBH/kw/WiVYEMT69oUY3l87hE65Y5OIzZn9OMneCWnIeuxTc/n2RTzBYf2HfhlyC7osIZlz +lqVnqNMZmZOG9LnhjMHzMpyVh8lULnkuYNk/pdLKHoD8QfEvB8qSWgHE7MPd+0Uw1JfKQ== X-Received: by 2002:a05:600c:3588:b0:477:7af8:c893 with SMTP id 5b1f17b1804b1-4777af8c976mr97573955e9.15.1762876800251; Tue, 11 Nov 2025 08:00:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpx5FDNulcYOLcvEPa6S4iBXE02DVPfAEl/jU1tdz0p6DViaVxlc+dQUDBo0TXuww7cGRRUQ== X-Received: by 2002:a05:600c:3588:b0:477:7af8:c893 with SMTP id 5b1f17b1804b1-4777af8c976mr97573685e9.15.1762876799816; Tue, 11 Nov 2025 07:59:59 -0800 (PST) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4777838199bsm168934905e9.9.2025.11.11.07.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Nov 2025 07:59:59 -0800 (PST) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: Eli Zaretskii Subject: Re: [PATCH 2/2] gdb: use current executable for 'remote exec-file' in some cases In-Reply-To: <45969c8b-2637-4ec5-875e-2241fdb3a2b9@simark.ca> References: <40cbbd9f0082b07e9767656fe044bbe9280983a3.1759763251.git.aburgess@redhat.com> <45969c8b-2637-4ec5-875e-2241fdb3a2b9@simark.ca> Date: Tue, 11 Nov 2025 15:59:58 +0000 Message-ID: <87tsz0zhj5.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AUsIgPuzabCA2sf5e43P3DOkx6r4De2S1N3dEI5v-E8_1762876800 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Simon Marchi writes: > On 10/11/25 9:34 AM, Andrew Burgess wrote: >> This commit allows GDB to make use of the file set with the 'file' >> command when starting a new inferior on an extended-remote target. >> There are however some restrictions. >> >> If the user has used 'set remote exec-file', then this setting is >> always used in preference to the file set with the 'file' command. >> >> Similarly, if the qExecAndArgs packet has succeeded, and GDB knows >> that the remote target has an executable set, then this will be used >> in preference to the file set with the 'file' command; this preserves >> GDB's existing behaviour. In effect, when GDB connects to the remote >> target, the remote sets the 'remote exec-file' and this prevents GDB >> from using the 'file' filename. >> >> And, GDB can only use the file set with the 'file' command if it >> believes that both GDB and the remote target will both be able to >> access this file. This means that one of these is true: >> >> + the the remote_target::filesystem_is_local function returns >> true (see the implementation of that function for details of when >> this can happen). This means GDB and the remote target can see >> the same file system, GDB can just use the current executable's >> filename as is, or >> >> + the user has set the 'file' to something with a 'target:' prefix, >> e.g. 'file target:/path/to/exec'. In this last case, GDB will use >> the exec filename without the 'target:' prefix, this filename is, >> by definition, something the remote target can see, or >> >> + the sysroot has been updated by the user and no longer contains a >> 'target:' prefix. In this case, if the 'file' filename is within >> the sysroot, then it is assumed the remote will also be able to >> see a file with the same filename. For example, if the sysroot is >> '/aa/', and the current executable is '/aa/bb/cc', then GDB will >> tell the remote to run '/bb/cc'. One common case here is when the >> sysroot is set to the empty string, which is usually done when GDB >> and the remote target can see the same filesystem, in this case >> GDB will use the current executable's filename unmodified. >> >> If one of these conditions is met, then GDB will use the current >> executable's filename (with possible modifications as mentioned >> above), when starting a new extended-remote inferior, in all other >> cases, GDB will use the file name set with 'set remote exec-file'. >> >> This change could be useful any time a user is running a remote target >> on the same machine as GDB, but I am specifically thinking of the case >> where GDB is using a tool other than gdbserver, e.g. valgrind, as this >> saves one additional step that a user must remember. The current >> steps to start valgrind with GDB, as given on the valgrind >> website (https://valgrind.org/docs/manual/manual-core-adv.html) are: >> >> $ gdb prog >> (gdb) set remote exec-file prog >> (gdb) set sysroot / >> (gdb) target extended-remote | vgdb --multi --vargs -q >> (gdb) start >> >> With this GDB work, and once support for the qExecAndArgs packet is >> added to valgrind, then the 'set remote exec-file' line can be dropped >> from those instructions. >> >> This commit also extends the 'show remote exec-file' command so that >> GDB will display the automatic value that it plans to use. Here's an >> example of the new output: >> >> $ gdb -q /tmp/hello >> Reading symbols from /tmp/hello... >> (gdb) set sysroot >> (gdb) target extended-remote | ./gdbserver/gdbserver --multi --once - >> Remote debugging using | ./gdbserver/gdbserver --multi --once - >> Remote debugging using stdio >> (gdb) show remote exec-file >> The remote exec-file is unset, using automatic value "/tmp/hello". >> >> The last line shows the new output. >> >> Reviewed-By: Eli Zaretskii > > I am investigating a regression when running gdb.gdb/selftest.exp with > the native-extended-gdbserver board, caused by my commit d6340aa42e25 > ("gdb/testsuite: use libtool to launch selftests"). A side-effect of my > change is that the test no longer does a "set remote exec-file", which > is currently required in order to run a new process with an > extended-remote board. I started writing a patch to add a manual "set > remote exec-file", but then remembered about this patch. I gave it a > try, and indeed it fixes those regressions. I would therefore be very > happy to see this patch merged (I had forgotten about it before just now > to be honest). > > I'm fine with what you have see below for small comments. > > Approved-By: Simon Marchi > I addressed the nits you pointed out, and pushed this patch. Thanks, Andrew