Author: walter erquinigo Date: 2023-08-30T14:14:28-04:00 New Revision: 79d5d9a0824ddcd5493a451e5009dd6393646e51
URL: https://github.com/llvm/llvm-project/commit/79d5d9a0824ddcd5493a451e5009dd6393646e51 DIFF: https://github.com/llvm/llvm-project/commit/79d5d9a0824ddcd5493a451e5009dd6393646e51.diff LOG: [lldb] Allow synthetic providers in C++ and fix linking problems - Allow the definition of synthetic formatters in C++ even when LLDB is built without python scripting support. - Fix linking problems with the CXXSyntheticChildren Differential Revision: https://reviews.llvm.org/D158010 Added: Modified: lldb/include/lldb/DataFormatters/TypeSynthetic.h lldb/source/Commands/CommandObjectType.cpp lldb/source/Core/ValueObject.cpp lldb/source/DataFormatters/TypeSynthetic.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 890a6eb4f44876..41be9b7efda8fd 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -228,9 +228,9 @@ class SyntheticChildren { uint32_t m_flags = lldb::eTypeOptionCascade; }; - SyntheticChildren(const Flags &flags) : m_flags(flags) {} + SyntheticChildren(const Flags &flags); - virtual ~SyntheticChildren() = default; + virtual ~SyntheticChildren(); bool Cascades() const { return m_flags.GetCascades(); } @@ -239,8 +239,8 @@ class SyntheticChildren { bool SkipsReferences() const { return m_flags.GetSkipReferences(); } bool NonCacheable() const { return m_flags.GetNonCacheable(); } - - bool WantsDereference() const { return m_flags.GetFrontEndWantsDereference();} + + bool WantsDereference() const { return m_flags.GetFrontEndWantsDereference();} void SetCascades(bool value) { m_flags.SetCascades(value); } @@ -361,9 +361,9 @@ class CXXSyntheticChildren : public SyntheticChildren { lldb::ValueObjectSP)> CreateFrontEndCallback; CXXSyntheticChildren(const SyntheticChildren::Flags &flags, - const char *description, CreateFrontEndCallback callback) - : SyntheticChildren(flags), m_create_callback(std::move(callback)), - m_description(description ? description : "") {} + const char *description, CreateFrontEndCallback callback); + + virtual ~CXXSyntheticChildren(); bool IsScripted() override { return false; } diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index e6dd63a6cb2138..2969f82f95882e 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -2171,8 +2171,6 @@ class CommandObjectTypeFilterList "Show a list of current filters.") {} }; -#if LLDB_ENABLE_PYTHON - // CommandObjectTypeSynthList class CommandObjectTypeSynthList @@ -2184,8 +2182,6 @@ class CommandObjectTypeSynthList "Show a list of current synthetic providers.") {} }; -#endif - // CommandObjectTypeFilterDelete class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete { @@ -2197,8 +2193,6 @@ class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete { ~CommandObjectTypeFilterDelete() override = default; }; -#if LLDB_ENABLE_PYTHON - // CommandObjectTypeSynthDelete class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete { @@ -2210,7 +2204,6 @@ class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete { ~CommandObjectTypeSynthDelete() override = default; }; -#endif // CommandObjectTypeFilterClear @@ -2222,7 +2215,6 @@ class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear { "Delete all existing filter.") {} }; -#if LLDB_ENABLE_PYTHON // CommandObjectTypeSynthClear class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear { @@ -2393,7 +2385,6 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name, return true; } -#endif #define LLDB_OPTIONS_type_filter_add #include "CommandOptions.inc" @@ -2941,8 +2932,6 @@ class CommandObjectTypeFormat : public CommandObjectMultiword { ~CommandObjectTypeFormat() override = default; }; -#if LLDB_ENABLE_PYTHON - class CommandObjectTypeSynth : public CommandObjectMultiword { public: CommandObjectTypeSynth(CommandInterpreter &interpreter) @@ -2970,8 +2959,6 @@ class CommandObjectTypeSynth : public CommandObjectMultiword { ~CommandObjectTypeSynth() override = default; }; -#endif - class CommandObjectTypeFilter : public CommandObjectMultiword { public: CommandObjectTypeFilter(CommandInterpreter &interpreter) @@ -3056,10 +3043,8 @@ CommandObjectType::CommandObjectType(CommandInterpreter &interpreter) CommandObjectSP(new CommandObjectTypeFormat(interpreter))); LoadSubCommand("summary", CommandObjectSP(new CommandObjectTypeSummary(interpreter))); -#if LLDB_ENABLE_PYTHON LoadSubCommand("synthetic", CommandObjectSP(new CommandObjectTypeSynth(interpreter))); -#endif LoadSubCommand("lookup", CommandObjectSP(new CommandObjectTypeLookup(interpreter))); } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ed9e26aad0f30b..3e9116f2d92293 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -218,10 +218,8 @@ bool ValueObject::UpdateFormatsIfNeeded() { SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues)); SetSummaryFormat( DataVisualization::GetSummaryFormat(*this, GetDynamicValueType())); -#if LLDB_ENABLE_PYTHON SetSyntheticChildren( DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType())); -#endif } return any_change; @@ -1153,7 +1151,7 @@ bool ValueObject::DumpPrintableRepresentation( Stream &s, ValueObjectRepresentationStyle val_obj_display, Format custom_format, PrintableRepresentationSpecialCases special, bool do_dump_error) { - + // If the ValueObject has an error, we might end up dumping the type, which // is useful, but if we don't even have a type, then don't examine the object // further as that's not meaningful, only the error is. @@ -2766,15 +2764,15 @@ ValueObjectSP ValueObject::DoCast(const CompilerType &compiler_type) { ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) { // Only allow casts if the original type is equal or larger than the cast - // type. We don't know how to fetch more data for all the ConstResult types, + // type. We don't know how to fetch more data for all the ConstResult types, // so we can't guarantee this will work: Status error; CompilerType my_type = GetCompilerType(); - ExecutionContextScope *exe_scope + ExecutionContextScope *exe_scope = ExecutionContext(GetExecutionContextRef()) .GetBestExecutionContextScope(); - if (compiler_type.GetByteSize(exe_scope) + if (compiler_type.GetByteSize(exe_scope) <= GetCompilerType().GetByteSize(exe_scope)) { return DoCast(compiler_type); } diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp index 2cca5d65f470a7..de042e474903e5 100644 --- a/lldb/source/DataFormatters/TypeSynthetic.cpp +++ b/lldb/source/DataFormatters/TypeSynthetic.cpp @@ -84,6 +84,27 @@ std::string TypeFilterImpl::GetDescription() { return std::string(sstr.GetString()); } +SyntheticChildren::SyntheticChildren(const Flags &flags) : m_flags(flags) {} + +SyntheticChildren::~SyntheticChildren() = default; + +CXXSyntheticChildren::CXXSyntheticChildren( + const SyntheticChildren::Flags &flags, const char *description, + CreateFrontEndCallback callback) + : SyntheticChildren(flags), m_create_callback(std::move(callback)), + m_description(description ? description : "") {} + +CXXSyntheticChildren::~CXXSyntheticChildren() = default; + +bool SyntheticChildren::IsScripted() { return false; } + +std::string SyntheticChildren::GetDescription() { return ""; } + +SyntheticChildrenFrontEnd::AutoPointer +SyntheticChildren::GetFrontEnd(ValueObject &backend) { + return nullptr; +} + std::string CXXSyntheticChildren::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)", _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits