[Lldb-commits] [PATCH] D13657: [lldb] char summary provider

Eugene Leviant via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 15 08:10:01 PDT 2015


evgeny777 updated this revision to Diff 37487.
evgeny777 added a comment.

Updated: callback is checked for null + explicit construction


http://reviews.llvm.org/D13657

Files:
  include/lldb/API/SBTypeSummary.h
  source/API/SBTypeSummary.cpp

Index: source/API/SBTypeSummary.cpp
===================================================================
--- source/API/SBTypeSummary.cpp
+++ source/API/SBTypeSummary.cpp
@@ -146,6 +146,25 @@
     return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)));
 }
 
+SBTypeSummary
+SBTypeSummary::CreateWithCallback (FormatCallback cb, uint32_t options)
+{
+    return SBTypeSummary(
+               TypeSummaryImplSP(
+                   cb ? new CXXFunctionSummaryFormat(options, 
+                       [cb] (ValueObject& valobj, Stream& stm, const TypeSummaryOptions& opt) -> bool {
+                            SBStream stream;
+                            if (!cb(SBValue(valobj.GetSP()), SBTypeSummaryOptions(&opt), stream))
+                                return false;
+                            stm.Write(stream.GetData(), stream.GetSize());
+                            return true;
+                       },
+                       "SBTypeSummary formatter callback"
+                   ) : nullptr
+                )
+            );    
+}
+
 SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) :
 m_opaque_sp(rhs.m_opaque_sp)
 {
Index: include/lldb/API/SBTypeSummary.h
===================================================================
--- include/lldb/API/SBTypeSummary.h
+++ include/lldb/API/SBTypeSummary.h
@@ -69,6 +69,8 @@
     class SBTypeSummary
     {
     public:
+        // Native function summary formatter callback
+        typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&);
         
         SBTypeSummary();
         
@@ -83,6 +85,9 @@
         static SBTypeSummary
         CreateWithScriptCode (const char* data,
                               uint32_t options = 0); // see lldb::eTypeOption values
+        static SBTypeSummary
+        CreateWithCallback (FormatCallback cb, 
+                            uint32_t options = 0);
         
         SBTypeSummary (const lldb::SBTypeSummary &rhs);
         


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13657.37487.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151015/645f9ab5/attachment-0001.bin>


More information about the lldb-commits mailing list