Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/1] skip confirmation in 'gdb_reinitialize_dir'
@ 2024-11-14  9:00 Stephan Rohr
  2024-11-14  9:00 ` [PATCH 1/1] testsuite: " Stephan Rohr
  0 siblings, 1 reply; 6+ messages in thread
From: Stephan Rohr @ 2024-11-14  9:00 UTC (permalink / raw)
  To: gdb-patches

Hi all,

I came across an issue when running the testsuite on Windows using
MinGW.  The 'dir' command is automatically confirmed by the shell:

  (gdb) dir
  Reinitialize source path to empty? (y or n)
    [answered Y; input not from terminal]
  Source directories searched: $cdir;$cwd
  (gdb) y

This patch provides a fix by parsing the (optional) 'answered Y; ...'
output.

I appreciate your feedback.

Thanks
stephan


Rohr, Stephan (1):
  testsuite: skip confirmation in 'gdb_reinitialize_dir'

 gdb/testsuite/lib/gdb.exp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
  2024-11-14  9:00 [PATCH 0/1] skip confirmation in 'gdb_reinitialize_dir' Stephan Rohr
@ 2024-11-14  9:00 ` Stephan Rohr
  2024-11-14  9:43   ` Eli Zaretskii
  2024-11-15 20:18   ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Stephan Rohr @ 2024-11-14  9:00 UTC (permalink / raw)
  To: gdb-patches

From: "Rohr, Stephan" <stephan.rohr@intel.com>

Some shells automatically confirm the 'dir' command:

  (gdb) dir
  Reinitialize source path to empty? (y or n)
    [answered Y; input not from terminal]
  Source directories searched: $cdir;$cwd
  (gdb) y
  dir <...>/gdb/testsuite/gdb.base
  Undefined command: "y".  Try "help".

For example, this reprdocues on a MinGW32 environment.  Skip sending
'y' if the command is already confirmed.
---
 gdb/testsuite/lib/gdb.exp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 410f99e3350..05101500eb9 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2238,8 +2238,10 @@ proc gdb_reinitialize_dir { subdir } {
     }
     send_gdb "dir\n"
     gdb_expect 60 {
-	-re "Reinitialize source path to empty.*y or n. " {
-	    send_gdb "y\n" answer
+	-re "Reinitialize source path to empty.*y or n.\(\\\s.answered Y; input not from terminal.\)?" {
+	    if {![info exists expect_out(1,string)]} {
+		send_gdb "y\n" answer
+	    }
 	    gdb_expect 60 {
 		-re "Source directories searched.*$gdb_prompt $" {
 		    send_gdb "dir $subdir\n"
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
  2024-11-14  9:00 ` [PATCH 1/1] testsuite: " Stephan Rohr
@ 2024-11-14  9:43   ` Eli Zaretskii
  2024-11-14 16:30     ` Rohr, Stephan
  2024-11-15 20:18   ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-11-14  9:43 UTC (permalink / raw)
  To: Stephan Rohr; +Cc: gdb-patches

> From: Stephan Rohr <stephan.rohr@intel.com>
> Date: Thu, 14 Nov 2024 01:00:51 -0800
> 
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> 
> Some shells automatically confirm the 'dir' command:
> 
>   (gdb) dir
>   Reinitialize source path to empty? (y or n)
>     [answered Y; input not from terminal]
>   Source directories searched: $cdir;$cwd
>   (gdb) y
>   dir <...>/gdb/testsuite/gdb.base
>   Undefined command: "y".  Try "help".

Which shell is involved here?

> For example, this reprdocues on a MinGW32 environment.  Skip sending
> 'y' if the command is already confirmed.
> ---
>  gdb/testsuite/lib/gdb.exp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Are you saying this problem happens only in the test suite?  When I
run GDB interactively, typing "dir" followed by Enter does request my
confirmation, it doesn't confirm automatically.  Why does that happen
in the test suite?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
  2024-11-14  9:43   ` Eli Zaretskii
@ 2024-11-14 16:30     ` Rohr, Stephan
  2024-11-14 16:58       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Rohr, Stephan @ 2024-11-14 16:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

Hi Eli,

I further investigated the issue.  The issue is triggered if "TERM=dump" is set in a MinGW
environment.  I can reproduce the issue in CLI mode, too:

  $ ./gdb -q
  (gdb) dir
  Reinitialize source path to empty? (y or n) [answered Y; input not from terminal]
  Source directories searched: $cdir;$cwd
  (gdb)

