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 08:53:57 +0300	[thread overview]
Message-ID: <867chd8yh6.fsf@gnu.org> (raw)
In-Reply-To: <7eb59d60-1092-4b68-b019-d145d8fe8ab1@campus.tu-berlin.de> (message from Max Yvon Zimmermann on Thu, 4 Apr 2024 02:05:11 +0200)

> Date: Thu, 4 Apr 2024 02:05:11 +0200
> CC: <gdb-patches@sourceware.org>
> From: Max Yvon Zimmermann <max.yvon.zimmermann@campus.tu-berlin.de>
> 
> Thank you for the quick reply!

Thank you for working on this feature in the first place.

> > But I wonder what does the above mean for Windows file names that use
> > backslashes as directory separators?  Does each backslash need to be
> > escaped by another one, when creating the rewrite rules??
> 
> 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.

> > Does this mean that multiple /usr/*/include directories could be
> > redirected to the same /mnt/include directory?  Won't that cause
> > trouble, if there are several distinct directories recorded in the
> > debug info whose names match the wildcard, and which are supposed to
> > resolve to different directories?
> 
> 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?

Thanks.

  reply	other threads:[~2024-04-04  5:54 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 [this message]
2024-04-04  8:52       ` Max Yvon Zimmermann
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=867chd8yh6.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).