Remove even more of the data formatters that silently run code

Fixes <rdar://problem/25629755>

llvm-svn: 265849
This commit is contained in:
Enrico Granata
2016-04-08 21:24:24 +00:00
parent 1e8e91b379
commit f4d521836d
7 changed files with 2 additions and 257 deletions

View File

@@ -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);

View File

@@ -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)'])

View File

@@ -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;

View File

@@ -133,183 +133,6 @@ lldb_private::formatters::AddFilter (TypeCategoryImpl::SharedPointer category_s
}
#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)
{

View File

@@ -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&);

View File

@@ -77,9 +77,6 @@ namespace lldb_private {
extern template bool
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);

View File

@@ -566,11 +566,6 @@ LoadObjCFormatters(TypeCategoryImplSP objc_category_sp)
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);