Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Fix timeouts in gdb.base/tls-dlobj.exp
@ 2026-01-07  9:19 Tom de Vries
  2026-01-09  4:00 ` Kevin Buettner
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2026-01-07  9:19 UTC (permalink / raw)
  To: gdb-patches

When running the testsuite on a busy system, occasionally I run into timeouts in
test-case gdb.base/tls-dlobj.exp (gdb build with -O0, as usual).

When building gdb with Address Sanitizer (and still with -O0), I always run
into timeouts, though it may differ where in the test-case.

I can address this using with_timeout_factor, and the test-case finishes after
a while without timeouts:
...
real	2m30.139s
user	2m32.834s
sys	0m1.777s
...

But the preferred way to deal with this is to cut up the long operation in
smaller observable steps, each with their own timeout, so I tried out
eliminating the use of continue in the test-case, and using next instead.

In order not to spent too much time stepping through for loops like this:
...
  for (i = 1; i <= 4; i++)
    s0 (i, 10 + i);
...
I rewrote those to a single line.

With this new approach, I get instead:
...
real	0m5.950s
user	0m8.239s
sys	0m1.318s
...

I'm not sure why there's such a big difference in execution time, but the
functionality of the test-case hasn't changed, so I'm assuming this is related
to Address Sanitizer behavior.

Tested on x86_64-linux.

PR testsuite/33707
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33707
---
 gdb/testsuite/gdb.base/tls-dlobj.c   | 150 +++++++++------------------
 gdb/testsuite/gdb.base/tls-dlobj.exp |  35 +++----
 2 files changed, 65 insertions(+), 120 deletions(-)

diff --git a/gdb/testsuite/gdb.base/tls-dlobj.c b/gdb/testsuite/gdb.base/tls-dlobj.c
index b6dc6e45e93..e99d7a590c1 100644
--- a/gdb/testsuite/gdb.base/tls-dlobj.c
+++ b/gdb/testsuite/gdb.base/tls-dlobj.c
@@ -99,20 +99,13 @@ main (int argc, char **argv)
   use_it (0);		/* main-breakpoint-1 */
 
   /* Set TLS variables in main program and all libraries.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 10 + i);
-  for (i = 1; i <= 4; i++)
-    s1 (i, 110 + i);
-  for (i = 1; i <= 4; i++)
-    s2 (i, 210 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 310 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 410 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1010 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1110 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 10 + i);
+  for (i = 1; i <= 4; i++) s1 (i, 110 + i);
+  for (i = 1; i <= 4; i++) s2 (i, 210 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 310 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 410 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1010 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1110 + i);
 
   use_it (0);		/* main-breakpoint-2 */
 
@@ -124,16 +117,11 @@ main (int argc, char **argv)
 
   /* Set TLS variables in main program and in libraries which are still
      loaded.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 20 + i);
-  for (i = 1; i <= 4; i++)
-    s1 (i, 120 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 420 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1020 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1120 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 20 + i);
+  for (i = 1; i <= 4; i++) s1 (i, 120 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 420 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1020 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1120 + i);
 
   use_it (0);		/* main-breakpoint-3 */
 
@@ -141,18 +129,12 @@ main (int argc, char **argv)
   h3 = load_dso (OBJ3, 3, &s3);
 
   /* Set TLS vars again; currently, only lib2 is not loaded.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 30 + i);
-  for (i = 1; i <= 4; i++)
-    s1 (i, 130 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 330 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 430 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1030 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1130 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 30 + i);
+  for (i = 1; i <= 4; i++) s1 (i, 130 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 330 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 430 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1030 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1130 + i);
 
   use_it (0);		/* main-breakpoint-4 */
 
@@ -165,16 +147,11 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib2 and lib3 are loaded,
      lib1 and lib4 are not.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 40 + i);
-  for (i = 1; i <= 4; i++)
-    s2 (i, 240 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 340 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1040 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1140 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 40 + i);
+  for (i = 1; i <= 4; i++) s2 (i, 240 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 340 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1040 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1140 + i);
 
   use_it (0);		/* main-breakpoint-5 */
 
@@ -186,18 +163,12 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib1, lib3, and lib4 are loaded;
      lib2 is not loaded.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 50 + i);
-  for (i = 1; i <= 4; i++)
-    s1 (i, 150 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 350 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 450 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1050 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1150 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 50 + i);
+  for (i = 1; i <= 4; i++) s1 (i, 150 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 350 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 450 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1050 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1150 + i);
 
   use_it (0);		/* main-breakpoint-6 */
 
@@ -213,16 +184,11 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib2 and lib3 are loaded;
      lib1 and lib4 are not loaded.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 60 + i);
-  for (i = 1; i <= 4; i++)
-    s2 (i, 260 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 360 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1060 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1160 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 60 + i);
+  for (i = 1; i <= 4; i++) s2 (i, 260 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 360 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1060 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1160 + i);
 
   use_it (0);		/* main-breakpoint-7 */
 
@@ -239,20 +205,13 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib1, lib2, lib3, and lib4 are all
      loaded.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 70 + i);
-  for (i = 1; i <= 4; i++)
-    s1 (i, 170 + i);
-  for (i = 1; i <= 4; i++)
-    s2 (i, 270 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 370 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 470 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1070 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1170 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 70 + i);
+  for (i = 1; i <= 4; i++) s1 (i, 170 + i);
+  for (i = 1; i <= 4; i++) s2 (i, 270 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 370 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 470 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1070 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1170 + i);
 
   use_it (0);		/* main-breakpoint-8 */
 
@@ -266,14 +225,10 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib2 is loaded; lib1, lib3, and lib4 are
      not.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 80 + i);
-  for (i = 1; i <= 4; i++)
-    s2 (i, 280 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1080 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1180 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 80 + i);
+  for (i = 1; i <= 4; i++) s2 (i, 280 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1080 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1180 + i);
 
   use_it (0);		/* main-breakpoint-9 */
 
@@ -285,16 +240,11 @@ main (int argc, char **argv)
 
   /* Set TLS vars; currently, lib3 and lib4 are loaded; lib1 and lib2
      are not.  */
-  for (i = 1; i <= 4; i++)
-    s0 (i, 90 + i);
-  for (i = 1; i <= 4; i++)
-    s3 (i, 390 + i);
-  for (i = 1; i <= 4; i++)
-    s4 (i, 490 + i);
-  for (i = 1; i <= 4; i++)
-    s10 (i, 1090 + i);
-  for (i = 1; i <= 4; i++)
-    s11 (i, 1190 + i);
+  for (i = 1; i <= 4; i++) s0 (i, 90 + i);
+  for (i = 1; i <= 4; i++) s3 (i, 390 + i);
+  for (i = 1; i <= 4; i++) s4 (i, 490 + i);
+  for (i = 1; i <= 4; i++) s10 (i, 1090 + i);
+  for (i = 1; i <= 4; i++) s11 (i, 1190 + i);
 
   use_it (0);		/* main-breakpoint-10 */
 
diff --git a/gdb/testsuite/gdb.base/tls-dlobj.exp b/gdb/testsuite/gdb.base/tls-dlobj.exp
index 68c8b781473..0b8cb35aa7d 100644
--- a/gdb/testsuite/gdb.base/tls-dlobj.exp
+++ b/gdb/testsuite/gdb.base/tls-dlobj.exp
@@ -55,6 +55,11 @@ proc gdb_test_with_xfail { cmd re cond} {
     }
 }
 
+proc next_to_main_breakpoint { n } {
+    repeat_cmd_until next "" main-breakpoint-$n \
+	"step to breakpoint: main-breakpoint-$n" 20
+}
+
 proc do_tests {force_internal_tls} {
     clean_restart $::testfile
     if {![runto_main]} {
@@ -65,8 +70,7 @@ proc do_tests {force_internal_tls} {
 	gdb_test_no_output "maint set force-internal-tls-address-lookup on"
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-1"]
-    gdb_continue_to_breakpoint "main-breakpoint-1"
+    next_to_main_breakpoint 1
 
     with_test_prefix "before assignments" {
 	gdb_test "print tls_main_tbss_1" ".* = 0"
@@ -100,8 +104,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-2"]
-    gdb_continue_to_breakpoint "main-breakpoint-2"
+    next_to_main_breakpoint 2
 
     with_test_prefix "at main-breakpoint-2" {
 	gdb_test "print tls_main_tbss_1" ".* = 11"
@@ -117,8 +120,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-3"]
-    gdb_continue_to_breakpoint "main-breakpoint-3"
+    next_to_main_breakpoint 3
 
     # At this point lib2 and lib3 have been unloaded.  Also, TLS vars
     # in remaining libraries have been changed.
@@ -137,8 +139,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-4"]
-    gdb_continue_to_breakpoint "main-breakpoint-4"
+    next_to_main_breakpoint 4
 
     # lib3 has been loaded again; lib2 is the only one not loaded.
 
@@ -157,8 +158,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-5"]
-    gdb_continue_to_breakpoint "main-breakpoint-5"
+    next_to_main_breakpoint 5
 
     # lib2 and lib3 are loaded; lib1 and lib4 are not.
 
@@ -177,8 +177,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-6"]
-    gdb_continue_to_breakpoint "main-breakpoint-6"
+    next_to_main_breakpoint 6
 
     # lib1, lib3 and lib4 are loaded; lib2 is not loaded.
 
@@ -197,8 +196,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-7"]
-    gdb_continue_to_breakpoint "main-breakpoint-7"
+    next_to_main_breakpoint 7
 
     # lib2 and lib3 are loaded; lib1 and lib4 are not.
 
@@ -217,8 +215,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-8"]
-    gdb_continue_to_breakpoint "main-breakpoint-8"
+    next_to_main_breakpoint 8
 
     # lib1, lib2, lib3, and lib4 are all loaded.
 
@@ -236,8 +233,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-9"]
-    gdb_continue_to_breakpoint "main-breakpoint-9"
+    next_to_main_breakpoint 9
 
     # lib2 is loaded; lib1, lib3, and lib4 are not.
 
@@ -255,8 +251,7 @@ proc do_tests {force_internal_tls} {
 	}
     }
 
-    gdb_breakpoint [gdb_get_line_number "main-breakpoint-10"]
-    gdb_continue_to_breakpoint "main-breakpoint-10"
+    next_to_main_breakpoint 10
 
     # lib3 and lib4 are loaded; lib1 and lib2 are not.
 

base-commit: fc9bd3b1baffa2af37d494751012d25618fdede5
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-10  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-07  9:19 [PATCH] [gdb/testsuite] Fix timeouts in gdb.base/tls-dlobj.exp Tom de Vries
2026-01-09  4:00 ` Kevin Buettner
2026-01-09 12:40   ` Tom de Vries
2026-01-09 13:02     ` Tom de Vries
2026-01-10  9:56     ` 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