|
6 | 6 | //
|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
| 9 | +#include "lldb/Core/PluginManager.h" |
9 | 10 | #include "lldb/Host/Config.h"
|
10 |
| -#if LLDB_ENABLE_PYTHON |
11 |
| -// LLDB Python header must be included first |
12 |
| -#include "../lldb-python.h" |
13 |
| -#endif |
14 | 11 | #include "lldb/Target/Process.h"
|
15 | 12 | #include "lldb/Utility/Log.h"
|
16 | 13 | #include "lldb/Utility/Status.h"
|
17 | 14 | #include "lldb/lldb-enumerations.h"
|
18 | 15 |
|
19 | 16 | #if LLDB_ENABLE_PYTHON
|
20 | 17 |
|
21 |
| -#include "../SWIGPythonBridge.h" |
22 |
| -#include "../ScriptInterpreterPythonImpl.h" |
| 18 | +// clang-format off |
| 19 | +// LLDB Python header must be included first |
| 20 | +#include "../../lldb-python.h" |
| 21 | +//clang-format on |
| 22 | + |
| 23 | +#include "../../SWIGPythonBridge.h" |
| 24 | +#include "../../ScriptInterpreterPythonImpl.h" |
| 25 | +#include "../ScriptedThreadPythonInterface.h" |
23 | 26 | #include "ScriptedProcessPythonInterface.h"
|
24 |
| -#include "ScriptedThreadPythonInterface.h" |
| 27 | + |
25 | 28 | #include <optional>
|
26 | 29 |
|
27 | 30 | using namespace lldb;
|
28 | 31 | using namespace lldb_private;
|
29 | 32 | using namespace lldb_private::python;
|
30 | 33 | using Locker = ScriptInterpreterPythonImpl::Locker;
|
31 | 34 |
|
| 35 | +LLDB_PLUGIN_DEFINE_ADV(ScriptedProcessPythonInterface, ScriptInterpreterPythonScriptedProcessPythonInterface) |
| 36 | + |
32 | 37 | ScriptedProcessPythonInterface::ScriptedProcessPythonInterface(
|
33 | 38 | ScriptInterpreterPythonImpl &interpreter)
|
34 | 39 | : ScriptedProcessInterface(), ScriptedPythonInterface(interpreter) {}
|
@@ -208,4 +213,24 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() {
|
208 | 213 | return dict;
|
209 | 214 | }
|
210 | 215 |
|
| 216 | +void ScriptedProcessPythonInterface::Initialize() { |
| 217 | + const std::vector<llvm::StringRef> ci_usages = { |
| 218 | + "process attach -C <script-name> [-k key -v value ...]", |
| 219 | + "process launch -C <script-name> [-k key -v value ...]"}; |
| 220 | + const std::vector<llvm::StringRef> api_usages = { |
| 221 | + "SBAttachInfo.SetScriptedProcessClassName", |
| 222 | + "SBAttachInfo.SetScriptedProcessDictionary", |
| 223 | + "SBTarget.Attach", |
| 224 | + "SBLaunchInfo.SetScriptedProcessClassName", |
| 225 | + "SBLaunchInfo.SetScriptedProcessDictionary", |
| 226 | + "SBTarget.Launch"}; |
| 227 | + PluginManager::RegisterPlugin( |
| 228 | + GetPluginNameStatic(), llvm::StringRef("Mock process state"), |
| 229 | + CreateInstance, eScriptLanguagePython, {ci_usages, api_usages}); |
| 230 | +} |
| 231 | + |
| 232 | +void ScriptedProcessPythonInterface::Terminate() { |
| 233 | + PluginManager::UnregisterPlugin(CreateInstance); |
| 234 | +} |
| 235 | + |
211 | 236 | #endif
|
0 commit comments