xref: /openbmc/qemu/tests/tcg/multiarch/gdbstub/sha1.py (revision 6a02465f)
1from __future__ import print_function
2#
3# A very simple smoke test for debugging the SHA1 userspace test on
4# each target.
5#
6# This is launched via tests/guest-debug/run-test.py
7#
8
9import gdb
10from test_gdbstub import main, report
11
12
13initial_vlen = 0
14
15
16def check_break(sym_name):
17    "Setup breakpoint, continue and check we stopped."
18    sym, ok = gdb.lookup_symbol(sym_name)
19    bp = gdb.Breakpoint(sym_name)
20
21    gdb.execute("c")
22
23    # hopefully we came back
24    end_pc = gdb.parse_and_eval('$pc')
25    report(bp.hit_count == 1,
26           "break @ %s (%s %d hits)" % (end_pc, sym.value(), bp.hit_count))
27
28    bp.delete()
29
30
31def run_test():
32    "Run through the tests one by one"
33
34    check_break("SHA1Init")
35
36    # Check step and inspect values. We do a double next after the
37    # breakpoint as depending on the version of gdb we may step the
38    # preamble and not the first actual line of source.
39    gdb.execute("next")
40    gdb.execute("next")
41    val_ctx = gdb.parse_and_eval("context->state[0]")
42    exp_ctx = 0x67452301
43    report(int(val_ctx) == exp_ctx, "context->state[0] == %x" % exp_ctx);
44
45    gdb.execute("next")
46    val_ctx = gdb.parse_and_eval("context->state[1]")
47    exp_ctx = 0xEFCDAB89
48    report(int(val_ctx) == exp_ctx, "context->state[1] == %x" % exp_ctx);
49
50    # finally check we don't barf inspecting registers
51    gdb.execute("info registers")
52
53
54main(run_test)
55