I used the setting to workaround some issues when running tests on Windows using
MinGW.  I can see that control characters are added to the output of different commands,
e.g., 'test_compiler_info' fails with:

  builtin_spawn -ignore SIGHUP gcc -fdiagnostics-color=never -c -o ...
  ^[[6nget_compiler_info: gcc-14-2-0
  get_compiler_info: gcc-14-2-0
  Executing on host: gcc  -fno-stack-protector  -w -c -g  -o ...
  builtin_spawn -ignore SIGHUP gcc -fno-stack-protector -w -c -g -o ...
  ^[[6noutput is:
  ^[[6n
  gdb compile failed, ^[[6n

I haven't understood yet why this is added in MinGW or how to disable those.

The patch enables me to run the tests I'm interested in in a MinGW environment.

Thanks
Stephan

> -----Original Message-----
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Thursday, 14 November 2024 10:44
> To: Rohr, Stephan <stephan.rohr@intel.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
> 
> > From: Stephan Rohr <stephan.rohr@intel.com>
> > Date: Thu, 14 Nov 2024 01:00:51 -0800
> >
> > From: "Rohr, Stephan" <stephan.rohr@intel.com>
> >
> > Some shells automatically confirm the 'dir' command:
> >
> >   (gdb) dir
> >   Reinitialize source path to empty? (y or n)
> >     [answered Y; input not from terminal]
> >   Source directories searched: $cdir;$cwd
> >   (gdb) y
> >   dir <...>/gdb/testsuite/gdb.base
> >   Undefined command: "y".  Try "help".
> 
> Which shell is involved here?
> 
> > For example, this reprdocues on a MinGW32 environment.  Skip sending
> > 'y' if the command is already confirmed.
> > ---
> >  gdb/testsuite/lib/gdb.exp | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> Are you saying this problem happens only in the test suite?  When I
> run GDB interactively, typing "dir" followed by Enter does request my
> confirmation, it doesn't confirm automatically.  Why does that happen
> in the test suite?
> 
> Thanks.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
  2024-11-14 16:30     ` Rohr, Stephan
@ 2024-11-14 16:58       ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-11-14 16:58 UTC (permalink / raw)
  To: Rohr, Stephan; +Cc: gdb-patches

> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> CC: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Thu, 14 Nov 2024 16:30:26 +0000
> 
> I further investigated the issue.  The issue is triggered if "TERM=dump" is set in a MinGW
> environment.  I can reproduce the issue in CLI mode, too:
> 
>   $ ./gdb -q
>   (gdb) dir
>   Reinitialize source path to empty? (y or n) [answered Y; input not from terminal]
>   Source directories searched: $cdir;$cwd
>   (gdb)

Strange, it doesn't happen here, at least not when I run GDB from
cmd.exe after setting TERM=dumb.

> I used the setting to workaround some issues when running tests on Windows using
> MinGW.  I can see that control characters are added to the output of different commands,
> e.g., 'test_compiler_info' fails with:
> 
>   builtin_spawn -ignore SIGHUP gcc -fdiagnostics-color=never -c -o ...
>   ^[[6nget_compiler_info: gcc-14-2-0
>   get_compiler_info: gcc-14-2-0
>   Executing on host: gcc  -fno-stack-protector  -w -c -g  -o ...
>   builtin_spawn -ignore SIGHUP gcc -fno-stack-protector -w -c -g -o ...
>   ^[[6noutput is:
>   ^[[6n
>   gdb compile failed, ^[[6n
> 
> I haven't understood yet why this is added in MinGW or how to disable those.
> 
> The patch enables me to run the tests I'm interested in in a MinGW environment.

OK, if that affects only the test suite and only in some environments,
I guess the change cannot do any harm.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] testsuite: skip confirmation in 'gdb_reinitialize_dir'
  2024-11-14  9:00 ` [PATCH 1/1] testsuite: " Stephan Rohr
  2024-11-14  9:43   ` Eli Zaretskii
@ 2024-11-15 20:18   ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2024-11-15 20:18 UTC (permalink / raw)
  To: Stephan Rohr; +Cc: gdb-patches

>>>>> "Stephan" == Stephan Rohr <stephan.rohr@intel.com> writes:

Stephan> +	-re "Reinitialize source path to empty.*y or n.\(\\\s.answered Y; input not from terminal.\)?" {

You don't need the backslash before "(" or ")".
Ok with this fixed.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-15 20:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14  9:00 [PATCH 0/1] skip confirmation in 'gdb_reinitialize_dir' Stephan Rohr
2024-11-14  9:00 ` [PATCH 1/1] testsuite: " Stephan Rohr
2024-11-14  9:43   ` Eli Zaretskii
2024-11-14 16:30     ` Rohr, Stephan
2024-11-14 16:58       ` Eli Zaretskii
2024-11-15 20:18   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox