Skip to content

Commit 26340d5

Browse files
DavidSpickettmedismailben
authored andcommitted
Reland "[lldb] Reland 2402b32 with /H to debug the windows build issue (llvm#101672)
This reverts commit 9effefb. With the include order in ScriptedProcessPythonInterface.cpp fixed (though I cannot explain exactly why it works) and removes the /H flag intended for debugging this issue. I think it is something to do with Process.h pulling in PosixApi.h somewhere along the line, and including Process.h after lldb-python.h means that NO_PID_T is defined to prevent a redefinition of pid_t. (cherry picked from commit 9d07f43)
1 parent 30d7985 commit 26340d5

File tree

5 files changed

+68
-13
lines changed

5 files changed

+68
-13
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ endif()
2121

2222
add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
2323
ScriptedPythonInterface.cpp
24-
ScriptedProcessPythonInterface.cpp
2524
ScriptedThreadPythonInterface.cpp
2625

2726
LINK_LIBS
@@ -38,5 +37,6 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
3837

3938
add_subdirectory(OperatingSystemPythonInterface)
4039
add_subdirectory(ScriptedPlatformPythonInterface)
40+
add_subdirectory(ScriptedProcessPythonInterface)
4141
add_subdirectory(ScriptedThreadPlanPythonInterface)
4242

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
add_lldb_library(lldbPluginScriptInterpreterPythonScriptedProcessPythonInterface PLUGIN
2+
3+
ScriptedProcessPythonInterface.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/ScriptedProcessPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp

+35-8
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,36 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "lldb/Core/PluginManager.h"
910
#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-
#include "lldb/Target/Process.h"
1511
#include "lldb/Utility/Log.h"
1612
#include "lldb/Utility/Status.h"
1713
#include "lldb/lldb-enumerations.h"
1814

1915
#if LLDB_ENABLE_PYTHON
2016

21-
#include "../SWIGPythonBridge.h"
22-
#include "../ScriptInterpreterPythonImpl.h"
17+
// clang-format off
18+
// LLDB Python header must be included first
19+
#include "../../lldb-python.h"
20+
21+
#include "../../SWIGPythonBridge.h"
22+
#include "../../ScriptInterpreterPythonImpl.h"
23+
#include "../ScriptedThreadPythonInterface.h"
2324
#include "ScriptedProcessPythonInterface.h"
24-
#include "ScriptedThreadPythonInterface.h"
25+
26+
// Included in this position to prevent redefinition of pid_t on Windows.
27+
#include "lldb/Target/Process.h"
28+
//clang-format off
29+
2530
#include <optional>
2631

2732
using namespace lldb;
2833
using namespace lldb_private;
2934
using namespace lldb_private::python;
3035
using Locker = ScriptInterpreterPythonImpl::Locker;
3136

37+
LLDB_PLUGIN_DEFINE_ADV(ScriptedProcessPythonInterface, ScriptInterpreterPythonScriptedProcessPythonInterface)
38+
3239
ScriptedProcessPythonInterface::ScriptedProcessPythonInterface(
3340
ScriptInterpreterPythonImpl &interpreter)
3441
: ScriptedProcessInterface(), ScriptedPythonInterface(interpreter) {}
@@ -208,4 +215,24 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() {
208215
return dict;
209216
}
210217

218+
void ScriptedProcessPythonInterface::Initialize() {
219+
const std::vector<llvm::StringRef> ci_usages = {
220+
"process attach -C <script-name> [-k key -v value ...]",
221+
"process launch -C <script-name> [-k key -v value ...]"};
222+
const std::vector<llvm::StringRef> api_usages = {
223+
"SBAttachInfo.SetScriptedProcessClassName",
224+
"SBAttachInfo.SetScriptedProcessDictionary",
225+
"SBTarget.Attach",
226+
"SBLaunchInfo.SetScriptedProcessClassName",
227+
"SBLaunchInfo.SetScriptedProcessDictionary",
228+
"SBTarget.Launch"};
229+
PluginManager::RegisterPlugin(
230+
GetPluginNameStatic(), llvm::StringRef("Mock process state"),
231+
CreateInstance, eScriptLanguagePython, {ci_usages, api_usages});
232+
}
233+
234+
void ScriptedProcessPythonInterface::Terminate() {
235+
PluginManager::UnregisterPlugin(CreateInstance);
236+
}
237+
211238
#endif

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
1111

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

1415
#if LLDB_ENABLE_PYTHON
1516

16-
#include "ScriptedPythonInterface.h"
17-
#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
17+
#include "../ScriptedPythonInterface.h"
18+
1819
#include <optional>
1920

2021
namespace lldb_private {
2122
class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
22-
public ScriptedPythonInterface {
23+
public ScriptedPythonInterface,
24+
public PluginInterface {
2325
public:
2426
ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter);
2527

@@ -67,6 +69,16 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
6769

6870
StructuredData::DictionarySP GetMetadata() override;
6971

72+
static void Initialize();
73+
74+
static void Terminate();
75+
76+
static llvm::StringRef GetPluginNameStatic() {
77+
return "ScriptedProcessPythonInterface";
78+
}
79+
80+
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
81+
7082
private:
7183
lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
7284
};

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "Interfaces/OperatingSystemPythonInterface/OperatingSystemPythonInterface.h"
1818
#include "Interfaces/ScriptedPlatformPythonInterface/ScriptedPlatformPythonInterface.h"
19-
#include "Interfaces/ScriptedProcessPythonInterface.h"
19+
#include "Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h"
2020
#include "Interfaces/ScriptedThreadPlanPythonInterface/ScriptedThreadPlanPythonInterface.h"
2121
#include "PythonDataObjects.h"
2222
#include "PythonReadline.h"

0 commit comments

Comments
 (0)