-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Fix evaluating expressions without JIT in an object context #145599
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
Merged
Changes from 2 commits
Commits
Show all changes
3 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
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
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
52 changes: 52 additions & 0 deletions
52
lldb/test/API/functionalities/postmortem/elf-core/expr/TestExpr.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,52 @@ | ||
| """ | ||
| Test evaluating expressions when debugging core file. | ||
| """ | ||
|
|
||
| import lldb | ||
| from lldbsuite.test.decorators import * | ||
| from lldbsuite.test.lldbtest import * | ||
| from lldbsuite.test import lldbutil | ||
|
|
||
|
|
||
| @skipIfLLVMTargetMissing("X86") | ||
| class CoreExprTestCase(TestBase): | ||
| def setUp(self): | ||
| TestBase.setUp(self) | ||
| self.target = self.dbg.CreateTarget("linux-x86_64.out") | ||
| self.process = self.target.LoadCore("linux-x86_64.core") | ||
| self.assertTrue(self.process, PROCESS_IS_VALID) | ||
|
|
||
| def test_result_var(self): | ||
| """Test that the result variable can be used in subsequent expressions.""" | ||
|
|
||
| self.expect_expr( | ||
| "outer", | ||
| result_type="Outer", | ||
| result_children=[ValueCheck(name="inner", type="Inner")], | ||
| ) | ||
| self.expect_expr( | ||
| "$0.inner", | ||
| result_type="Inner", | ||
| result_children=[ValueCheck(name="val", type="int", value="5")], | ||
| ) | ||
| self.expect_expr("$1.val", result_type="int", result_value="5") | ||
|
|
||
| def test_persist_var(self): | ||
| """Test that user-defined variables can be used in subsequent expressions.""" | ||
|
|
||
| self.target.EvaluateExpression("int $my_int = 5") | ||
| self.expect_expr("$my_int * 2", result_type="int", result_value="10") | ||
|
|
||
| def test_context_object(self): | ||
| """Test expression evaluation in context of an object.""" | ||
|
|
||
| val_outer = self.expect_expr("outer", result_type="Outer") | ||
|
|
||
| val_inner = val_outer.EvaluateExpression("inner") | ||
| self.assertTrue(val_inner.IsValid()) | ||
| self.assertEqual("Inner", val_inner.GetDisplayTypeName()) | ||
|
|
||
| val_val = val_inner.EvaluateExpression("this->val") | ||
| self.assertTrue(val_val.IsValid()) | ||
| self.assertEqual("int", val_val.GetDisplayTypeName()) | ||
| self.assertEqual(val_val.GetValueAsSigned(), 5) |
Binary file added
BIN
+40 KB
lldb/test/API/functionalities/postmortem/elf-core/expr/linux-x86_64.core
Binary file not shown.
Binary file added
BIN
+10.6 KB
lldb/test/API/functionalities/postmortem/elf-core/expr/linux-x86_64.out
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
lldb/test/API/functionalities/postmortem/elf-core/expr/main.cpp
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,15 @@ | ||
| struct Inner { | ||
| Inner(int val) : val(val) {} | ||
| int val; | ||
| }; | ||
|
|
||
| struct Outer { | ||
| Outer(int val) : inner(val) {} | ||
| Inner inner; | ||
| }; | ||
|
|
||
| extern "C" void _start(void) { | ||
| Outer outer(5); | ||
| char *boom = (char *)0; | ||
| *boom = 47; | ||
| } |
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
Oops, something went wrong.
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.
Can you put error last here? We generally put the error return last among the out parameters.
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.
That would mean more intrusive code changes because
used_policywould become a required parameter. Maybe it would make more sense to switch to usingllvm::Expected<>for this method?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.
Done in #146016, PTAL.