1*4a82be77SPavel Labathfrom __future__ import print_function 2*4a82be77SPavel Labath# 3*4a82be77SPavel Labath# Test auxiliary vector is loaded via gdbstub 4*4a82be77SPavel Labath# 5*4a82be77SPavel Labath# This is launched via tests/guest-debug/run-test.py 6*4a82be77SPavel Labath# 7*4a82be77SPavel Labath 8*4a82be77SPavel Labathimport gdb 9*4a82be77SPavel Labathimport sys 10*4a82be77SPavel Labath 11*4a82be77SPavel Labathfailcount = 0 12*4a82be77SPavel Labath 13*4a82be77SPavel Labathdef report(cond, msg): 14*4a82be77SPavel Labath "Report success/fail of test" 15*4a82be77SPavel Labath if cond: 16*4a82be77SPavel Labath print ("PASS: %s" % (msg)) 17*4a82be77SPavel Labath else: 18*4a82be77SPavel Labath print ("FAIL: %s" % (msg)) 19*4a82be77SPavel Labath global failcount 20*4a82be77SPavel Labath failcount += 1 21*4a82be77SPavel Labath 22*4a82be77SPavel Labathdef run_test(): 23*4a82be77SPavel Labath "Run through the tests one by one" 24*4a82be77SPavel Labath 25*4a82be77SPavel Labath sym, ok = gdb.lookup_symbol("thread1_func") 26*4a82be77SPavel Labath gdb.execute("b thread1_func") 27*4a82be77SPavel Labath gdb.execute("c") 28*4a82be77SPavel Labath 29*4a82be77SPavel Labath frame = gdb.selected_frame() 30*4a82be77SPavel Labath report(str(frame.function()) == "thread1_func", "break @ %s"%frame) 31*4a82be77SPavel Labath 32*4a82be77SPavel Labath# 33*4a82be77SPavel Labath# This runs as the script it sourced (via -x, via run-test.py) 34*4a82be77SPavel Labath# 35*4a82be77SPavel Labathtry: 36*4a82be77SPavel Labath inferior = gdb.selected_inferior() 37*4a82be77SPavel Labath arch = inferior.architecture() 38*4a82be77SPavel Labath print("ATTACHED: %s" % arch.name()) 39*4a82be77SPavel Labathexcept (gdb.error, AttributeError): 40*4a82be77SPavel Labath print("SKIPPING (not connected)", file=sys.stderr) 41*4a82be77SPavel Labath exit(0) 42*4a82be77SPavel Labath 43*4a82be77SPavel Labathif gdb.parse_and_eval('$pc') == 0: 44*4a82be77SPavel Labath print("SKIP: PC not set") 45*4a82be77SPavel Labath exit(0) 46*4a82be77SPavel Labath 47*4a82be77SPavel Labathtry: 48*4a82be77SPavel Labath # These are not very useful in scripts 49*4a82be77SPavel Labath gdb.execute("set pagination off") 50*4a82be77SPavel Labath gdb.execute("set confirm off") 51*4a82be77SPavel Labath 52*4a82be77SPavel Labath # Run the actual tests 53*4a82be77SPavel Labath run_test() 54*4a82be77SPavel Labathexcept (gdb.error): 55*4a82be77SPavel Labath print ("GDB Exception: %s" % (sys.exc_info()[0])) 56*4a82be77SPavel Labath failcount += 1 57*4a82be77SPavel Labath pass 58*4a82be77SPavel Labath 59*4a82be77SPavel Labathprint("All tests complete: %d failures" % failcount) 60*4a82be77SPavel Labathexit(failcount) 61