[Lldb-commits] [lldb] r171431 - in /lldb/trunk: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp test/lang/objc/objc-property/TestObjCProperty.py test/lang/objc/objc-property/main.m
Sean Callanan
scallanan at apple.com
Wed Jan 2 16:06:04 PST 2013
Author: spyffe
Date: Wed Jan 2 18:05:56 2013
New Revision: 171431
URL: http://llvm.org/viewvc/llvm-project?rev=171431&view=rev
Log:
Clang sometimes emits "objc_object*" rather than "id"
for id types with protocols on them. We detect this
and report "id" instead.
Also added a testcase.
<rdar://problem/12595644>
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/test/lang/objc/objc-property/TestObjCProperty.py
lldb/trunk/test/lang/objc/objc-property/main.m
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=171431&r1=171430&r2=171431&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Jan 2 18:05:56 2013
@@ -5511,51 +5511,80 @@
case DW_TAG_volatile_type: encoding_data_type = Type::eEncodingIsVolatileUID; break;
}
- if (clang_type == NULL && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID))
+ if (clang_type == NULL && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID) && sc.comp_unit != NULL)
{
- if (type_name_cstr != NULL && sc.comp_unit != NULL &&
- (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus))
+ bool translation_unit_is_objc = (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
+
+ if (translation_unit_is_objc)
{
- static ConstString g_objc_type_name_id("id");
- static ConstString g_objc_type_name_Class("Class");
- static ConstString g_objc_type_name_selector("SEL");
-
- if (type_name_const_str == g_objc_type_name_id)
+ if (type_name_cstr != NULL)
{
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBuiltInType_objc_id();
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
+ static ConstString g_objc_type_name_id("id");
+ static ConstString g_objc_type_name_Class("Class");
+ static ConstString g_objc_type_name_selector("SEL");
+
+ if (type_name_const_str == g_objc_type_name_id)
+ {
+ if (log)
+ GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, dwarf_cu));
+ clang_type = ast.GetBuiltInType_objc_id();
+ encoding_data_type = Type::eEncodingIsUID;
+ encoding_uid = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ else if (type_name_const_str == g_objc_type_name_Class)
+ {
+ if (log)
+ GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, dwarf_cu));
+ clang_type = ast.GetBuiltInType_objc_Class();
+ encoding_data_type = Type::eEncodingIsUID;
+ encoding_uid = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ else if (type_name_const_str == g_objc_type_name_selector)
+ {
+ if (log)
+ GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, dwarf_cu));
+ clang_type = ast.GetBuiltInType_objc_selector();
+ encoding_data_type = Type::eEncodingIsUID;
+ encoding_uid = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
}
- else if (type_name_const_str == g_objc_type_name_Class)
- {
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBuiltInType_objc_Class();
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
- }
- else if (type_name_const_str == g_objc_type_name_selector)
+ else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid != LLDB_INVALID_UID)
{
- if (log)
- GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.",
- die->GetOffset(),
- DW_TAG_value_to_name(die->Tag()),
- die->GetName(this, dwarf_cu));
- clang_type = ast.GetBuiltInType_objc_selector();
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid = LLDB_INVALID_UID;
- resolve_state = Type::eResolveStateFull;
+ // Clang sometimes erroneously emits id as objc_object*. In that case we fix up the type to "id".
+
+ DWARFDebugInfoEntry* encoding_die = dwarf_cu->GetDIEPtr(encoding_uid);
+
+ if (encoding_die && encoding_die->Tag() == DW_TAG_structure_type)
+ {
+ if (const char *struct_name = encoding_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_name, NULL))
+ {
+ if (!strcmp(struct_name, "objc_object"))
+ {
+ if (log)
+ GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is 'objc_object*', which we overrode to 'id'.",
+ die->GetOffset(),
+ DW_TAG_value_to_name(die->Tag()),
+ die->GetName(this, dwarf_cu));
+ clang_type = ast.GetBuiltInType_objc_id();
+ encoding_data_type = Type::eEncodingIsUID;
+ encoding_uid = LLDB_INVALID_UID;
+ resolve_state = Type::eResolveStateFull;
+ }
+ }
+ }
}
}
}
Modified: lldb/trunk/test/lang/objc/objc-property/TestObjCProperty.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-property/TestObjCProperty.py?rev=171431&r1=171430&r2=171431&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/objc-property/TestObjCProperty.py (original)
+++ lldb/trunk/test/lang/objc/objc-property/TestObjCProperty.py Wed Jan 2 18:05:56 2013
@@ -124,6 +124,11 @@
unbacked_value = frame.EvaluateExpression("mine.unbackedInt", False)
unbacked_error = unbacked_value.GetError()
self.assertTrue (unbacked_error.Success())
+
+ idWithProtocol_value = frame.EvaluateExpression("mine.idWithProtocol", False)
+ idWithProtocol_error = idWithProtocol_value.GetError()
+ self.assertTrue (idWithProtocol_error.Success())
+ self.assertTrue (idWithProtocol_value.GetTypeName() == "id")
if __name__ == '__main__':
import atexit
Modified: lldb/trunk/test/lang/objc/objc-property/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-property/main.m?rev=171431&r1=171430&r2=171431&view=diff
==============================================================================
--- lldb/trunk/test/lang/objc/objc-property/main.m (original)
+++ lldb/trunk/test/lang/objc/objc-property/main.m Wed Jan 2 18:05:56 2013
@@ -1,5 +1,11 @@
#import <Foundation/Foundation.h>
+ at protocol MyProtocol
+
+-(const char *)hello;
+
+ at end
+
@interface BaseClass : NSObject
{
int _backedInt;
@@ -18,6 +24,7 @@
@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
@property int backedInt;
+ at property (nonatomic, assign) id <MyProtocol> idWithProtocol;
@end
@implementation BaseClass
@@ -79,6 +86,8 @@
int unbackedInt = mine.unbackedInt;
+ id idWithProtocol = mine.idWithProtocol;
+
NSLog (@"Results for %p: nonexistant: %d backed: %d unbacked: %d accessCount: %d.",
mine,
nonexistant,
More information about the lldb-commits
mailing list