From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 5F604381E718; Thu, 27 Oct 2022 14:53:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F604381E718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666882423; bh=OO4KCK3mMN2sY1u19MO6qYun4CJEH6DYEZuj3i/dvPI=; h=From:To:Subject:Date:From; b=nolzZqY/8fSxREtX47eM4ZbjfrXbkxGCvQplVWvUSo9yy1TKMMfcQs2p3oF69lcSr sT1B17PrOhGDePo/FyhcLRtHKoMH6JEghkt+1+YUJT5+uGMIHXZAbXe9R8vW0y0Dx7 HuH2beKvEAdbuckGj+Qt0ufo6eXtHfgspDcZuQ9Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Use remote_exec chmod instead of remote_spawn X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: f52fb009085e63da25eeacd39990ac6243ffed76 X-Git-Newrev: b253899c901fed0ff56b2746945ffc824e412b81 Message-Id: <20221027145343.5F604381E718@sourceware.org> Date: Thu, 27 Oct 2022 14:53:42 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db253899c901f= ed0ff56b2746945ffc824e412b81 commit b253899c901fed0ff56b2746945ffc824e412b81 Author: Tom de Vries Date: Thu Oct 27 16:53:12 2022 +0200 [gdb/testsuite] Use remote_exec chmod instead of remote_spawn =20 I build gdb using -O2, and ran the testsuite using taskset -c 0, and ra= n into: ... (gdb) PASS: gdb.server/connect-with-no-symbol-file.exp: sysroot=3D: \ action=3Ddelete: setup: adjust sysroot builtin_spawn gdbserver --once localhost:2385 /connect-with-no-symbol-f= ile^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=3D: \ action=3Ddelete: connection to GDBserver succeeded ... =20 The expected series of events is (skipping disconnect and detach as I d= on'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 =20 The problem is that the chmod is executed using remote_spawn: ... } elseif { $action =3D=3D "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. =20 The FAIL we're seeing above is explained by the chmod having effect dur= ing the delete scenario, after the "cp $exec.bak $exec" and before the "gdbserv= er start with $exec". =20 Fix this by using remote_exec instead. =20 Likewise, fix a similar case in gdb.mi/mi-exec-run.exp. =20 Tested on x86_64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29726 Diff: --- 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" =20 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 =3D=3D "delete" } then { remote_file target delete $target_exec } elseif { $action =3D=3D "permission" } { - remote_spawn target "chmod 000 $target_exec" + remote_exec target "chmod 000 $target_exec" } =20 # Connect to GDBserver.