[Lldb-commits] [lldb] r265181 - Remove more of the code-running ObjC data formatter support
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 1 13:33:23 PDT 2016
Author: enrico
Date: Fri Apr 1 15:33:22 2016
New Revision: 265181
URL: http://llvm.org/viewvc/llvm-project?rev=265181&view=rev
Log:
Remove more of the code-running ObjC data formatter support
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp
lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
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=265181&r1=265180&r2=265181&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 1 15:33:22 2016
@@ -192,7 +192,7 @@ class ObjCDataFormatterTestCase(TestBase
def nsnumber_data_formatter_commands(self):
# Now enable AppKit and check we are displaying Cocoa classes correctly
- self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num8_Y num8_N num9',
+ self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num9',
substrs = ['(NSNumber *) num1 = ',' (int)5',
'(NSNumber *) num2 = ',' (float)3.1',
'(NSNumber *) num3 = ',' (double)3.14',
@@ -200,13 +200,8 @@ class ObjCDataFormatterTestCase(TestBase
'(NSNumber *) num5 = ',' (char)65',
'(NSNumber *) num6 = ',' (long)255',
'(NSNumber *) num7 = ','2000000',
- '(NSNumber *) num8_Y = ',' @"1"',
- '(NSNumber *) num8_N = ',' @"0"',
'(NSNumber *) num9 = ',' (short)-31616'])
- self.expect('frame variable decimal_one',
- substrs = ['(NSDecimalNumber *) decimal_one = 0x','1'])
-
self.expect('frame variable num_at1 num_at2 num_at3 num_at4',
substrs = ['(NSNumber *) num_at1 = ',' (int)12',
'(NSNumber *) num_at2 = ',' (int)-12',
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=265181&r1=265180&r2=265181&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Fri Apr 1 15:33:22 2016
@@ -78,9 +78,8 @@ lldb_private::formatters::NSBundleSummar
return true;
}
}
- // this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
- // which is encoded differently and needs to be handled by running code
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "bundlePath", stream, options.GetLanguage());
+
+ return false;
}
bool
@@ -124,7 +123,8 @@ lldb_private::formatters::NSTimeZoneSumm
return true;
}
}
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream, options.GetLanguage());
+
+ return false;
}
bool
@@ -168,9 +168,8 @@ lldb_private::formatters::NSNotification
return true;
}
}
- // this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
- // which is encoded differently and needs to be handled by running code
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream, options.GetLanguage());
+
+ return false;
}
bool
@@ -204,22 +203,19 @@ lldb_private::formatters::NSMachPortSumm
uint64_t port_number = 0;
- do
+ if (!strcmp(class_name,"NSMachPort"))
{
- if (!strcmp(class_name,"NSMachPort"))
+ uint64_t offset = (ptr_size == 4 ? 12 : 20);
+ Error error;
+ port_number = process_sp->ReadUnsignedIntegerFromMemory(offset+valobj_addr, 4, 0, error);
+ if (error.Success())
{
- uint64_t offset = (ptr_size == 4 ? 12 : 20);
- Error error;
- port_number = process_sp->ReadUnsignedIntegerFromMemory(offset+valobj_addr, 4, 0, error);
- if (error.Success())
- break;
+ stream.Printf("mach port: %u",(uint32_t)(port_number & 0x00000000FFFFFFFF));
+ return true;
}
- if (!ExtractValueFromObjCExpression(valobj, "int", "machPort", port_number))
- return false;
- } while (false);
+ }
- stream.Printf("mach port: %u",(uint32_t)(port_number & 0x00000000FFFFFFFF));
- return true;
+ return false;
}
bool
@@ -289,10 +285,7 @@ lldb_private::formatters::NSIndexSetSumm
}
}
else
- {
- if (!ExtractValueFromObjCExpression(valobj, "unsigned long long int", "count", count))
- return false;
- }
+ return false;
} while (false);
stream.Printf("%" PRIu64 " index%s",
count,
@@ -562,10 +555,8 @@ lldb_private::formatters::NSNumberSummar
return true;
}
}
- else
- {
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "stringValue", stream, options.GetLanguage());
- }
+
+ return false;
}
bool
@@ -626,10 +617,7 @@ lldb_private::formatters::NSURLSummaryPr
return true;
}
}
- else
- {
- return ExtractSummaryFromObjCExpression(valobj, "NSString*", "description", stream, options.GetLanguage());
- }
+
return false;
}
@@ -660,14 +648,19 @@ lldb_private::formatters::NSDateSummaryP
uint64_t date_value_bits = 0;
double date_value = 0.0;
- const char* class_name = descriptor->GetClassName().GetCString();
+ ConstString class_name = descriptor->GetClassName();
- if (!class_name || !*class_name)
+ static const ConstString g_NSDate("NSDate");
+ static const ConstString g___NSDate("__NSDate");
+ static const ConstString g___NSTaggedDate("__NSTaggedDate");
+ static const ConstString g_NSCalendarDate("NSCalendarDate");
+
+ if (class_name.IsEmpty())
return false;
- if (strcmp(class_name,"NSDate") == 0 ||
- strcmp(class_name,"__NSDate") == 0 ||
- strcmp(class_name,"__NSTaggedDate") == 0)
+ if ((class_name == g_NSDate) ||
+ (class_name == g___NSDate) ||
+ (class_name == g___NSTaggedDate))
{
uint64_t info_bits=0,value_bits = 0;
if (descriptor->GetTaggedPointerInfo(&info_bits,&value_bits))
@@ -684,7 +677,7 @@ lldb_private::formatters::NSDateSummaryP
return false;
}
}
- else if (!strcmp(class_name,"NSCalendarDate"))
+ else if (class_name == g_NSCalendarDate)
{
Error error;
date_value_bits = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+2*ptr_size, 8, 0, error);
@@ -693,11 +686,8 @@ lldb_private::formatters::NSDateSummaryP
return false;
}
else
- {
- if (!ExtractValueFromObjCExpression(valobj, "NSTimeInterval", "ExtractValueFromObjCExpression", date_value_bits))
- return false;
- date_value = *((double*)&date_value_bits);
- }
+ return false;
+
if (date_value == -63114076800)
{
stream.Printf("0001-12-30 00:00:00 +0000");
@@ -835,11 +825,16 @@ lldb_private::formatters::NSDataSummaryP
if (error.Fail())
return false;
}
- else
+ else if (!strcmp(class_name, "_NSInlineData"))
{
- if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
+ uint32_t offset = (is_64bit ? 8 : 4);
+ Error error;
+ value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, 2, 0, error);
+ if (error.Fail())
return false;
}
+ else
+ return false;
stream.Printf("%s%" PRIu64 " byte%s%s",
(needs_at ? "@\"" : ""),
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp?rev=265181&r1=265180&r2=265181&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSSet.cpp Fri Apr 1 15:33:22 2016
@@ -94,33 +94,6 @@ namespace lldb_private {
std::vector<SetItemDescriptor> m_children;
};
- class NSOrderedSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~NSOrderedSetSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- uint32_t m_count;
- std::map<uint32_t,lldb::ValueObjectSP> m_children;
- };
-
class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
@@ -339,10 +312,6 @@ SyntheticChildrenFrontEnd* lldb_private:
{
return (new NSSetMSyntheticFrontEnd(valobj_sp));
}
- else if ((!strcmp(class_name,"__NSOrderedSetI")) || (!strcmp(class_name,"__NSOrderedSetM")))
- {
- return new NSOrderedSetSyntheticFrontEnd(valobj_sp); // this runs code
- }
else
{
auto& map(NSSet_Additionals::GetAdditionalSynthetics());
@@ -688,70 +657,6 @@ lldb_private::formatters::NSSetMSyntheti
return set_item.valobj_sp;
}
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_count(UINT32_MAX),
- m_children()
-{
-}
-
-size_t
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (m_count != UINT32_MAX)
- return m_count;
- uint64_t count_temp;
- if (ExtractValueFromObjCExpression(m_backend,"unsigned int","count",count_temp))
- return (m_count = count_temp);
- return (m_count = 0);
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- auto iter = m_children.find(idx);
- if (iter == m_children.end())
- {
- lldb::ValueObjectSP retval_sp;
- if (idx <= m_count)
- {
- retval_sp = CallSelectorOnObject(m_backend, "id", "objectAtIndex", idx);
- if (retval_sp)
- {
- StreamString idx_name;
- idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- retval_sp->SetName(ConstString(idx_name.GetData()));
- }
- m_children[idx] = retval_sp;
- }
- return retval_sp;
- }
- else
- return iter->second;
-}
-
-bool
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::Update()
-{
- return false;
-}
-
-bool
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
template bool
lldb_private::formatters::NSSetSummaryProvider<true> (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
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=265181&r1=265180&r2=265181&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp Fri Apr 1 15:33:22 2016
@@ -546,6 +546,7 @@ LoadObjCFormatters(TypeCategoryImplSP ob
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSBundleSummaryProvider, "NSBundle summary provider", ConstString("NSBundle"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSData"), appkit_flags);
+ AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("_NSInlineData"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteMutableData"), appkit_flags);
AddCXXSummary(objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSMutableData"), appkit_flags);
More information about the lldb-commits
mailing list