Skip to content

Commit 79d5d9a

Browse files
author
walter erquinigo
committed
[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
1 parent 5f8ee45 commit 79d5d9a

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

lldb/include/lldb/DataFormatters/TypeSynthetic.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ class SyntheticChildren {
228228
uint32_t m_flags = lldb::eTypeOptionCascade;
229229
};
230230

231-
SyntheticChildren(const Flags &flags) : m_flags(flags) {}
231+
SyntheticChildren(const Flags &flags);
232232

233-
virtual ~SyntheticChildren() = default;
233+
virtual ~SyntheticChildren();
234234

235235
bool Cascades() const { return m_flags.GetCascades(); }
236236

@@ -239,8 +239,8 @@ class SyntheticChildren {
239239
bool SkipsReferences() const { return m_flags.GetSkipReferences(); }
240240

241241
bool NonCacheable() const { return m_flags.GetNonCacheable(); }
242-
243-
bool WantsDereference() const { return m_flags.GetFrontEndWantsDereference();}
242+
243+
bool WantsDereference() const { return m_flags.GetFrontEndWantsDereference();}
244244

245245
void SetCascades(bool value) { m_flags.SetCascades(value); }
246246

@@ -361,9 +361,9 @@ class CXXSyntheticChildren : public SyntheticChildren {
361361
lldb::ValueObjectSP)>
362362
CreateFrontEndCallback;
363363
CXXSyntheticChildren(const SyntheticChildren::Flags &flags,
364-
const char *description, CreateFrontEndCallback callback)
365-
: SyntheticChildren(flags), m_create_callback(std::move(callback)),
366-
m_description(description ? description : "") {}
364+
const char *description, CreateFrontEndCallback callback);
365+
366+
virtual ~CXXSyntheticChildren();
367367

368368
bool IsScripted() override { return false; }
369369

lldb/source/Commands/CommandObjectType.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,8 +2171,6 @@ class CommandObjectTypeFilterList
21712171
"Show a list of current filters.") {}
21722172
};
21732173

2174-
#if LLDB_ENABLE_PYTHON
2175-
21762174
// CommandObjectTypeSynthList
21772175

21782176
class CommandObjectTypeSynthList
@@ -2184,8 +2182,6 @@ class CommandObjectTypeSynthList
21842182
"Show a list of current synthetic providers.") {}
21852183
};
21862184

2187-
#endif
2188-
21892185
// CommandObjectTypeFilterDelete
21902186

21912187
class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
@@ -2197,8 +2193,6 @@ class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
21972193
~CommandObjectTypeFilterDelete() override = default;
21982194
};
21992195

2200-
#if LLDB_ENABLE_PYTHON
2201-
22022196
// CommandObjectTypeSynthDelete
22032197

22042198
class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
@@ -2210,7 +2204,6 @@ class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
22102204
~CommandObjectTypeSynthDelete() override = default;
22112205
};
22122206

2213-
#endif
22142207

22152208
// CommandObjectTypeFilterClear
22162209

@@ -2222,7 +2215,6 @@ class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear {
22222215
"Delete all existing filter.") {}
22232216
};
22242217

2225-
#if LLDB_ENABLE_PYTHON
22262218
// CommandObjectTypeSynthClear
22272219

22282220
class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
@@ -2393,7 +2385,6 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
23932385
return true;
23942386
}
23952387

2396-
#endif
23972388
#define LLDB_OPTIONS_type_filter_add
23982389
#include "CommandOptions.inc"
23992390

@@ -2941,8 +2932,6 @@ class CommandObjectTypeFormat : public CommandObjectMultiword {
29412932
~CommandObjectTypeFormat() override = default;
29422933
};
29432934

