aboutsummaryrefslogtreecommitdiff
path: root/tests/guest-debug/test-gdbstub.py
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2023-08-31 08:29:00 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2023-08-31 08:29:00 -0400
commitdb1a88a5acc0df7d8a941aa772ef63c8941d1893 (patch)
tree67cb563f7738f508faaf35cab798fabf70b8f1fa /tests/guest-debug/test-gdbstub.py
parent156618d9ea67f2f2e31d9dedd97f2dcccbe6808c (diff)
parent8dd7a4b3487ab93ff8fddc5f818942ff39d4550f (diff)
Merge tag 'pull-maintainer-ominbus-300823-1' of https://gitlab.com/stsquad/qemu into staging
testing and gdbstub updates: - enable ccache for gitlab builds - fix various test info leakages for non V=1 - update style to allow loop vars - bump FreeBSD to v13.2 - clean-up gdbstub tests - various gdbstub doc and refactorings # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmTvS2AACgkQ+9DbCVqe # KkRiRwgAhsinp2/KgnvkD0n6deQy/JWg9MfYIvvZacKEakIfQvCDoJ752AUZzUTw # ggQ+W2KuaoHTzwG+AOMLdzulkmspQ8xeFuD2aIpFjRMnZrO9jN2T4L0vcGLAd95c # 9QLqPeH8xRdhuK28+ILuYzKOKBcefQ44ufMLpxrS2iNITEsSg/Tw3MU91hbct49g # 3OR4bD1ueG5Ib/lXp8V/4GnRmfLdnp3k0i/6OHriq7Mpz4Lia67WblVsPEple66U # n7JCo2sI5/m+6p2tvKs7rH60xc8s1Za3kbK4ggEq3LVRfzVOordZqO+1ep6wklTY # 6nP9Ry9nZG3gqCmcNXfhoofm0vHaZA== # =Km9m # -----END PGP SIGNATURE----- # gpg: Signature made Wed 30 Aug 2023 10:00:00 EDT # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * tag 'pull-maintainer-ominbus-300823-1' of https://gitlab.com/stsquad/qemu: gdbstub: move comment for gdb_register_coprocessor gdbstub: replace global gdb_has_xml with a function gdbstub: refactor get_feature_xml gdbstub: remove unused user_ctx field gdbstub: fixes cases where wrong threads were reported to GDB on SIGINT tests/tcg: clean-up gdb confirm/pagination settings tests: remove test-gdbstub.py .gitlab-ci.d/cirrus.yml: Update FreeBSD to v13.2 docs/style: permit inline loop variables tests/tcg: remove quoting for info output tests/docker: cleanup non-verbose output gitlab: enable ccache for many build jobs Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/guest-debug/test-gdbstub.py')
-rw-r--r--tests/guest-debug/test-gdbstub.py177
1 files changed, 0 insertions, 177 deletions
diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
deleted file mode 100644
index 98a5df4d42..0000000000
--- a/tests/guest-debug/test-gdbstub.py
+++ /dev/null
@@ -1,177 +0,0 @@
-#
-# This script needs to be run on startup
-# qemu -kernel ${KERNEL} -s -S
-# and then:
-# gdb ${KERNEL}.vmlinux -x ${QEMU_SRC}/tests/guest-debug/test-gdbstub.py
-
-import gdb
-
-failcount = 0
-
-
-def report(cond, msg):
- "Report success/fail of test"
- if cond:
- print ("PASS: %s" % (msg))
- else:
- print ("FAIL: %s" % (msg))
- global failcount
- failcount += 1
-
-
-def check_step():
- "Step an instruction, check it moved."
- start_pc = gdb.parse_and_eval('$pc')
- gdb.execute("si")
- end_pc = gdb.parse_and_eval('$pc')
-
- return not (start_pc == end_pc)
-
-
-def check_break(sym_name):
- "Setup breakpoint, continue and check we stopped."
- sym, ok = gdb.lookup_symbol(sym_name)
- bp = gdb.Breakpoint(sym_name)
-
- gdb.execute("c")
-
- # hopefully we came back
- end_pc = gdb.parse_and_eval('$pc')
- print ("%s == %s %d" % (end_pc, sym.value(), bp.hit_count))
- bp.delete()
-
- # can we test we hit bp?
- return end_pc == sym.value()
-
-
-# We need to do hbreak manually as the python interface doesn't export it
-def check_hbreak(sym_name):
- "Setup hardware breakpoint, continue and check we stopped."
- sym, ok = gdb.lookup_symbol(sym_name)
- gdb.execute("hbreak %s" % (sym_name))
- gdb.execute("c")
-
- # hopefully we came back
- end_pc = gdb.parse_and_eval('$pc')
- print ("%s == %s" % (end_pc, sym.value()))
-
- if end_pc == sym.value():
- gdb.execute("d 1")
- return True
- else:
- return False
-
-
-class WatchPoint(gdb.Breakpoint):
-
- def get_wpstr(self, sym_name):
- "Setup sym and wp_str for given symbol."
- self.sym, ok = gdb.lookup_symbol(sym_name)
- wp_addr = gdb.parse_and_eval(sym_name).address
- self.wp_str = '*(%(type)s)(&%(address)s)' % dict(
- type = wp_addr.type, address = sym_name)
-
- return(self.wp_str)
-
- def __init__(self, sym_name, type):
- wp_str = self.get_wpstr(sym_name)
- super(WatchPoint, self).__init__(wp_str, gdb.BP_WATCHPOINT, type)
-
- def stop(self):
- end_pc = gdb.parse_and_eval('$pc')
- print ("HIT WP @ %s" % (end_pc))
- return True
-
-
-def do_one_watch(sym, wtype, text):
-
- wp = WatchPoint(sym, wtype)
- gdb.execute("c")
- report_str = "%s for %s (%s)" % (text, sym, wp.sym.value())
-
- if wp.hit_count > 0:
- report(True, report_str)
- wp.delete()
- else:
- report(False, report_str)
-
-
-def check_watches(sym_name):
- "Watch a symbol for any access."
-
- # Should hit for any read
- do_one_watch(sym_name, gdb.WP_ACCESS, "awatch")
-
- # Again should hit for reads
- do_one_watch(sym_name, gdb.WP_READ, "rwatch")
-
- # Finally when it is written
- do_one_watch(sym_name, gdb.WP_WRITE, "watch")
-
-
-class CatchBreakpoint(gdb.Breakpoint):
- def __init__(self, sym_name):
- super(CatchBreakpoint, self).__init__(sym_name)
- self.sym, ok = gdb.lookup_symbol(sym_name)
-
- def stop(self):
- end_pc = gdb.parse_and_eval('$pc')
- print ("CB: %s == %s" % (end_pc, self.sym.value()))
- if end_pc == self.sym.value():
- report(False, "Hit final catchpoint")
-
-
-def run_test():
- "Run through the tests one by one"
-
- print ("Checking we can step the first few instructions")
- step_ok = 0
- for i in range(3):
- if check_step():
- step_ok += 1
-
- report(step_ok == 3, "single step in boot code")
-
- print ("Checking HW breakpoint works")
- break_ok = check_hbreak("kernel_init")
- report(break_ok, "hbreak @ kernel_init")
-
- # Can't set this up until we are in the kernel proper
- # if we make it to run_init_process we've over-run and
- # one of the tests failed
- print ("Setup catch-all for run_init_process")
- cbp = CatchBreakpoint("run_init_process")
- cpb2 = CatchBreakpoint("try_to_run_init_process")
-
- print ("Checking Normal breakpoint works")
- break_ok = check_break("wait_for_completion")
- report(break_ok, "break @ wait_for_completion")
-
- print ("Checking watchpoint works")
- check_watches("system_state")
-
-#
-# This runs as the script it sourced (via -x)
-#
-
-try:
- print ("Connecting to remote")
- gdb.execute("target remote localhost:1234")
-
- # These are not very useful in scripts
- gdb.execute("set pagination off")
- gdb.execute("set confirm off")
-
- # Run the actual tests
- run_test()
-
-except:
- print ("GDB Exception: %s" % (sys.exc_info()[0]))
- failcount += 1
- import code
- code.InteractiveConsole(locals=globals()).interact()
- raise
-
-# Finally kill the inferior and exit gdb with a count of failures
-gdb.execute("kill")
-exit(failcount)