[binutils-gdb] Update gdb.ada/unchecked_union.exp for gnat-llvm

Tom Tromey via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8e0b14a98975d5762117f4d145443ac4df0b0396

commit 8e0b14a98975d5762117f4d145443ac4df0b0396
Author: Tom Tromey <[email protected]>
Date:   Wed Jul 29 15:21:42 2026 -0600

    Update gdb.ada/unchecked_union.exp for gnat-llvm
    
    gnat-llvm emits a slightly different encoding for Ada unchecked
    unions. This encoding lets GDB resolve the discriminant for some
    branches that appear as "?" when compiled with GCC's GNAT.
    
    This patch updates gdb.ada/unchecked_union.exp to allow this.
    
    Approved-By: Andrew Burgess <[email protected]>

Diff:
---
 gdb/testsuite/gdb.ada/unchecked_union.exp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/unchecked_union.exp b/gdb/testsuite/gdb.ada/unchecked_union.exp
index 6a54e606712..ef9da787e65 100644
--- a/gdb/testsuite/gdb.ada/unchecked_union.exp
+++ b/gdb/testsuite/gdb.ada/unchecked_union.exp
@@ -24,20 +24,23 @@ standard_ada_testfile unchecked_union
 proc multi_line_string {str} {
     set result {}
     foreach line $str {
-	lappend result [string_to_regexp $line]
+	lappend result [quotemeta $line]
     }
     set res [multi_line {*}$result]
     verbose -log "RES: '$res'"
     return $res
 }
 
+# Note the quotemeta expression here.  gnat-llvm emits slightly a
+# different encoding here, which lets gdb see the discriminant for a
+# branch.
 set inner_string \
     [list \
 	 "    case ? is" \
 	 "        when 0 =>" \
 	 "            small: range 0 .. 255;" \
 	 "            second: range 0 .. 255;" \
-	 "        when ? =>" \
+	 "        when @/\[1?\]/ =>" \
 	 "            bval: range 0 .. 255;" \
 	 "        when others =>" \
 	 "            large: range 255 .. 510;" \
@@ -50,12 +53,15 @@ set inner_full \
 	 $inner_string \
 	 [list "end record"]]
 
+# Note the quotemeta expression here.  gnat-llvm emits slightly a
+# different encoding here, which lets gdb see the discriminant for a
+# branch.
 set pair_string \
     [list \
 	 "    case ? is" \
-	 "        when ? =>" \
+	 "        when @/\[0?\]/ =>" \
 	 "            field_one: range 0 .. 255;" \
-	 "        when ? =>" \
+	 "        when @/(\\?|others)/ =>" \
 	 "            field_two: range 255 .. 510;" \
 	 "    end case;"]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.