Make lldb -P work on Windows.
lldb -P, which outputs its python path, works by using Host-layer
facilities to get information about the loaded python module. This
Host functionality was unimplemented on Windows, so this patch
implements it. Additionally, it removes a pexpect dependency from
the test runner and uses an equivalent invocation of subprocess.
Reviewed by: Todd Fiala
Differential Revision: http://reviews.llvm.org/D4548
llvm-svn: 213410
diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
index e2197ca..9fa2652 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -247,6 +247,20 @@
Host::GetModuleFileSpecForHostAddress (const void *host_addr)
{
FileSpec module_filespec;
+
+ HMODULE hmodule = NULL;
+ if (!::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)host_addr, &hmodule))
+ return module_filespec;
+
+ std::vector<char> buffer(MAX_PATH);
+ DWORD chars_copied = 0;
+ do {
+ chars_copied = ::GetModuleFileName(hmodule, &buffer[0], buffer.size());
+ if (chars_copied == buffer.size() && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ buffer.resize(buffer.size() * 2);
+ } while (chars_copied >= buffer.size());
+
+ module_filespec.SetFile(&buffer[0], false);
return module_filespec;
}