Created
November 9, 2018 16:56
-
-
Save stsquad/ddfb00787cb133b4b658756cb6c47f63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
# | |
# 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-ss.py | |
# | |
# This is a soak test for single-stepping which attempts to detect | |
# failed single-steps by single stepping a whole kernel. | |
import gdb | |
import re | |
def run_test(): | |
"Run through the tests one by one" | |
print ("Stepping... until we fails") | |
steps_taken = 0 | |
step_ok = True | |
while step_ok: | |
start_pc = gdb.parse_and_eval('$pc') | |
result = gdb.execute("si", to_string=True) | |
end_pc = gdb.parse_and_eval('$pc') | |
if start_pc == end_pc: | |
step_ok = False | |
else: | |
steps_taken += 1 | |
if steps_taken % 1000 == 0: | |
print ("Stepping %d insns, currently @ %s" % | |
(steps_taken, end_pc)) | |
print ("Failed at %s (%s)" % (end_pc, result)) | |
# | |
# 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])) | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment