xref: /qemu/tests/tcg/aarch64/gdbstub/test-sve.py (revision abff1abf)
1from __future__ import print_function
2#
3# Test the SVE registers are visable and changeable via gdbstub
4#
5# This is launched via tests/guest-debug/run-test.py
6#
7
8import gdb
9import sys
10
11MAGIC = 0xDEADBEEF
12
13failcount = 0
14
15def report(cond, msg):
16    "Report success/fail of test"
17    if cond:
18        print ("PASS: %s" % (msg))
19    else:
20        print ("FAIL: %s" % (msg))
21        global failcount
22        failcount += 1
23
24def run_test():
25    "Run through the tests one by one"
26
27    gdb.execute("info registers")
28    report(True, "info registers")
29
30    gdb.execute("info registers vector")
31    report(True, "info registers vector")
32
33    # Now all the zregs
34    frame = gdb.selected_frame()
35    for i in range(0, 32):
36        rname = "z%d" % (i)
37        zreg = frame.read_register(rname)
38        report(True, "Reading %s" % rname)
39        for j in range(0, 4):
40            cmd = "set $%s.q.u[%d] = 0x%x" % (rname, j, MAGIC)
41            gdb.execute(cmd)
42            report(True, "%s" % cmd)
43        for j in range(0, 4):
44            reg = "$%s.q.u[%d]" % (rname, j)
45            v = gdb.parse_and_eval(reg)
46            report(str(v.type) == "uint128_t", "size of %s" % (reg))
47        for j in range(0, 8):
48            cmd = "set $%s.d.u[%d] = 0x%x" % (rname, j, MAGIC)
49            gdb.execute(cmd)
50            report(True, "%s" % cmd)
51        for j in range(0, 8):
52            reg = "$%s.d.u[%d]" % (rname, j)
53            v = gdb.parse_and_eval(reg)
54            report(str(v.type) == "uint64_t", "size of %s" % (reg))
55            report(int(v) == MAGIC, "%s is 0x%x" % (reg, MAGIC))
56
57#
58# This runs as the script it sourced (via -x, via run-test.py)
59#
60try:
61    inferior = gdb.selected_inferior()
62    arch = inferior.architecture()
63    report(arch.name() == "aarch64", "connected to aarch64")
64except (gdb.error, AttributeError):
65    print("SKIPPING (not connected)", file=sys.stderr)
66    exit(0)
67
68try:
69    # These are not very useful in scripts
70    gdb.execute("set pagination off")
71
72    # Run the actual tests
73    run_test()
74except:
75    print ("GDB Exception: %s" % (sys.exc_info()[0]))
76    failcount += 1
77
78print("All tests complete: %d failures" % failcount)
79
80exit(failcount)
81