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