asmith updated this revision to Diff 198675.
asmith retitled this revision from "Disable pty redirection on Windows and add
a method to get the parent pid" to "Enable lldb-server on Windows".
asmith edited the summary of this revision.
Herald added subscribers: mgorny, srhines.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61686/new/
https://reviews.llvm.org/D61686
Files:
cmake/modules/LLDBConfig.cmake
include/lldb/Host/windows/PosixApi.h
source/Host/windows/Host.cpp
source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
tools/lldb-server/lldb-gdbserver.cpp
tools/lldb-server/lldb-platform.cpp
Index: tools/lldb-server/lldb-platform.cpp
===================================================================
--- tools/lldb-server/lldb-platform.cpp
+++ tools/lldb-server/lldb-platform.cpp
@@ -15,8 +15,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if !defined(_WIN32)
#include <sys/wait.h>
-
+#endif
#include <fstream>
#include "llvm/Support/FileSystem.h"
@@ -69,6 +70,7 @@
// Watch for signals
static void signal_handler(int signo) {
+#if !defined(_WIN32)
switch (signo) {
case SIGHUP:
// Use SIGINT first, if that does not work, use SIGHUP as a last resort.
@@ -80,6 +82,7 @@
abort();
break;
}
+#endif
}
static void display_usage(const char *progname, const char *subcommand) {
@@ -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;
Index: tools/lldb-server/lldb-gdbserver.cpp
===================================================================
--- tools/lldb-server/lldb-gdbserver.cpp
+++ tools/lldb-server/lldb-gdbserver.cpp
@@ -515,7 +515,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: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -214,8 +214,14 @@
m_process_launch_info.GetFlags().Set(eLaunchFlagDebug);
if (should_forward_stdio) {
+ // There is no pty support on Windows currently which means O* and I*
+ // notification packets will not be generated about the inferior.
+ // In most cases the missing notifications do not affect lldb-server
+ // so we are temporarily relaxing the following for Windows.
+#if !defined(_WIN32)
if (llvm::Error Err = m_process_launch_info.SetUpPtyRedirection())
return Status(std::move(Err));
+#endif
}
{
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1185,12 +1185,17 @@
void GDBRemoteCommunicationServerCommon::
CreateProcessInfoResponse_DebugServerStyle(
const ProcessInstanceInfo &proc_info, StreamString &response) {
+#if defined(_WIN32)
+ response.Printf("pid:%" PRIx64 ";parent-pid:%" PRIx64 ";",
+ proc_info.GetProcessID(), proc_info.GetParentProcessID());
+#else
response.Printf("pid:%" PRIx64 ";parent-pid:%" PRIx64
";real-uid:%x;real-gid:%x;effective-uid:%x;effective-gid:%x;",
proc_info.GetProcessID(), proc_info.GetParentProcessID(),
proc_info.GetUserID(), proc_info.GetGroupID(),
proc_info.GetEffectiveUserID(),
proc_info.GetEffectiveGroupID());
+#endif
const ArchSpec &proc_arch = proc_info.GetArchitecture();
if (proc_arch.IsValid()) {
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/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;
}
HostThread Host::StartMonitoringChildProcess(
Index: include/lldb/Host/windows/PosixApi.h
===================================================================
--- include/lldb/Host/windows/PosixApi.h
+++ include/lldb/Host/windows/PosixApi.h
@@ -74,6 +74,8 @@
#endif // _MSC_VER
+#define WNOHANG 1
+
// Various useful posix functions that are not present in Windows. We provide
// custom implementations.
int vasprintf(char **ret, const char *fmt, va_list ap);
@@ -101,4 +103,8 @@
inline pid_t fork(void) { LLVM_BUILTIN_UNREACHABLE; }
inline pid_t setsid(void) { LLVM_BUILTIN_UNREACHABLE; }
+inline pid_t waitpid(pid_t pid, int *status, int options) {
+ // To be implemented.
+ return pid_t(-1);
+}
#endif
Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -418,7 +418,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 1)
else()
set(LLDB_CAN_USE_LLDB_SERVER 0)
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits