diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-08-09 17:12:40 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-08-09 17:37:46 +0100 |
commit | c1abad9ebadc94e2ca215fd0fb6b59072b67351c (patch) | |
tree | 4a6867a99a44b245ffea809e5f873038aac5b90b /gdb | |
parent | 410a3464e7960d24de4a200e70502dcd01eff98d (diff) | |
download | gdb-c1abad9ebadc94e2ca215fd0fb6b59072b67351c.zip gdb-c1abad9ebadc94e2ca215fd0fb6b59072b67351c.tar.gz gdb-c1abad9ebadc94e2ca215fd0fb6b59072b67351c.tar.bz2 |
gdb/riscv/testsuite: fix failures in gdb.arch/riscv-reg-aliases.exp
When running on a native RISC-V Linux target I currently see failures
in the gdb.arch/riscv-reg-aliases.exp test like this:
set $ft0.float = 501
(gdb) PASS: gdb.arch/riscv-reg-aliases.exp: write non-zero value to ft0
p/d $ft0.float
$263 = 1140490240
(gdb) FAIL: gdb.arch/riscv-reg-aliases.exp: read ft0 after non-zero write to ft0
This test started failing after this commit:
commit 56262a931b7ca8ee3ec9104bc7e9e0b40cf3d64e
Date: Thu Feb 17 13:43:59 2022 -0700
Change how "print/x" displays floating-point value
The problem is that when 501 is written to $ft0.float the value is
converted to floating point format and stored in the register. Prior
to the above commit printing with /x and /d would first extract the
value as a float, and then convert the value to an integer for
display. After the above commit GDB now uses the raw register value
when displaying /x and /d, and so we see this behaviour:
(gdb) info registers $ft0
ft0 {float = 501, double = 5.6347704700123827e-315} (raw 0x0000000043fa8000)
(gdb) p/f $ft0.float
$1 = 501
(gdb) p/d $ft0.float
$2 = 1140490240
(gdb) p/x $ft0.float
$3 = 0x43fa8000
To fix this test I now print the float registers using the /f format
rather than /d. With this change the test now passes.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.arch/riscv-reg-aliases.exp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.arch/riscv-reg-aliases.exp b/gdb/testsuite/gdb.arch/riscv-reg-aliases.exp index 0c413a4..4c188b7 100644 --- a/gdb/testsuite/gdb.arch/riscv-reg-aliases.exp +++ b/gdb/testsuite/gdb.arch/riscv-reg-aliases.exp @@ -67,18 +67,22 @@ proc check_zero_register_value {testname} { # and we need to read/write using a ".float" extension. This is passed in # REG_EXTENSION. If no extension is needed then REG_EXTENSION is the empty # string. -proc check_setting_registers_to_zero { reg_set reg_extension } { +# +# PRINT_FMT is used when inspecting the registers, and should be a +# character that can be used in a GDB print command as an output +# format, e.g. 'd' (decimal), or 'f' (float). +proc check_setting_registers_to_zero { reg_set reg_extension print_fmt } { foreach reg_desc ${reg_set} { set primary_name [lindex ${reg_desc} 0] set alias_names [lindex ${reg_desc} 1] gdb_test_no_output "set \$${primary_name}${reg_extension} = 0" \ "set register ${primary_name} to an initial value of zero" - gdb_test "p/d \$${primary_name}${reg_extension}" " = 0" \ + gdb_test "p/${print_fmt} \$${primary_name}${reg_extension}" " = 0" \ "check the initial value of ${primary_name} is now zero" foreach reg_alias ${alias_names} { - gdb_test "p/d \$${reg_alias}${reg_extension}" " = 0" \ + gdb_test "p/${print_fmt} \$${reg_alias}${reg_extension}" " = 0" \ "check the initial value of ${reg_alias} is now zero" } } @@ -94,7 +98,11 @@ proc check_setting_registers_to_zero { reg_set reg_extension } { # of the aliases. # # The REG_EXTENSION field is used as in CHECK_SETTING_REGISTERS_TO_ZERO. -proc check_setting_registers_to_value { reg_set reg_extension reg_value } { +# +# PRINT_FMT is used when inspecting the registers, and should be a +# character that can be used in a GDB print command as an output +# format, e.g. 'd' (decimal), or 'f' (float). +proc check_setting_registers_to_value { reg_set reg_extension reg_value print_fmt } { foreach reg_desc ${reg_set} { set primary_name [lindex ${reg_desc} 0] set alias_names [lindex ${reg_desc} 1] @@ -104,10 +112,10 @@ proc check_setting_registers_to_value { reg_set reg_extension reg_value } { set reg_value [incr reg_value] gdb_test_no_output "set \$${primary_name}${reg_extension} = $reg_value" \ "write non-zero value to ${primary_name}" - gdb_test "p/d \$${primary_name}${reg_extension}" " = $reg_value" \ + gdb_test "p/${print_fmt} \$${primary_name}${reg_extension}" " = $reg_value" \ "read ${primary_name} after non-zero write to ${primary_name}" foreach reg_alias ${alias_names} { - gdb_test "p/d \$${reg_alias}${reg_extension}" " = $reg_value" \ + gdb_test "p/${print_fmt} \$${reg_alias}${reg_extension}" " = $reg_value" \ "read ${reg_alias} after non-zero write to ${primary_name}" } @@ -119,11 +127,11 @@ proc check_setting_registers_to_value { reg_set reg_extension reg_value } { gdb_test_no_output "set \$${reg_alias}${reg_extension} = $reg_value" \ "write non-zero value to ${reg_alias}" - gdb_test "p/d \$${primary_name}${reg_extension}" " = $reg_value" \ + gdb_test "p/${print_fmt} \$${primary_name}${reg_extension}" " = $reg_value" \ "read ${primary_name} after non-zero write to ${reg_alias}" foreach other_reg_alias ${alias_names} { - gdb_test "p/d \$${other_reg_alias}${reg_extension}" " = $reg_value" \ + gdb_test "p/${print_fmt} \$${other_reg_alias}${reg_extension}" " = $reg_value" \ "read ${other_reg_alias} after non-zero write to ${reg_alias}" } } @@ -173,10 +181,10 @@ gdb_assert ![string eq "${freg_extension}" "INVALID"] \ # Now check that we can write zero, and read zero back to all of the integer # and floating point registers. -check_setting_registers_to_zero ${xreg_names} "" +check_setting_registers_to_zero ${xreg_names} "" "d" if { ! $skip_freg_tests } { - check_setting_registers_to_zero ${freg_names} ${freg_extension} + check_setting_registers_to_zero ${freg_names} ${freg_extension} "f" } # Set each register in turn to a new value, and confirm that the new value can @@ -184,8 +192,8 @@ if { ! $skip_freg_tests } { # value passed in to each test invocation here is arbitrary, they are # significantly different so that the float tests don't reuse value from the # integer tests. -check_setting_registers_to_value ${xreg_names} "" 100 +check_setting_registers_to_value ${xreg_names} "" 100 "d" if { ! $skip_freg_tests } { - check_setting_registers_to_value ${freg_names} ${freg_extension} 500 + check_setting_registers_to_value ${freg_names} ${freg_extension} 500 "f" } |