Skip to content

Commit e45b7b7

Browse files
committed
[lldb][riscv][test] Add test for stepi with illegal instr
1 parent a95314e commit e45b7b7

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
C_SOURCES := main.c
2+
3+
include Makefile.rules
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Test that we can set up software breakpoint even if we failed to decode and execute instruction
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
from lldbsuite.test import lldbutil
9+
10+
11+
class TestBreakpointIlligal(TestBase):
12+
@skipIf(archs=no_match(["rv64gc"]))
13+
def test(self):
14+
self.build()
15+
(target, process, cur_thread, bkpt) = lldbutil.run_to_source_breakpoint(
16+
self, "main", lldb.SBFileSpec("main.c")
17+
)
18+
self.runCmd("thread step-inst")
19+
# we need to step more, as some compilers do not set appropriate debug info.
20+
while cur_thread.GetStopDescription(256) == "instruction step into":
21+
self.runCmd("thread step-inst")
22+
# The stop reason of the thread should be illegal opcode.
23+
self.expect(
24+
"thread list",
25+
STOPPED_DUE_TO_SIGNAL,
26+
substrs=["stopped", "stop reason = signal SIGILL: illegal opcode"],
27+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main() {
2+
// This instruction is not valid, but we have an ability to set
3+
// software breakpoint.
4+
// This results illegal instruction during execution, not fail to set
5+
// breakpoint
6+
asm volatile(".insn r 0x73, 0, 0, a0, a1, a2" : :);
7+
}

0 commit comments

Comments
 (0)