docs/system/gdb.rst: Add some more heading structure
[qemu/ar7.git] / tests / tcg / aarch64 / gdbstub / test-sve.py
blobb96bdbb99af5c77ecc802bcd69990e06619999ff
1 from __future__ import print_function
3 # Test the SVE registers are visable and changeable via gdbstub
5 # This is launched via tests/guest-debug/run-test.py
8 import gdb
9 import sys
11 MAGIC = 0xDEADBEEF
13 failcount = 0
15 def 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
24 def run_test():
25 "Run through the tests one by one"
27 gdb.execute("info registers")
28 report(True, "info registers")
30 gdb.execute("info registers vector")
31 report(True, "info registers vector")
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))
58 # This runs as the script it sourced (via -x, via run-test.py)
60 try:
61 inferior = gdb.selected_inferior()
62 arch = inferior.architecture()
63 report(arch.name() == "aarch64", "connected to aarch64")
64 except (gdb.error, AttributeError):
65 print("SKIPPING (not connected)", file=sys.stderr)
66 exit(0)
68 try:
69 # These are not very useful in scripts
70 gdb.execute("set pagination off")
72 # Run the actual tests
73 run_test()
74 except:
75 print ("GDB Exception: %s" % (sys.exc_info()[0]))
76 failcount += 1
78 print("All tests complete: %d failures" % failcount)
80 exit(failcount)