Let Language plugins vend a default DeclPrintingHelper in case a custom one is not specified for the specific invocation

llvm-svn: 250744
This commit is contained in:
Enrico Granata 2015-10-19 22:04:25 +00:00
parent 69a50a1e17
commit c8e7649a19
8 changed files with 455 additions and 298 deletions

View File

@ -0,0 +1,181 @@
//===-- DumpValueObjectOptions.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_DumpValueObjectOptions_h_
#define lldb_DumpValueObjectOptions_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
#include <functional>
#include <string>
namespace lldb_private {
class DumpValueObjectOptions
{
public:
struct PointerDepth
{
enum class Mode
{
Always,
Formatters,
Default,
Never
} m_mode;
uint32_t m_count;
PointerDepth
operator --() const
{
if (m_count > 0)
return PointerDepth {m_mode,m_count-1};
return PointerDepth {m_mode,m_count};
}
bool
CanAllowExpansion () const;
bool
CanAllowExpansion (bool is_root,
TypeSummaryImpl* entry,
ValueObject *valobj,
const std::string& summary);
};
typedef std::function<bool(ConstString,
ConstString,
const DumpValueObjectOptions &,
Stream&)> DeclPrintingHelper;
public:
static const DumpValueObjectOptions
DefaultOptions()
{
static DumpValueObjectOptions g_default_options;
return g_default_options;
}
DumpValueObjectOptions();
DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
DumpValueObjectOptions (ValueObject& valobj);
DumpValueObjectOptions&
SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0});
DumpValueObjectOptions&
SetMaximumDepth(uint32_t depth = 0);
DumpValueObjectOptions&
SetDeclPrintingHelper(DeclPrintingHelper helper);
DumpValueObjectOptions&
SetShowTypes(bool show = false);
DumpValueObjectOptions&
SetShowLocation(bool show = false);
DumpValueObjectOptions&
SetUseObjectiveC(bool use = false);
DumpValueObjectOptions&
SetShowSummary(bool show = true);
DumpValueObjectOptions&
SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
DumpValueObjectOptions&
SetUseSyntheticValue(bool use_synthetic = true);
DumpValueObjectOptions&
SetScopeChecked(bool check = true);
DumpValueObjectOptions&
SetFlatOutput(bool flat = false);
DumpValueObjectOptions&
SetOmitSummaryDepth(uint32_t depth = 0);
DumpValueObjectOptions&
SetIgnoreCap(bool ignore = false);
DumpValueObjectOptions&
SetRawDisplay();
DumpValueObjectOptions&
SetFormat (lldb::Format format = lldb::eFormatDefault);
DumpValueObjectOptions&
SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
DumpValueObjectOptions&
SetRootValueObjectName (const char* name = NULL);
DumpValueObjectOptions&
SetHideRootType (bool hide_root_type = false);
DumpValueObjectOptions&
SetHideName (bool hide_name = false);
DumpValueObjectOptions&
SetHideValue (bool hide_value = false);
DumpValueObjectOptions&
SetHidePointerValue (bool hide = false);
DumpValueObjectOptions&
SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
DumpValueObjectOptions&
SetRunValidator (bool run = true);
DumpValueObjectOptions&
SetUseTypeDisplayName (bool dis = false);
DumpValueObjectOptions&
SetAllowOnelinerMode (bool oneliner = false);
public:
uint32_t m_max_depth = UINT32_MAX;
lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
uint32_t m_omit_summary_depth = 0;
lldb::Format m_format = lldb::eFormatDefault;
lldb::TypeSummaryImplSP m_summary_sp;
std::string m_root_valobj_name;
lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
PointerDepth m_max_ptr_depth;
DeclPrintingHelper m_decl_printing_helper;
bool m_use_synthetic : 1;
bool m_scope_already_checked : 1;
bool m_flat_output : 1;
bool m_ignore_cap : 1;
bool m_show_types : 1;
bool m_show_location : 1;
bool m_use_objc : 1;
bool m_hide_root_type : 1;
bool m_hide_name : 1;
bool m_hide_value : 1;
bool m_run_validator : 1;
bool m_use_type_display_name : 1;
bool m_allow_oneliner_mode : 1;
bool m_hide_pointer_value : 1;
};
} // namespace lldb_private
#endif // lldb_DumpValueObjectOptions_h_

View File

