def test(self):
self.check_reg("f18", "fs2")
+class CustomRegisterTest(SimpleRegisterTest):
+ def early_applicable(self):
+ return self.target.implements_custom_test
+
+ def check_custom(self, magic):
+ regs = self.gdb.info_registers("custom")
+ assertEqual(set(regs.keys()),
+ set(("custom1",
+ "custom12345",
+ "custom12346",
+ "custom12347",
+ "custom12348")))
+ for name, value in regs.iteritems():
+ number = int(name[6:])
+ if number % 2:
+ expect = number + magic
+ assertIn(value, (expect, expect + (1<<32)))
+ else:
+ assertIn("Could not fetch register", value)
+
+ def test(self):
+ self.check_custom(0)
+
+ # Now test writing
+ magic = 6667
+ self.gdb.p("$custom12345=%d" % (12345 + magic))
+ self.gdb.stepi()
+
+ self.check_custom(magic)
+
class SimpleNoExistTest(GdbTest):
def test(self):
try:
# Supports mtime at 0x2004000
supports_clint_mtime = True
+ # Implements custom debug registers like spike does. It seems unlikely any
+ # hardware will every do that.
+ implements_custom_test = False
+
# Internal variables:
directory = None
temporary_files = []
# Expose an unimplemented CSR so we can test non-existent register access
# behavior.
riscv expose_csrs 2288
+riscv expose_custom 1,12345-12348
init
# Expose an unimplemented CSR so we can test non-existent register access
# behavior.
riscv expose_csrs 2288
+riscv expose_custom 1,12345-12348
init
# Expose an unimplemented CSR so we can test non-existent register access
# behavior.
riscv expose_csrs 2288
+riscv expose_custom 1,12345-12348
init
harts = [spike32.spike32_hart(), spike32.spike32_hart()]
openocd_config_path = "spike-rtos.cfg"
timeout_sec = 30
+ implements_custom_test = True
def create(self):
return testlib.Spike(self, progbufsize=0)
harts = [spike32.spike32_hart(), spike32.spike32_hart()]
openocd_config_path = "spike-2.cfg"
timeout_sec = 30
+ implements_custom_test = True
def create(self):
return testlib.Spike(self, isa="RV32IMAFC", progbufsize=0)
harts = [spike32_hart()]
openocd_config_path = "spike-1.cfg"
timeout_sec = 30
+ implements_custom_test = True
def create(self):
# 64-bit FPRs on 32-bit target
harts = [spike64.spike64_hart(), spike64.spike64_hart()]
openocd_config_path = "spike-rtos.cfg"
timeout_sec = 60
+ implements_custom_test = True
def create(self):
return testlib.Spike(self)
harts = [spike64.spike64_hart(), spike64.spike64_hart()]
openocd_config_path = "spike-2.cfg"
timeout_sec = 60
+ implements_custom_test = True
def create(self):
return testlib.Spike(self, isa="RV64IMAFD")
harts = [spike64_hart()]
openocd_config_path = "spike-1.cfg"
timeout_sec = 30
+ implements_custom_test = True
def create(self):
# 32-bit FPRs only
value = shlex.split(output.split('=')[-1].strip())[1]
return value
+ def info_registers(self, group):
+ output = self.command("info registers %s" % group)
+ result = {}
+ for line in output.splitlines():
+ if "Could not fetch" in line:
+ name, value = line.split(None, 1)
+ else:
+ name, hex_value, _ = line.split(None, 2)
+ value = int(hex_value, 0)
+ result[name] = value
+ return result
+
def stepi(self):
output = self.command("stepi", ops=10)
return output