-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[lldb] convert jit-loader_rtdyld_elf.test to an API test #170333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
07ecfc8
887a09d
28b3a57
9074baa
faf36ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
|
|
||
| class TestJitBreakpoint(TestBase): | ||
| def setUp(self): | ||
| TestBase.setUp(self) | ||
| self.ll = self.getBuildArtifact("jitbp.ll") | ||
|
||
|
|
||
| @skipUnlessArch("x86_64") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added |
||
| @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") | ||
|
||
| 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()) | ||
|
||
|
|
||
| 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(); } |
This file was deleted.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks 👍