1*bbc0543bSGustavo Romerofrom __future__ import print_function
2*bbc0543bSGustavo Romero#
3*bbc0543bSGustavo Romero# Test gdbstub Xfer:siginfo:read stub.
4*bbc0543bSGustavo Romero#
5*bbc0543bSGustavo Romero# The test runs a binary that causes a SIGSEGV and then looks for additional
6*bbc0543bSGustavo Romero# info about the signal through printing GDB's '$_siginfo' special variable,
7*bbc0543bSGustavo Romero# which sends a Xfer:siginfo:read query to the gdbstub.
8*bbc0543bSGustavo Romero#
9*bbc0543bSGustavo Romero# The binary causes a SIGSEGV at dereferencing a pointer with value 0xdeadbeef,
10*bbc0543bSGustavo Romero# so the test looks for and checks if this address is correctly reported by the
11*bbc0543bSGustavo Romero# gdbstub.
12*bbc0543bSGustavo Romero#
13*bbc0543bSGustavo Romero# This is launched via tests/guest-debug/run-test.py
14*bbc0543bSGustavo Romero#
15*bbc0543bSGustavo Romero
16*bbc0543bSGustavo Romeroimport gdb
17*bbc0543bSGustavo Romerofrom test_gdbstub import main, report
18*bbc0543bSGustavo Romero
19*bbc0543bSGustavo Romerodef run_test():
20*bbc0543bSGustavo Romero    "Run through the test"
21*bbc0543bSGustavo Romero
22*bbc0543bSGustavo Romero    gdb.execute("continue", False, True)
23*bbc0543bSGustavo Romero    resp = gdb.execute("print/x $_siginfo", False, True)
24*bbc0543bSGustavo Romero    report(resp.find("si_addr = 0xdeadbeef"), "Found fault address.")
25*bbc0543bSGustavo Romero
26*bbc0543bSGustavo Romeromain(run_test)
27