|
20 | 20 | from testlib import TestNotApplicable, CompileError |
21 | 21 | from testlib import UnknownThread |
22 | 22 | from testlib import CouldNotReadRegisters, CommandException |
| 23 | +from testlib import ThreadTerminated |
23 | 24 |
|
24 | 25 | MSTATUS_UIE = 0x00000001 |
25 | 26 | MSTATUS_SIE = 0x00000002 |
@@ -1879,22 +1880,36 @@ def test(self): |
1879 | 1880 | except CouldNotReadRegisters: |
1880 | 1881 | pass |
1881 | 1882 |
|
1882 | | -class CeaseRunTest(ProgramTest): |
| 1883 | +class UnavailableRunTest(ProgramTest): |
1883 | 1884 | """Test that we work correctly when the hart we're debugging ceases to |
1884 | 1885 | respond.""" |
1885 | 1886 | def early_applicable(self): |
1886 | | - return self.hart.support_cease |
| 1887 | + return self.hart.support_cease or \ |
| 1888 | + self.target.support_unavailable_control |
1887 | 1889 |
|
1888 | 1890 | def test(self): |
1889 | 1891 | self.gdb.b("main") |
1890 | 1892 | output = self.gdb.c() |
1891 | 1893 | assertIn("Breakpoint", output) |
1892 | 1894 | assertIn("main", output) |
1893 | 1895 |
|
1894 | | - self.gdb.p("$pc=precease") |
| 1896 | + if self.target.support_unavailable_control: |
| 1897 | + self.gdb.p("$pc=loop_forever") |
| 1898 | + else: |
| 1899 | + self.gdb.p("$pc=cease") |
1895 | 1900 | self.gdb.c(wait=False) |
| 1901 | + if self.target.support_unavailable_control: |
| 1902 | + self.server.wait_until_running([self.hart]) |
| 1903 | + self.server.command( |
| 1904 | + f"riscv dmi_write 0x1f 0x{(~(1<<self.hart.id))&0x3:x}") |
1896 | 1905 | self.gdb.expect(r"\S+ became unavailable.") |
1897 | 1906 | self.gdb.interrupt() |
| 1907 | + # gdb might automatically switch to the available hart. |
| 1908 | + try: |
| 1909 | + self.gdb.select_hart(self.hart) |
| 1910 | + except ThreadTerminated: |
| 1911 | + # GDB sees that the thread is gone. Count this as success. |
| 1912 | + return |
1898 | 1913 | try: |
1899 | 1914 | self.gdb.p("$pc") |
1900 | 1915 | assert False, ("Registers shouldn't be accessible when the hart is " |
|
0 commit comments