llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp
rchamala 0773c83e66
[lldb] Fix pid_t redefinition on Windows in ScriptInterpreterPythonInterfaces (#181493)
## Summary
Include `lldb-python.h` as the first include inside the
`LLDB_ENABLE_PYTHON` block in `ScriptInterpreterPythonInterfaces.cpp`,
matching the pattern used by every other Python interface `.cpp` file in
this directory.

On Windows, `lldb-python.h` defines `NO_PID_T` before including
`Python.h`. This prevents `PosixApi.h` (transitively included via
`lldb-private.h`) from redefining `pid_t` with a conflicting type
(`uint32_t` vs `int`).

The issue was introduced by #181334 (ScriptedSymbolLocator plugin),
which added a new header whose include chain transitively reaches
`PosixApi.h`.

Fixes Windows build failures on lldb-aarch64-windows, lldb-x86_64-win,
and lldb-remote-linux-win.

## Test plan
- [ ] lldb-aarch64-windows build passes
- [ ] lldb-x86_64-win build passes
- [ ] lldb-remote-linux-win build passes

Co-authored-by: Rahul Reddy Chamala <rachamal@meta.com>
2026-02-14 09:44:46 -08:00

55 lines
1.8 KiB
C++

//===-- ScriptInterpreterPythonInterfaces.cpp -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/Config.h"
#include "lldb/lldb-enumerations.h"
#if LLDB_ENABLE_PYTHON
// Include lldb-python.h first to define NO_PID_T on Windows before any
// LLDB header transitively pulls in PosixApi.h.
#include "../lldb-python.h"
#include "ScriptInterpreterPythonInterfaces.h"
#include "lldb/Core/PluginManager.h"
using namespace lldb;
using namespace lldb_private;
LLDB_PLUGIN_DEFINE(ScriptInterpreterPythonInterfaces)
llvm::StringRef
ScriptInterpreterPythonInterfaces::GetPluginDescriptionStatic() {
return "Script Interpreter Python Interfaces";
}
void ScriptInterpreterPythonInterfaces::Initialize() {
OperatingSystemPythonInterface::Initialize();
ScriptedPlatformPythonInterface::Initialize();
ScriptedProcessPythonInterface::Initialize();
ScriptedStopHookPythonInterface::Initialize();
ScriptedBreakpointPythonInterface::Initialize();
ScriptedThreadPlanPythonInterface::Initialize();
ScriptedFrameProviderPythonInterface::Initialize();
ScriptedSymbolLocatorPythonInterface::Initialize();
}
void ScriptInterpreterPythonInterfaces::Terminate() {
OperatingSystemPythonInterface::Terminate();
ScriptedPlatformPythonInterface::Terminate();
ScriptedProcessPythonInterface::Terminate();
ScriptedStopHookPythonInterface::Terminate();
ScriptedBreakpointPythonInterface::Terminate();
ScriptedThreadPlanPythonInterface::Terminate();
ScriptedFrameProviderPythonInterface::Terminate();
ScriptedSymbolLocatorPythonInterface::Terminate();
}
#endif