[gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-call.exp

Message ID 20240828091451.26425-1-tdevries@suse.de
State Committed
Headers
Series [gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-call.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Aug. 28, 2024, 9:14 a.m. UTC
  Usually, with test-case gdb.arch/i386-disp-step-self-call.exp I get:
...
(gdb) x/1wx 0xffffc4f8^M
0xffffc4f8:     0x08048472^M
(gdb) PASS: $exp: check return address was updated correctly
...
but sometimes I run into:
...
(gdb) x/1wx 0xffffc5c8^M
0xffffc5c8:     0x0804917e^M
(gdb) FAIL: $exp: check return address was updated correctly
...

The problem is that here:
...
set next_insn_addr 0x[format %08X $next_insn_addr]
gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
    "check return address was updated correctly"
...
we're trying to match string 0x0804917e against regexp 0x0804917E due to using
"%08X" as format string.

We only run into this problem if the address contains letters, which apparantly
usually isn't the case.

Fix this by using "%08x" instead as format string.

Likewise in test-case gdb.arch/amd64-disp-step-self-call.exp.

Tested on x86_64-linux.

PR testsuite/32121
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32121
---
 gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp | 2 +-
 gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 934fcc7c916ad2876515a099ee09fa40dc08b489
  

Comments

Felix Willgerodt Aug. 28, 2024, 9:20 a.m. UTC | #1
> -----Original Message-----
> From: Tom de Vries <tdevries@suse.de>
> Sent: Mittwoch, 28. August 2024 11:15
> To: gdb-patches@sourceware.org
> Subject: [PATCH] [gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-
> call.exp
> 
> Usually, with test-case gdb.arch/i386-disp-step-self-call.exp I get:
> ...
> (gdb) x/1wx 0xffffc4f8^M
> 0xffffc4f8:     0x08048472^M
> (gdb) PASS: $exp: check return address was updated correctly
> ...
> but sometimes I run into:
> ...
> (gdb) x/1wx 0xffffc5c8^M
> 0xffffc5c8:     0x0804917e^M
> (gdb) FAIL: $exp: check return address was updated correctly
> ...
> 
> The problem is that here:
> ...
> set next_insn_addr 0x[format %08X $next_insn_addr]
> gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>     "check return address was updated correctly"
> ...
> we're trying to match string 0x0804917e against regexp 0x0804917E due to using
> "%08X" as format string.
> 
> We only run into this problem if the address contains letters, which apparantly
> usually isn't the case.
> 
> Fix this by using "%08x" instead as format string.
> 
> Likewise in test-case gdb.arch/amd64-disp-step-self-call.exp.
> 
> Tested on x86_64-linux.
> 
> PR testsuite/32121
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32121
> ---
>  gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp | 2 +-
>  gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
> b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
> index 762d19a2960..2db3ff228c9 100644
> --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
> +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
> @@ -77,6 +77,6 @@ gdb_assert {[expr $sp == $new_sp]} \
>      "check stack pointer was updated as expected"
> 
>  # Check the contents of the stack were updated to the expected value.
> -set next_insn_addr 0x[format %016X $next_insn_addr]
> +set next_insn_addr 0x[format %016x $next_insn_addr]
>  gdb_test "x/1gx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>      "check return address was updated correctly"
> diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
> b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
> index b2cb902f8ed..5de7ebcd69f 100644
> --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
> +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
> @@ -77,6 +77,6 @@ gdb_assert {[expr $sp == $new_sp]} \
>      "check stack pointer was updated as expected"
> 
>  # Check the contents of the stack were updated to the expected value.
> -set next_insn_addr 0x[format %08X $next_insn_addr]
> +set next_insn_addr 0x[format %08x $next_insn_addr]
>  gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>      "check return address was updated correctly"
> 
> base-commit: 934fcc7c916ad2876515a099ee09fa40dc08b489
> --
> 2.35.3

Hi Tom,

This looks fine to me.

Thanks,
Felix

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  
Tom de Vries Aug. 28, 2024, 10:59 a.m. UTC | #2
On 8/28/24 11:20, Willgerodt, Felix wrote:
>> -----Original Message-----
>> From: Tom de Vries <tdevries@suse.de>
>> Sent: Mittwoch, 28. August 2024 11:15
>> To: gdb-patches@sourceware.org
>> Subject: [PATCH] [gdb/testsuite] Fix regexp in gdb.arch/i386-disp-step-self-
>> call.exp
>>
>> Usually, with test-case gdb.arch/i386-disp-step-self-call.exp I get:
>> ...
>> (gdb) x/1wx 0xffffc4f8^M
>> 0xffffc4f8:     0x08048472^M
>> (gdb) PASS: $exp: check return address was updated correctly
>> ...
>> but sometimes I run into:
>> ...
>> (gdb) x/1wx 0xffffc5c8^M
>> 0xffffc5c8:     0x0804917e^M
>> (gdb) FAIL: $exp: check return address was updated correctly
>> ...
>>
>> The problem is that here:
>> ...
>> set next_insn_addr 0x[format %08X $next_insn_addr]
>> gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>>      "check return address was updated correctly"
>> ...
>> we're trying to match string 0x0804917e against regexp 0x0804917E due to using
>> "%08X" as format string.
>>
>> We only run into this problem if the address contains letters, which apparantly
>> usually isn't the case.
>>
>> Fix this by using "%08x" instead as format string.
>>
>> Likewise in test-case gdb.arch/amd64-disp-step-self-call.exp.
>>
>> Tested on x86_64-linux.
>>
>> PR testsuite/32121
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32121
>> ---
>>   gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp | 2 +-
>>   gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp  | 2 +-
>>   2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
>> b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
>> index 762d19a2960..2db3ff228c9 100644
>> --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
>> +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
>> @@ -77,6 +77,6 @@ gdb_assert {[expr $sp == $new_sp]} \
>>       "check stack pointer was updated as expected"
>>
>>   # Check the contents of the stack were updated to the expected value.
>> -set next_insn_addr 0x[format %016X $next_insn_addr]
>> +set next_insn_addr 0x[format %016x $next_insn_addr]
>>   gdb_test "x/1gx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>>       "check return address was updated correctly"
>> diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
>> b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
>> index b2cb902f8ed..5de7ebcd69f 100644
>> --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
>> +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
>> @@ -77,6 +77,6 @@ gdb_assert {[expr $sp == $new_sp]} \
>>       "check stack pointer was updated as expected"
>>
>>   # Check the contents of the stack were updated to the expected value.
>> -set next_insn_addr 0x[format %08X $next_insn_addr]
>> +set next_insn_addr 0x[format %08x $next_insn_addr]
>>   gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
>>       "check return address was updated correctly"
>>
>> base-commit: 934fcc7c916ad2876515a099ee09fa40dc08b489
>> --
>> 2.35.3
> 
> Hi Tom,
> 
> This looks fine to me.
> 

Hi Felix,

thanks for the review.

Please consider adding a tag to your review(s), to get the proper credit 
for your efforts ( 
https://sourceware.org/gdb/wiki/ContributionChecklist#Receiving_positive_reviews 
).

Thanks,
- Tom
  

Patch

diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
index 762d19a2960..2db3ff228c9 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
@@ -77,6 +77,6 @@  gdb_assert {[expr $sp == $new_sp]} \
     "check stack pointer was updated as expected"
 
 # Check the contents of the stack were updated to the expected value.
-set next_insn_addr 0x[format %016X $next_insn_addr]
+set next_insn_addr 0x[format %016x $next_insn_addr]
 gdb_test "x/1gx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
     "check return address was updated correctly"
diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
index b2cb902f8ed..5de7ebcd69f 100644
--- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
+++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
@@ -77,6 +77,6 @@  gdb_assert {[expr $sp == $new_sp]} \
     "check stack pointer was updated as expected"
 
 # Check the contents of the stack were updated to the expected value.
-set next_insn_addr 0x[format %08X $next_insn_addr]
+set next_insn_addr 0x[format %08x $next_insn_addr]
 gdb_test "x/1wx 0x[format %x $sp]" "$hex:\\s+$next_insn_addr" \
     "check return address was updated correctly"