[committed] testsuite: Fix a `server_pid' access crash in gdb.server/server-kill.exp

Message ID alpine.DEB.2.00.1805151547410.10896@tp.orcam.me.uk
State Committed
Headers

Commit Message

Maciej W. Rozycki May 15, 2018, 2:56 p.m. UTC
  Fix a commit f90183d7e31b ("Get GDBserver pid on remote target") bug and 
correctly handle the case where the PID of `gdbserver' could not have 
been retrieved.  If that happens, $server_pid is unset causing:

FAIL: gdb.server/server-kill.exp: p server_pid
ERROR: tcl error sourcing .../gdb/testsuite/gdb.server/server-kill.exp.
ERROR: can't read "server_pid": no such variable
    while executing
"if {$server_pid == "" } {
    return -1
}"
    (file ".../gdb/testsuite/gdb.server/server-kill.exp" line 49)
    invoked from within
"source .../gdb/testsuite/gdb.server/server-kill.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source .../gdb/testsuite/gdb.server/server-kill.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

Verify that the variable exists then rather than trying to access it.

	gdb/testsuite/
	* gdb.server/server-kill.exp: Verify whether `server_pid' exists
	rather then trying to access it in determining whether the PID 
	of `gdbserver' could have been retrieved.
---
Hi,

 Committed as obvious.

  Maciej
---
 gdb/testsuite/gdb.server/server-kill.exp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

gdb-test-server-kill-pid.diff
  

Patch

Index: gdb/gdb/testsuite/gdb.server/server-kill.exp
===================================================================
--- gdb.orig/gdb/testsuite/gdb.server/server-kill.exp	2018-02-23 14:15:32.000000000 +0000
+++ gdb/gdb/testsuite/gdb.server/server-kill.exp	2018-05-11 18:39:10.143071990 +0100
@@ -46,7 +46,7 @@  gdb_test_multiple $test $test {
     }
 }
 
-if {$server_pid == "" } {
+if ![info exists server_pid] {
     return -1
 }