2944-
#if LLDB_ENABLE_PYTHON
2945-
29462935
class CommandObjectTypeSynth : public CommandObjectMultiword {
29472936
public:
29482937
CommandObjectTypeSynth(CommandInterpreter &interpreter)
@@ -2970,8 +2959,6 @@ class CommandObjectTypeSynth : public CommandObjectMultiword {
29702959
~CommandObjectTypeSynth() override = default;
29712960
};
29722961

2973-
#endif
2974-
29752962
class CommandObjectTypeFilter : public CommandObjectMultiword {
29762963
public:
29772964
CommandObjectTypeFilter(CommandInterpreter &interpreter)
@@ -3056,10 +3043,8 @@ CommandObjectType::CommandObjectType(CommandInterpreter &interpreter)
30563043
CommandObjectSP(new CommandObjectTypeFormat(interpreter)));
30573044
LoadSubCommand("summary",
30583045
CommandObjectSP(new CommandObjectTypeSummary(interpreter)));
3059-
#if LLDB_ENABLE_PYTHON
30603046
LoadSubCommand("synthetic",
30613047
CommandObjectSP(new CommandObjectTypeSynth(interpreter)));
3062-
#endif
30633048
LoadSubCommand("lookup",
30643049
CommandObjectSP(new CommandObjectTypeLookup(interpreter)));
30653050
}

lldb/source/Core/ValueObject.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,8 @@ bool ValueObject::UpdateFormatsIfNeeded() {
218218
SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
219219
SetSummaryFormat(
220220
DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
221-
#if LLDB_ENABLE_PYTHON
222221
SetSyntheticChildren(
223222
DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
224-
#endif
225223
}
226224

227225
return any_change;
@@ -1153,7 +1151,7 @@ bool ValueObject::DumpPrintableRepresentation(
11531151
Stream &s, ValueObjectRepresentationStyle val_obj_display,
11541152
Format custom_format, PrintableRepresentationSpecialCases special,
11551153
bool do_dump_error) {
1156-
1154+
11571155
// If the ValueObject has an error, we might end up dumping the type, which
11581156
// is useful, but if we don't even have a type, then don't examine the object
11591157
// further as that's not meaningful, only the error is.
@@ -2766,15 +2764,15 @@ ValueObjectSP ValueObject::DoCast(const CompilerType &compiler_type) {
27662764

27672765
ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
27682766
// Only allow casts if the original type is equal or larger than the cast
2769-
// type. We don't know how to fetch more data for all the ConstResult types,
2767+
// type. We don't know how to fetch more data for all the ConstResult types,
27702768
// so we can't guarantee this will work:
27712769
Status error;
27722770
CompilerType my_type = GetCompilerType();
27732771

2774-
ExecutionContextScope *exe_scope
2772+
ExecutionContextScope *exe_scope
27752773
= ExecutionContext(GetExecutionContextRef())
27762774
.GetBestExecutionContextScope();
2777-
if (compiler_type.GetByteSize(exe_scope)
2775+
if (compiler_type.GetByteSize(exe_scope)
27782776
<= GetCompilerType().GetByteSize(exe_scope)) {
27792777
return DoCast(compiler_type);
27802778
}

lldb/source/DataFormatters/TypeSynthetic.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@ std::string TypeFilterImpl::GetDescription() {
8484
return std::string(sstr.GetString());
8585
}
8686

87+
SyntheticChildren::SyntheticChildren(const Flags &flags) : m_flags(flags) {}
88+
89+
SyntheticChildren::~SyntheticChildren() = default;
90+
91+
CXXSyntheticChildren::CXXSyntheticChildren(
92+
const SyntheticChildren::Flags &flags, const char *description,
93+
CreateFrontEndCallback callback)
94+
: SyntheticChildren(flags), m_create_callback(std::move(callback)),
95+
m_description(description ? description : "") {}
96+
97+
CXXSyntheticChildren::~CXXSyntheticChildren() = default;
98+
99+
bool SyntheticChildren::IsScripted() { return false; }
100+
101+
std::string SyntheticChildren::GetDescription() { return ""; }
102+
103+
SyntheticChildrenFrontEnd::AutoPointer
104+
SyntheticChildren::GetFrontEnd(ValueObject &backend) {
105+
return nullptr;
106+
}
107+
87108
std::string CXXSyntheticChildren::GetDescription() {
88109
StreamString sstr;
89110
sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)",

0 commit comments

Comments
 (0)