* [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers
@ 2026-07-13 9:11 srinath.parvathaneni
2026-07-13 12:26 ` Simon Marchi
2026-07-13 13:37 ` Aktemur, Baris
0 siblings, 2 replies; 3+ messages in thread
From: srinath.parvathaneni @ 2026-07-13 9:11 UTC (permalink / raw)
To: gdb-patches
Cc: guinevere, thiago.bauermann, luis.machado.foss, Ezra.Sitorus,
Srinath Parvathaneni
From: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
GDB reports "Invalid cast" when assigning small integer literals (32-bit) to
64-bit TYPE_CODE_FLAGS registers. For example, with the existing upstream FPMR
register, set $fpmr = 0x777777777 succeeds, whereas set $fpmr = 0x77 fails with
"Invalid cast" and this patch fixes the issue but makes changes to a generic
function value_cast in gdb/valops.c.
* testsuite/gdb.arch/aarch64-fpmr.exp : Add "set $fpmr" test.
* gdb/valops.c (value_cast): Add TYPE_CODE_FLAGS condition to integer
assignment.
Regression tested on aarch64-none-linux-gnu with no regressions.
Ok for GDB master?
Regards,
Srinath
---
gdb/testsuite/gdb.arch/aarch64-fpmr.exp | 6 ++++++
gdb/valops.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.arch/aarch64-fpmr.exp b/gdb/testsuite/gdb.arch/aarch64-fpmr.exp
index 72fd977fc67..2eee10fe924 100644
--- a/gdb/testsuite/gdb.arch/aarch64-fpmr.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-fpmr.exp
@@ -97,3 +97,9 @@ gdb_test_multiple "set \$fpmr=0x3f007f4008" "" {
pass "Write to FPMR from GDB"
}
}
+
+gdb_test_multiple "set \$fpmr=0x1255C041" "" {
+ -re ".*\r\n.*\[ F8S1=E4M3 F8S2=E5M2 F8D=E4M3 OSM=MaxNormal OSC=MaxNormal LSCALE=85 NSCALE=18 LSCALE2=0 \]" {
+ pass "Write 32-bit value to 64-bit register FPMR from GDB"
+ }
+}
diff --git a/gdb/valops.c b/gdb/valops.c
index ab6fd5079e1..170311dc63c 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -557,7 +557,7 @@ value_cast (struct type *type, struct value *arg2)
return value_from_longest (to_type, value_as_long (arg2));
}
else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM
- || code1 == TYPE_CODE_RANGE)
+ || code1 == TYPE_CODE_RANGE || code1 == TYPE_CODE_FLAGS)
&& (scalar || code2 == TYPE_CODE_PTR
|| code2 == TYPE_CODE_MEMBERPTR))
{
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers
2026-07-13 9:11 [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers srinath.parvathaneni
@ 2026-07-13 12:26 ` Simon Marchi
2026-07-13 13:37 ` Aktemur, Baris
1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-07-13 12:26 UTC (permalink / raw)
To: srinath.parvathaneni, gdb-patches
Cc: guinevere, thiago.bauermann, luis.machado.foss, Ezra.Sitorus
On 7/13/26 5:11 AM, srinath.parvathaneni@arm.com wrote:
> From: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
>
> GDB reports "Invalid cast" when assigning small integer literals (32-bit) to
> 64-bit TYPE_CODE_FLAGS registers. For example, with the existing upstream FPMR
> register, set $fpmr = 0x777777777 succeeds, whereas set $fpmr = 0x77 fails with
> "Invalid cast" and this patch fixes the issue but makes changes to a generic
> function value_cast in gdb/valops.c.
>
> * testsuite/gdb.arch/aarch64-fpmr.exp : Add "set $fpmr" test.
> * gdb/valops.c (value_cast): Add TYPE_CODE_FLAGS condition to integer
> assignment.
>
> Regression tested on aarch64-none-linux-gnu with no regressions.
>
> Ok for GDB master?
This seems fine to me, but I am not as confident with this value_cast
code as I am with other things, so I'll give you the:
Approved-By: Simon Marchi <simon.marchi@efficios.com>
but wait ~1 week before pushing in case someone sees something I don't.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers
2026-07-13 9:11 [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers srinath.parvathaneni
2026-07-13 12:26 ` Simon Marchi
@ 2026-07-13 13:37 ` Aktemur, Baris
1 sibling, 0 replies; 3+ messages in thread
From: Aktemur, Baris @ 2026-07-13 13:37 UTC (permalink / raw)
To: srinath.parvathaneni, gdb-patches
Cc: guinevere, thiago.bauermann, luis.machado.foss, Ezra.Sitorus
AMD General
On Monday, July 13, 2026 11:11 AM, srinath.parvathaneni@arm.com wrote:
> From: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
>
> GDB reports "Invalid cast" when assigning small integer literals (32-bit) to
> 64-bit TYPE_CODE_FLAGS registers. For example, with the existing upstream FPMR
> register, set $fpmr = 0x777777777 succeeds, whereas set $fpmr = 0x77 fails with
> "Invalid cast" and this patch fixes the issue but makes changes to a generic
> function value_cast in gdb/valops.c.
>
> * testsuite/gdb.arch/aarch64-fpmr.exp : Add "set $fpmr" test.
> * gdb/valops.c (value_cast): Add TYPE_CODE_FLAGS condition to integer
> assignment.
>
> Regression tested on aarch64-none-linux-gnu with no regressions.
>
> Ok for GDB master?
>
> Regards,
> Srinath
> ---
> gdb/testsuite/gdb.arch/aarch64-fpmr.exp | 6 ++++++
> gdb/valops.c | 2 +-
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/gdb.arch/aarch64-fpmr.exp b/gdb/testsuite/gdb.arch/aarch64-
> fpmr.exp
> index 72fd977fc67..2eee10fe924 100644
> --- a/gdb/testsuite/gdb.arch/aarch64-fpmr.exp
> +++ b/gdb/testsuite/gdb.arch/aarch64-fpmr.exp
> @@ -97,3 +97,9 @@ gdb_test_multiple "set \$fpmr=0x3f007f4008" "" {
> pass "Write to FPMR from GDB"
> }
> }
> +
> +gdb_test_multiple "set \$fpmr=0x1255C041" "" {
> + -re ".*\r\n.*\[ F8S1=E4M3 F8S2=E5M2 F8D=E4M3 OSM=MaxNormal OSC=MaxNormal
It should be possible to remove ".*\r\n.*" from the beginning of the regexp.
Is there a specific reason gdb_test_multiple was used instead of a simpler gdb_test?
If gdb_test_multiple is necessary for some reason, I'd also suggest adding -wrap to avoid
leaving unmatched contents in the buffer.
Regards,
-Baris
> LSCALE=85 NSCALE=18 LSCALE2=0 \]" {
> + pass "Write 32-bit value to 64-bit register FPMR from GDB"
> + }
> +}
> diff --git a/gdb/valops.c b/gdb/valops.c
> index ab6fd5079e1..170311dc63c 100644
> --- a/gdb/valops.c
> +++ b/gdb/valops.c
> @@ -557,7 +557,7 @@ value_cast (struct type *type, struct value *arg2)
> return value_from_longest (to_type, value_as_long (arg2));
> }
> else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM
> - || code1 == TYPE_CODE_RANGE)
> + || code1 == TYPE_CODE_RANGE || code1 == TYPE_CODE_FLAGS)
> && (scalar || code2 == TYPE_CODE_PTR
> || code2 == TYPE_CODE_MEMBERPTR))
> {
> --
> 2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-13 13:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 9:11 [PATCH v1] gdb: Fix assignment to TYPE_CODE_FLAGS registers srinath.parvathaneni
2026-07-13 12:26 ` Simon Marchi
2026-07-13 13:37 ` Aktemur, Baris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox