-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[lldb][Target] RunThreadPlan to save/restore the ExecutionContext's frame if one exists #134097
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
Merged
Michael137
merged 4 commits into
llvm:main
from
Michael137:lldb/save-restore-exe-ctx-frame
Apr 3, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lldb/test/API/commands/expression/expr-from-non-zero-frame/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
30 changes: 30 additions & 0 deletions
30
lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class ExprFromNonZeroFrame(TestBase): | ||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
def test(self): | ||
""" | ||
Tests that we can use SBFrame::EvaluateExpression on a frame | ||
that we're not stopped in, even if thread-plans run as part of | ||
parsing the expression (e.g., when running static initializers). | ||
""" | ||
self.build() | ||
|
||
(_, _, thread, _) = lldbutil.run_to_source_breakpoint( | ||
self, "Break here", lldb.SBFileSpec("main.c") | ||
) | ||
frame = thread.GetFrameAtIndex(1) | ||
|
||
# Using a function pointer inside the expression ensures we | ||
# emit a ptrauth static initializer on arm64e into the JITted | ||
# expression. The thread-plan that runs for this static | ||
# initializer should save/restore the current execution context | ||
# frame (which in this test is frame #1). | ||
result = frame.EvaluateExpression("int (*fptr)() = &func; fptr()") | ||
self.assertTrue(result.GetError().Success()) | ||
self.assertEqual(result.GetValueAsSigned(), 5) |
6 changes: 6 additions & 0 deletions
6
lldb/test/API/commands/expression/expr-from-non-zero-frame/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
int func(void) { | ||
__builtin_printf("Break here"); | ||
return 5; | ||
} | ||
|
||
int main(int argc, const char *argv[]) { return func(); } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This fails to compile on Windows:
https://lab.llvm.org/buildbot/#/builders/141/builds/7573
No idea why it would complain, perhaps on some platforms the builtin use here is compiled to puts and on windows it isn't?
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.
Oh I fixed this in a follow-up commit. Is the test still failing?
Yea not exactly sure about why the builtin doesnt link. Your theory sounds plausible
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.
Sorry yes it is building now but failing:
False is indeed not true, thank you test framework /s
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.
Skipped for now: d4002b4
It could be another case where we link with link.exe which can't handle DWARF information, and that's needed for the test. We will try to confirm or deny that.
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.
Thanks!