Index: cmake/modules/LLDBConfig.cmake =================================================================== --- cmake/modules/LLDBConfig.cmake +++ cmake/modules/LLDBConfig.cmake @@ -399,7 +399,7 @@ # Figure out if lldb could use lldb-server. If so, then we'll # ensure we build lldb-server when an lldb target is being built. -if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD") +if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows") set(LLDB_CAN_USE_LLDB_SERVER ON) else() set(LLDB_CAN_USE_LLDB_SERVER OFF) Index: source/Host/windows/Host.cpp =================================================================== --- source/Host/windows/Host.cpp +++ source/Host/windows/Host.cpp @@ -169,7 +169,23 @@ GetProcessExecutableAndTriple(handle, process_info); // Need to read the PEB to get parent process and command line arguments. - return true; + + AutoHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)); + if (!snapshot.IsValid()) + return false; + + PROCESSENTRY32W pe; + pe.dwSize = sizeof(PROCESSENTRY32W); + if (Process32FirstW(snapshot.get(), &pe)) { + do { + if (pe.th32ProcessID == pid) { + process_info.SetParentProcessID(pe.th32ParentProcessID); + return true; + } + } while (Process32NextW(snapshot.get(), &pe)); + } + + return false; } llvm::Expected Host::StartMonitoringChildProcess( Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -38,6 +38,8 @@ #if defined(__APPLE__) #define DEBUGSERVER_BASENAME "debugserver" +#elif defined(_WIN32) +#define DEBUGSERVER_BASENAME "lldb-server.exe" #else #define DEBUGSERVER_BASENAME "lldb-server" #endif Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -217,8 +217,13 @@ m_process_launch_info.GetFlags().Set(eLaunchFlagDebug); if (should_forward_stdio) { + // Temporarily relax the following for Windows until we can take advantage + // of the recently added pty support. This doesn't really affect the use of + // lldb-server on Windows. +#if !defined(_WIN32) if (llvm::Error Err = m_process_launch_info.SetUpPtyRedirection()) return Status(std::move(Err)); +#endif } { Index: tools/lldb-server/lldb-gdbserver.cpp =================================================================== --- tools/lldb-server/lldb-gdbserver.cpp +++ tools/lldb-server/lldb-gdbserver.cpp @@ -514,7 +514,7 @@ handle_launch(gdb_server, argc, argv); // Print version info. - printf("%s-%s", LLGS_PROGRAM_NAME, LLGS_VERSION_STR); + printf("%s-%s\n", LLGS_PROGRAM_NAME, LLGS_VERSION_STR); ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port, progname, subcommand, named_pipe_path.c_str(), Index: tools/lldb-server/lldb-platform.cpp =================================================================== --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -15,8 +15,9 @@ #include #include #include +#if !defined(_WIN32) #include - +#endif #include #include "llvm/Support/FileSystem.h" @@ -67,6 +68,7 @@ #define HIGH_PORT (49151u) #endif +#if !defined(_WIN32) // Watch for signals static void signal_handler(int signo) { switch (signo) { @@ -81,6 +83,7 @@ break; } } +#endif static void display_usage(const char *progname, const char *subcommand) { fprintf(stderr, "Usage:\n %s %s [--log-file log-file-name] [--log-channels " @@ -131,8 +134,10 @@ const char *subcommand = argv[1]; argc--; argv++; +#if !defined(_WIN32) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, signal_handler); +#endif int long_option_index = 0; Status error; std::string listen_host_port; @@ -309,8 +314,10 @@ printf("Connection established.\n"); if (g_server) { // Collect child zombie processes. +#if !defined(_WIN32) while (waitpid(-1, nullptr, WNOHANG) > 0) ; +#endif if (fork()) { // Parent doesn't need a connection to the lldb client delete conn;