[v2] gdb/testsuite: Skip dump ihex for 64-bit address in gdb.base/dump.exp

Message ID 20230410015236.25639-1-lihui@loongson.cn
State New
Headers
Series [v2] gdb/testsuite: Skip dump ihex for 64-bit address in gdb.base/dump.exp |

Commit Message

Hui Li April 10, 2023, 1:52 a.m. UTC
  (1) Description of problem

In the current code, when execute the following test on LoongArch:

$make check-gdb TESTS="gdb.base/dump.exp"
```
FAIL: gdb.base/dump.exp: dump array as value, intel hex
FAIL: gdb.base/dump.exp: dump struct as value, intel hex
FAIL: gdb.base/dump.exp: dump array as memory, ihex
FAIL: gdb.base/dump.exp: dump struct as memory, ihex

```
These tests passed on the X86_64,

(2) Root cause

On LoongArch, variable intarray address 0x120008068 out of range for IHEX,
so dump ihex test failed.

gdb.base/dump.exp has the following code to check 64-bit address

```
 # Check the address of a variable.  If it is bigger than 32-bit,
 # assume our target has 64-bit addresses that are not supported by SREC,
 # IHEX and TEKHEX.  We skip those tests then.
 set max_32bit_address "0xffffffff"
 set data_address [get_hexadecimal_valueof "&intarray" 0x100000000]
 if {${data_address} > ${max_32bit_address}} {
    set is64bitonly "yes"
}
```

We check the "&intarray" on different target as follow:

```
$gdb gdb/testsuite/outputs/gdb.base/dump/dump
...
(gdb) start
...

On X86_64:
(gdb) print /x &intarray
$1 = 0x404060

On LoongArch:
(gdb) print /x &intarray
$1 = 0x120008068
```
The variable address difference here is due to the link script
of linker.

```
On X86_64:
$ld --verbose
...
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000));
. = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;

On LoongArch:
$ld --verbose
...
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x120000000));
. = SEGMENT_START("text-segment", 0x120000000) + SIZEOF_HEADERS;

```

(3) How to fix

Because 64-bit variable address out of range for IHEX, it's not an
functional problem for LoongArch. Refer to the handling of 64-bit
targets in this testsuite, use the "is64bitonly" flag to skip those
tests for the target has 64-bit addresses.

Signed-off-by: Hui Li <lihui@loongson.cn>
---
 gdb/testsuite/gdb.base/dump.exp | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
  

Comments

Tom Tromey April 13, 2023, 2:19 p.m. UTC | #1
>>>>> Hui Li <lihui@loongson.cn> writes:

> (3) How to fix

> Because 64-bit variable address out of range for IHEX, it's not an
> functional problem for LoongArch. Refer to the handling of 64-bit
> targets in this testsuite, use the "is64bitonly" flag to skip those
> tests for the target has 64-bit addresses.

Thank you, this is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Tiezhu Yang April 14, 2023, 12:11 p.m. UTC | #2
On 4/10/23 09:52, Hui Li wrote:
> (1) Description of problem
> 
> In the current code, when execute the following test on LoongArch:
> 
> $make check-gdb TESTS="gdb.base/dump.exp"
> ```
> FAIL: gdb.base/dump.exp: dump array as value, intel hex
> FAIL: gdb.base/dump.exp: dump struct as value, intel hex
> FAIL: gdb.base/dump.exp: dump array as memory, ihex
> FAIL: gdb.base/dump.exp: dump struct as memory, ihex
> 
> ```
> These tests passed on the X86_64,
> 
> (2) Root cause
> 
> On LoongArch, variable intarray address 0x120008068 out of range for IHEX,
> so dump ihex test failed.
> 
> gdb.base/dump.exp has the following code to check 64-bit address
> 
> ```
>   # Check the address of a variable.  If it is bigger than 32-bit,
>   # assume our target has 64-bit addresses that are not supported by SREC,
>   # IHEX and TEKHEX.  We skip those tests then.
>   set max_32bit_address "0xffffffff"
>   set data_address [get_hexadecimal_valueof "&intarray" 0x100000000]
>   if {${data_address} > ${max_32bit_address}} {
>      set is64bitonly "yes"
> }
> ```
> 
> We check the "&intarray" on different target as follow:
> 
> ```
> $gdb gdb/testsuite/outputs/gdb.base/dump/dump
> ...
> (gdb) start
> ...
> 
> On X86_64:
> (gdb) print /x &intarray
> $1 = 0x404060
> 
> On LoongArch:
> (gdb) print /x &intarray
> $1 = 0x120008068
> ```
> The variable address difference here is due to the link script
> of linker.
> 
> ```
> On X86_64:
> $ld --verbose
> ...
> PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000));
> . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
> 
> On LoongArch:
> $ld --verbose
> ...
> PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x120000000));
> . = SEGMENT_START("text-segment", 0x120000000) + SIZEOF_HEADERS;
> 
> ```
> 
> (3) How to fix
> 
> Because 64-bit variable address out of range for IHEX, it's not an
> functional problem for LoongArch. Refer to the handling of 64-bit
> targets in this testsuite, use the "is64bitonly" flag to skip those
> tests for the target has 64-bit addresses.
> 
> Signed-off-by: Hui Li <lihui@loongson.cn>

Tested on LoongArch, pushed.

Thanks,
Tiezhu
  

Patch

diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index bc0ab4a8805..b361d05d392 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -141,11 +141,14 @@  make_dump_file "dump srec val [set intarr1.srec] intarray" \
 make_dump_file "dump srec val [set intstr1.srec] intstruct" \
 	"dump struct as value, srec"
 
-make_dump_file "dump ihex val [set intarr1.ihex] intarray" \
-	"dump array as value, intel hex"
+# 64-bit address out of range for Intel Hex file
+if {![string compare $is64bitonly "no"]} {
+    make_dump_file "dump ihex val [set intarr1.ihex] intarray" \
+	    "dump array as value, intel hex"
 
-make_dump_file "dump ihex val [set intstr1.ihex] intstruct" \
-	"dump struct as value, intel hex"
+    make_dump_file "dump ihex val [set intstr1.ihex] intstruct" \
+	    "dump struct as value, intel hex"
+}
 
 make_dump_file "dump tekhex val [set intarr1.tekhex] intarray" \
 	"dump array as value, tekhex"
@@ -242,11 +245,14 @@  make_dump_file "dump srec mem [set intarr2.srec] $array_start $array_end" \
 make_dump_file "dump srec mem [set intstr2.srec] $struct_start $struct_end" \
 	"dump struct as memory, srec"
 
-make_dump_file "dump ihex mem [set intarr2.ihex] $array_start $array_end" \
-	"dump array as memory, ihex"
+# 64-bit address out of range for Intel Hex file
+if {![string compare $is64bitonly "no"]} {
+    make_dump_file "dump ihex mem [set intarr2.ihex] $array_start $array_end" \
+	    "dump array as memory, ihex"
 
-make_dump_file "dump ihex mem [set intstr2.ihex] $struct_start $struct_end" \
-	"dump struct as memory, ihex"
+    make_dump_file "dump ihex mem [set intstr2.ihex] $struct_start $struct_end" \
+	    "dump struct as memory, ihex"
+}
 
 make_dump_file "dump tekhex mem [set intarr2.tekhex] $array_start $array_end" \
 	"dump array as memory, tekhex"