diff options
5 files changed, 51 insertions, 18 deletions
diff --git a/lldb/examples/synthetic/CFString.py b/lldb/examples/synthetic/CFString.py index bf82c1ddde3..0e39b73ae57 100644 --- a/lldb/examples/synthetic/CFString.py +++ b/lldb/examples/synthetic/CFString.py @@ -7,6 +7,8 @@ class CFStringSynthProvider: self.update() # children other than "content" are for debugging only and must not be used in production code def num_children(self): + if self.invalid: + return 0; return 6; def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() @@ -167,7 +169,12 @@ class CFStringSynthProvider: self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); cfinfo.SetFormat(11) info = cfinfo.GetValue(); - return int(info,0); + if info != None: + self.invalid = False; + return int(info,0); + else: + self.invalid = True; + return None; # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): @@ -196,6 +203,8 @@ class CFStringSynthProvider: # useful values to get at the real data def compute_flags(self): self.info_bits = self.read_info_bits(); + if self.info_bits == None: + return; self.mutable = self.is_mutable(); self.inline = self.is_inline(); self.explicit = self.has_explicit_length(); @@ -204,3 +213,9 @@ class CFStringSynthProvider: def update(self): self.adjust_for_architecture(); self.compute_flags(); +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == True: + return "<invalid object>"; + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index ceb58e2b97b..3c80c263a31 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -235,6 +235,8 @@ ClangASTType::GetMinimumLanguage (lldb::clang_type_t clang_type) case clang::BuiltinType::BoundMember: case clang::BuiltinType::UnknownAny: break; + case clang::Type::Typedef: + return GetMinimumLanguage(cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); } break; } diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/CFString.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/CFString.py index bf82c1ddde3..0e39b73ae57 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/CFString.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/CFString.py @@ -7,6 +7,8 @@ class CFStringSynthProvider: self.update() # children other than "content" are for debugging only and must not be used in production code def num_children(self): + if self.invalid: + return 0; return 6; def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() @@ -167,7 +169,12 @@ class CFStringSynthProvider: self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); cfinfo.SetFormat(11) info = cfinfo.GetValue(); - return int(info,0); + if info != None: + self.invalid = False; + return int(info,0); + else: + self.invalid = True; + return None; # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): @@ -196,6 +203,8 @@ class CFStringSynthProvider: # useful values to get at the real data def compute_flags(self): self.info_bits = self.read_info_bits(); + if self.info_bits == None: + return; self.mutable = self.is_mutable(); self.inline = self.is_inline(); self.explicit = self.has_explicit_length(); @@ -204,3 +213,9 @@ class CFStringSynthProvider: def update(self): self.adjust_for_architecture(); self.compute_flags(); +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == True: + return "<invalid object>"; + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index a180c33e6fe..e17b6fc195b 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -103,99 +103,100 @@ class DataFormatterTestCase(TestBase): self.runCmd("script from CFString import *") self.runCmd("type synth add -l CFStringSynthProvider NSString") - self.expect('frame variable str -P 1', + self.expect('frame variable str -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A rather short ASCII NSString object is here']) - self.expect('frame variable str2 -P 1', + self.expect('frame variable str2 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A rather short UTF8 NSString object is here']) - self.expect('frame variable str3 -P 1', + self.expect('frame variable str3 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A string made with the at sign is here']) - self.expect('frame variable str4 -P 1', + self.expect('frame variable str4 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'This is string number 4 right here']) - self.expect('frame variable str5 -P 1', + self.expect('frame variable str5 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '{{1, 1}, {5, 5}}']) - self.expect('frame variable str6 -P 1', + self.expect('frame variable str6 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '1ST']) - self.expect('frame variable str7 -P 1', + self.expect('frame variable str7 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '\\xcf\\x83xx']) - self.expect('frame variable str8 -P 1', + self.expect('frame variable str8 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'hasVeryLongExtensionThisTime']) - self.expect('frame variable str9 -P 1', + self.expect('frame variable str9 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'a very much boring task to write a string this way!!\\xe4\\x8c\\xb3']) - self.expect('frame variable str10 -P 1', + self.expect('frame variable str10 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'This is a Unicode string \\xcf\\x83 number 4 right here']) - self.expect('frame variable str11 -P 1', + self.expect('frame variable str11 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '__NSCFString']) - self.expect('frame variable processName -P 1', + self.expect('frame variable processName -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'a.out']) - self.expect('frame variable str12 -P 1', + self.expect('frame variable str12 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'Process Name: a.out Process Id:']) - # make it a summary - self.runCmd("type summary add -f \"${svar.content}\" NSString") + # delete the synth and set a summary + self.runCmd("type synth delete NSString") + self.runCmd("type summary add -F CFString_SummaryProvider NSString") self.expect('frame variable str', substrs = ['A rather short ASCII NSString object is here']) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m b/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m index 4749749b953..6b7df5df10b 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m +++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -86,7 +86,7 @@ int main (int argc, const char * argv[]) NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; - NSRect rect = NSMakeRect(1,1,5,5); + NSRect rect = {{1,1},{5,5}}; NSString* str5 = NSStringFromRect(rect); |