https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/178238
>From e299cb168e6f1a0c42d20e3c5e52f2dacb4e92fb Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Tue, 27 Jan 2026 15:38:59 +0000 Subject: [PATCH 1/2] [lldb][windows] fix an invalid cast from a filedescriptor to a HANDLE --- lldb/include/lldb/Host/FileAction.h | 2 ++ lldb/source/Host/common/FileAction.cpp | 12 ++++++++++++ lldb/source/Host/windows/ProcessLauncherWindows.cpp | 5 +++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Host/FileAction.h b/lldb/include/lldb/Host/FileAction.h index b2cc8be32d296..fcfc63c02e4ff 100644 --- a/lldb/include/lldb/Host/FileAction.h +++ b/lldb/include/lldb/Host/FileAction.h @@ -35,6 +35,8 @@ class FileAction { int GetFD() const { return m_fd; } + void *GetHandle() const; + Action GetAction() const { return m_action; } int GetActionArgument() const { return m_arg; } diff --git a/lldb/source/Host/common/FileAction.cpp b/lldb/source/Host/common/FileAction.cpp index ec271f7b920d8..7bae82cada32d 100644 --- a/lldb/source/Host/common/FileAction.cpp +++ b/lldb/source/Host/common/FileAction.cpp @@ -12,12 +12,24 @@ #include "lldb/Host/PosixApi.h" #include "lldb/Utility/Stream.h" +#ifdef _WIN32 +#include "lldb/Host/windows/windows.h" +#endif + using namespace lldb_private; // FileAction member functions FileAction::FileAction() : m_file_spec() {} +#ifdef _WIN32 +HANDLE FileAction::GetHandle() const { + if (m_fd == -1) + return INVALID_HANDLE_VALUE; + return reinterpret_cast<HANDLE>(_get_osfhandle(m_fd)); +} +#endif + void FileAction::Clear() { m_action = eFileActionNone; m_fd = -1; diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp index ec1a20ebb2200..0ee71ea17fd50 100644 --- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp +++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp @@ -242,8 +242,9 @@ llvm::ErrorOr<std::vector<HANDLE>> ProcessLauncherWindows::GetInheritedHandles( for (size_t i = 0; i < launch_info.GetNumFileActions(); ++i) { const FileAction *act = launch_info.GetFileActionAtIndex(i); if (act->GetAction() == FileAction::eFileActionDuplicate && - act->GetFD() == act->GetActionArgument()) - inherited_handles.push_back(reinterpret_cast<HANDLE>(act->GetFD())); + act->GetFD() == act->GetActionArgument()) { + inherited_handles.push_back(act->GetHandle()); + } } if (inherited_handles.empty()) >From c3818c9a02a2e6634c3db079048cbf7b406e93f7 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Wed, 28 Jan 2026 13:27:11 +0000 Subject: [PATCH 2/2] add ifdef --- lldb/include/lldb/Host/FileAction.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lldb/include/lldb/Host/FileAction.h b/lldb/include/lldb/Host/FileAction.h index fcfc63c02e4ff..4a064c1e5ec08 100644 --- a/lldb/include/lldb/Host/FileAction.h +++ b/lldb/include/lldb/Host/FileAction.h @@ -35,7 +35,9 @@ class FileAction { int GetFD() const { return m_fd; } +#ifdef _WIN32 void *GetHandle() const; +#endif Action GetAction() const { return m_action; } _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
