]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/tcg/multiarch/gdbstub/interrupt.py
1 from __future__
import print_function
3 # Test some of the system debug features with the multiarch memory
4 # test. It is a port of the original vmlinux focused test case but
5 # using the "memory" test instead.
7 # This is launched via tests/guest-debug/run-test.py
11 from test_gdbstub
import main
, report
14 def check_interrupt(thread
):
16 Check that, if thread is resumed, we go back to the same thread when the
17 program gets interrupted.
20 # Switch to the thread we're going to be running the test in.
21 print("thread ", thread
.num
)
22 gdb
.execute("thr %d" % thread
.num
)
24 # Enter the loop() function on this thread.
26 # While there are cleaner ways to do this, we want to minimize the number of
27 # side effects on the gdbstub's internal state, since those may mask bugs.
28 # Ideally, there should be no difference between what we're doing here and
29 # the program reaching the loop() function on its own.
31 # For this to be safe, we only need the prologue of loop() to not have
32 # instructions that may have problems with what we're doing here. We don't
33 # have to worry about anything else, as this function never returns.
34 gdb
.execute("set $pc = loop")
36 # Continue and then interrupt the task.
37 gdb
.post_event(lambda: gdb
.execute("interrupt"))
40 # Check whether the thread we're in after the interruption is the same we
42 return (thread
.num
== gdb
.selected_thread().num
)
47 Test if interrupting the code always lands us on the same thread when
48 running with scheduler-lock enabled.
50 if len(gdb
.selected_inferior().threads()) == 1:
51 print("SKIP: set to run on a single thread")
54 gdb
.execute("set scheduler-locking on")
55 for thread
in gdb
.selected_inferior().threads():
56 report(check_interrupt(thread
),
57 "thread %d resumes correctly on interrupt" % thread
.num
)