Skip to content

Commit de4b7ff

Browse files
Merge pull request #11992 from charles-zablit/charles-zablit/lldb/windows/convert-to-api-test
🍒 [lldb] convert jit-loader_rtdyld_elf.test to an API test
2 parents c426073 + f9efae4 commit de4b7ff

File tree

5 files changed

+73
-22
lines changed

5 files changed

+73
-22
lines changed

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,19 @@ def is_compiler_clang_with_call_site_info():
960960
return skipTestIfFn(is_compiler_clang_with_call_site_info)(func)
961961

962962

963+
def skipUnlessCompilerIsClang(func):
964+
"""Decorate the item to skip test unless the compiler is clang."""
965+
966+
def is_compiler_clang():
967+
compiler_path = lldbplatformutil.getCompiler()
968+
compiler = os.path.basename(compiler_path)
969+
if not compiler.startswith("clang"):
970+
return "Test requires clang as compiler"
971+
return None
972+
973+
return skipTestIfFn(is_compiler_clang)(func)
974+
975+
963976
def skipUnlessThreadSanitizer(func):
964977
"""Decorate the item to skip test unless Clang -fsanitize=thread is supported."""
965978

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 \
7+
-o $@ $<
8+
9+
all: jitbp.ll
10+
11+
clean::
12+
rm -f jitbp.ll
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
9+
10+
class TestJitBreakpoint(TestBase):
11+
@skipUnlessArch("x86_64")
12+
@skipUnlessCompilerIsClang
13+
@expectedFailureAll(oslist=["windows"])
14+
def test_jit_breakpoints(self):
15+
self.build()
16+
self.ll = self.getBuildArtifact("jitbp.ll")
17+
self.do_test("--jit-kind=mcjit")
18+
self.do_test("--jit-linker=rtdyld")
19+
20+
def do_test(self, jit_flag: str):
21+
self.runCmd("settings set plugin.jit-loader.gdb.enable on")
22+
23+
clang_path = self.findBuiltClang()
24+
self.assertTrue(clang_path, "built clang could not be found")
25+
lli_path = os.path.join(os.path.dirname(clang_path), "lli")
26+
self.assertTrue(lldbutil.is_exe(lli_path), f"'{lli_path}' is not an executable")
27+
self.runCmd(f"target create {lli_path}", CURRENT_EXECUTABLE_SET)
28+
29+
line = line_number("jitbp.cpp", "int jitbp()")
30+
lldbutil.run_break_set_by_file_and_line(
31+
self, "jitbp.cpp", line, num_expected_locations=0
32+
)
33+
34+
self.runCmd(f"run {jit_flag} {self.ll}", RUN_SUCCEEDED)
35+
36+
# The stop reason of the thread should be breakpoint.
37+
# And it should break at jitbp.cpp:1.
38+
self.expect(
39+
"thread list",
40+
STOPPED_DUE_TO_BREAKPOINT,
41+
substrs=[
42+
"stopped",
43+
"jitbp.cpp:%d" % line,
44+
"stop reason = breakpoint",
45+
],
46+
)
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)