]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Make portnum a persistent global
authorTom de Vries <tdevries@suse.de>
Sat, 4 May 2024 08:41:09 +0000 (10:41 +0200)
committerTom de Vries <tdevries@suse.de>
Sat, 4 May 2024 08:41:09 +0000 (10:41 +0200)
When instrumenting get_portnum using:
...
    puts "PORTNUM: $res"
...
and running:
...
$ cd build/gdb
$ make check TESTS=gdb.server/*.exp
...
we get:
...
Running gdb.server/target-exec-file.exp ...
PORTNUM: 2345
Running gdb.server/stop-reply-no-thread-multi.exp ...
PORTNUM: 2345
PORTNUM: 2346
PORTNUM: 2347
PORTNUM: 2348
PORTNUM: 2349
PORTNUM: 2350
...

So, while get_portnum does return increasing numbers in a single test-case, it
restarts at each test-case.

This is a regression since the introduction of persistent globals.

Fix this by using "gdb_persistent_global portnum", such that we get:
...
Running gdb.server/target-exec-file.exp ...
PORTNUM: 2345
Running gdb.server/stop-reply-no-thread-multi.exp ...
PORTNUM: 2346
PORTNUM: 2347
PORTNUM: 2348
PORTNUM: 2349
PORTNUM: 2350
PORTNUM: 2351
...

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/lib/gdbserver-support.exp

index bf000119db6405ca1f97ce980e156129e8dd7ce6..0f97ce9c0fd384c7ff84fcca09c25bc097bc6330 100644 (file)
@@ -142,7 +142,7 @@ proc get_portnum {} {
     set initial_portnum 2345
 
     # Currently available port number.
-    global portnum
+    gdb_persistent_global portnum
 
     # Initialize, if necessary.
     if { ![info exists portnum] } {