[1/2,gdb/testsuite] Simplify gdb.server/server-kill-python.exp

Message ID 20240412175101.9154-1-tdevries@suse.de
State Committed
Headers
Series [1/2,gdb/testsuite] Simplify gdb.server/server-kill-python.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom de Vries April 12, 2024, 5:51 p.m. UTC
  In test-case gdb.server/server-kill-python.exp we have:
...
if {[gdb_spawn_with_cmdline_opts \
         "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} {
    fail "spawn"
    return
}
...

I reproduced the problem by reverting the fix at the commit adding both the
fix and the test-case, and the reproduced the same problem using:
...
(gdb) source $host_file1
...
so there doesn't seem to be a specific need to source the python file using
"-ex".

Simplify the test-case by sourcing the python file using send_gdb.

This also allow us to simplify the python script.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.server/server-kill-python.exp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


base-commit: 3d67591c6ff0443e36cbc38ece082cc240e87bf6
  

Comments

Tom Tromey April 16, 2024, 5:21 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom>  # Now start GDB, sourcing the python command file we generated above.
Tom>  # Set the height and width so we don't end up at a paging prompt.
Tom>  if {[gdb_spawn_with_cmdline_opts \
Tom> -	 "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} {
Tom> +	 "-quiet -iex \"set height 0\" -iex \"set width 0\""] != 0} {
Tom>      fail "spawn"
Tom>      return

Do this even need any arguments now?  I thought the default was to set
width and height to 0.

Tom
  
Tom de Vries April 17, 2024, 9:48 a.m. UTC | #2
On 4/16/24 19:21, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom>  # Now start GDB, sourcing the python command file we generated above.
> Tom>  # Set the height and width so we don't end up at a paging prompt.
> Tom>  if {[gdb_spawn_with_cmdline_opts \
> Tom> -	 "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} {
> Tom> +	 "-quiet -iex \"set height 0\" -iex \"set width 0\""] != 0} {
> Tom>      fail "spawn"
> Tom>      return
> 
> Do this even need any arguments now?  I thought the default was to set
> width and height to 0.

Indeed that's not needed.

I've committed this in the current, "minimal change" form, and I'll 
write a patch cleaning up the issue you raised here in general.

Thanks,
- Tom
  

Patch

diff --git a/gdb/testsuite/gdb.server/server-kill-python.exp b/gdb/testsuite/gdb.server/server-kill-python.exp
index ebf6176ebba..87f9b56bd39 100644
--- a/gdb/testsuite/gdb.server/server-kill-python.exp
+++ b/gdb/testsuite/gdb.server/server-kill-python.exp
@@ -48,8 +48,6 @@  puts $fd \
 "import gdb
 
 def do_gdb_stuff ():
-    gdb.execute ('file $host_binfile')
-    gdb.execute ('target $gdbserver_protocol $gdbserver_gdbport')
     gdb.execute ('break $srcfile:$break_linenr')
     gdb.execute ('continue')
     gdb.execute ('p server_pid')
@@ -63,11 +61,15 @@  set host_file1 [gdb_remote_download host $file1]
 # Now start GDB, sourcing the python command file we generated above.
 # Set the height and width so we don't end up at a paging prompt.
 if {[gdb_spawn_with_cmdline_opts \
-	 "-quiet -iex \"set height 0\" -iex \"set width 0\" -ex \"source $host_file1\""] != 0} {
+	 "-quiet -iex \"set height 0\" -iex \"set width 0\""] != 0} {
     fail "spawn"
     return
 }
 
+gdb_load $binfile
+gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
+send_gdb "source $host_file1\n"
+
 # Get the gdbserver PID.
 set gdbserver_pid 0