public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Max Yvon Zimmermann <max.yvon.zimmermann@campus.tu-berlin.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Add wildcard matching to substitute-path rules
Date: Thu, 4 Apr 2024 10:52:31 +0200	[thread overview]
Message-ID: <a3549ad0-4983-4b26-8548-2db359551a81@campus.tu-berlin.de> (raw)
In-Reply-To: <867chd8yh6.fsf@gnu.org>

Thank you.

>> On DOS-based systems both backslashes and forward slashes are valid path separators. So while Windows users COULD write their paths as \\path\\to\\, /path/to/ would work as well. This behavior is not new, the previous version behaved similarly. New is that to match a backslash from the GDB command line you would have to escape a backslash twice (because the CLI already unescapes backslashes). But because everyone can just continue to use forwards slashes, I think this should be fine.
> 
> So extra \-escaping will still be needed for DOS-based filesystems.  I
> think this should be mentioned in the documentation.

Actually, this is already mentioned in the documentation. But maybe it can be made a bit clearer. On the other hand, I really do not want to encourage the extra \-escaping. I am thinking of writing something like this instead:

"On DOS-based file system, you are encouraged to use '/' as the path separator within your patterns. This avoids escaping the '\' characters and would still match against file names that use '\' as the path separator. For instance, the pattern 'C:/foo/*' would still match 'C:\foo\bar'."

>> I realize now that /usr/*/include is actually a terrible example for this feature. I will change the example to avoid confusion. However it is correct that two files from distinct directories COULD accidentally get matched. But you could argue that this is already the case. Let's say we set the following two rules:
>>
>> set substitute-path /foo/include /mnt/include
>> set substitute-path /bar/include /mnt/include
>>
>> Then we could run into exactly the same issue.
> 
> The difference here is that the two lines above must be explicitly
> written by the user, whereas the wildcard rule could catch another
> directory unintentionally.
> 
>> I would also like to point out that the rule selection is unaffected by this patch. To quote from the documentation: "In the case when more than one substitution rule have been defined, the rules are evaluated one by one in the order where they have been defined. The first one matching, if any, is selected to perform the substitution."
> 
> To me, this means that the two-line example you've shown is processed
> in a predictable way, by only using the first one if both match,
> whereas a wildcard rule will cause unpredictable results, because the
> order in which files are compared against a wildcard is undefined.
> Right?

No, rules that use wildcards are still processed in a predictable way. If we set the following two rules (and in that order!):

set substitute-path /foo/include /path/to/foo
set substitute-path /*/include /path/to/somewhere

Then any file names matching '/foo/include' would be rewritten to '/path/to/foo' and NOT '/path/to/somewhere'. Even though any file name matching '/foo/include' would of course also match '/*/include'. The rule selection is entirely based on the order of their definition.

Also, in the example I stated in my last reply, no file name that matches '/foo/include' would ever match '/bar/include'. The point I was trying to get across was that two unrelated files can already be mapped onto the same file (accidentally).

  reply	other threads:[~2024-04-04  8:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 21:26 Max Yvon Zimmermann
2024-04-02 11:46 ` Eli Zaretskii
2024-04-04  0:05   ` Max Yvon Zimmermann
2024-04-04  5:53     ` Eli Zaretskii
2024-04-04  8:52       ` Max Yvon Zimmermann [this message]
2024-04-04 11:52         ` Eli Zaretskii
2024-04-04 12:42           ` Guinevere Larsen
2024-04-04 22:52             ` Max Yvon Zimmermann
2024-04-05  5:58               ` Max Yvon Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3549ad0-4983-4b26-8548-2db359551a81@campus.tu-berlin.de \
    --to=max.yvon.zimmermann@campus.tu-berlin.de \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).