-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[LLDB] Add bit extraction to DIL #141422
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
[LLDB] Add bit extraction to DIL #141422
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ class Token { | |
| identifier, | ||
| l_paren, | ||
| l_square, | ||
| minus, | ||
| numeric_constant, | ||
| period, | ||
| r_paren, | ||
|
|
||
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
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
3 changes: 3 additions & 0 deletions
3
lldb/test/API/commands/frame/var-dil/basics/BitFieldExtraction/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 @@ | ||
| CXX_SOURCES := main.cpp | ||
|
|
||
| include Makefile.rules |
56 changes: 56 additions & 0 deletions
56
...API/commands/frame/var-dil/basics/BitFieldExtraction/TestFrameVarDILBitFieldExtraction.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,56 @@ | ||
| """ | ||
| Test DIL BifField extraction. | ||
| """ | ||
|
|
||
| import lldb | ||
| from lldbsuite.test.lldbtest import * | ||
| from lldbsuite.test.decorators import * | ||
| from lldbsuite.test import lldbutil | ||
|
|
||
|
|
||
| class TestFrameVarDILBitFieldExtraction(TestBase): | ||
| NO_DEBUG_INFO_TESTCASE = True | ||
|
|
||
| def expect_var_path(self, expr, compare_to_framevar=False, value=None, type=None): | ||
| value_dil = super().expect_var_path(expr, value=value, type=type) | ||
| if compare_to_framevar: | ||
| self.runCmd("settings set target.experimental.use-DIL false") | ||
| value_frv = super().expect_var_path(expr, value=value, type=type) | ||
| self.runCmd("settings set target.experimental.use-DIL true") | ||
| self.assertEqual(value_dil.GetValue(), value_frv.GetValue()) | ||
|
|
||
| def test_bitfield_extraction(self): | ||
| self.build() | ||
| lldbutil.run_to_source_breakpoint( | ||
| self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp") | ||
| ) | ||
|
|
||
| self.runCmd("settings set target.experimental.use-DIL true") | ||
|
|
||
| # Test ranges and type | ||
| self.expect_var_path("value[0-1]", True, value="3", type="int:2") | ||
| self.expect_var_path("value[4-7]", True, value="7", type="int:4") | ||
| self.expect_var_path("value[7-0]", True, value="115", type="int:8") | ||
|
|
||
| # Test reference and dereferenced pointer | ||
| self.expect_var_path("value_ref[0-1]", value="3", type="int:2") | ||
| self.expect_var_path("(*value_ptr)[0-1]", value="3", type="int:2") | ||
|
|
||
| # Test array and pointer | ||
| self.expect( | ||
| "frame var 'int_arr[0-2]'", | ||
| error=True, | ||
| substrs=["bitfield range 0-2 is not valid"], | ||
| ) | ||
| self.expect( | ||
| "frame var 'value_ptr[0-1]'", | ||
| error=True, | ||
| substrs=["bitfield range 0-1 is not valid"], | ||
| ) | ||
|
|
||
| # Test invalid input | ||
| self.expect( | ||
| "frame var 'value[1-]'", | ||
| error=True, | ||
| substrs=["failed to parse integer constant"], | ||
| ) |
9 changes: 9 additions & 0 deletions
9
lldb/test/API/commands/frame/var-dil/basics/BitFieldExtraction/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,9 @@ | ||
| int main(int argc, char **argv) { | ||
| int value = 0b01110011; | ||
| int &value_ref = value; | ||
| int *value_ptr = &value; | ||
|
|
||
| int int_arr[] = {7, 3, 1}; | ||
|
|
||
| return 0; // Set a breakpoint here | ||
| } |
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.
This is more of the previous PR, but I think this should actually work. Current "frame var" will happily access a pointer/array with negative indexes.
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.
Should I make a separate PR to fix this?