-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LLDB] Add unary operators Dereference and AddressOf to DIL #134428
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
58c4f08
Add unary operators Dereference and AddressOf
kuilpd 36d4f95
Fix parsing, remove dereferencing, add unit tests
kuilpd d7fdf3f
Remove unit tests, add Python tests
kuilpd 336d59f
Remove array conversion, cut down evaluation of & and *.
kuilpd 8b63dfd
Rename rhs to operand, remove extra check and return `ValueObject::De…
kuilpd b183a3b
Remove a pointer to void check
kuilpd 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
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
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/AddressOf/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 |
38 changes: 38 additions & 0 deletions
38
lldb/test/API/commands/frame/var-dil/basics/AddressOf/TestFrameVarDILAddressOf.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,38 @@ | ||
""" | ||
Test DIL address calculation. | ||
""" | ||
|
||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestFrameVarDILGlobalVariableLookup(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_frame_var(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") | ||
self.expect_var_path("&x", True, type="int *") | ||
self.expect_var_path("r", True, type="int &") | ||
self.expect_var_path("&r", True, type="int &*") | ||
self.expect_var_path("pr", True, type="int *&") | ||
self.expect_var_path("&pr", True, type="int *&*") | ||
self.expect_var_path("my_pr", True) | ||
self.expect_var_path("&my_pr", True, type="mypr *") | ||
self.expect_var_path("&globalVar", True, type="int *") | ||
self.expect_var_path("&s_str", True, type="const char **") | ||
self.expect_var_path("&argc", True, type="int *") |
16 changes: 16 additions & 0 deletions
16
lldb/test/API/commands/frame/var-dil/basics/AddressOf/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,16 @@ | ||
int globalVar = 0xDEADBEEF; | ||
|
||
int main(int argc, char **argv) { | ||
int x = 42; | ||
int &r = x; | ||
int *p = &x; | ||
int *&pr = p; | ||
|
||
typedef int *&mypr; | ||
mypr my_pr = p; | ||
|
||
const char *s_str = "hello"; | ||
|
||
char c = 1; | ||
return 0; // Set a breakpoint here | ||
} |
3 changes: 3 additions & 0 deletions
3
lldb/test/API/commands/frame/var-dil/basics/PointerArithmetic/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 |
50 changes: 50 additions & 0 deletions
50
...t/API/commands/frame/var-dil/basics/PointerArithmetic/TestFrameVarDILPointerArithmetic.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,50 @@ | ||
""" | ||
Test DIL pointer arithmetic. | ||
""" | ||
|
||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestFrameVarDILGlobalVariableLookup(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_dereference(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") | ||
self.expect_var_path("*p_int0", True, value="0") | ||
self.expect_var_path("*cp_int5", True, value="5") | ||
self.expect_var_path("*rcp_int0", True, type="const int *") | ||
self.expect_var_path("*offset_p", True, value="5") | ||
self.expect_var_path("*offset_pref", True, type="int *") | ||
self.expect_var_path("**pp_int0", value="0") | ||
self.expect_var_path("&**pp_int0", type="int *") | ||
self.expect( | ||
"frame var '*array'", | ||
error=True, | ||
substrs=["not a pointer or reference type"], | ||
) | ||
self.expect( | ||
"frame var '&*p_null'", | ||
error=True, | ||
substrs=["doesn't have a valid address"], | ||
) | ||
self.expect( | ||
"frame var '&*p_void'", | ||
error=True, | ||
substrs=["dereference failed: (void *) p_void"], | ||
) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.