[Lldb-commits] [lldb] r265979 - Add support for additional NSArray formatters
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 11 11:46:38 PDT 2016
Author: enrico
Date: Mon Apr 11 13:46:37 2016
New Revision: 265979
URL: http://llvm.org/viewvc/llvm-project?rev=265979&view=rev
Log:
Add support for additional NSArray formatters
Modified:
lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h
lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
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=265979&r1=265978&r2=265979&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.h Mon Apr 11 13:46:37 2016
@@ -13,6 +13,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
namespace lldb_private {
@@ -88,6 +89,16 @@ namespace lldb_private {
SyntheticChildrenFrontEnd*
NSExceptionSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
+
+ class NSArray_Additionals
+ {
+ public:
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+ GetAdditionalSummaries ();
+
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+ GetAdditionalSynthetics ();
+ };
} // namespace formatters
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp?rev=265979&r1=265978&r2=265979&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/NSArray.cpp Mon Apr 11 13:46:37 2016
@@ -35,6 +35,20 @@ using namespace lldb_private::formatters
namespace lldb_private {
namespace formatters {
+ std::map<ConstString, CXXFunctionSummaryFormat::Callback>&
+ NSArray_Additionals::GetAdditionalSummaries ()
+ {
+ static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
+ return g_map;
+ }
+
+ std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>&
+ NSArray_Additionals::GetAdditionalSynthetics ()
+ {
+ static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> g_map;
+ return g_map;
+ }
+
class NSArrayMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
{
public:
@@ -322,7 +336,14 @@ lldb_private::formatters::NSArraySummary
return false;
}
else
- return false;
+ {
+ auto& map(NSArray_Additionals::GetAdditionalSummaries());
+ auto iter = map.find(class_name), end = map.end();
+ if (iter != end)
+ return iter->second(valobj, stream, options);
+ else
+ return false;
+ }
std::string prefix,suffix;
if (Language* language = Language::FindPlugin(options.GetLanguage()))
@@ -746,7 +767,7 @@ lldb_private::formatters::NSArray1Synthe
return lldb::ValueObjectSP();
}
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
+SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren* synth, lldb::ValueObjectSP valobj_sp)
{
if (!valobj_sp)
return nullptr;
@@ -803,6 +824,13 @@ SyntheticChildrenFrontEnd* lldb_private:
else
return (new NSArrayMSyntheticFrontEnd_109(valobj_sp));
}
+ else
+ {
+ auto& map(NSArray_Additionals::GetAdditionalSynthetics());
+ auto iter = map.find(class_name), end = map.end();
+ if (iter != end)
+ return iter->second(synth, valobj_sp);
+ }
return nullptr;
}
More information about the lldb-commits
mailing list