diff options
author | Enrico Granata <egranata@apple.com> | 2015-10-07 18:36:53 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-10-07 18:36:53 +0000 |
commit | 675f49bbd58ef78c947ac0ba32835051ff33f4e5 (patch) | |
tree | 00baf04dc2cd932e2cf4e227fa51f78f4c444f23 /lldb/source/Plugins/Language/ObjC/CF.cpp | |
parent | 75230398c233828a07806c4ffd627df3b239b73d (diff) | |
download | bcm5719-llvm-675f49bbd58ef78c947ac0ba32835051ff33f4e5.tar.gz bcm5719-llvm-675f49bbd58ef78c947ac0ba32835051ff33f4e5.zip |
This is the work I was building up to with my patches yesterday
Introduce the notion of Language-based formatter prefix/suffix
This is meant for languages that share certain data types but present them in syntatically different ways, such that LLDB can now have language-based awareness of which of the syntax variations it has to present to the user when formatting those values
This is goodness for new languages and interoperability, but is NFC for existing languages. As such, existing tests cover this
llvm-svn: 249587
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC/CF.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/ObjC/CF.cpp | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp index fb1b87154a8..0dc0c662fe9 100644 --- a/lldb/source/Plugins/Language/ObjC/CF.cpp +++ b/lldb/source/Plugins/Language/ObjC/CF.cpp @@ -17,6 +17,7 @@ #include "lldb/DataFormatters/FormattersHelpers.h" #include "lldb/Host/Endian.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Target.h" @@ -42,6 +43,8 @@ lldb_private::formatters::CFAbsoluteTimeSummaryProvider (ValueObject& valobj, St bool lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { + static ConstString g_TypeHint("CFBag"); + ProcessSP process_sp = valobj.GetProcessSP(); if (!process_sp) return false; @@ -84,7 +87,9 @@ lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& str ValueObjectSP count_sp; StreamString expr; expr.Printf("(int)CFBagGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue()); - if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExpressionCompleted) + EvaluateExpressionOptions options; + options.SetResultIsInternal(true); + if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp, options) != eExpressionCompleted) return false; if (!count_sp) return false; @@ -98,8 +103,21 @@ lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& str if (error.Fail()) return false; } - stream.Printf("@\"%u value%s\"", - count,(count == 1 ? "" : "s")); + + std::string prefix,suffix; + if (Language* language = Language::FindPlugin(options.GetLanguage())) + { + if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix)) + { + prefix.clear(); + suffix.clear(); + } + } + + stream.Printf("%s\"%u value%s\"%s", + prefix.c_str(), + count,(count == 1 ? "" : "s"), + suffix.c_str()); return true; } @@ -236,6 +254,8 @@ lldb_private::formatters::CFBitVectorSummaryProvider (ValueObject& valobj, Strea bool lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) { + static ConstString g_TypeHint("CFBinaryHeap"); + ProcessSP process_sp = valobj.GetProcessSP(); if (!process_sp) return false; @@ -278,7 +298,9 @@ lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stre ValueObjectSP count_sp; StreamString expr; expr.Printf("(int)CFBinaryHeapGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue()); - if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExpressionCompleted) + EvaluateExpressionOptions options; + options.SetResultIsInternal(true); + if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp, options) != eExpressionCompleted) return false; if (!count_sp) return false; @@ -292,7 +314,20 @@ lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stre if (error.Fail()) return false; } - stream.Printf("@\"%u item%s\"", - count,(count == 1 ? "" : "s")); + + std::string prefix,suffix; + if (Language* language = Language::FindPlugin(options.GetLanguage())) + { + if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix)) + { + prefix.clear(); + suffix.clear(); + } + } + + stream.Printf("%s\"%u item%s\"%s", + prefix.c_str(), + count,(count == 1 ? "" : "s"), + suffix.c_str()); return true; } |