[binutils-gdb] Make two Ada tests more robust

Tom Tromey via Gdb-cvs <[email protected]> Tue, 9 Jun 2026 16:39:42 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d47ddaea734d0e423378466a7d899175e4a52796

commit d47ddaea734d0e423378466a7d899175e4a52796
Author: Tom Tromey <[email protected]>
Date:   Tue Jun 9 07:36:37 2026 -0600

    Make two Ada tests more robust
    
    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.

Diff:
---
 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;