class DebugTest(DeleteServer):
def setUp(self):
- self.binary = target.compile("programs/debug.c", "programs/checksum.c")
+ # Include malloc so that gdb can make function calls. I suspect this
+ # malloc will silently blow through the memory set aside for it, so be
+ # careful.
+ self.binary = target.compile("programs/debug.c", "programs/checksum.c",
+ "programs/tiny-malloc.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE")
self.server = target.server()
self.gdb = testlib.Gdb()
self.gdb.command("file %s" % self.binary)
# Use a0 until gdb can resolve "status"
self.assertEqual(self.gdb.p("$a0") & 0xffffffff, 0xc86455d4)
+ def test_function_call(self):
+ text = "Howdy, Earth!"
+ gdb_length = self.gdb.p('strlen("%s")' % text)
+ self.assertEqual(gdb_length, len(text))
+ self.exit()
+
def test_turbostep(self):
"""Single step a bunch of times."""
self.gdb.command("p i=0");
output = self.gdb.c()
self.assertIn("Cannot insert hardware breakpoint", output)
+ # Clean up, otherwise the hardware breakpoints stay set and future
+ # tests may fail.
+ self.gdb.command("D")
def test_registers(self):
# Get to a point in the code where some registers have actually been
def test_step(self):
main = self.gdb.p("$pc")
- for expected in (4, 0xc, 0x10, 0x18, 0x14, 0x14):
+ for expected in (4, 8, 0xc, 0x10, 0x18, 0x1c, 0x28, 0x20, 0x2c, 0x2c):
self.gdb.stepi()
pc = self.gdb.p("$pc")
- self.assertEqual(pc - main, expected)
+ self.assertEqual("%x" % pc, "%x" % (expected + main))
class RegsTest(DeleteServer):
def setUp(self):
class DownloadTest(DeleteServer):
def setUp(self):
- length = 2**20
+ length = min(2**20, target.ram_size - 2048)
fd = file("download.c", "w")
fd.write("#include <stdint.h>\n")
fd.write("unsigned int crc32a(uint8_t *message, unsigned int size);\n")
name = "spike"
xlen = 64
ram = 0x80010000
+ ram_size = 5 * 1024 * 1024
def server(self):
return testlib.Spike(parsed.cmd, halted=True)
directory = "spike"
xlen = 32
ram = 0x80010000
+ ram_size = 5 * 1024 * 1024
def server(self):
return testlib.Spike(parsed.cmd, halted=True, xlen=32)
name = "m2gl_m2s"
xlen = 32
ram = 0x80000000
+ ram_size = 16 * 1024
def server(self):
return testlib.Openocd(cmd=parsed.cmd,