Skip to content

Commit c83a241

Browse files
[lldb] convert TestJitBreakpoint to API test
1 parent 7bced74 commit c83a241

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CXX_SOURCES := jitbp.cpp
2+
3+
include Makefile.rules
4+
5+
jitbp.ll: jitbp.cpp
6+
$(CXX) -g -S -emit-llvm --target=x86_64-unknown-unknown-elf -o $@ $<
7+
8+
all: jitbp.ll
9+
10+
clean::
11+
rm -f jitbp.ll
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Test that pending breakpoints resolve for JITted code with mcjit and rtdyld.
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 TestJitBreakpoint(TestBase):
12+
def setUp(self):
13+
TestBase.setUp(self)
14+
self.ll = self.getBuildArtifact("jitbp.ll")
15+
16+
@skipUnlessArch("x86_64")
17+
@expectedFailureAll(oslist=["windows"])
18+
def test_jit_breakpoints(self):
19+
self.build()
20+
self.do_test("--jit-kind=mcjit")
21+
self.do_test("--jit-linker=rtdyld")
22+
23+
def do_test(self, jit_flag: str):
24+
self.dbg.SetAsync(False)
25+
26+
self.dbg.HandleCommand("settings set plugin.jit-loader.gdb.enable on")
27+
28+
lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
29+
lli_path = shutil.which("lli", path=lldb_dir)
30+
self.assertTrue(os.path.exists(lli_path), "lli not found")
31+
target = self.dbg.CreateTarget(lli_path)
32+
self.assertTrue(target.IsValid())
33+
34+
bp = target.BreakpointCreateByName("jitbp")
35+
self.assertTrue(bp.IsValid())
36+
self.assertEqual(bp.GetNumLocations(), 0, "Expected a pending breakpoint")
37+
38+
launch_info = target.GetLaunchInfo()
39+
launch_info.SetArguments([jit_flag, self.ll], True)
40+
41+
error = lldb.SBError()
42+
process = target.Launch(launch_info, error)
43+
self.assertTrue(process.IsValid())
44+
self.assertTrue(error.Success(), error.GetCString())
45+
46+
self.assertEqual(process.GetState(), lldb.eStateStopped)
47+
48+
thread = process.GetSelectedThread()
49+
frame = thread.GetSelectedFrame()
50+
self.assertIn("jitbp", frame.GetFunctionName())
51+
52+
self.assertGreaterEqual(
53+
bp.GetNumLocations(), 1, "Breakpoint must be resolved after JIT loads code"
54+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
int jitbp() { return 0; }
2+
int main() { return jitbp(); }

lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)