Skip to content

Commit 2d65bdb

Browse files
[lldb] convert jit-loader_rtdyld_elf.test to an API test (#170333)
This patch converts the `jit-loader_rtdyld_elf.test` test from a Shell test to an API test. This test is timing out in CI on Windows and the hang cannot be reproduced at desk. Converting it to an API test would allow us to instrument it better in order to trace the failure.
1 parent 11e457c commit 2d65bdb

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
@@ -953,6 +953,19 @@ def is_compiler_clang_with_call_site_info():
953953
return skipTestIfFn(is_compiler_clang_with_call_site_info)(func)
954954

955955

956+
def skipUnlessCompilerIsClang(func):
957+
"""Decorate the item to skip test unless the compiler is clang."""
958+
959+
def is_compiler_clang():
960+
compiler_path = lldbplatformutil.getCompiler()
961+
compiler = os.path.basename(compiler_path)
962+
if not compiler.startswith("clang"):
963+
return "Test requires clang as compiler"
964+
return None
965+
966+
return skipTestIfFn(is_compiler_clang)(func)
967+
968+
956969
def skipUnlessThreadSanitizer(func):
957970
"""Decorate the item to skip test unless Clang -fsanitize=thread is supported."""
958971

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)