public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Make portnum a persistent global
@ 2024-05-04  8:40 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2024-05-04  8:40 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c42c12f9bf93b5f10f3d6dc10f45d9484a7f9faa

commit c42c12f9bf93b5f10f3d6dc10f45d9484a7f9faa
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat May 4 10:41:09 2024 +0200

    [gdb/testsuite] Make portnum a persistent global
    
    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>

Diff:
---
 gdb/testsuite/lib/gdbserver-support.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index bf000119db6..0f97ce9c0fd 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -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] } {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-04  8:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-04  8:40 [binutils-gdb] [gdb/testsuite] Make portnum a persistent global 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).