diff mbox series

[v2,07/11] tests/tcg: relax the next step precision of the gdb sha1 test

Message ID 20210401102530.12030-8-alex.bennee@linaro.org (mailing list archive)
State New, archived
Headers show
Series various fixes, pre-PR (check-tcg, gdbstub, gitlab) | expand

Commit Message

Alex Bennée April 1, 2021, 10:25 a.m. UTC
Depending on the version of gdb we may not execute the first line of
SHA1Init when executing the first "next" command - instead just
stepping over the preamble. As we don't actually care about the
position of the PC after the steps and want to be sure the
context->state[] has been loaded before we inspect it do a double next
at the start.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/multiarch/gdbstub/sha1.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Richard Henderson April 2, 2021, 4:41 p.m. UTC | #1
On 4/1/21 3:25 AM, Alex Bennée wrote:
>       check_break("SHA1Init")
>   
> -    # check step and inspect values
> +    # Check step and inspect values. We do a double next after the
> +    # breakpoint as depending on the version of gdb we may step the
> +    # preamble and not the first actual line of source.
> +    gdb.execute("next")
>       gdb.execute("next")
>       val_ctx = gdb.parse_and_eval("context->state[0]")
>       exp_ctx = 0x67452301

This double next seems just as fragile.  Why don't you just set the breakpoint 
where you want, which appears to be sha1.c:138?


r~
Richard Henderson April 2, 2021, 6:38 p.m. UTC | #2
On 4/2/21 9:41 AM, Richard Henderson wrote:
> On 4/1/21 3:25 AM, Alex Bennée wrote:
>>       check_break("SHA1Init")
>> -    # check step and inspect values
>> +    # Check step and inspect values. We do a double next after the
>> +    # breakpoint as depending on the version of gdb we may step the
>> +    # preamble and not the first actual line of source.
>> +    gdb.execute("next")
>>       gdb.execute("next")
>>       val_ctx = gdb.parse_and_eval("context->state[0]")
>>       exp_ctx = 0x67452301
> 
> This double next seems just as fragile.  Why don't you just set the breakpoint 
> where you want, which appears to be sha1.c:138?

That said, make check-tcg has passed, completely, on my laptop for the first 
time in a year.  So,

Tested-by: Richard Henderson <richard.henderson@linaro.org>

r~
Alex Bennée April 6, 2021, 9:43 a.m. UTC | #3
Richard Henderson <richard.henderson@linaro.org> writes:

> On 4/1/21 3:25 AM, Alex Bennée wrote:
>>       check_break("SHA1Init")
>>   -    # check step and inspect values
>> +    # Check step and inspect values. We do a double next after the
>> +    # breakpoint as depending on the version of gdb we may step the
>> +    # preamble and not the first actual line of source.
>> +    gdb.execute("next")
>>       gdb.execute("next")
>>       val_ctx = gdb.parse_and_eval("context->state[0]")
>>       exp_ctx = 0x67452301
>
> This double next seems just as fragile.  Why don't you just set the
> breakpoint where you want, which appears to be sha1.c:138?

Ideally I'd want an unambiguous label that gdb would understand lest it
got broken by someone tweaking the sha1.c code. I thought a function
header would be better but it appears only marginally so. 

>
>
> r~
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/gdbstub/sha1.py b/tests/tcg/multiarch/gdbstub/sha1.py
index 2bfde49633..423b720e6d 100644
--- a/tests/tcg/multiarch/gdbstub/sha1.py
+++ b/tests/tcg/multiarch/gdbstub/sha1.py
@@ -40,7 +40,10 @@  def run_test():
 
     check_break("SHA1Init")
 
-    # check step and inspect values
+    # Check step and inspect values. We do a double next after the
+    # breakpoint as depending on the version of gdb we may step the
+    # preamble and not the first actual line of source.
+    gdb.execute("next")
     gdb.execute("next")
     val_ctx = gdb.parse_and_eval("context->state[0]")
     exp_ctx = 0x67452301