[Lldb-commits] [PATCH] Make lldb -P work on Windows
Zachary Turner
zturner at google.com
Fri Jul 18 09:14:05 PDT 2014
Bump.
On Wed, Jul 16, 2014 at 3:58 PM, Zachary Turner <zturner at google.com> wrote:
> Hi tfiala,
>
> This fixes a few issues related to running the test suite on Windows.
> Most notably, it makes lldb -P return the expected python path so this can
> be used by the test script.
>
> http://reviews.llvm.org/D4548
>
> Files:
> source/Host/common/Host.cpp
> source/Host/windows/Host.cpp
> test/dotest.py
>
> Index: source/Host/common/Host.cpp
> ===================================================================
> --- source/Host/common/Host.cpp
> +++ source/Host/common/Host.cpp
> @@ -1152,6 +1152,10 @@
> {
> char raw_path[PATH_MAX];
> char resolved_path[PATH_MAX];
> +#if defined(_WIN32)
> +
> lldb_file_spec.AppendPathComponent("../lib/site-packages");
> + lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
> +#else
> lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
>
> #if defined (__APPLE__)
> @@ -1174,7 +1178,7 @@
>
> ::strncat(raw_path, python_version_dir.c_str(),
> sizeof(raw_path) - strlen(raw_path) -
> 1);
> -
> +#endif
> #if defined (__APPLE__)
> }
> #endif
> Index: source/Host/windows/Host.cpp
> ===================================================================
> --- source/Host/windows/Host.cpp
> +++ source/Host/windows/Host.cpp
> @@ -247,6 +247,22 @@
> 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;
> + bool success = false;
> + bool error = false;
> + 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;
> }
>
> Index: test/dotest.py
> ===================================================================
> --- test/dotest.py
> +++ test/dotest.py
> @@ -883,11 +883,6 @@
> os.environ["LLDB_SRC"] = os.path.join(sys.path[0], os.pardir)
>
> pluginPath = os.path.join(scriptPath, 'plugins')
> - pexpectPath = os.path.join(scriptPath, 'pexpect-2.4')
> -
> - # Put embedded pexpect at front of the load path so we ensure we
> - # use that version.
> - sys.path.insert(0, pexpectPath)
>
> # Append script dir and plugin dir to the sys.path.
> sys.path.append(scriptPath)
> @@ -1004,17 +999,17 @@
>
> # If our lldb supports the -P option, use it to find the python
> path:
> init_in_python_dir = 'lldb/__init__.py'
> - import pexpect
> lldb_dash_p_result = None
>
> if lldbHere:
> - lldb_dash_p_result = pexpect.run("%s -P"%(lldbHere))
> + lldb_dash_p_result = subprocess.check_output("%s
> -P"%(lldbHere), stderr=subprocess.STDOUT)
> elif lldbExec:
> - lldb_dash_p_result = pexpect.run("%s -P"%(lldbExec))
> + lldb_dash_p_result = subprocess.check_output("%s
> -P"%(lldbExec), stderr=subprocess.STDOUT)
>
> - if lldb_dash_p_result and not lldb_dash_p_result.startswith(("<",
> "lldb: invalid option:")):
> + if lldb_dash_p_result and not lldb_dash_p_result.startswith(("<",
> "lldb: invalid option:")) \
> + and not
> lldb_dash_p_result.startswith("Traceback"):
> lines = lldb_dash_p_result.splitlines()
> - if len(lines) == 1 and os.path.isfile(os.path.join(lines[0],
> init_in_python_dir)):
> + if len(lines) >= 1 and os.path.isfile(os.path.join(lines[0],
> init_in_python_dir)):
> lldbPath = lines[0]
> if "freebsd" in sys.platform or "linux" in sys.platform:
> os.environ['LLDB_LIB_DIR'] = os.path.join(lldbPath,
> '..', '..')
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140718/69cc6d96/attachment.html>
More information about the lldb-commits
mailing list