@ -18,296 +18,12 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include <functional>
#include "lldb/Core/Flags.h"
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/Symbol/CompilerType.h"
namespace lldb_private {
struct DumpValueObjectOptions
{
struct PointerDepth
{
enum class Mode
{
Always,
Formatters,
Default,
Never
} m_mode;
uint32_t m_count;
PointerDepth
operator --() const
{
if (m_count > 0)
return PointerDepth {m_mode,m_count-1};
return PointerDepth {m_mode,m_count};
}
bool
CanAllowExpansion () const;
bool
CanAllowExpansion (bool is_root,
TypeSummaryImpl* entry,
ValueObject *valobj,
const std::string& summary);
};
typedef std::function<bool(ConstString,
ConstString,
const DumpValueObjectOptions &,
Stream&)> DeclPrintingHelper;
uint32_t m_max_depth = UINT32_MAX;
lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
uint32_t m_omit_summary_depth = 0;
lldb::Format m_format = lldb::eFormatDefault;
lldb::TypeSummaryImplSP m_summary_sp;
std::string m_root_valobj_name;
lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
PointerDepth m_max_ptr_depth;
DeclPrintingHelper m_decl_printing_helper;
bool m_use_synthetic : 1;
bool m_scope_already_checked : 1;
bool m_flat_output : 1;
bool m_ignore_cap : 1;
bool m_show_types : 1;
bool m_show_location : 1;
bool m_use_objc : 1;
bool m_hide_root_type : 1;
bool m_hide_name : 1;
bool m_hide_value : 1;
bool m_run_validator : 1;
bool m_use_type_display_name : 1;
bool m_allow_oneliner_mode : 1;
bool m_hide_pointer_value : 1;
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)
{}
static const DumpValueObjectOptions
DefaultOptions()
{
static DumpValueObjectOptions g_default_options;
return g_default_options;
}
DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
DumpValueObjectOptions (ValueObject& valobj);
DumpValueObjectOptions&
SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0})
{
m_max_ptr_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetMaximumDepth(uint32_t depth = 0)
{
m_max_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetDeclPrintingHelper(DeclPrintingHelper helper)
{
m_decl_printing_helper = helper;
return *this;
}
DumpValueObjectOptions&
SetShowTypes(bool show = false)
{
m_show_types = show;
return *this;
}
DumpValueObjectOptions&
SetShowLocation(bool show = false)
{
m_show_location = show;
return *this;
}
DumpValueObjectOptions&
SetUseObjectiveC(bool use = false)
{
m_use_objc = use;
return *this;
}
DumpValueObjectOptions&
SetShowSummary(bool show = true)
{
if (show == false)
SetOmitSummaryDepth(UINT32_MAX);
else
SetOmitSummaryDepth(0);
return *this;
}
DumpValueObjectOptions&
SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
{
m_use_dynamic = dyn;
return *this;
}
DumpValueObjectOptions&
SetUseSyntheticValue(bool use_synthetic = true)
{
m_use_synthetic = use_synthetic;
return *this;
}
DumpValueObjectOptions&
SetScopeChecked(bool check = true)
{
m_scope_already_checked = check;
return *this;
}
DumpValueObjectOptions&
SetFlatOutput(bool flat = false)
{
m_flat_output = flat;
return *this;
}
DumpValueObjectOptions&
SetOmitSummaryDepth(uint32_t depth = 0)
{
m_omit_summary_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetIgnoreCap(bool ignore = false)
{
m_ignore_cap = ignore;
return *this;
}
DumpValueObjectOptions&
SetRawDisplay()
{
SetUseSyntheticValue(false);
SetOmitSummaryDepth(UINT32_MAX);
SetIgnoreCap(true);
SetHideName(false);
SetHideValue(false);
SetUseTypeDisplayName(false);
SetAllowOnelinerMode(false);
return *this;
}
DumpValueObjectOptions&
SetFormat (lldb::Format format = lldb::eFormatDefault)
{
m_format = format;
return *this;
}
DumpValueObjectOptions&
SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP())
{
m_summary_sp = summary;
return *this;
}
DumpValueObjectOptions&
SetRootValueObjectName (const char* name = NULL)
{
if (name)
m_root_valobj_name.assign(name);
else
m_root_valobj_name.clear();
return *this;
}
DumpValueObjectOptions&
SetHideRootType (bool hide_root_type = false)
{
m_hide_root_type = hide_root_type;
return *this;
}
DumpValueObjectOptions&
SetHideName (bool hide_name = false)
{
m_hide_name = hide_name;
return *this;
}
DumpValueObjectOptions&
SetHideValue (bool hide_value = false)
{
m_hide_value = hide_value;
return *this;
}
DumpValueObjectOptions&
SetHidePointerValue (bool hide = false)
{
m_hide_pointer_value = hide;
return *this;
}
DumpValueObjectOptions&
SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown)
{
m_varformat_language = lang;
return *this;
}
DumpValueObjectOptions&
SetRunValidator (bool run = true)
{
m_run_validator = run;
return *this;
}
DumpValueObjectOptions&
SetUseTypeDisplayName (bool dis = false)
{
m_use_type_display_name = dis;
return *this;
}
DumpValueObjectOptions&
SetAllowOnelinerMode (bool oneliner = false)
{
m_allow_oneliner_mode = oneliner;
return *this;
}
};
class ValueObjectPrinter
{
public:

View File

@ -22,6 +22,7 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/StringPrinter.h"
@ -113,6 +114,11 @@ public:
GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
std::string& prefix, std::string& suffix);
// if a language has a custom format for printing variable declarations that it wants LLDB to honor
// it should return an appropriate closure here
virtual DumpValueObjectOptions::DeclPrintingHelper
GetDeclPrintingHelper ();
// These are accessors for general information about the Languages lldb knows about:
static lldb::LanguageType

