summaryrefslogtreecommitdiffstats
path: root/lldb/source/DataFormatters
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/DataFormatters')
-rw-r--r--lldb/source/DataFormatters/CMakeLists.txt1
-rw-r--r--lldb/source/DataFormatters/DumpValueObjectOptions.cpp236
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp27
3 files changed, 253 insertions, 11 deletions
diff --git a/lldb/source/DataFormatters/CMakeLists.txt b/lldb/source/DataFormatters/CMakeLists.txt
index 51539a7d265..bfb5c8b9f68 100644
--- a/lldb/source/DataFormatters/CMakeLists.txt
+++ b/lldb/source/DataFormatters/CMakeLists.txt
@@ -1,6 +1,7 @@
add_lldb_library(lldbDataFormatters
CXXFunctionPointer.cpp
DataVisualization.cpp
+ DumpValueObjectOptions.cpp
FormatCache.cpp
FormatClasses.cpp
FormatManager.cpp
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
new file mode 100644
index 00000000000..d22783422ea
--- /dev/null
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -0,0 +1,236 @@
+//===-- DumpValueObjectOptions.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ValueObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+DumpValueObjectOptions::DumpValueObjectOptions() :
+ m_summary_sp(),
+ m_root_valobj_name(),
+ m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default,0}),
+ m_decl_printing_helper(),
+ m_use_synthetic(true),
+ m_scope_already_checked(false),
+ m_flat_output(false),
+ m_ignore_cap(false),
+ m_show_types(false),
+ m_show_location(false),
+ m_use_objc(false),
+ m_hide_root_type(false),
+ m_hide_name(false),
+ m_hide_value(false),
+ m_run_validator(false),
+ m_use_type_display_name(true),
+ m_allow_oneliner_mode(true),
+ m_hide_pointer_value(false)
+{}
+
+
+DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
+ DumpValueObjectOptions()
+{
+ m_use_dynamic = valobj.GetDynamicValueType();
+ m_use_synthetic = valobj.IsSynthetic();
+ m_varformat_language = valobj.GetPreferredDisplayLanguage();
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth)
+{
+ m_max_ptr_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetMaximumDepth(uint32_t depth)
+{
+ m_max_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetDeclPrintingHelper(DeclPrintingHelper helper)
+{
+ m_decl_printing_helper = helper;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowTypes(bool show)
+{
+ m_show_types = show;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowLocation(bool show)
+{
+ m_show_location = show;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseObjectiveC(bool use)
+{
+ m_use_objc = use;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetShowSummary(bool show)
+{
+ if (show == false)
+ SetOmitSummaryDepth(UINT32_MAX);
+ else
+ SetOmitSummaryDepth(0);
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseDynamicType(lldb::DynamicValueType dyn)
+{
+ m_use_dynamic = dyn;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseSyntheticValue(bool use_synthetic)
+{
+ m_use_synthetic = use_synthetic;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetScopeChecked(bool check)
+{
+ m_scope_already_checked = check;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetFlatOutput(bool flat)
+{
+ m_flat_output = flat;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetOmitSummaryDepth(uint32_t depth)
+{
+ m_omit_summary_depth = depth;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetIgnoreCap(bool ignore)
+{
+ m_ignore_cap = ignore;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRawDisplay()
+{
+ SetUseSyntheticValue(false);
+ SetOmitSummaryDepth(UINT32_MAX);
+ SetIgnoreCap(true);
+ SetHideName(false);
+ SetHideValue(false);
+ SetUseTypeDisplayName(false);
+ SetAllowOnelinerMode(false);
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetFormat (lldb::Format format)
+{
+ m_format = format;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetSummary (lldb::TypeSummaryImplSP summary)
+{
+ m_summary_sp = summary;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRootValueObjectName (const char* name)
+{
+ if (name)
+ m_root_valobj_name.assign(name);
+ else
+ m_root_valobj_name.clear();
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideRootType (bool hide_root_type)
+{
+ m_hide_root_type = hide_root_type;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideName (bool hide_name)
+{
+ m_hide_name = hide_name;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHideValue (bool hide_value)
+{
+ m_hide_value = hide_value;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetHidePointerValue (bool hide)
+{
+ m_hide_pointer_value = hide;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetVariableFormatDisplayLanguage (lldb::LanguageType lang)
+{
+ m_varformat_language = lang;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetRunValidator (bool run)
+{
+ m_run_validator = run;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetUseTypeDisplayName (bool dis)
+{
+ m_use_type_display_name = dis;
+ return *this;
+}
+
+DumpValueObjectOptions&
+DumpValueObjectOptions::SetAllowOnelinerMode (bool oneliner)
+{
+ m_allow_oneliner_mode = oneliner;
+ return *this;
+}
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