From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3C36F3858D1E for ; Sat, 27 Apr 2024 09:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C36F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none 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 3C36F3858D1E 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=1714208494; cv=none; b=t6vCfQlWCgNErcLRe2Ez7abU0pSnxPuBGRuclStgrNZG2xu3nGTy1mwWy/QmWkDx9+a0+YaQemviNJESS5rzC3/otMJFNC8cJhzSXSn6yMFIccr4xUGcU1k9hvohk+bdKX1Y/6dhiBYJHQJYA1gTkfgSwIUqzz641BKkN/cT/ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714208494; c=relaxed/simple; bh=ClOB0hjYrQ9PIa7SacY7oqPmDufjZS7SM13gHxqttb4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=V6g/gTQA2chC4FYAc1sjxijvdnGpCBnwKlWWeiqgtLS7a7jpQsMcEgrIzhHZ3fxdey/XOavZfPl5ylzT+vfbw48/XjmUoiaRJglYBWUN+7hsNgKcxa0zou9AI0rQFuZZpq6ziOhSFPStnXOSaNCwkYfQqZP04JME6vy1aiNut2Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714208491; 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=OxcBSRRMx8QPZR33BYW2MMgtk1kNEJ1Sb+wdQ0eDq7A=; b=TcVwKTBb+V5FBm2QDsuE2XqTaPNK2/Oq+PCKbYoguuTzM8k98H9jazu05JLDgZ7nGiScP1 0xUt5TX8yT+XT88csIB82T9/aDbmvnp0bDD1SFjUSKESrJVjCoSNWZdsX/MYyCLRE5jWCL mP/OraPqMK8EsTL3e4D9y5PDJbgkWjo= 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-593-KUt3O-ajOuGo3GzsQHrnPg-1; Sat, 27 Apr 2024 05:01:30 -0400 X-MC-Unique: KUt3O-ajOuGo3GzsQHrnPg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-41a074e2d69so12347365e9.3 for ; Sat, 27 Apr 2024 02:01:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714208489; x=1714813289; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OxcBSRRMx8QPZR33BYW2MMgtk1kNEJ1Sb+wdQ0eDq7A=; b=V2Aqgbbi8jpkLyQKenQ48GSFA16ankUPNgtVwKs6ZXsUikI87LR5i222HZFoceQU+o ivs6svljIo088x+BPBRfUVsQG5svCoXq+3t8bD0Nh/pK4FBgeRa4SBoG4XMzPCFgy+VS 5FtxQcC2jlbs9GVKImdrvrYNF36lEOgetOpTqgANmTUL4HlFHfRzWUCYJApcxVFTI1Bw BbQxHLaDwHq5KE5g+gPW7xhPS5SPriuT+0uSJ0uMS6t2GVw77XXLtxKpIwri3FErTe0P Cjhyr4jkrJi+1bD5T0MP+NyMJ+m2fOs2TrXwX+pTciwc8OaG7RBOnVioi/zNRqq4ba6c 9FQw== X-Gm-Message-State: AOJu0Yz6TsDuFgEaznLdh03bB/OCJunGAmOU/CdDj74oLYTt8nO+Yii3 rACmcHQvkcqoAghj1pUkyCCn89TaO/FtY/xyBTLAM2b9Gn8XwWrvHZAdP78gwzQVQBbQzUp5xrd wF7+2qdCj/Z6XpMeXPPsCCZejSL2fDfxRR6kGpyKCO67I73GZg3+iz1JGruQ= X-Received: by 2002:a05:600c:190d:b0:416:2a95:6e8b with SMTP id j13-20020a05600c190d00b004162a956e8bmr3539342wmq.26.1714208488584; Sat, 27 Apr 2024 02:01:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLgppn1NP/gnCilAzwpF6biKY3ywhBm73yqc7deAog46AqBbOYP6Em76JZdhQwSVnfqMiSZg== X-Received: by 2002:a05:600c:190d:b0:416:2a95:6e8b with SMTP id j13-20020a05600c190d00b004162a956e8bmr3539321wmq.26.1714208487988; Sat, 27 Apr 2024 02:01:27 -0700 (PDT) Received: from localhost (92.40.184.204.threembb.co.uk. [92.40.184.204]) by smtp.gmail.com with ESMTPSA id h15-20020a05600c350f00b00418d68df226sm34576900wmq.0.2024.04.27.02.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 02:01:27 -0700 (PDT) From: Andrew Burgess To: Eli Zaretskii Cc: gdb-patches@sourceware.org, lsix@lancelotsix.com Subject: Re: [PATCHv2 1/8] gdb/doc: document how filename arguments are formatted In-Reply-To: <86y1988j2j.fsf@gnu.org> References: <33ee1a27758e76ef6c0185040bdc15e2aea8b6f2.1713603415.git.aburgess@redhat.com> <86y1988j2j.fsf@gnu.org> Date: Sat, 27 Apr 2024 11:01:23 +0100 Message-ID: <8734r7t98s.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_ABUSEAT,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP 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: Eli, Thanks for your feedback. I've addressed the issues you pointed out, and have added some additional text at the end to better describe the escaping of quote characters and of backslash itself. Let me know what you think. Thanks, Andrew --- commit 4d1a140481d8e7262d631cf10756a0d698f75477 Author: Andrew Burgess Date: Wed Apr 17 14:47:49 2024 +0100 gdb/doc: document how filename arguments are formatted In the following commits I intend to improve GDB's filename completion. However, how filenames should be completed is a little complex because GDB is not consistent with how it expects filename arguments to be formatted. This commit documents the current state of GDB when it comes to formatting filename arguments. Currently GDB will not correctly complete filenames inline with this documentation; GDB will either fail to complete, or complete incorrectly (i.e. the result of completion will not then be accepted by GDB). However, later commits in this series will fix completion. Reviewed-By: Eli Zaretskii diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b2e9faac82d..4ba77b56b8f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1752,6 +1752,7 @@ * Command Syntax:: How to give commands to @value{GDBN} * Command Settings:: How to change default behavior of commands * Completion:: Command completion +* Filename Arguments:: Filenames As Command Arguments * Command Options:: Command options * Help:: How to ask @value{GDBN} for help @end menu @@ -2123,6 +2124,68 @@ @} @end smallexample +@node Filename Arguments +@section Filenames As Command Arguments +@cindex file names, quoting and escaping + +When passing filenames (or directory names) as arguments to a command, +if the filename argument does not include any whitespace, double +quotes, or single quotes, then for all commands the filename can be +written as a simple string, for example: + +@smallexample +(@value{GDBP}) file /path/to/some/file +@end smallexample + +If the filename does include whitespace, double quotes, or single +quotes, then @value{GDBN} has two approaches for how these filenames +should be formatted; which format to use depends on which command is +being used. + +Most @value{GDBN} commands don't require, or support, quoting and +escaping. These commands treat any text after the command name, that +is not a command option (@pxref{Command Options}), as the filename, +even if the filename contains whitespace or quote characters. In the +following example the user is adding @w{@file{/path/that contains/two +spaces/}} to the auto-load safe-path (@pxref{add-auto-load-safe-path}): + +@smallexample +(@value{GDBP}) add-auto-load-safe-path /path/that contains/two spaces/ +@end smallexample + +A small number of commands require that filenames containing +whitespace or quote characters are either quoted, or have the special +characters escaped with a backslash. Commands that support this style +are marked as such in the manual, any command not marked as accepting +quoting and escaping of its filename argument, does not accept this +filename argument style. + +For example, to load the file @file{/path/with spaces/to/a file} with +the @code{file} command (@pxref{Files, ,Commands to Specify Files}), +you can escape the whitespace characters with a backslash: + +@smallexample +(@value{GDBP}) file /path/with\ spaces/to/a\ file +@end smallexample + +Alternatively the entire filename can be wrapped in either single or +double quotes, in which case no backlsashes are needed, for example: + +@smallexample +(@value{GDBP}) symbol-file "/path/with spaces/to/a file" +(@value{GDBP}) exec-file '/path/with spaces/to/a file' +@end smallexample + +It is possible to include a quote character within a quoted filename +by escaping it with a backslash, for example, within a filename +surrounded by double quotes, a double quote character should be +escaped with a backslash, but a single quote character should not be +escaped. Within a single quoted string a single quote character needs +to be escaped, but a double quote character does not. + +A literal backslash character can also be included by escaping it with +a backslash. + @node Command Options @section Command options @@ -21615,6 +21678,9 @@ to run. You can change the value of this variable, for both @value{GDBN} and your program, using the @code{path} command. +The @var{filename} argument supports escaping and quoting, see +@ref{Filename Arguments,,Filenames As Command Arguments}. + @cindex unlinked object files @cindex patching object files You can load unlinked object @file{.o} files into @value{GDBN} using @@ -21637,6 +21703,9 @@ if necessary to locate your program. Omitting @var{filename} means to discard information on the executable file. +The @var{filename} argument supports escaping and quoting, see +@ref{Filename Arguments,,Filenames As Command Arguments}. + @kindex symbol-file @item symbol-file @r{[} @var{filename} @r{[} -o @var{offset} @r{]]} Read symbol table information from file @var{filename}. @env{PATH} is @@ -21660,6 +21729,9 @@ @code{symbol-file} does not repeat if you press @key{RET} again after executing it once. +The @var{filename} argument supports escaping and quoting, see +@ref{Filename Arguments,,Filenames As Command Arguments}. + When @value{GDBN} is configured for a particular environment, it understands debugging information in whatever format is the standard generated for that environment; you may use either a @sc{gnu} compiler, or @@ -21754,6 +21826,9 @@ @code{add-symbol-file} command any number of times; the new symbol data thus read is kept in addition to the old. +The @var{filename} argument supports escaping and quoting, see +@ref{Filename Arguments,,Filenames As Command Arguments}. + Changes can be reverted using the command @code{remove-symbol-file}. @cindex relocatable object files, reading symbols from @@ -21813,6 +21888,9 @@ @code{remove-symbol-file} does not repeat if you press @key{RET} after using it. +The @var{filename} argument supports escaping and quoting, see +@ref{Filename Arguments,,Filenames As Command Arguments}. + @kindex add-symbol-file-from-memory @cindex @code{syscall DSO} @cindex load symbols from memory