electriclilies created this revision.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Allow the definition of synthetic formatters in C++, and fix linking problems
with the CXXSyntheticChildren
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158010
Files:
lldb/include/lldb/DataFormatters/TypeSynthetic.h
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/DataFormatters/TypeSynthetic.cpp
Index: lldb/source/DataFormatters/TypeSynthetic.cpp
===================================================================
--- lldb/source/DataFormatters/TypeSynthetic.cpp
+++ lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -84,6 +84,27 @@
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)",
Index: lldb/source/Core/ValueObject.cpp
===================================================================
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
SetSummaryFormat(
DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-#if LLDB_ENABLE_PYTHON
SetSyntheticChildren(
DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
-#endif
}
return any_change;
@@ -1170,7 +1168,7 @@
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.
@@ -2785,15 +2783,15 @@
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);
}
Index: lldb/source/Commands/CommandObjectType.cpp
===================================================================
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2171,8 +2171,6 @@
"Show a list of current filters.") {}
};
-#if LLDB_ENABLE_PYTHON
-
// CommandObjectTypeSynthList
class CommandObjectTypeSynthList
@@ -2184,8 +2182,6 @@
"Show a list of current synthetic providers.") {}
};
-#endif
-
// CommandObjectTypeFilterDelete
class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
@@ -2197,8 +2193,6 @@
~CommandObjectTypeFilterDelete() override = default;
};
-#if LLDB_ENABLE_PYTHON
-
// CommandObjectTypeSynthDelete
class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
@@ -2210,7 +2204,6 @@
~CommandObjectTypeSynthDelete() override = default;
};
-#endif
// CommandObjectTypeFilterClear
@@ -2222,7 +2215,6 @@
"Delete all existing filter.") {}
};
-#if LLDB_ENABLE_PYTHON
// CommandObjectTypeSynthClear
class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
@@ -2393,7 +2385,6 @@
return true;
}
-#endif
#define LLDB_OPTIONS_type_filter_add
#include "CommandOptions.inc"
@@ -2941,8 +2932,6 @@
~CommandObjectTypeFormat() override = default;
};
-#if LLDB_ENABLE_PYTHON
-
class CommandObjectTypeSynth : public CommandObjectMultiword {
public:
CommandObjectTypeSynth(CommandInterpreter &interpreter)
@@ -2970,8 +2959,6 @@
~CommandObjectTypeSynth() override = default;
};
-#endif
-
class CommandObjectTypeFilter : public CommandObjectMultiword {
public:
CommandObjectTypeFilter(CommandInterpreter &interpreter)
@@ -3056,10 +3043,8 @@
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)));
}
Index: lldb/include/lldb/DataFormatters/TypeSynthetic.h
===================================================================
--- lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -228,9 +228,9 @@
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 @@
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); }
@@ -254,12 +254,12 @@
void SetOptions(uint32_t value) { m_flags.SetValue(value); }
- virtual bool IsScripted() = 0;
+ virtual bool IsScripted();
- virtual std::string GetDescription() = 0;
+ virtual std::string GetDescription();
virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend) = 0;
+ GetFrontEnd(ValueObject &backend);
typedef std::shared_ptr<SyntheticChildren> SharedPointer;
@@ -361,9 +361,9 @@
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; }
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits