public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra.loosemore@siemens.com>
To: Tom Tromey <tom@tromey.com>, Sandra Loosemore <sandra@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames
Date: Fri, 21 Apr 2023 13:26:50 -0600	[thread overview]
Message-ID: <fc3ed92b-ba1b-0c32-88ae-cc37783dafed@siemens.com> (raw)
In-Reply-To: <87bkjh1eib.fsf@tromey.com>

On 4/21/23 08:44, Tom Tromey wrote:
>>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:
> 
> Sandra> This patch fixes some testcases that formerly had patterns with
> Sandra> hardwired "/" pathname separators in them, which broke when testing on
> Sandra> (remote) Windows host.
> 
> Sandra> +    set STRINGHOME ""
> Sandra>      set test "show environment HOME"
> Sandra>      gdb_test_multiple $test $test {
> Sandra>  	-re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$::gdb_prompt $" {
> Sandra>  	    set HOME $expect_out(1,string)
> Sandra> +	    if { [ishost *-*-mingw*] } {
> Sandra> +	      # Backslashes in the pathname must be escaped for the patterns
> Sandra> +	      # that match quoted string output.
> Sandra> +	      regsub -all {\\} $HOME {\\\\} STRINGHOME
> 
> I don't understand this one, because the uses all use string_to_regexp.
> But if the computed value of HOME doesn't work in that context, then it
> seems like that means there is a bug in string_to_regexp, because the
> contract of string_to_regexp is to return a regexp that will exactly
> match the input, no matter what it is.

The output of the two commands it is trying to match using STRINGHOME 
(as opposed to HOME) is

p $_gdb_setting("history filename")
$1 = "C:\\cygwin\\home\\sandra/foobar.baz"

p $_gdb_setting_str("history filename")
$2 = "C:\\cygwin\\home\\sandra/foobar.baz"

E.g., the output is printed with C string syntax, in which every 
backslash is doubled.  So the thing passed to string_to_regexp also 
needs to have doubled backslashes.

> 
> Sandra> -	"The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
> Sandra> +	"The filename in which to record the command history is \"[string_to_regexp $HOME].foobar.baz\"..*" \
> 
> Also why didn't this one need to be changed?  (Though if there really is
> a bug in string_to_regexp then it's irrelevant.)

Because in this case the output it is trying to match does is *not* 
printed with C string escapes in spite of the surrounding quotes.

Maybe this just needs more comments?  Or is there a utility function to 
add C escapes to a string that should be used on non-Windows hosts too?

-Sandra

  reply	other threads:[~2023-04-21 19:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19 19:30 [PATCH 0/5] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
2023-04-19 19:30 ` [PATCH 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
2023-04-19 19:30 ` [PATCH 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling Sandra Loosemore
2023-04-21 14:37   ` Tom Tromey
2023-04-21 19:15     ` Sandra Loosemore
2023-04-19 19:30 ` [PATCH 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
2023-04-21 14:44   ` Tom Tromey
2023-04-21 19:26     ` Sandra Loosemore [this message]
2023-04-22  0:11       ` Tom Tromey
2023-04-19 19:30 ` [PATCH 4/5] gdb/testsuite: Disable some tests that are broken on remote Windows host Sandra Loosemore
2023-04-21 14:46   ` Tom Tromey
2023-04-21 14:52   ` Tom Tromey
2023-04-21 19:33     ` Sandra Loosemore
2023-04-22  0:11       ` Tom Tromey

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=fc3ed92b-ba1b-0c32-88ae-cc37783dafed@siemens.com \
    --to=sandra.loosemore@siemens.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sandra@codesourcery.com \
    --cc=tom@tromey.com \
    /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).