Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CXX_SOURCES := jitbp.cpp

include Makefile.rules

jitbp.ll: jitbp.cpp
$(CXX) -g -S -emit-llvm --target=x86_64-unknown-unknown-elf \
-o $@ $<

all: jitbp.ll

clean::
rm -f jitbp.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Test that pending breakpoints resolve for JITted code with mcjit and rtdyld.
"""

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *

import shutil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe sinking this into the function below makes test discovery marginally faster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks 👍



class TestJitBreakpoint(TestBase):
def setUp(self):
TestBase.setUp(self)
self.ll = self.getBuildArtifact("jitbp.ll")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make this a local variable below, you can remove the entire setUp function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks 👍


@skipUnlessArch("x86_64")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also need a decorator that checks that the compiler is clang (and not, e.g., gcc) since we use the -emit-llvm flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added @skipUnlessCompilerIsClang

@expectedFailureAll(oslist=["windows"])
def test_jit_breakpoints(self):
self.build()
self.do_test("--jit-kind=mcjit")
self.do_test("--jit-linker=rtdyld")

def do_test(self, jit_flag: str):
self.dbg.SetAsync(False)

self.dbg.HandleCommand("settings set plugin.jit-loader.gdb.enable on")

lldb_dir = os.path.dirname(lldbtest_config.lldbExec)
lli_path = shutil.which("lli", path=lldb_dir)
self.assertTrue(os.path.exists(lli_path), "lli not found")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to fail in out-of-tree builds?
Do we have a way to get the LLVM BINDIR here?

Copy link
Contributor Author

@charles-zablit charles-zablit Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have replaced the whole invocation with self.runCmd("target create lli", CURRENT_EXECUTABLE_SET). This is what we were doing in the shell version of the test.

I did not find a way to get the LLVM bindir.

target = self.dbg.CreateTarget(lli_path)
self.assertTrue(target.IsValid())

bp = target.BreakpointCreateByName("jitbp")
self.assertTrue(bp.IsValid())
self.assertEqual(bp.GetNumLocations(), 0, "Expected a pending breakpoint")

launch_info = target.GetLaunchInfo()
launch_info.SetArguments([jit_flag, self.ll], True)

error = lldb.SBError()
process = target.Launch(launch_info, error)
self.assertTrue(process.IsValid())
self.assertTrue(error.Success(), error.GetCString())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a good reason why we can't use any of the lldbutil helper functions that launch a program and check for breakpoints here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I tried to mimic the Shell test style. Now, I copied how the TestInlinedBreakpoints.py test is setup.


self.assertEqual(process.GetState(), lldb.eStateStopped)

thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
self.assertIn("jitbp", frame.GetFunctionName())

self.assertGreaterEqual(
bp.GetNumLocations(), 1, "Breakpoint must be resolved after JIT loads code"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int jitbp() { return 0; }
int main() { return jitbp(); }
22 changes: 0 additions & 22 deletions lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test

This file was deleted.

Loading