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):