Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Update gdb.ada/unchecked_union.exp for gnat-llvm
@ 2026-08-17 19:54 Tom Tromey
  2026-08-18 12:41 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2026-08-17 19:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gnat-llvm emits a slightly different encoding for Ada unchecked
unions.  In particular this will let gdb show the discrminant for some
branches of a union which currently cannot be seen in GCC's output.

This patch updates gdb.ada/unchecked_union.exp to allow this.
---
 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;"]
 

base-commit: 0f9faaebc91bc1886a563bde6c178601b4be743b
-- 
2.55.0


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

* Re: [PATCH] Update gdb.ada/unchecked_union.exp for gnat-llvm
  2026-08-17 19:54 [PATCH] Update gdb.ada/unchecked_union.exp for gnat-llvm Tom Tromey
@ 2026-08-18 12:41 ` Andrew Burgess
  2026-08-18 17:35   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2026-08-18 12:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches; +Cc: Tom Tromey

Tom Tromey <tromey@adacore.com> writes:

> gnat-llvm emits a slightly different encoding for Ada unchecked
> unions.  In particular this will let gdb show the discrminant for some
> branches of a union which currently cannot be seen in GCC's output.

I found this text really hard to understand initially.  I initially
thought the "this" in the second sentence was talking about "this
patch", the encoding change.  I also assumed the talk about "GCC's
output" was a typo for "GDB's output", but you really mean "GDB's output
when compiling with GCC's GNAT".

Could I suggest a rewording:

  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.

I do wish the quotemeta system didn't do hungry white space matching by
default, especially as it's use expands through the testsuite.  But
that's out of scope for this patch, which looks good.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


>
> This patch updates gdb.ada/unchecked_union.exp to allow this.
> ---
>  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;"]
>  
>
> base-commit: 0f9faaebc91bc1886a563bde6c178601b4be743b
> -- 
> 2.55.0


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

* Re: [PATCH] Update gdb.ada/unchecked_union.exp for gnat-llvm
  2026-08-18 12:41 ` Andrew Burgess
@ 2026-08-18 17:35   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2026-08-18 17:35 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> Could I suggest a rewording:

I made this change.

Andrew> I do wish the quotemeta system didn't do hungry white space matching by
Andrew> default, especially as it's use expands through the testsuite.  But
Andrew> that's out of scope for this patch, which looks good.

Better to fix things early than late.

I did it this way mainly because that's how the AdaCore one works; but
the rationale for that is it makes the test suite less sensitive to
word-wrap decisions.

We could perhaps handle this a different way though, like a special "@{ }"
or something.

Also I suppose maybe in practice the word wrap issue may not come up all
that much.  I'm not sure.

Tom

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

end of thread, other threads:[~2026-08-18 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-17 19:54 [PATCH] Update gdb.ada/unchecked_union.exp for gnat-llvm Tom Tromey
2026-08-18 12:41 ` Andrew Burgess
2026-08-18 17:35   ` Tom Tromey

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