public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/3] [gdb/testsuite] Use remote_exec chmod instead of remote_spawn
@ 2022-10-27 14:54 Tom de Vries
  2022-10-27 14:54 ` [pushed 2/3] [gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host Tom de Vries
  2022-10-27 14:54 ` [pushed 3/3] [gdb/testsuite] Disable styling in host board local-remote-host-native.exp Tom de Vries
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2022-10-27 14:54 UTC (permalink / raw)
  To: gdb-patches

I build gdb using -O2, and ran the testsuite using taskset -c 0, and ran into:
...
(gdb) PASS: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \
  action=delete: setup: adjust sysroot
builtin_spawn gdbserver --once localhost:2385 /connect-with-no-symbol-file^M
/bin/bash: connect-with-no-symbol-file: Permission denied^M
/bin/bash: line 0: exec: connect-with-no-symbol-file: cannot execute: \
  Permission denied^M
During startup program exited with code 126.^M
Exiting^M
target remote localhost:2385^M
`connect-with-no-symbol-file' has disappeared; keeping its symbols.^M
localhost:2385: Connection timed out.^M
(gdb) FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \
  action=delete: connection to GDBserver succeeded
...

The expected series of events is (skipping disconnect and detach as I don't
think they're relevant to the problem):
- enter scenario "permission"
- cp $exec.bak $exec
- gdbserver start with $exec
- chmod 000 $exec
- connect to gdbserver
- enter scenario "delete"
- cp $exec.bak $exec
- gdbserver start with $exec
- delete $exec
- connect to gdbserver

The problem is that the chmod is executed using remote_spawn:
...
       } elseif { $action == "permission" } {
         remote_spawn target "chmod 000 $target_exec"
       }
...
without waiting on the resulting spawn id, so we're not sure when the
chmod will have effect.

The FAIL we're seeing above is explained by the chmod having effect during the
delete scenario, after the "cp $exec.bak $exec" and before the "gdbserver
start with $exec".

Fix this by using remote_exec instead.

Likewise, fix a similar case in gdb.mi/mi-exec-run.exp.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29726
---
 gdb/testsuite/gdb.mi/mi-exec-run.exp                     | 2 +-
 gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi-exec-run.exp
index f8e6550850f..3b373b2c84d 100644
--- a/gdb/testsuite/gdb.mi/mi-exec-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp
@@ -171,7 +171,7 @@ proc test {inftty_mode mi_mode force_fail} {
 # Create a not-executable copy of the program, in order to exercise
 # vfork->exec failing.
 gdb_remote_download host $binfile $binfile.nox
-remote_spawn target "chmod \"a-x\" $binfile.nox"
+remote_exec target "chmod \"a-x\" $binfile.nox"
 
 foreach_with_prefix inferior-tty {"main" "separate"} {
     foreach_with_prefix mi {"main" "separate"} {
diff --git a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
index d45e958a529..0ada144a803 100644
--- a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
+++ b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
@@ -66,7 +66,7 @@ proc connect_no_symbol_file { sysroot action } {
 	if { $action == "delete" } then {
 	  remote_file target delete $target_exec
 	} elseif { $action == "permission" } {
-	  remote_spawn target "chmod 000 $target_exec"
+	  remote_exec target "chmod 000 $target_exec"
 	}
        
 	# Connect to GDBserver.

base-commit: f52fb009085e63da25eeacd39990ac6243ffed76
-- 
2.35.3


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

* [pushed 2/3] [gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host
  2022-10-27 14:54 [pushed 1/3] [gdb/testsuite] Use remote_exec chmod instead of remote_spawn Tom de Vries
@ 2022-10-27 14:54 ` Tom de Vries
  2022-10-27 14:54 ` [pushed 3/3] [gdb/testsuite] Disable styling in host board local-remote-host-native.exp Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2022-10-27 14:54 UTC (permalink / raw)
  To: gdb-patches

I noticed that running test-case gdb.mi/mi-exec-run.exp with host board
local-remote-host.exp takes about 44 seconds.

I found two silent timeouts responsible for this.

The first is in mi_gdb_exit, where we have:
...
    if { [is_remote host] && [board_info host exists fileid] } {
        send_gdb "999-gdb-exit\n"
        gdb_expect 10 {
            -re "y or n" {
                send_gdb "y\n"
                exp_continue
            }
            -re "Undefined command.*$gdb_prompt $" {
                send_gdb "quit\n"
                exp_continue
            }
            -re "DOSEXIT code" { }
        }
    }
...
so in gdb.log we see:
...
999-gdb-exit^M
999^exit^M
=thread-exited,id="1",group-id="i1"^M
=thread-group-exited,id="i1"^M
...
after which expect just waits for the timeout.

Fix this by adding a gdb_expect clause to parse the exit:
...
            -re "\r\n999\\^exit\r\n" { }
...

Note that we're not parsing the thread-exited/thread-group-exited messages, because
they may not be present:
...
$ gdb -i=mi
=thread-group-added,id="i1"
(gdb)
999-gdb-exit
999^exit
$
...

After fixing that, we have:
...
(gdb) ^M
saw mi error
PASS: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: \
  force-fail=1: run failure detected
quit^M
&"quit\n"^M
...

What seems to be happening is that default_gdb_exit sends a cli interpreter
quit command to an mi interpreter, after which again expect just waits for the
timeout.

Fix this by adding mi_gdb_exit to the end of the test-case, as in many other
gdb.mi/*.exp test-cases.

After these two fixes, the test-case takes about 4 seconds.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.mi/mi-exec-run.exp | 2 ++
 gdb/testsuite/lib/mi-support.exp     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi-exec-run.exp
index 3b373b2c84d..01f52e22578 100644
--- a/gdb/testsuite/gdb.mi/mi-exec-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp
@@ -180,3 +180,5 @@ foreach_with_prefix inferior-tty {"main" "separate"} {
 	}
     }
 }
+
+mi_gdb_exit
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index e537d3b546b..b11457693be 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -83,7 +83,7 @@ proc mi_uncatched_gdb_exit {} {
 		exp_continue
 	    }
 	    -re "DOSEXIT code" { }
-	    default { }
+	    -re "\r\n999\\^exit\r\n" { }
 	}
     }
 
-- 
2.35.3


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

* [pushed 3/3] [gdb/testsuite] Disable styling in host board local-remote-host-native.exp
  2022-10-27 14:54 [pushed 1/3] [gdb/testsuite] Use remote_exec chmod instead of remote_spawn Tom de Vries
  2022-10-27 14:54 ` [pushed 2/3] [gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host Tom de Vries
@ 2022-10-27 14:54 ` Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2022-10-27 14:54 UTC (permalink / raw)
  To: gdb-patches

Propagate fix from commit 17c68d98f74 ("[gdb/testsuite] Disable styling in host
board local-remote-host.exp") to local-remote-host-native.exp.

Tested on x86_64-linux.
---
 gdb/testsuite/boards/local-remote-host-native.exp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/testsuite/boards/local-remote-host-native.exp b/gdb/testsuite/boards/local-remote-host-native.exp
index f784e2617a8..472a8ea8c27 100644
--- a/gdb/testsuite/boards/local-remote-host-native.exp
+++ b/gdb/testsuite/boards/local-remote-host-native.exp
@@ -83,3 +83,7 @@ proc ${board}_download { board src dest } {
 
     return $destfile
 }
+
+if { $board_type == "host" } {
+    set GDBFLAGS "${GDBFLAGS} -iex \"set style enabled off\""
+}
-- 
2.35.3


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

end of thread, other threads:[~2022-10-27 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 14:54 [pushed 1/3] [gdb/testsuite] Use remote_exec chmod instead of remote_spawn Tom de Vries
2022-10-27 14:54 ` [pushed 2/3] [gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote host Tom de Vries
2022-10-27 14:54 ` [pushed 3/3] [gdb/testsuite] Disable styling in host board local-remote-host-native.exp Tom de Vries

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