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: Tue, 02 Apr 2024 14:46:40 +0300	[thread overview]
Message-ID: <86o7as9ecf.fsf@gnu.org> (raw)
In-Reply-To: <5ff720ec-4453-441e-ba82-84d60a2e8d50@campus.tu-berlin.de> (message from Max Yvon Zimmermann on Mon, 1 Apr 2024 23:26:36 +0200)

> Date: Mon, 1 Apr 2024 23:26:36 +0200
> From: Max Yvon Zimmermann <max.yvon.zimmermann@campus.tu-berlin.de>
> 
> I have developed a patch that allows for glob pattern matching within substitute-path rules.

Thanks.

> diff --git a/gdb/NEWS b/gdb/NEWS
> index feb3a37393a..5a041175507 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -90,6 +90,11 @@ show unwind-on-signal
>    These new commands replaces the existing set/show unwindonsignal.  The
>    old command is maintained as an alias.
>  
> +set substitute-path
> +  This command now supports glob pattern matching for substitution
> +  rules.  Wildcards '?' and '*' are supported.  Use '\' to escape
> +  '?', '*' and '\' characters.

This part is approved, documentation-wise.

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

> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -9954,6 +9954,35 @@ For instance, if we had entered the following commands:
>  use the second rule to rewrite @file{/usr/src/lib/foo.c} into
>  @file{/mnt/src/lib/foo.c}.
>  
> +Rules can contain wildcards to match multiple paths.  The supported
> +wildcards are @samp{?} (to match any single character) and @samp{*}
> +(to match any string).  Wildcards will never match the path separator of
> +the system.

File names of their parts should have the @file markup, not @samp.
(Wildcards are file names of sorts.)

> +For instance, if we had entered the following command:
> +
> +@smallexample
> +(@value{GDBP}) set substitute-path /usr/*/include /mnt/include
> +@end smallexample

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?

> +Use @samp{@backslashchar{}} to escape the characters @samp{?}@comma{}
> +@samp{*} and @samp{@backslashchar{}}.  Note that you need to escape any
> +@samp{@backslashchar{}} characters twice in the @value{GDBN} command line.

I'd prefer not to use @comma{} and @backslashchar{} except where the
literal characters will confuse TeX.  AFAIU, they are not needed here,
and literal characters will do the job.

> +  if (IS_DIR_SEPARATOR (path[last]))
> +    {
> +      path[last] = '\0';
> +
> +      if (path[last] != '\\')
> +        return;

Something's wrong here: you assign path[last] and then test its value?

Also, how does this handle Windows-style file names with backslashes?

> +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
> +          /* On DOS-based file systems, the '/' and the '\' are equivalent.  */
> +          if (pattern_c == '/')
> +            pattern_c = '\\';
> +          if (string_c == '/')
> +            string_c = '\\';
> +#endif

Does this mean "//" (two slashes in a row) will be converted to "\\",
and will then be interpreted as an escaped single backslash?

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

  reply	other threads:[~2024-04-02 12:25 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 [this message]
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
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=86o7as9ecf.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).