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