summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters/ValueObjectPrinter.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-10-19 22:04:25 +0000
committerEnrico Granata <egranata@apple.com>2015-10-19 22:04:25 +0000
commitc8e7649a1952eb67f3a97d89fef1a02126248816 (patch)
tree5e9c259ef75ef5fde4cb01d3371c2c2e7b305171 /lldb/source/DataFormatters/ValueObjectPrinter.cpp
parent69a50a1e17c9bdc077b3c377c1413b5c70eb7ac4 (diff)
downloadbcm5719-llvm-c8e7649a1952eb67f3a97d89fef1a02126248816.tar.gz
bcm5719-llvm-c8e7649a1952eb67f3a97d89fef1a02126248816.zip
Let Language plugins vend a default DeclPrintingHelper in case a custom one is not specified for the specific invocation
llvm-svn: 250744
Diffstat (limited to 'lldb/source/DataFormatters/ValueObjectPrinter.cpp')
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 17dfd8be367..fec0c5f2857 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -13,22 +13,16 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
-DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
-DumpValueObjectOptions()
-{
- m_use_dynamic = valobj.GetDynamicValueType();
- m_use_synthetic = valobj.IsSynthetic();
- m_varformat_language = valobj.GetPreferredDisplayLanguage();
-}
-
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s)
{
@@ -298,7 +292,7 @@ ValueObjectPrinter::PrintDecl ()
type_name_str.erase(iter, 2);
}
}
- typeName.Printf("(%s)", type_name_str.c_str());
+ typeName.Printf("%s", type_name_str.c_str());
}
}
@@ -320,6 +314,16 @@ ValueObjectPrinter::PrintDecl ()
}
bool decl_printed = false;
+ if (!options.m_decl_printing_helper)
+ {
+ // if the user didn't give us a custom helper, pick one based upon the language, either the one that this printer is bound to, or the preferred one for the ValueObject
+ lldb::LanguageType lang_type = (options.m_varformat_language == lldb::eLanguageTypeUnknown) ? m_valobj->GetPreferredDisplayLanguage() : options.m_varformat_language;
+ if (Language *lang_plugin = Language::FindPlugin(lang_type))
+ {
+ options.m_decl_printing_helper = lang_plugin->GetDeclPrintingHelper();
+ }
+ }
+
if (options.m_decl_printing_helper)
{
ConstString type_name_cstr(typeName.GetData());
@@ -336,10 +340,11 @@ ValueObjectPrinter::PrintDecl ()
}
}
+ // if the helper failed, or there is none, do a default thing
if (!decl_printed)
{
if (typeName.GetSize())
- m_stream->Printf("%s ", typeName.GetData());
+ m_stream->Printf("(%s) ", typeName.GetData());
if (varName.GetSize())
m_stream->Printf("%s =", varName.GetData());
else if (!options.m_hide_name)
OpenPOWER on IntegriCloud