1from __future__ import print_function
2#
3# Test the SVE registers are visible and changeable via gdbstub
4#
5# This is launched via tests/guest-debug/run-test.py
6#
7
8import gdb
9from test_gdbstub import main, report
10
11MAGIC = 0xDEADBEEF
12
13
14def run_test():
15    "Run through the tests one by one"
16
17    gdb.execute("info registers")
18    report(True, "info registers")
19
20    gdb.execute("info registers vector")
21    report(True, "info registers vector")
22
23    # Now all the zregs
24    frame = gdb.selected_frame()
25    for i in range(0, 32):
26        rname = "z%d" % (i)
27        zreg = frame.read_register(rname)
28        report(True, "Reading %s" % rname)
29        for j in range(0, 4):
30            cmd = "set $%s.q.u[%d] = 0x%x" % (rname, j, MAGIC)
31            gdb.execute(cmd)
32            report(True, "%s" % cmd)
33        for j in range(0, 4):
34            reg = "$%s.q.u[%d]" % (rname, j)
35            v = gdb.parse_and_eval(reg)
36            report(str(v.type) == "uint128_t", "size of %s" % (reg))
37        for j in range(0, 8):
38            cmd = "set $%s.d.u[%d] = 0x%x" % (rname, j, MAGIC)
39            gdb.execute(cmd)
40            report(True, "%s" % cmd)
41        for j in range(0, 8):
42            reg = "$%s.d.u[%d]" % (rname, j)
43            v = gdb.parse_and_eval(reg)
44            report(str(v.type) == "uint64_t", "size of %s" % (reg))
45            report(int(v) == MAGIC, "%s is 0x%x" % (reg, MAGIC))
46
47
48main(run_test, expected_arch="aarch64")
49