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

> Date: Thu, 4 Apr 2024 10:52:31 +0200
> CC: <gdb-patches@sourceware.org>
> From: Max Yvon Zimmermann <max.yvon.zimmermann@campus.tu-berlin.de>
> 
> 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'm not sure this should be in the manual, since the way file names
are written in the debug info is not under user's control.  If the
file names in the debug info use backslashes, will GDB recognize
rewrite rules that use forward slashes?  Even if GDB does treat both
characters as equal on Windows, I'm not sure users will trust that up
front, so they might use backslashes in the rewrite rules anyway.

> > 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.

That's not what I meant.  I meant that a rule like

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

can catch any parent directory of 'include', and which one it will
catch is not known in advance.

> 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).

Well, two wrongs don't make a right.

I'd be interested to hear opinions of others about this.

  reply	other threads:[~2024-04-04 11: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
2024-04-04 11:52         ` Eli Zaretskii [this message]
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=86zfu973b1.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=max.yvon.zimmermann@campus.tu-berlin.de \
    /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).