Skip to content

Commit ecf125e

Browse files
committed
[lldb] Add ScriptedPlatform to scripting template list
This patch is a follow-up to bccff3b which adds the `ScriptedPlatform` extension to the `scripting template list` command as well as its description. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent f1a7d14 commit ecf125e

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
2424
ScriptedPythonInterface.cpp
2525
ScriptedProcessPythonInterface.cpp
2626
ScriptedThreadPythonInterface.cpp
27-
ScriptedPlatformPythonInterface.cpp
2827

2928
LINK_LIBS
3029
lldbCore
@@ -37,4 +36,5 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
3736
LINK_COMPONENTS
3837
Support
3938
)
39+
add_subdirectory(ScriptedPlatformPythonInterface)
4040
add_subdirectory(ScriptedThreadPlanPythonInterface)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
add_lldb_library(lldbPluginScriptInterpreterPythonScriptedPlatformPythonInterface PLUGIN
2+
3+
ScriptedPlatformPythonInterface.cpp
4+
5+
LINK_LIBS
6+
lldbCore
7+
lldbHost
8+
lldbInterpreter
9+
lldbTarget
10+
lldbPluginScriptInterpreterPython
11+
${Python3_LIBRARIES}
12+
${LLDB_LIBEDIT_LIBS}
13+
14+
LINK_COMPONENTS
15+
Support
16+
)

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface/ScriptedPlatformPythonInterface.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "lldb/Core/PluginManager.h"
910
#include "lldb/Host/Config.h"
11+
#include "lldb/Target/ExecutionContext.h"
1012
#include "lldb/Utility/Log.h"
1113
#include "lldb/Utility/Status.h"
1214
#include "lldb/lldb-enumerations.h"
1315

1416
#if LLDB_ENABLE_PYTHON
1517

18+
// clang-format off
1619
// LLDB Python header must be included first
17-
#include "../lldb-python.h"
20+
#include "../../lldb-python.h"
21+
//clang-format on
1822

19-
#include "../SWIGPythonBridge.h"
20-
#include "../ScriptInterpreterPythonImpl.h"
23+
#include "../../SWIGPythonBridge.h"
24+
#include "../../ScriptInterpreterPythonImpl.h"
2125
#include "ScriptedPlatformPythonInterface.h"
2226

23-
#include "lldb/Target/ExecutionContext.h"
24-
2527
using namespace lldb;
2628
using namespace lldb_private;
2729
using namespace lldb_private::python;
2830
using Locker = ScriptInterpreterPythonImpl::Locker;
2931

32+
LLDB_PLUGIN_DEFINE_ADV(ScriptedPlatformPythonInterface, ScriptInterpreterPythonScriptedPlatformPythonInterface)
33+
3034
ScriptedPlatformPythonInterface::ScriptedPlatformPythonInterface(
3135
ScriptInterpreterPythonImpl &interpreter)
3236
: ScriptedPlatformInterface(), ScriptedPythonInterface(interpreter) {}
@@ -93,4 +97,14 @@ Status ScriptedPlatformPythonInterface::KillProcess(lldb::pid_t pid) {
9397
return GetStatusFromMethod("kill_process", pid);
9498
}
9599

100+
void ScriptedPlatformPythonInterface::Initialize() {
101+
PluginManager::RegisterPlugin(
102+
GetPluginNameStatic(), "Mock platform and interact with its processes.",
103+
CreateInstance, eScriptLanguagePython, {});
104+
}
105+
106+
void ScriptedPlatformPythonInterface::Terminate() {
107+
PluginManager::UnregisterPlugin(CreateInstance);
108+
}
109+
96110
#endif // LLDB_ENABLE_PYTHON

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface/ScriptedPlatformPythonInterface.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H
1111

1212
#include "lldb/Host/Config.h"
13+
#include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h"
1314

1415
#if LLDB_ENABLE_PYTHON
1516

16-
#include "ScriptedPythonInterface.h"
17-
#include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h"
17+
#include "../ScriptedPythonInterface.h"
1818

1919
namespace lldb_private {
2020
class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface,
21-
public ScriptedPythonInterface {
21+
public ScriptedPythonInterface,
22+
public PluginInterface {
2223
public:
2324
ScriptedPlatformPythonInterface(ScriptInterpreterPythonImpl &interpreter);
2425

@@ -43,6 +44,16 @@ class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface,
4344
Status LaunchProcess(lldb::ProcessLaunchInfoSP launch_info) override;
4445

4546
Status KillProcess(lldb::pid_t pid) override;
47+
48+
static void Initialize();
49+
50+
static void Terminate();
51+
52+
static llvm::StringRef GetPluginNameStatic() {
53+
return "ScriptedPlatformPythonInterface";
54+
}
55+
56+
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
4657
};
4758
} // namespace lldb_private
4859

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "lldb-python.h"
1616

1717
#include "Interfaces/OperatingSystemPythonInterface.h"
18-
#include "Interfaces/ScriptedPlatformPythonInterface.h"
18+
#include "Interfaces/ScriptedPlatformPythonInterface/ScriptedPlatformPythonInterface.h"
1919
#include "Interfaces/ScriptedProcessPythonInterface.h"
2020
#include "Interfaces/ScriptedThreadPlanPythonInterface/ScriptedThreadPlanPythonInterface.h"
2121
#include "Interfaces/ScriptedThreadPythonInterface.h"

0 commit comments

Comments
 (0)