Skip to content

Commit 7991412

Browse files
authored
[lldb/Interpreter] Make Scripted*Interface base class abstract (#71465)
This patch makes the various Scripted Interface base class abstract by making the `CreatePluginObject` method pure virtual. This means that we cannot construct a Scripted Interface base class instance, so this patch also updates the various `ScriptedInterpreter::CreateScripted*Interface` methods to return a `nullptr` instead.` This patch also removes the `ScriptedPlatformInterface` member from the `ScriptInterpreter` class since it the interpreter can be owned by the `ScriptedPlatform` instance itself, like we do for `ScriptedProcess` objects. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 3267cd3 commit 7991412

File tree

6 files changed

+12
-27
lines changed

6 files changed

+12
-27
lines changed

lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ class ScriptedPlatformInterface : virtual public ScriptedInterface {
2222
virtual llvm::Expected<StructuredData::GenericSP>
2323
CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
2424
StructuredData::DictionarySP args_sp,
25-
StructuredData::Generic *script_obj = nullptr) {
26-
return {llvm::make_error<UnimplementedError>()};
27-
}
25+
StructuredData::Generic *script_obj = nullptr) = 0;
2826

2927
virtual StructuredData::DictionarySP ListProcesses() { return {}; }
3028

lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
2424
virtual llvm::Expected<StructuredData::GenericSP>
2525
CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
2626
StructuredData::DictionarySP args_sp,
27-
StructuredData::Generic *script_obj = nullptr) {
28-
return {llvm::make_error<UnimplementedError>()};
29-
}
27+
StructuredData::Generic *script_obj = nullptr) = 0;
3028

3129
virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
3230

lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class ScriptedThreadInterface : virtual public ScriptedInterface {
2323
virtual llvm::Expected<StructuredData::GenericSP>
2424
CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
2525
StructuredData::DictionarySP args_sp,
26-
StructuredData::Generic *script_obj = nullptr) {
27-
return {llvm::make_error<UnimplementedError>()};
28-
}
26+
StructuredData::Generic *script_obj = nullptr) = 0;
2927

3028
virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
3129

lldb/include/lldb/Interpreter/ScriptInterpreter.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ class ScriptInterpreter : public PluginInterface {
151151
eScriptReturnTypeOpaqueObject
152152
};
153153

154-
ScriptInterpreter(
155-
Debugger &debugger, lldb::ScriptLanguage script_lang,
156-
lldb::ScriptedPlatformInterfaceUP scripted_platform_interface_up =
157-
std::make_unique<ScriptedPlatformInterface>());
154+
ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang);
158155

159156
virtual StructuredData::DictionarySP GetInterpreterInfo();
160157

@@ -559,19 +556,19 @@ class ScriptInterpreter : public PluginInterface {
559556
lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
560557

561558
virtual lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInterface() {
562-
return std::make_unique<ScriptedProcessInterface>();
559+
return {};
563560
}
564561

565562
virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
566-
return std::make_shared<ScriptedThreadInterface>();
563+
return {};
567564
}
568565

569566
virtual lldb::OperatingSystemInterfaceSP CreateOperatingSystemInterface() {
570-
return std::make_shared<OperatingSystemInterface>();
567+
return {};
571568
}
572569

573-
ScriptedPlatformInterface &GetScriptedPlatformInterface() {
574-
return *m_scripted_platform_interface_up;
570+
virtual lldb::ScriptedPlatformInterfaceUP GetScriptedPlatformInterface() {
571+
return {};
575572
}
576573

577574
virtual StructuredData::ObjectSP
@@ -599,7 +596,6 @@ class ScriptInterpreter : public PluginInterface {
599596
protected:
600597
Debugger &m_debugger;
601598
lldb::ScriptLanguage m_script_lang;
602-
lldb::ScriptedPlatformInterfaceUP m_scripted_platform_interface_up;
603599
};
604600

605601
} // namespace lldb_private

lldb/source/Interpreter/ScriptInterpreter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@
2727
using namespace lldb;
2828
using namespace lldb_private;
2929

30-
ScriptInterpreter::ScriptInterpreter(
31-
Debugger &debugger, lldb::ScriptLanguage script_lang,
32-
lldb::ScriptedPlatformInterfaceUP scripted_platform_interface_up)
33-
: m_debugger(debugger), m_script_lang(script_lang),
34-
m_scripted_platform_interface_up(
35-
std::move(scripted_platform_interface_up)) {}
30+
ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
31+
lldb::ScriptLanguage script_lang)
32+
: m_debugger(debugger), m_script_lang(script_lang) {}
3633

3734
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
3835
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,6 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
427427
m_active_io_handler(eIOHandlerNone), m_session_is_active(false),
428428
m_pty_secondary_is_open(false), m_valid_session(true), m_lock_count(0),
429429
m_command_thread_state(nullptr) {
430-
m_scripted_platform_interface_up =
431-
std::make_unique<ScriptedPlatformPythonInterface>(*this);
432430

433431
m_dictionary_name.append("_dict");
434432
StreamString run_string;

0 commit comments

Comments
 (0)