qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

tests/tcg: add a multiarch linux-user gdb test

When the gdbstub code was converted to the new API we missed a few
snafus in the various guests. Add a simple gdb test script which can
be used on all our linux-user guests to check for obvious failures.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200430190122.4592-9-alex.bennee@linaro.org>

+98 -3
+2 -3
tests/tcg/aarch64/Makefile.target
··· 54 54 ifneq ($(HAVE_GDB_BIN),) 55 55 GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py 56 56 57 - AARCH64_TESTS += gdbstub-sysregs gdbstub-sve-ioctls 58 - 59 - .PHONY: gdbstub-sysregs gdbstub-sve-ioctls 60 57 run-gdbstub-sysregs: sysregs 61 58 $(call run-test, $@, $(GDB_SCRIPT) \ 62 59 --gdb $(HAVE_GDB_BIN) \ ··· 70 67 --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ 71 68 --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \ 72 69 "basic gdbstub SVE ZLEN support") 70 + 71 + EXTRA_RUNS += run-gdbstub-sysregs run-gdbstub-sve-ioctls 73 72 endif 74 73 75 74 endif
+1
tests/tcg/cris/Makefile.target
··· 23 23 24 24 # override the list of tests, as we can't build the multiarch tests 25 25 TESTS = $(CRIS_USABLE_TESTS) 26 + EXTRA_RUNS = 26 27 VPATH = $(CRIS_SRC) 27 28 28 29 AS = $(CC) -x assembler-with-cpp
+14
tests/tcg/multiarch/Makefile.target
··· 42 42 $(call run-test, test-mmap-$*, $(QEMU) -p $* $<,\ 43 43 "$< ($* byte pages) on $(TARGET_NAME)") 44 44 45 + ifneq ($(HAVE_GDB_BIN),) 46 + GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py 47 + 48 + run-gdbstub-sha1: sha1 49 + $(call run-test, $@, $(GDB_SCRIPT) \ 50 + --gdb $(HAVE_GDB_BIN) \ 51 + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ 52 + --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ 53 + "basic gdbstub support") 54 + 55 + EXTRA_RUNS += run-gdbstub-sha1 56 + endif 57 + 58 + 45 59 # Update TESTS 46 60 TESTS += $(MULTIARCH_TESTS)
+81
tests/tcg/multiarch/gdbstub/sha1.py
··· 1 + from __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 + 9 + import gdb 10 + import sys 11 + 12 + initial_vlen = 0 13 + failcount = 0 14 + 15 + def report(cond, msg): 16 + "Report success/fail of test" 17 + if cond: 18 + print("PASS: %s" % (msg)) 19 + else: 20 + print("FAIL: %s" % (msg)) 21 + global failcount 22 + failcount += 1 23 + 24 + def check_break(sym_name): 25 + "Setup breakpoint, continue and check we stopped." 26 + sym, ok = gdb.lookup_symbol(sym_name) 27 + bp = gdb.Breakpoint(sym_name) 28 + 29 + gdb.execute("c") 30 + 31 + # hopefully we came back 32 + end_pc = gdb.parse_and_eval('$pc') 33 + report(bp.hit_count == 1, 34 + "break @ %s (%s %d hits)" % (end_pc, sym.value(), bp.hit_count)) 35 + 36 + bp.delete() 37 + 38 + def run_test(): 39 + "Run through the tests one by one" 40 + 41 + check_break("SHA1Init") 42 + 43 + # check step and inspect values 44 + gdb.execute("next") 45 + val_ctx = gdb.parse_and_eval("context->state[0]") 46 + exp_ctx = 0x67452301 47 + report(int(val_ctx) == exp_ctx, "context->state[0] == %x" % exp_ctx); 48 + 49 + gdb.execute("next") 50 + val_ctx = gdb.parse_and_eval("context->state[1]") 51 + exp_ctx = 0xEFCDAB89 52 + report(int(val_ctx) == exp_ctx, "context->state[1] == %x" % exp_ctx); 53 + 54 + # finally check we don't barf inspecting registers 55 + gdb.execute("info registers") 56 + 57 + # 58 + # This runs as the script it sourced (via -x, via run-test.py) 59 + # 60 + try: 61 + inferior = gdb.selected_inferior() 62 + arch = inferior.architecture() 63 + print("ATTACHED: %s" % arch.name()) 64 + except (gdb.error, AttributeError): 65 + print("SKIPPING (not connected)", file=sys.stderr) 66 + exit(0) 67 + 68 + try: 69 + # These are not very useful in scripts 70 + gdb.execute("set pagination off") 71 + gdb.execute("set confirm off") 72 + 73 + # Run the actual tests 74 + run_test() 75 + except (gdb.error): 76 + print ("GDB Exception: %s" % (sys.exc_info()[0])) 77 + failcount += 1 78 + pass 79 + 80 + print("All tests complete: %d failures" % failcount) 81 + exit(failcount)