Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [pushed] Make two Ada tests more robust
@ 2026-06-09 16:38 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2026-06-09 16:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

tasks.exp and task_watch.exp were failing when run with gnat-llvm.
Investigating these showed the same problem (which makes sense because
the tests use the same program).  In this code:

    for J in Task_List'Range loop  -- STOP_HERE
       Task_List (J).Call_Break_Me;
    end loop;

... with GCC, the breakpoint set on the 'for' line is only hit a
single time.  However, with gnat-llvm, the breakpoint is hit on every
iteration of the loop.  IMO this is a GCC bug.

Similarly, at the end of the function:

    null; -- STOP_HERE_2

... with gnat-llvm, a breakpoint set here was not being hit.  It seems
perhaps somewhat strange to set a breakpoint on a null statement at
the end of a function; and while this might possibly be a gnat-llvm
bug, this isn't really the point of this test.

This patch makes these tests more robust by arranging for the
breakpoints to be set before the loop and on a call, respectively.

Because this is Ada-specific, was reviewed internally, and is just a
minor test case adjustment, I am checking it in.
---
 gdb/testsuite/gdb.ada/task_watch.exp     |  3 ++-
 gdb/testsuite/gdb.ada/task_watch/foo.adb | 10 ++++++++--
 gdb/testsuite/gdb.ada/tasks.exp          |  3 ++-
 gdb/testsuite/gdb.ada/tasks/foo.adb      | 10 ++++++++--
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/task_watch.exp b/gdb/testsuite/gdb.ada/task_watch.exp
index a39773f4925..7031abf41ff 100644
--- a/gdb/testsuite/gdb.ada/task_watch.exp
+++ b/gdb/testsuite/gdb.ada/task_watch.exp
@@ -82,4 +82,5 @@ gdb_test "info tasks" \
 # running to completion.
 set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb]
 gdb_breakpoint foo.adb:$bp_location
-gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2"
+gdb_continue_to_breakpoint second \
+    ".*foo.adb:$bp_location.*Do_Nothing; -- STOP_HERE_2"
diff --git a/gdb/testsuite/gdb.ada/task_watch/foo.adb b/gdb/testsuite/gdb.ada/task_watch/foo.adb
index 7db4565022b..c8ae2f389ba 100644
--- a/gdb/testsuite/gdb.ada/task_watch/foo.adb
+++ b/gdb/testsuite/gdb.ada/task_watch/foo.adb
@@ -24,6 +24,11 @@ procedure Foo is
    end Caller;
    type Caller_Ptr is access Caller;
 
+   procedure Do_Nothing is
+   begin
+      null;
+   end Do_Nothing;
+
    procedure Break_Me is
    begin
       Value := Value + 1;
@@ -59,7 +64,8 @@ begin
 
    --  Next, call their Call_Break_Me entry of each task, using the same
    --  order as the order used to create them.
-   for J in Task_List'Range loop  -- STOP_HERE
+   Do_Nothing;                   --  STOP_HERE
+   for J in Task_List'Range loop
       Task_List (J).Call_Break_Me;
    end loop;
 
@@ -68,6 +74,6 @@ begin
       Task_List (J).Finalize;
    end loop;
 
-   null; -- STOP_HERE_2
+   Do_Nothing; -- STOP_HERE_2
 
 end Foo;
diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp
index 9862663d566..b37cf0cadd1 100644
--- a/gdb/testsuite/gdb.ada/tasks.exp
+++ b/gdb/testsuite/gdb.ada/tasks.exp
@@ -178,7 +178,8 @@ gdb_test "info tasks" \
 # running to completion.
 set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb]
 gdb_breakpoint foo.adb:$bp_location
-gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2"
+gdb_continue_to_breakpoint second \
+    ".*foo.adb:$bp_location.*Do_Nothing; -- STOP_HERE_2"
 
 # A regression test for a crash caused by trying to find the thread
 # for a terminated task.
diff --git a/gdb/testsuite/gdb.ada/tasks/foo.adb b/gdb/testsuite/gdb.ada/tasks/foo.adb
index f19672d6ae4..dfc6664130e 100644
--- a/gdb/testsuite/gdb.ada/tasks/foo.adb
+++ b/gdb/testsuite/gdb.ada/tasks/foo.adb
@@ -22,6 +22,11 @@ procedure Foo is
    end Caller;
    type Caller_Ptr is access Caller;
 
+   procedure Do_Nothing is
+   begin
+      null;
+   end Do_Nothing;
+
    procedure Break_Me is
    begin
       null;
@@ -57,7 +62,8 @@ begin
 
    --  Next, call their Call_Break_Me entry of each task, using the same
    --  order as the order used to create them.
-   for J in Task_List'Range loop  -- STOP_HERE
+   Do_Nothing;                  --  STOP_HERE
+   for J in Task_List'Range loop
       Task_List (J).Call_Break_Me;
    end loop;
 
@@ -66,6 +72,6 @@ begin
       Task_List (J).Finalize;
    end loop;
 
-   null; -- STOP_HERE_2
+   Do_Nothing; -- STOP_HERE_2
 
 end Foo;

base-commit: 1eed06ae51d73a195b78ce0903ada9c9c2c14cfb
-- 
2.54.0


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

only message in thread, other threads:[~2026-06-09 16:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-09 16:38 [pushed] Make two Ada tests more robust Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox