[Lldb-commits] [lldb] r265849 - Remove even more of the data formatters that silently run code

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 8 14:24:24 PDT 2016


Author: enrico
Date: Fri Apr  8 16:24:24 2016
New Revision: 265849

URL: http://llvm.org/viewvc/llvm-project?rev=265849&view=rev
Log:
Remove even more of the data formatters that silently run code

Fixes <rdar://problem/25629755>


Modified:
    lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
    lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
    lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
    lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h
    lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h Fri Apr  8 16:24:24 2016
@@ -75,35 +75,7 @@ namespace lldb_private {
                     ScriptedSyntheticChildren::Flags flags,
                     bool regex = false);
 #endif
-        
-        StackFrame*
-        GetViableFrame (ExecutionContext exe_ctx);
-        
-        bool
-        ExtractValueFromObjCExpression (ValueObject &valobj,
-                                        const char* target_type,
-                                        const char* selector,
-                                        uint64_t &value);
-        
-        bool
-        ExtractSummaryFromObjCExpression (ValueObject &valobj,
-                                          const char* target_type,
-                                          const char* selector,
-                                          Stream &stream,
-                                          lldb::LanguageType lang_type);
-        
-        lldb::ValueObjectSP
-        CallSelectorOnObject (ValueObject &valobj,
-                              const char* return_type,
-                              const char* selector,
-                              uint64_t index);
-        
-        lldb::ValueObjectSP
-        CallSelectorOnObject (ValueObject &valobj,
-                              const char* return_type,
-                              const char* selector,
-                              const char* key);
-        
+
         size_t
         ExtractIndexFromString (const char* item_name);
         

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Fri Apr  8 16:24:24 2016
@@ -67,11 +67,6 @@ class ObjCDataFormatterTestCase(TestBase
         """Test formatters for NSException."""
         self.appkit_tester_impl(self.nsexception_data_formatter_commands)
 
-    @skipUnlessDarwin
-    def test_nsmisc_with_run_command(self):
-        """Test formatters for misc NS classes."""
-        self.appkit_tester_impl(self.nsmisc_data_formatter_commands)
-
 
     @skipUnlessDarwin
     def test_nsdate_with_run_command(self):
@@ -271,20 +266,6 @@ class ObjCDataFormatterTestCase(TestBase
                     '(NSException *) except2 = ','name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"',
                     '(NSException *) except3 = ','name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"'])
 
-    def nsmisc_data_formatter_commands(self):
-        self.expect('frame variable localhost',
-                    substrs = ['<NSHost ','> localhost ((','"127.0.0.1"'])
-
-        if self.getArchitecture() in ['i386', 'x86_64']:
-            self.expect('frame variable my_task',
-                        substrs = ['<NS','Task: 0x'])
-
-        self.expect('frame variable range_value',
-                    substrs = ['NSRange: {4, 4}'])
-
-        self.expect('frame variable port',
-                    substrs = ['(NSMachPort *) port = ',' mach port: '])
-
     def nsdate_data_formatter_commands(self):
         self.expect('frame variable date1 date2',
                     patterns = ['(1985-04-10|1985-04-11)','(2011-01-01|2010-12-31)'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m Fri Apr  8 16:24:24 2016
@@ -506,8 +506,6 @@ int main (int argc, const char * argv[])
 	    NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil];
 	    NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil];
 
-	    NSMachPort *port = [NSMachPort port];
-
 	    NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];
 	    NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
 	    NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
@@ -554,21 +552,12 @@ int main (int argc, const char * argv[])
 		NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"];
 		NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"];
 
-		NSHost *localhost = [NSHost hostWithAddress:@"127.0.0.1"];
-
-#ifndef IOS
-		NSTask *my_task = [[NSTask alloc] init];
-#endif
-
-
 	CFGregorianUnits cf_greg_units = {1,3,5,12,5,7};
 	CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL);
 	CFRange cf_range = {4,4};
 	NSPoint ns_point = {4,4};
 	NSRange ns_range = {4,4};
-	
-	NSValue *range_value = [NSValue valueWithRange:ns_range];
-	
+		
 	NSRect ns_rect = {{1,1},{5,5}};
 	NSRect* ns_rect_ptr = &ns_rect;
 	NSRectArray ns_rect_arr = &ns_rect;

Modified: lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormattersHelpers.cpp?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormattersHelpers.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormattersHelpers.cpp Fri Apr  8 16:24:24 2016
@@ -133,183 +133,6 @@ lldb_private::formatters::AddFilter  (Ty
 }
 #endif
 
-StackFrame*
-lldb_private::formatters::GetViableFrame (ExecutionContext exe_ctx)
-{
-    StackFrame* frame = exe_ctx.GetFramePtr();
-    if (frame)
-        return frame;
-    
-    Thread *thread = exe_ctx.GetThreadPtr();
-    if (thread)
-        return thread->GetSelectedFrame().get();
-
-    Process* process = exe_ctx.GetProcessPtr();
-    if (!process)
-        return nullptr;
-    
-    thread = process->GetThreadList().GetSelectedThread().get();
-    if (thread)
-        return thread->GetSelectedFrame().get();
-    
-    return nullptr;
-}
-
-bool
-lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
-                                                          const char* target_type,
-                                                          const char* selector,
-                                                          uint64_t &value)
-{
-    if (!target_type || !*target_type)
-        return false;
-    if (!selector || !*selector)
-        return false;
-    StreamString expr;
-    expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
-    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-    lldb::ValueObjectSP result_sp;
-    Target* target = exe_ctx.GetTargetPtr();
-    StackFrame* stack_frame = GetViableFrame(exe_ctx);
-    if (!target || !stack_frame)
-        return false;
-    
-    EvaluateExpressionOptions options;
-    options.SetCoerceToId(false);
-    options.SetUnwindOnError(true);
-    options.SetKeepInMemory(true);
-    options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
-    options.SetResultIsInternal(true);
-    options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-
-    target->EvaluateExpression(expr.GetData(),
-                               stack_frame,
-                               result_sp,
-                               options);
-    if (!result_sp)
-        return false;
-    value = result_sp->GetValueAsUnsigned(0);
-    return true;
-}
-
-bool
-lldb_private::formatters::ExtractSummaryFromObjCExpression (ValueObject &valobj,
-                                                            const char* target_type,
-                                                            const char* selector,
-                                                            Stream &stream,
-                                                            lldb::LanguageType lang_type)
-{
-    if (!target_type || !*target_type)
-        return false;
-    if (!selector || !*selector)
-        return false;
-    StreamString expr;
-    expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
-    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-    lldb::ValueObjectSP result_sp;
-    Target* target = exe_ctx.GetTargetPtr();
-    StackFrame* stack_frame = GetViableFrame(exe_ctx);
-    if (!target || !stack_frame)
-        return false;
-    
-    EvaluateExpressionOptions options;
-    options.SetCoerceToId(false);
-    options.SetUnwindOnError(true);
-    options.SetKeepInMemory(true);
-    options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
-    options.SetResultIsInternal(true);
-    options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-    
-    target->EvaluateExpression(expr.GetData(),
-                               stack_frame,
-                               result_sp,
-                               options);
-    if (!result_sp)
-        return false;
-    stream.Printf("%s",result_sp->GetSummaryAsCString(lang_type));
-    return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
-                                                const char* return_type,
-                                                const char* selector,
-                                                uint64_t index)
-{
-    lldb::ValueObjectSP valobj_sp;
-    if (!return_type || !*return_type)
-        return valobj_sp;
-    if (!selector || !*selector)
-        return valobj_sp;
-    StreamString expr;
-    const char *colon = "";
-    llvm::StringRef selector_sr(selector);
-    if (selector_sr.back() != ':')
-        colon = ":";
-    expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%" PRId64 "]",return_type,valobj.GetPointerValue(),selector,colon,index);
-    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-    lldb::ValueObjectSP result_sp;
-    Target* target = exe_ctx.GetTargetPtr();
-    StackFrame* stack_frame = GetViableFrame(exe_ctx);
-    if (!target || !stack_frame)
-        return valobj_sp;
-    
-    EvaluateExpressionOptions options;
-    options.SetCoerceToId(false);
-    options.SetUnwindOnError(true);
-    options.SetKeepInMemory(true);
-    options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
-    options.SetResultIsInternal(true);
-    options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-    
-    target->EvaluateExpression(expr.GetData(),
-                               stack_frame,
-                               valobj_sp,
-                               options);
-    return valobj_sp;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
-                                                const char* return_type,
-                                                const char* selector,
-                                                const char* key)
-{
-    lldb::ValueObjectSP valobj_sp;
-    if (!return_type || !*return_type)
-        return valobj_sp;
-    if (!selector || !*selector)
-        return valobj_sp;
-    if (!key || !*key)
-        return valobj_sp;
-    StreamString expr;
-    const char *colon = "";
-    llvm::StringRef selector_sr(selector);
-    if (selector_sr.back() != ':')
-        colon = ":";
-    expr.Printf("(%s)[(id)0x%" PRIx64 " %s%s%s]",return_type,valobj.GetPointerValue(),selector,colon,key);
-    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-    lldb::ValueObjectSP result_sp;
-    Target* target = exe_ctx.GetTargetPtr();
-    StackFrame* stack_frame = GetViableFrame(exe_ctx);
-    if (!target || !stack_frame)
-        return valobj_sp;
-    
-    EvaluateExpressionOptions options;
-    options.SetCoerceToId(false);
-    options.SetUnwindOnError(true);
-    options.SetKeepInMemory(true);
-    options.SetLanguage(lldb::eLanguageTypeObjC_plus_plus);
-    options.SetResultIsInternal(true);
-    options.SetUseDynamic(lldb::eDynamicCanRunTarget);
-    
-    target->EvaluateExpression(expr.GetData(),
-                               stack_frame,
-                               valobj_sp,
-                               options);
-    return valobj_sp;
-}
-
 size_t
 lldb_private::formatters::ExtractIndexFromString (const char* item_name)
 {

Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Fri Apr  8 16:24:24 2016
@@ -944,18 +944,6 @@ lldb_private::formatters::GetOSXEpoch ()
     return epoch;
 }
 
-bool
-lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
-    if (const char* description = valobj.GetObjectDescription())
-    {
-        stream.Printf("%s", description);
-        return true;
-    }
-    else
-        return false;
-}
-
 template bool
 lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&);
 

Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h Fri Apr  8 16:24:24 2016
@@ -78,9 +78,6 @@ namespace lldb_private {
         ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&);
         
         bool
-        RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-        
-        bool
         NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
         
         bool

Modified: lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp?rev=265849&r1=265848&r2=265849&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp Fri Apr  8 16:24:24 2016
@@ -566,11 +566,6 @@ LoadObjCFormatters(TypeCategoryImplSP ob
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
     
-    AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSDecimalNumber summary provider", ConstString("NSDecimalNumber"), appkit_flags);
-    AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSHost summary provider", ConstString("NSHost"), appkit_flags);
-    AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
-    AddCXXSummary(objc_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
-    
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("NSURL"), appkit_flags);
     AddCXXSummary(objc_category_sp, lldb_private::formatters::NSURLSummaryProvider, "NSURL summary provider", ConstString("CFURLRef"), appkit_flags);
     




More information about the lldb-commits mailing list