Skip to content

Commit

Permalink
debug: Create UnavailableCycleTest
Browse files Browse the repository at this point in the history
Use new spike mechanism to test OpenOCD behavior when a hart becomes
unavailable, and then available again.
  • Loading branch information
timsifive committed Jul 7, 2023
1 parent ca2e92d commit 2ce89e0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,33 @@ def test(self):
except CouldNotReadRegisters:
pass

class UnavailableCycleTest(ProgramTest):
"""Test that harts can be debugged after becoming temporarily
unavailable."""
def early_applicable(self):
return self.target.support_unavailable_control

def test(self):
self.gdb.b("main")
output = self.gdb.c()
assertIn("Breakpoint", output)
assertIn("main", output)

self.gdb.p("$pc=loop_forever")
self.gdb.c(wait=False)
self.server.wait_until_running([self.hart])
self.server.command(
f"riscv dmi_write 0x1f 0x{(~(1<<self.hart.id))&0x3:x}")
self.gdb.expect(r"\S+ became unavailable.")

# Now send a DMI command through OpenOCD to make the hart available
# again.

self.server.command("riscv dmi_write 0x1f 0x3")
self.gdb.expect(r"\S+ became available")
self.gdb.interrupt()
self.gdb.p("$pc")

class FreeRtosTest(GdbTest):
def early_applicable(self):
return self.target.freertos_binary
Expand Down

0 comments on commit 2ce89e0

Please sign in to comment.