View File

@ -747,6 +747,7 @@
944372DC171F6B4300E57C32 /* RegisterContextDummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 944372DA171F6B4300E57C32 /* RegisterContextDummy.cpp */; };
9443B122140C18C40013457C /* SBData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9443B121140C18C10013457C /* SBData.cpp */; };
9443B123140C26AB0013457C /* SBData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443B120140C18A90013457C /* SBData.h */; settings = {ATTRIBUTES = (Public, ); }; };
9447DE431BD5963300E67212 /* DumpValueObjectOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9447DE421BD5963300E67212 /* DumpValueObjectOptions.cpp */; };
945215DF17F639EE00521C0B /* ValueObjectPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945215DE17F639EE00521C0B /* ValueObjectPrinter.cpp */; };
9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
945261BF1B9A11FC00BF138D /* CxxStringTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B31B9A11E800BF138D /* CxxStringTypes.cpp */; };
@ -2461,6 +2462,8 @@
944372DB171F6B4300E57C32 /* RegisterContextDummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDummy.h; path = Utility/RegisterContextDummy.h; sourceTree = "<group>"; };
9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = "<group>"; };
9447DE411BD5962900E67212 /* DumpValueObjectOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DumpValueObjectOptions.h; path = include/lldb/DataFormatters/DumpValueObjectOptions.h; sourceTree = "<group>"; };
9447DE421BD5963300E67212 /* DumpValueObjectOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DumpValueObjectOptions.cpp; path = source/DataFormatters/DumpValueObjectOptions.cpp; sourceTree = "<group>"; };
9449B8031B30E0690019342B /* ThreadSafeDenseSet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSafeDenseSet.h; path = include/lldb/Core/ThreadSafeDenseSet.h; sourceTree = "<group>"; };
944DC3481774C99000D7D884 /* python-swigsafecast.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-swigsafecast.swig"; sourceTree = "<group>"; };
945215DD17F639E600521C0B /* ValueObjectPrinter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectPrinter.h; path = include/lldb/DataFormatters/ValueObjectPrinter.h; sourceTree = "<group>"; };
@ -5431,6 +5434,8 @@
945261C71B9A14D300BF138D /* CXXFunctionPointer.cpp */,
94CB256016B069800059775D /* DataVisualization.h */,
94CB255816B069770059775D /* DataVisualization.cpp */,
9447DE411BD5962900E67212 /* DumpValueObjectOptions.h */,
9447DE421BD5963300E67212 /* DumpValueObjectOptions.cpp */,
94CB257516B1D3910059775D /* FormatCache.h */,
94CB257316B1D3870059775D /* FormatCache.cpp */,
94CB256116B069800059775D /* FormatClasses.h */,
@ -6415,6 +6420,7 @@
2689008013353E2200698AC0 /* CommandInterpreter.cpp in Sources */,
AF77E0A41A033D360096C0EA /* RegisterContextPOSIX_powerpc.cpp in Sources */,
AF9B8F33182DB52900DA866F /* SystemRuntimeMacOSX.cpp in Sources */,
9447DE431BD5963300E67212 /* DumpValueObjectOptions.cpp in Sources */,
2689008113353E2200698AC0 /* CommandObject.cpp in Sources */,
3F8160A61AB9F7DD001DA9DF /* Logging.cpp in Sources */,
26BF51F61B3C754400016294 /* ABISysV_i386.cpp in Sources */,

View File

@ -1,6 +1,7 @@
add_lldb_library(lldbDataFormatters
CXXFunctionPointer.cpp
DataVisualization.cpp
DumpValueObjectOptions.cpp
FormatCache.cpp
FormatClasses.cpp
FormatManager.cpp

View File

@ -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;
}

View File

@ -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)

View File

@ -334,6 +334,12 @@ Language::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
return false;
}
DumpValueObjectOptions::DeclPrintingHelper
Language::GetDeclPrintingHelper ()
{
return nullptr;
}
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------