Skip to content

Commit 77c1872

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

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CXX_SOURCES := jitbp.cpp
2+
3+
include Makefile.rules
4+
5+
# Build LLVM IR that lli will JIT.
6+
# Matches the commands from the shell test.
7+
jitbp.ll: jitbp.cpp
8+
$(CXX) -g -S -emit-llvm --target=x86_64-unknown-unknown-elf \
9+
-o $@ $<
10+
11+
all: jitbp.ll
12+
13+
clean::
14+
rm -f jitbp.ll
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
lli_path = lldbutil.which("lli")
29+
self.assertIsNotNone(lli_path, "Could not find lli executable")
30+
target = self.dbg.CreateTarget(lli_path)
31+
self.assertTrue(target.IsValid())
32+
33+
bp = target.BreakpointCreateByName("jitbp")
34+
self.assertTrue(bp.IsValid())
35+
self.assertEqual(bp.GetNumLocations(), 0, "Expected a pending breakpoint")
36+
37+
launch_info = target.GetLaunchInfo()
38+
launch_info.SetArguments([jit_flag, self.ll], True)
39+
40+
error = lldb.SBError()
41+
process = target.Launch(launch_info, error)
42+
self.assertTrue(process.IsValid())
43+
self.assertTrue(error.Success(), error.GetCString())
44+
45+
self.assertEqual(process.GetState(), lldb.eStateStopped)
46+
47+
thread = process.GetSelectedThread()
48+
frame = thread.GetSelectedFrame()
49+
self.assertIn("jitbp", frame.GetFunctionName())
50+
51+
self.assertGreaterEqual(
52+
bp.GetNumLocations(), 1, "Breakpoint must be resolved after JIT loads code"
53+
)

lldb/test/Shell/Breakpoint/Inputs/jitbp.cpp renamed to lldb/test/API/functionalities/breakpoint/jit_loader_rtdyld_elf/jitbp.cpp

File renamed without changes.

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

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

0 commit comments

Comments
 (0)