Author: dperchik Date: Thu Oct 22 19:02:56 2015 New Revision: 251080 URL: http://llvm.org/viewvc/llvm-project?rev=251080&view=rev Log: Summary provider for char.
This patch enables type summary for 'char' type. Given: char c = 'h'; Before this patch, c evaluates as: (char) $0 = 'h' After this patch, we get: (char) $0 = 104 'h' This change allows the formatting of character types in MI to be removed and replaced with that in lldb, and can be useful when evaluating non-printable characters. Patch from evgeny.levi...@gmail.com Reviewed by: granata.enrico Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13657 Modified: lldb/trunk/include/lldb/API/SBTypeSummary.h lldb/trunk/source/API/SBTypeSummary.cpp Modified: lldb/trunk/include/lldb/API/SBTypeSummary.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTypeSummary.h?rev=251080&r1=251079&r2=251080&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTypeSummary.h (original) +++ lldb/trunk/include/lldb/API/SBTypeSummary.h Thu Oct 22 19:02:56 2015 @@ -69,6 +69,9 @@ namespace lldb { public: SBTypeSummary(); + + // Native function summary formatter callback + typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&); static SBTypeSummary CreateWithSummaryString (const char* data, @@ -81,6 +84,10 @@ namespace lldb { 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); Modified: lldb/trunk/source/API/SBTypeSummary.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSummary.cpp?rev=251080&r1=251079&r2=251080&view=diff ============================================================================== --- lldb/trunk/source/API/SBTypeSummary.cpp (original) +++ lldb/trunk/source/API/SBTypeSummary.cpp Thu Oct 22 19:02:56 2015 @@ -146,6 +146,25 @@ SBTypeSummary::CreateWithScriptCode (con 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 { + BStream 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) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits