Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how we handle bit-fields for Objective-C when creating an AST
Currently expressions dealing with bit-fields in Objective-C objects is pretty broken. When generating debug-info for Objective-C bit-fields DW_AT_data_bit_offset has a different meaning than it does to C and C++. When we parse the DWARF we validate bit offsets for C and C++ correctly but not for ObjC. For ObjC in some cases we end up incorrectly flagging an error and we don't generate further bit-fields in the AST. Later on when we do a name lookup we don't find the ObjCIvarDecl in the ObjCInterfaceDecl in some cases since we never added it and then we don't go to the runtime to obtain the offset. This will fix how we handle bit-fields for the Objective-C case and add tests to verify this fix but also to documents areas that still don't work and will be addressed in follow-up PRs. Note: we can never correctly calculate offsets statically because of how Objective-C deals with the fragile base class issue. Which means the runtime may need to shift fields over. Differential Revision: https://reviews.llvm.org/D83433
- Loading branch information
Showing
4 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 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,4 @@ | ||
OBJC_SOURCES := main.m | ||
LD_EXTRAS = -framework Foundation | ||
|
||
include Makefile.rules |
51 changes: 39 additions & 12 deletions
51
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
This file contains 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 |
---|---|---|
@@ -1,12 +1,39 @@ | ||
from lldbsuite.test import lldbinline | ||
from lldbsuite.test import decorators | ||
|
||
lldbinline.MakeInlineTest( | ||
__file__, | ||
globals(), | ||
[ | ||
# This is a Darwin-only failure related to incorrect expression- | ||
# evaluation for single-bit ObjC bitfields. | ||
decorators.skipUnlessDarwin, | ||
decorators.expectedFailureAll( | ||
bugnumber="rdar://problem/17990991")]) | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
class TestBitfieldIvars(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
|
||
@skipUnlessDarwin | ||
def test(self): | ||
self.build() | ||
lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m")) | ||
|
||
self.expect_expr("chb->hb->field1", result_type="unsigned int", result_value="0") | ||
|
||
## FIXME field2 should have a value of 1 | ||
self.expect("expr chb->hb->field2", matching=False, substrs = ["= 1"]) # this must happen second | ||
|
||
self.expect_expr("hb2->field1", result_type="unsigned int", result_value="10") | ||
self.expect_expr("hb2->field2", result_type="unsigned int", result_value="3") | ||
self.expect_expr("hb2->field3", result_type="unsigned int", result_value="4") | ||
|
||
self.expect("frame var *hb2", substrs = [ 'x =', '100', | ||
'field1 =', '10', | ||
'field2 =', '3', | ||
'field3 =', '4']) | ||
|
||
@expectedFailureAll() | ||
def testExprWholeObject(self): | ||
self.build() | ||
lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m")) | ||
|
||
## FIXME expression with individual bit-fields obtains correct values but not with the whole object | ||
self.expect("expr *hb2", substrs = [ 'x =', '100', | ||
'field1 =', '10', | ||
'field2 =', '3', | ||
'field3 =', '4']) |
This file contains 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