Skip to content

Commit

Permalink
Summary provider for char.
Browse files Browse the repository at this point in the history
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.leviant@gmail.com
Reviewed by: granata.enrico
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D13657

llvm-svn: 251080
  • Loading branch information
Dawn Perchik committed Oct 23, 2015
1 parent 1e9aadb commit 8826519
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lldb/include/lldb/API/SBTypeSummary.h
Expand Up @@ -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,
Expand All @@ -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);

Expand Down
19 changes: 19 additions & 0 deletions lldb/source/API/SBTypeSummary.cpp
Expand Up @@ -146,6 +146,25 @@ SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options)
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)
{
Expand Down

0 comments on commit 8826519

Please sign in to comment.