<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This change breaks the OS X build by adding a direct dependency between lldb-mi and the static lldb-core library. The code in question is<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">bool</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">CMIUtilFileStd::IsFileExist(</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">const</span><span style="font-variant-ligatures: no-common-ligatures" class=""> CMIUtilString &vFileNamePath) </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">const</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (vFileNamePath.empty())</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">false</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> FILE *pTmp = lldb_private::FileSystem::Fopen(vFileNamePath.c_str(), </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"wb"</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (pTmp != </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nullptr</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> ::fclose(pTmp);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">true</span><span style="font-variant-ligatures: no-common-ligatures" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">false</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">This is the only lldb_private reference in the mi code, which is supposed to use the public API exclusively. I am going to revert this change only.</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Sean</span></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 22, 2016, at 10:58 AM, Zachary Turner via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: zturner<br class="">Date: Tue Mar 22 12:58:09 2016<br class="">New Revision: 264074<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264074&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=264074&view=rev</a><br class="">Log:<br class="">Unicode support on Win32.<br class=""><br class="">Win32 API calls that are Unicode aware require wide character<br class="">strings, but LLDB uses UTF8 everywhere. This patch does conversions<br class="">wherever necessary when passing strings into and out of Win32 API<br class="">calls.<br class=""><br class="">Patch by Cameron<br class="">Differential Revision: <a href="http://reviews.llvm.org/D17107" class="">http://reviews.llvm.org/D17107</a><br class="">Reviewed By: zturner, amccarth<br class=""><br class="">Modified:<br class=""> lldb/trunk/cmake/modules/LLDBConfig.cmake<br class=""> lldb/trunk/include/lldb/Host/FileSystem.h<br class=""> lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h<br class=""> lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h<br class=""> lldb/trunk/packages/Python/lldbsuite/test/dotest.py<br class=""> lldb/trunk/source/Commands/CommandCompletions.cpp<br class=""> lldb/trunk/source/Core/ConnectionSharedMemory.cpp<br class=""> lldb/trunk/source/Core/Disassembler.cpp<br class=""> lldb/trunk/source/Host/common/File.cpp<br class=""> lldb/trunk/source/Host/common/FileSpec.cpp<br class=""> lldb/trunk/source/Host/posix/FileSystem.cpp<br class=""> lldb/trunk/source/Host/posix/HostInfoPosix.cpp<br class=""> lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp<br class=""> lldb/trunk/source/Host/windows/FileSystem.cpp<br class=""> lldb/trunk/source/Host/windows/Host.cpp<br class=""> lldb/trunk/source/Host/windows/HostInfoWindows.cpp<br class=""> lldb/trunk/source/Host/windows/HostProcessWindows.cpp<br class=""> lldb/trunk/source/Host/windows/PipeWindows.cpp<br class=""> lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp<br class=""> lldb/trunk/source/Host/windows/Windows.cpp<br class=""> lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp<br class=""> lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp<br class=""> lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp<br class=""> lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp<br class=""> lldb/trunk/source/Target/ProcessLaunchInfo.cpp<br class=""> lldb/trunk/tools/driver/Driver.cpp<br class=""> lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp<br class=""> lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp<br class=""> lldb/trunk/tools/lldb-mi/Platform.h<br class=""><br class="">Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)<br class="">+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Tue Mar 22 12:58:09 2016<br class="">@@ -245,6 +245,11 @@ if( MSVC )<br class=""> )<br class=""> endif()<br class=""><br class="">+# Use the Unicode (UTF-16) APIs by default on Win32<br class="">+if (CMAKE_SYSTEM_NAME MATCHES "Windows")<br class="">+<span class="Apple-tab-span" style="white-space:pre"> </span>add_definitions( /D _UNICODE /D UNICODE )<br class="">+endif()<br class="">+<br class=""> set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})<br class=""> set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})<br class=""><br class=""><br class="">Modified: lldb/trunk/include/lldb/Host/FileSystem.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/include/lldb/Host/FileSystem.h (original)<br class="">+++ lldb/trunk/include/lldb/Host/FileSystem.h Tue Mar 22 12:58:09 2016<br class="">@@ -11,6 +11,8 @@<br class=""> #define liblldb_Host_FileSystem_h<br class=""><br class=""> #include <stdint.h><br class="">+#include <stdio.h><br class="">+#include <sys/stat.h><br class=""><br class=""> #include "lldb/lldb-types.h"<br class=""><br class="">@@ -23,6 +25,7 @@ class FileSystem<br class=""> {<br class=""> public:<br class=""> static const char *DEV_NULL;<br class="">+ static const char *PATH_CONVERSION_ERROR;<br class=""><br class=""> static FileSpec::PathSyntax GetNativePathSyntax();<br class=""><br class="">@@ -59,6 +62,15 @@ class FileSystem<br class=""><br class=""> /// Return \b true if \a spec is on a locally mounted file system, \b false otherwise.<br class=""> static bool IsLocal(const FileSpec &spec);<br class="">+<br class="">+ /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be<br class="">+ /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.<br class="">+ static FILE *<br class="">+ Fopen(const char *path, const char *mode);<br class="">+<br class="">+ /// Wraps ::stat in a platform-independent way.<br class="">+ static int<br class="">+ Stat(const char *path, struct stat *stats);<br class=""> };<br class=""> }<br class=""><br class=""><br class="">Modified: lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h (original)<br class="">+++ lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h Tue Mar 22 12:58:09 2016<br class="">@@ -33,7 +33,10 @@ class HostInfoPosix : public HostInfoBas<br class=""><br class=""> static FileSpec GetDefaultShell();<br class=""><br class="">- protected:<br class="">+ static bool<br class="">+ GetEnvironmentVar(const std::string &var_name, std::string &var);<br class="">+<br class="">+protected:<br class=""> static bool ComputeSupportExeDirectory(FileSpec &file_spec);<br class=""> static bool ComputeHeaderDirectory(FileSpec &file_spec);<br class=""> static bool ComputePythonDirectory(FileSpec &file_spec);<br class=""><br class="">Modified: lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h (original)<br class="">+++ lldb/trunk/include/lldb/Host/windows/HostInfoWindows.h Tue Mar 22 12:58:09 2016<br class="">@@ -47,6 +47,9 @@ class HostInfoWindows : public HostInfoB<br class=""> static FileSpec<br class=""> GetDefaultShell();<br class=""><br class="">+ static bool<br class="">+ GetEnvironmentVar(const std::string &var_name, std::string &var);<br class="">+<br class=""> protected:<br class=""> static bool ComputePythonDirectory(FileSpec &file_spec);<br class=""><br class=""><br class="">Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)<br class="">+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Tue Mar 22 12:58:09 2016<br class="">@@ -659,7 +659,7 @@ def setupSysPath():<br class=""> print(" location of LLDB\'s site-packages folder.")<br class=""> print(" 3) A different version of Python than that which was built against is exported in")<br class=""> print(" the system\'s PATH environment variable, causing conflicts.")<br class="">- print(" 4) The executable '%s' could not be found. Please check " % lldbExecutable)<br class="">+ print(" 4) The executable '%s' could not be found. Please check " % lldbtest_config.lldbExec)<br class=""> print(" that it exists and is executable.")<br class=""><br class=""> if lldbPythonDir:<br class=""><br class="">Modified: lldb/trunk/source/Commands/CommandCompletions.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)<br class="">+++ lldb/trunk/source/Commands/CommandCompletions.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -18,10 +18,11 @@<br class=""> #include "llvm/ADT/SmallString.h"<br class=""><br class=""> // Project includes<br class="">-#include "lldb/Host/FileSpec.h"<br class=""> #include "lldb/Core/FileSpecList.h"<br class="">-#include "lldb/Core/PluginManager.h"<br class=""> #include "lldb/Core/Module.h"<br class="">+#include "lldb/Core/PluginManager.h"<br class="">+#include "lldb/Host/FileSpec.h"<br class="">+#include "lldb/Host/FileSystem.h"<br class=""> #include "lldb/Interpreter/Args.h"<br class=""> #include "lldb/Interpreter/CommandCompletions.h"<br class=""> #include "lldb/Interpreter/CommandInterpreter.h"<br class="">@@ -31,6 +32,8 @@<br class=""> #include "lldb/Target/Target.h"<br class=""> #include "lldb/Utility/CleanUp.h"<br class=""><br class="">+#include "llvm/ADT/SmallString.h"<br class="">+<br class=""> using namespace lldb_private;<br class=""><br class=""> CommandCompletions::CommonCompletionElement<br class="">@@ -160,8 +163,7 @@ FileSpec::EnumerateDirectoryResult DiskF<br class=""> isa_directory = true;<br class=""> else if (file_type == FileSpec::eFileTypeSymbolicLink)<br class=""> {<br class="">- struct stat stat_buf;<br class="">- if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))<br class="">+ if (FileSpec(partial_name_copy, false).IsDirectory())<br class=""> isa_directory = true;<br class=""> }<br class=""><br class=""><br class="">Modified: lldb/trunk/source/Core/ConnectionSharedMemory.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Core/ConnectionSharedMemory.cpp (original)<br class="">+++ lldb/trunk/source/Core/ConnectionSharedMemory.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -32,6 +32,8 @@<br class=""> #include "lldb/Core/Communication.h"<br class=""> #include "lldb/Core/Log.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class=""> using namespace lldb;<br class=""> using namespace lldb_private;<br class=""><br class="">@@ -135,18 +137,18 @@ ConnectionSharedMemory::Open (bool creat<br class=""> m_name.assign (name);<br class=""><br class=""> #ifdef _WIN32<br class="">- HANDLE handle;<br class="">- if (create) {<br class="">- handle = CreateFileMapping(<br class="">- INVALID_HANDLE_VALUE,<br class="">- nullptr,<br class="">- PAGE_READWRITE,<br class="">- llvm::Hi_32(size),<br class="">- llvm::Lo_32(size),<br class="">- name);<br class="">+ HANDLE handle = INVALID_HANDLE_VALUE;<br class="">+ std::wstring wname;<br class="">+ if (llvm::ConvertUTF8toWide(name, wname))<br class="">+ {<br class="">+ if (create)<br class="">+ {<br class="">+ handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, llvm::Hi_32(size),<br class="">+ llvm::Lo_32(size), wname.c_str());<br class="">+ }<br class="">+ else<br class="">+ handle = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, wname.c_str());<br class=""> }<br class="">- else<br class="">- handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name);<br class=""><br class=""> m_fd = _open_osfhandle((intptr_t)handle, 0);<br class=""> #else<br class=""><br class="">Modified: lldb/trunk/source/Core/Disassembler.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Core/Disassembler.cpp (original)<br class="">+++ lldb/trunk/source/Core/Disassembler.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -16,16 +16,16 @@<br class=""><br class=""> // Other libraries and framework includes<br class=""> // Project includes<br class="">-#include "lldb/lldb-private.h"<br class="">-#include "lldb/Core/Error.h"<br class=""> #include "lldb/Core/DataBufferHeap.h"<br class=""> #include "lldb/Core/DataExtractor.h"<br class=""> #include "lldb/Core/Debugger.h"<br class=""> #include "lldb/Core/EmulateInstruction.h"<br class="">+#include "lldb/Core/Error.h"<br class=""> #include "lldb/Core/Module.h"<br class=""> #include "lldb/Core/PluginManager.h"<br class=""> #include "lldb/Core/RegularExpression.h"<br class=""> #include "lldb/Core/Timer.h"<br class="">+#include "lldb/Host/FileSystem.h"<br class=""> #include "lldb/Interpreter/OptionValue.h"<br class=""> #include "lldb/Interpreter/OptionValueArray.h"<br class=""> #include "lldb/Interpreter/OptionValueDictionary.h"<br class="">@@ -38,6 +38,7 @@<br class=""> #include "lldb/Target/SectionLoadList.h"<br class=""> #include "lldb/Target/StackFrame.h"<br class=""> #include "lldb/Target/Target.h"<br class="">+#include "lldb/lldb-private.h"<br class=""><br class=""> #define DEFAULT_DISASM_BYTE_SIZE 32<br class=""><br class="">@@ -849,8 +850,7 @@ Instruction::TestEmulation (Stream *out_<br class=""> out_stream->Printf ("Instruction::TestEmulation: Missing file_name.");<br class=""> return false;<br class=""> }<br class="">- <br class="">- FILE *test_file = fopen (file_name, "r");<br class="">+ FILE *test_file = FileSystem::Fopen(file_name, "r");<br class=""> if (!test_file)<br class=""> {<br class=""> out_stream->Printf ("Instruction::TestEmulation: Attempt to open test file failed.");<br class=""><br class="">Modified: lldb/trunk/source/Host/common/File.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/common/File.cpp (original)<br class="">+++ lldb/trunk/source/Host/common/File.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -14,7 +14,6 @@<br class=""> #include <limits.h><br class=""> #include <stdarg.h><br class=""> #include <stdio.h><br class="">-#include <sys/stat.h><br class=""><br class=""> #ifdef _WIN32<br class=""> #include "lldb/Host/windows/windows.h"<br class="">@@ -22,6 +21,7 @@<br class=""> #include <sys/ioctl.h><br class=""> #endif<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors()<br class=""><br class=""> #include "lldb/Core/DataBufferHeap.h"<br class="">@@ -29,6 +29,7 @@<br class=""> #include "lldb/Core/Log.h"<br class=""> #include "lldb/Host/Config.h"<br class=""> #include "lldb/Host/FileSpec.h"<br class="">+#include "lldb/Host/FileSystem.h"<br class=""><br class=""> using namespace lldb;<br class=""> using namespace lldb_private;<br class="">@@ -267,7 +268,18 @@ File::Open (const char *path, uint32_t o<br class=""><br class=""> do<br class=""> {<br class="">+#ifdef _WIN32<br class="">+ std::wstring wpath;<br class="">+ if (!llvm::ConvertUTF8toWide(path, wpath))<br class="">+ {<br class="">+ m_descriptor = -1;<br class="">+ error.SetErrorString("Error converting path to UTF-16");<br class="">+ return error;<br class="">+ }<br class="">+ ::_wsopen_s(&m_descriptor, wpath.c_str(), oflag, _SH_DENYNO, mode);<br class="">+#else<br class=""> m_descriptor = ::open(path, oflag, mode);<br class="">+#endif<br class=""> } while (m_descriptor < 0 && errno == EINTR);<br class=""><br class=""> if (!DescriptorIsValid())<br class="">@@ -287,7 +299,8 @@ File::GetPermissions(const FileSpec &fil<br class=""> if (file_spec)<br class=""> {<br class=""> struct stat file_stats;<br class="">- if (::stat(file_spec.GetCString(), &file_stats) == -1)<br class="">+ int stat_result = FileSystem::Stat(file_spec.GetCString(), &file_stats);<br class="">+ if (stat_result == -1)<br class=""> error.SetErrorToErrno();<br class=""> else<br class=""> {<br class=""><br class="">Modified: lldb/trunk/source/Host/common/FileSpec.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/common/FileSpec.cpp (original)<br class="">+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -17,7 +17,6 @@<br class=""> #ifndef _MSC_VER<br class=""> #include <libgen.h><br class=""> #endif<br class="">-#include <sys/stat.h><br class=""> #include <set><br class=""> #include <string.h><br class=""> #include <fstream><br class="">@@ -40,6 +39,7 @@<br class=""> #include "lldb/Utility/CleanUp.h"<br class=""><br class=""> #include "llvm/ADT/StringRef.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/FileSystem.h"<br class=""> #include "llvm/Support/Path.h"<br class=""> #include "llvm/Support/Program.h"<br class="">@@ -90,7 +90,7 @@ GetFileStats (const FileSpec *file_spec,<br class=""> {<br class=""> char resolved_path[PATH_MAX];<br class=""> if (file_spec->GetPath (resolved_path, sizeof(resolved_path)))<br class="">- return ::stat (resolved_path, stats_ptr) == 0;<br class="">+ return FileSystem::Stat(resolved_path, stats_ptr) == 0;<br class=""> return false;<br class=""> }<br class=""><br class="">@@ -206,15 +206,10 @@ FileSpec::Resolve (llvm::SmallVectorImpl<br class=""> #endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER<br class=""><br class=""> // Save a copy of the original path that's passed in<br class="">- llvm::SmallString<PATH_MAX> original_path(path.begin(), path.end());<br class="">+ llvm::SmallString<128> original_path(path.begin(), path.end());<br class=""><br class=""> llvm::sys::fs::make_absolute(path);<br class="">-<br class="">- <br class="">- path.push_back(0); // Be sure we have a nul terminated string<br class="">- path.pop_back();<br class="">- struct stat file_stats;<br class="">- if (::stat (path.data(), &file_stats) != 0)<br class="">+ if (!llvm::sys::fs::exists(path))<br class=""> {<br class=""> path.clear();<br class=""> path.append(original_path.begin(), original_path.end());<br class="">@@ -815,7 +810,10 @@ FileSpec::IsSymbolicLink () const<br class=""> return false;<br class=""><br class=""> #ifdef _WIN32<br class="">- auto attrs = ::GetFileAttributes (resolved_path);<br class="">+ std::wstring wpath;<br class="">+ if (!llvm::ConvertUTF8toWide(resolved_path, wpath))<br class="">+ return false;<br class="">+ auto attrs = ::GetFileAttributesW(wpath.c_str());<br class=""> if (attrs == INVALID_FILE_ATTRIBUTES)<br class=""> return false;<br class=""><br class="">@@ -1114,12 +1112,18 @@ FileSpec::ForEachItemInDirectory (const<br class=""> {<br class=""> if (dir_path && dir_path[0])<br class=""> {<br class="">-#if _WIN32<br class="">+#ifdef _WIN32<br class=""> std::string szDir(dir_path);<br class=""> szDir += "\\*";<br class=""><br class="">- WIN32_FIND_DATA ffd;<br class="">- HANDLE hFind = FindFirstFile(szDir.c_str(), &ffd);<br class="">+ std::wstring wszDir;<br class="">+ if (!llvm::ConvertUTF8toWide(szDir, wszDir))<br class="">+ {<br class="">+ return eEnumerateDirectoryResultNext;<br class="">+ }<br class="">+<br class="">+ WIN32_FIND_DATAW ffd;<br class="">+ HANDLE hFind = FindFirstFileW(wszDir.c_str(), &ffd);<br class=""><br class=""> if (hFind == INVALID_HANDLE_VALUE)<br class=""> {<br class="">@@ -1131,12 +1135,12 @@ FileSpec::ForEachItemInDirectory (const<br class=""> FileSpec::FileType file_type = eFileTypeUnknown;<br class=""> if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)<br class=""> {<br class="">- size_t len = strlen(ffd.cFileName);<br class="">+ size_t len = wcslen(ffd.cFileName);<br class=""><br class="">- if (len == 1 && ffd.cFileName[0] == '.')<br class="">+ if (len == 1 && ffd.cFileName[0] == L'.')<br class=""> continue;<br class=""><br class="">- if (len == 2 && ffd.cFileName[0] == '.' && ffd.cFileName[1] == '.')<br class="">+ if (len == 2 && ffd.cFileName[0] == L'.' && ffd.cFileName[1] == L'.')<br class=""> continue;<br class=""><br class=""> file_type = eFileTypeDirectory;<br class="">@@ -1150,12 +1154,19 @@ FileSpec::ForEachItemInDirectory (const<br class=""> file_type = eFileTypeRegular;<br class=""> }<br class=""><br class="">- char child_path[MAX_PATH];<br class="">- const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s\\%s", dir_path, ffd.cFileName);<br class="">- if (child_path_len < (int)(sizeof(child_path) - 1))<br class="">+ std::string fileName;<br class="">+ if (!llvm::convertWideToUTF8(ffd.cFileName, fileName))<br class="">+ {<br class="">+ continue;<br class="">+ }<br class="">+<br class="">+ std::vector<char> child_path(PATH_MAX);<br class="">+ const int child_path_len =<br class="">+ ::snprintf(child_path.data(), child_path.size(), "%s\\%s", dir_path, fileName.c_str());<br class="">+ if (child_path_len < (int)(child_path.size() - 1))<br class=""> {<br class=""> // Don't resolve the file type or path<br class="">- FileSpec child_path_spec (child_path, false);<br class="">+ FileSpec child_path_spec(child_path.data(), false);<br class=""><br class=""> EnumerateDirectoryResult result = callback (file_type, child_path_spec);<br class=""><br class="">@@ -1168,7 +1179,8 @@ FileSpec::ForEachItemInDirectory (const<br class=""> break;<br class=""><br class=""> case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not<br class="">- if (FileSpec::ForEachItemInDirectory(child_path, callback) == eEnumerateDirectoryResultQuit)<br class="">+ if (FileSpec::ForEachItemInDirectory(child_path.data(), callback) ==<br class="">+ eEnumerateDirectoryResultQuit)<br class=""> {<br class=""> // The subdirectory returned Quit, which means to<br class=""> // stop all directory enumerations at all levels.<br class="">@@ -1185,7 +1197,7 @@ FileSpec::ForEachItemInDirectory (const<br class=""> return eEnumerateDirectoryResultQuit;<br class=""> }<br class=""> }<br class="">- } while (FindNextFile(hFind, &ffd) != 0);<br class="">+ } while (FindNextFileW(hFind, &ffd) != 0);<br class=""><br class=""> FindClose(hFind);<br class=""> #else<br class=""><br class="">Modified: lldb/trunk/source/Host/posix/FileSystem.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/FileSystem.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/FileSystem.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/posix/FileSystem.cpp (original)<br class="">+++ lldb/trunk/source/Host/posix/FileSystem.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -299,3 +299,15 @@ FileSystem::IsLocal(const FileSpec &spec<br class=""> return false;<br class=""> }<br class=""> #endif<br class="">+<br class="">+FILE *<br class="">+FileSystem::Fopen(const char *path, const char *mode)<br class="">+{<br class="">+ return ::fopen(path, mode);<br class="">+}<br class="">+<br class="">+int<br class="">+FileSystem::Stat(const char *path, struct stat *stats)<br class="">+{<br class="">+ return ::stat(path, stats);<br class="">+}<br class=""><br class="">Modified: lldb/trunk/source/Host/posix/HostInfoPosix.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/posix/HostInfoPosix.cpp (original)<br class="">+++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -242,3 +242,14 @@ HostInfoPosix::ComputePythonDirectory(Fi<br class=""> return false;<br class=""> #endif<br class=""> }<br class="">+<br class="">+bool<br class="">+HostInfoPosix::GetEnvironmentVar(const std::string &var_name, std::string &var)<br class="">+{<br class="">+ if (const char *pvar = ::getenv(var_name.c_str()))<br class="">+ {<br class="">+ var = std::string(pvar);<br class="">+ return true;<br class="">+ }<br class="">+ return false;<br class="">+}<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -14,6 +14,7 @@<br class=""><br class=""> #include "llvm/ADT/STLExtras.h"<br class=""> #include "llvm/ADT/StringRef.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""><br class=""> using namespace lldb;<br class=""> using namespace lldb_private;<br class="">@@ -138,7 +139,15 @@ ConnectionGenericFile::Connect(const cha<br class=""> // Open the file for overlapped access. If it does not exist, create it. We open it overlapped<br class=""> // so that we can issue asynchronous reads and then use WaitForMultipleObjects to allow the read<br class=""> // to be interrupted by an event object.<br class="">- m_file = ::CreateFile(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_FLAG_OVERLAPPED, NULL);<br class="">+ std::wstring wpath;<br class="">+ if (!llvm::ConvertUTF8toWide(path, wpath))<br class="">+ {<br class="">+ if (error_ptr)<br class="">+ error_ptr->SetError(1, eErrorTypeGeneric);<br class="">+ return eConnectionStatusError;<br class="">+ }<br class="">+ m_file = ::CreateFileW(wpath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,<br class="">+ FILE_FLAG_OVERLAPPED, NULL);<br class=""> if (m_file == INVALID_HANDLE_VALUE)<br class=""> {<br class=""> if (error_ptr)<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/FileSystem.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/FileSystem.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/FileSystem.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/FileSystem.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/FileSystem.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -15,6 +15,8 @@<br class=""><br class=""> #include "lldb/Host/FileSystem.h"<br class=""> #include "lldb/Host/windows/AutoHandle.h"<br class="">+<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/FileSystem.h"<br class=""><br class=""> using namespace lldb_private;<br class="">@@ -22,6 +24,8 @@ using namespace lldb_private;<br class=""> const char *<br class=""> FileSystem::DEV_NULL = "nul";<br class=""><br class="">+const char *FileSystem::PATH_CONVERSION_ERROR = "Error converting path between UTF-8 and native encoding";<br class="">+<br class=""> FileSpec::PathSyntax<br class=""> FileSystem::GetNativePathSyntax()<br class=""> {<br class="">@@ -47,25 +51,32 @@ Error<br class=""> FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse)<br class=""> {<br class=""> Error error;<br class="">+ std::wstring path_buffer;<br class="">+ if (!llvm::ConvertUTF8toWide(file_spec.GetPath(), path_buffer))<br class="">+ {<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class="">+ return error;<br class="">+ }<br class=""> if (!recurse)<br class=""> {<br class="">- BOOL result = ::RemoveDirectory(file_spec.GetCString());<br class="">+ BOOL result = ::RemoveDirectoryW(path_buffer.c_str());<br class=""> if (!result)<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> }<br class=""> else<br class=""> {<br class=""> // SHFileOperation() accepts a list of paths, and so must be double-null-terminated to<br class="">- // indicate the end of the list.<br class="">- std::string path_buffer{file_spec.GetPath()};<br class="">+ // indicate the end of the list. The first null terminator is there only in the backing<br class="">+ // store but not the actual vector contents, and so we need to push twice.<br class="">+ path_buffer.push_back(0);<br class=""> path_buffer.push_back(0);<br class=""><br class="">- SHFILEOPSTRUCT shfos = {0};<br class="">+ SHFILEOPSTRUCTW shfos = {0};<br class=""> shfos.wFunc = FO_DELETE;<br class="">- shfos.pFrom = path_buffer.c_str();<br class="">+ shfos.pFrom = (LPCWSTR)path_buffer.data();<br class=""> shfos.fFlags = FOF_NO_UI;<br class=""><br class="">- int result = ::SHFileOperation(&shfos);<br class="">+ int result = ::SHFileOperationW(&shfos);<br class=""> // TODO(zturner): Correctly handle the intricacies of SHFileOperation return values.<br class=""> if (result != 0)<br class=""> error.SetErrorStringWithFormat("SHFileOperation failed");<br class="">@@ -121,7 +132,10 @@ Error<br class=""> FileSystem::Hardlink(const FileSpec &src, const FileSpec &dst)<br class=""> {<br class=""> Error error;<br class="">- if (!::CreateHardLink(src.GetCString(), dst.GetCString(), nullptr))<br class="">+ std::wstring wsrc, wdst;<br class="">+ if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc) || !llvm::ConvertUTF8toWide(dst.GetCString(), wdst))<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class="">+ else if (!::CreateHardLinkW(wsrc.c_str(), wdst.c_str(), nullptr))<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> return error;<br class=""> }<br class="">@@ -129,13 +143,12 @@ FileSystem::Hardlink(const FileSpec &src<br class=""> int<br class=""> FileSystem::GetHardlinkCount(const FileSpec &file_spec)<br class=""> {<br class="">- HANDLE file_handle = ::CreateFile(file_spec.GetCString(),<br class="">- FILE_READ_ATTRIBUTES,<br class="">- FILE_SHARE_READ,<br class="">- nullptr,<br class="">- OPEN_EXISTING,<br class="">- FILE_ATTRIBUTE_NORMAL,<br class="">- nullptr);<br class="">+ std::wstring path;<br class="">+ if (!llvm::ConvertUTF8toWide(file_spec.GetCString(), path))<br class="">+ return -1;<br class="">+<br class="">+ HANDLE file_handle = ::CreateFileW(path.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING,<br class="">+ FILE_ATTRIBUTE_NORMAL, nullptr);<br class=""><br class=""> if (file_handle == INVALID_HANDLE_VALUE)<br class=""> return -1;<br class="">@@ -152,7 +165,12 @@ Error<br class=""> FileSystem::Symlink(const FileSpec &src, const FileSpec &dst)<br class=""> {<br class=""> Error error;<br class="">- DWORD attrib = ::GetFileAttributes(dst.GetCString());<br class="">+ std::wstring wsrc, wdst;<br class="">+ if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc) || !llvm::ConvertUTF8toWide(dst.GetCString(), wdst))<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class="">+ if (error.Fail())<br class="">+ return error;<br class="">+ DWORD attrib = ::GetFileAttributesW(wdst.c_str());<br class=""> if (attrib == INVALID_FILE_ATTRIBUTES)<br class=""> {<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class="">@@ -160,7 +178,7 @@ FileSystem::Symlink(const FileSpec &src,<br class=""> }<br class=""> bool is_directory = !!(attrib & FILE_ATTRIBUTE_DIRECTORY);<br class=""> DWORD flag = is_directory ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0;<br class="">- BOOL result = ::CreateSymbolicLink(src.GetCString(), dst.GetCString(), flag);<br class="">+ BOOL result = ::CreateSymbolicLinkW(wsrc.c_str(), wdst.c_str(), flag);<br class=""> if (!result)<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> return error;<br class="">@@ -170,7 +188,13 @@ Error<br class=""> FileSystem::Unlink(const FileSpec &file_spec)<br class=""> {<br class=""> Error error;<br class="">- BOOL result = ::DeleteFile(file_spec.GetCString());<br class="">+ std::wstring path;<br class="">+ if (!llvm::ConvertUTF8toWide(file_spec.GetCString(), path))<br class="">+ {<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class="">+ return error;<br class="">+ }<br class="">+ BOOL result = ::DeleteFileW(path.c_str());<br class=""> if (!result)<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> return error;<br class="">@@ -180,23 +204,31 @@ Error<br class=""> FileSystem::Readlink(const FileSpec &src, FileSpec &dst)<br class=""> {<br class=""> Error error;<br class="">- HANDLE h = ::CreateFile(src.GetCString(), GENERIC_READ,<br class="">- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,<br class="">- FILE_FLAG_OPEN_REPARSE_POINT, NULL);<br class="">+ std::wstring wsrc;<br class="">+ if (!llvm::ConvertUTF8toWide(src.GetCString(), wsrc))<br class="">+ {<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class="">+ return error;<br class="">+ }<br class="">+<br class="">+ HANDLE h = ::CreateFileW(wsrc.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,<br class="">+ FILE_FLAG_OPEN_REPARSE_POINT, NULL);<br class=""> if (h == INVALID_HANDLE_VALUE)<br class=""> {<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> return error;<br class=""> }<br class=""><br class="">- char buf[PATH_MAX];<br class="">+ std::vector<wchar_t> buf(PATH_MAX + 1);<br class=""> // Subtract 1 from the path length since this function does not add a null terminator.<br class="">- DWORD result = ::GetFinalPathNameByHandle(h, buf, sizeof(buf) - 1,<br class="">- FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);<br class="">+ DWORD result = ::GetFinalPathNameByHandleW(h, buf.data(), buf.size() - 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);<br class="">+ std::string path;<br class=""> if (result == 0)<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class="">+ else if (!llvm::convertWideToUTF8(buf.data(), path))<br class="">+ error.SetErrorString(PATH_CONVERSION_ERROR);<br class=""> else<br class="">- dst.SetFile(buf, false);<br class="">+ dst.SetFile(path, false);<br class=""><br class=""> ::CloseHandle(h);<br class=""> return error;<br class="">@@ -219,3 +251,43 @@ FileSystem::IsLocal(const FileSpec &spec<br class=""><br class=""> return false;<br class=""> }<br class="">+<br class="">+FILE *<br class="">+FileSystem::Fopen(const char *path, const char *mode)<br class="">+{<br class="">+ std::wstring wpath, wmode;<br class="">+ if (!llvm::ConvertUTF8toWide(path, wpath))<br class="">+ return nullptr;<br class="">+ if (!llvm::ConvertUTF8toWide(mode, wmode))<br class="">+ return nullptr;<br class="">+ FILE *file;<br class="">+ if (_wfopen_s(&file, wpath.c_str(), wmode.c_str()) != 0)<br class="">+ return nullptr;<br class="">+ return file;<br class="">+}<br class="">+<br class="">+int<br class="">+FileSystem::Stat(const char *path, struct stat *stats)<br class="">+{<br class="">+ std::wstring wpath;<br class="">+ if (!llvm::ConvertUTF8toWide(path, wpath))<br class="">+ {<br class="">+ errno = EINVAL;<br class="">+ return -EINVAL;<br class="">+ }<br class="">+ int stat_result;<br class="">+#ifdef _USE_32BIT_TIME_T<br class="">+ struct _stat32 file_stats;<br class="">+ stat_result = ::_wstat32(wpath.c_str(), &file_stats);<br class="">+#else<br class="">+ struct _stat64i32 file_stats;<br class="">+ stat_result = ::_wstat64i32(wpath.c_str(), &file_stats);<br class="">+#endif<br class="">+ if (stat_result == 0)<br class="">+ {<br class="">+ static_assert(sizeof(struct stat) == sizeof(file_stats),<br class="">+ "stat and _stat32/_stat64i32 must have the same layout");<br class="">+ *stats = *reinterpret_cast<struct stat *>(&file_stats);<br class="">+ }<br class="">+ return stat_result;<br class="">+}<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/Host.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/Host.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/Host.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -26,6 +26,8 @@<br class=""> #include "lldb/Core/StreamFile.h"<br class=""> #include "lldb/Core/StructuredData.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class=""> // Windows includes<br class=""> #include <TlHelp32.h><br class=""><br class="">@@ -68,12 +70,11 @@ namespace<br class=""> bool GetExecutableForProcess(const AutoHandle &handle, std::string &path)<br class=""> {<br class=""> // Get the process image path. MAX_PATH isn't long enough, paths can actually be up to 32KB.<br class="">- std::vector<char> buffer(32768);<br class="">+ std::vector<wchar_t> buffer(PATH_MAX);<br class=""> DWORD dwSize = buffer.size();<br class="">- if (!::QueryFullProcessImageNameA(handle.get(), 0, &buffer[0], &dwSize))<br class="">+ if (!::QueryFullProcessImageNameW(handle.get(), 0, &buffer[0], &dwSize))<br class=""> return false;<br class="">- path.assign(&buffer[0]);<br class="">- return true;<br class="">+ return llvm::convertWideToUTF8(buffer.data(), path);<br class=""> }<br class=""><br class=""> void GetProcessExecutableAndTriple(const AutoHandle &handle, ProcessInstanceInfo &process)<br class="">@@ -156,15 +157,17 @@ Host::GetModuleFileSpecForHostAddress (c<br class=""> if (!::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)host_addr, &hmodule))<br class=""> return module_filespec;<br class=""><br class="">- std::vector<char> buffer(MAX_PATH);<br class="">+ std::vector<wchar_t> buffer(PATH_MAX);<br class=""> DWORD chars_copied = 0;<br class=""> do {<br class="">- chars_copied = ::GetModuleFileName(hmodule, &buffer[0], buffer.size());<br class="">+ chars_copied = ::GetModuleFileNameW(hmodule, &buffer[0], buffer.size());<br class=""> if (chars_copied == buffer.size() && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER)<br class=""> buffer.resize(buffer.size() * 2);<br class=""> } while (chars_copied >= buffer.size());<br class="">-<br class="">- module_filespec.SetFile(&buffer[0], false);<br class="">+ std::string path;<br class="">+ if (!llvm::convertWideToUTF8(buffer.data(), path))<br class="">+ return module_filespec;<br class="">+ module_filespec.SetFile(path, false);<br class=""> return module_filespec;<br class=""> }<br class=""><br class="">@@ -177,23 +180,25 @@ Host::FindProcesses (const ProcessInstan<br class=""> if (!snapshot.IsValid())<br class=""> return 0;<br class=""><br class="">- PROCESSENTRY32 pe = {0};<br class="">- pe.dwSize = sizeof(PROCESSENTRY32);<br class="">- if (Process32First(snapshot.get(), &pe))<br class="">+ PROCESSENTRY32W pe = {0};<br class="">+ pe.dwSize = sizeof(PROCESSENTRY32W);<br class="">+ if (Process32FirstW(snapshot.get(), &pe))<br class=""> {<br class=""> do<br class=""> {<br class=""> AutoHandle handle(::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pe.th32ProcessID), nullptr);<br class=""><br class=""> ProcessInstanceInfo process;<br class="">- process.SetExecutableFile(FileSpec(pe.szExeFile, false), true);<br class="">+ std::string exeFile;<br class="">+ llvm::convertWideToUTF8(pe.szExeFile, exeFile);<br class="">+ process.SetExecutableFile(FileSpec(exeFile, false), true);<br class=""> process.SetProcessID(pe.th32ProcessID);<br class=""> process.SetParentProcessID(pe.th32ParentProcessID);<br class=""> GetProcessExecutableAndTriple(handle, process);<br class=""><br class=""> if (match_info.MatchAllProcesses() || match_info.Matches(process))<br class=""> process_infos.Append(process);<br class="">- } while (Process32Next(snapshot.get(), &pe));<br class="">+ } while (Process32NextW(snapshot.get(), &pe));<br class=""> }<br class=""> return process_infos.GetSize();<br class=""> }<br class="">@@ -312,15 +317,21 @@ Host::GetEnvironment(StringList &env)<br class=""> {<br class=""> // The environment block on Windows is a contiguous buffer of NULL terminated strings,<br class=""> // where the end of the environment block is indicated by two consecutive NULLs.<br class="">- LPCH environment_block = ::GetEnvironmentStrings();<br class="">+ LPWCH environment_block = ::GetEnvironmentStringsW();<br class=""> env.Clear();<br class="">- while (*environment_block != '\0')<br class="">+ while (*environment_block != L'\0')<br class=""> {<br class="">- llvm::StringRef current_var(environment_block);<br class="">+ std::string current_var;<br class="">+ auto current_var_size = wcslen(environment_block) + 1;<br class="">+ if (!llvm::convertWideToUTF8(environment_block, current_var))<br class="">+ {<br class="">+ environment_block += current_var_size;<br class="">+ continue;<br class="">+ }<br class=""> if (current_var[0] != '=')<br class=""> env.AppendString(current_var);<br class=""><br class="">- environment_block += current_var.size()+1;<br class="">+ environment_block += current_var_size;<br class=""> }<br class=""> return env.GetSize();<br class=""> }<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/HostInfoWindows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostInfoWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostInfoWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/HostInfoWindows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/HostInfoWindows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -15,9 +15,10 @@<br class=""><br class=""> #include "lldb/Host/windows/HostInfoWindows.h"<br class=""> #include "llvm/ADT/SmallString.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/FileSystem.h"<br class="">-#include "llvm/Support/raw_ostream.h"<br class=""> #include "llvm/Support/Path.h"<br class="">+#include "llvm/Support/raw_ostream.h"<br class=""><br class=""> using namespace lldb_private;<br class=""><br class="">@@ -92,23 +93,24 @@ HostInfoWindows::GetOSKernelDescription(<br class=""> bool<br class=""> HostInfoWindows::GetHostname(std::string &s)<br class=""> {<br class="">- char buffer[MAX_COMPUTERNAME_LENGTH + 1];<br class="">+ wchar_t buffer[MAX_COMPUTERNAME_LENGTH + 1];<br class=""> DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;<br class="">- if (!::GetComputerName(buffer, &dwSize))<br class="">+ if (!::GetComputerNameW(buffer, &dwSize))<br class=""> return false;<br class=""><br class="">- s.assign(buffer, buffer + dwSize);<br class="">- return true;<br class="">+ return llvm::convertWideToUTF8(buffer, s);<br class=""> }<br class=""><br class=""> FileSpec<br class=""> HostInfoWindows::GetProgramFileSpec()<br class=""> {<br class=""> static std::once_flag g_once_flag;<br class="">- std::call_once(g_once_flag, []() {<br class="">- char buffer[PATH_MAX];<br class="">- ::GetModuleFileName(NULL, buffer, sizeof(buffer));<br class="">- m_program_filespec.SetFile(buffer, false);<br class="">+ std::call_once(g_once_flag, []() {<br class="">+ std::vector<wchar_t> buffer(PATH_MAX);<br class="">+ ::GetModuleFileNameW(NULL, buffer.data(), buffer.size());<br class="">+ std::string path;<br class="">+ llvm::convertWideToUTF8(buffer.data(), path);<br class="">+ m_program_filespec.SetFile(path, false);<br class=""> });<br class=""> return m_program_filespec;<br class=""> }<br class="">@@ -116,7 +118,9 @@ HostInfoWindows::GetProgramFileSpec()<br class=""> FileSpec<br class=""> HostInfoWindows::GetDefaultShell()<br class=""> {<br class="">- return FileSpec(::getenv("ComSpec"), false);<br class="">+ std::string shell;<br class="">+ GetEnvironmentVar("ComSpec", shell);<br class="">+ return FileSpec(shell, false);<br class=""> }<br class=""><br class=""> bool<br class="">@@ -132,3 +136,15 @@ HostInfoWindows::ComputePythonDirectory(<br class=""> file_spec.GetDirectory().SetString(path.c_str());<br class=""> return true;<br class=""> }<br class="">+<br class="">+bool<br class="">+HostInfoWindows::GetEnvironmentVar(const std::string &var_name, std::string &var)<br class="">+{<br class="">+ std::wstring wvar_name;<br class="">+ if (!llvm::ConvertUTF8toWide(var_name, wvar_name))<br class="">+ return false;<br class="">+<br class="">+ if (const wchar_t *wvar = _wgetenv(wvar_name.c_str()))<br class="">+ return llvm::convertWideToUTF8(wvar, var);<br class="">+ return false;<br class="">+}<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/HostProcessWindows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostProcessWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostProcessWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/HostProcessWindows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/HostProcessWindows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -14,6 +14,7 @@<br class=""> #include "lldb/Host/windows/HostProcessWindows.h"<br class=""><br class=""> #include "llvm/ADT/STLExtras.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""><br class=""> #include <Psapi.h><br class=""><br class="">@@ -70,9 +71,15 @@ Error HostProcessWindows::GetMainModule(<br class=""> if (m_process == nullptr)<br class=""> error.SetError(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32);<br class=""><br class="">- char path[MAX_PATH] = { 0 };<br class="">- if (::GetProcessImageFileName(m_process, path, llvm::array_lengthof(path)))<br class="">- file_spec.SetFile(path, false);<br class="">+ std::vector<wchar_t> wpath(PATH_MAX);<br class="">+ if (::GetProcessImageFileNameW(m_process, wpath.data(), wpath.size()))<br class="">+ {<br class="">+ std::string path;<br class="">+ if (llvm::convertWideToUTF8(wpath.data(), path))<br class="">+ file_spec.SetFile(path, false);<br class="">+ else<br class="">+ error.SetErrorString("Error converting path to UTF-8");<br class="">+ }<br class=""> else<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""><br class=""><br class="">Modified: lldb/trunk/source/Host/windows/PipeWindows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/PipeWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/PipeWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/PipeWindows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/PipeWindows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -73,8 +73,8 @@ PipeWindows::CreateNew(llvm::StringRef n<br class=""><br class=""> // Always open for overlapped i/o. We implement blocking manually in Read and Write.<br class=""> DWORD read_mode = FILE_FLAG_OVERLAPPED;<br class="">- m_read =<br class="">- ::CreateNamedPipe(pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, PIPE_TYPE_BYTE | PIPE_WAIT, 1, 1024, 1024, 120 * 1000, NULL);<br class="">+ m_read = ::CreateNamedPipeA(pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, PIPE_TYPE_BYTE | PIPE_WAIT, 1, 1024,<br class="">+ 1024, 120 * 1000, NULL);<br class=""> if (INVALID_HANDLE_VALUE == m_read)<br class=""> return Error(::GetLastError(), eErrorTypeWin32);<br class=""> m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY);<br class="">@@ -153,7 +153,8 @@ PipeWindows::OpenNamedPipe(llvm::StringR<br class=""><br class=""> if (is_read)<br class=""> {<br class="">- m_read = ::CreateFile(pipe_path.c_str(), GENERIC_READ, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);<br class="">+ m_read =<br class="">+ ::CreateFileA(pipe_path.c_str(), GENERIC_READ, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);<br class=""> if (INVALID_HANDLE_VALUE == m_read)<br class=""> return Error(::GetLastError(), eErrorTypeWin32);<br class=""><br class="">@@ -164,7 +165,8 @@ PipeWindows::OpenNamedPipe(llvm::StringR<br class=""> }<br class=""> else<br class=""> {<br class="">- m_write = ::CreateFile(pipe_path.c_str(), GENERIC_WRITE, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);<br class="">+ m_write =<br class="">+ ::CreateFileA(pipe_path.c_str(), GENERIC_WRITE, 0, &attributes, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);<br class=""> if (INVALID_HANDLE_VALUE == m_write)<br class=""> return Error(::GetLastError(), eErrorTypeWin32);<br class=""><br class=""><br class="">Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -11,6 +11,9 @@<br class=""> #include "lldb/Host/windows/ProcessLauncherWindows.h"<br class=""> #include "lldb/Target/ProcessLaunchInfo.h"<br class=""><br class="">+#include "llvm/ADT/SmallVector.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class=""> #include <string><br class=""> #include <vector><br class=""><br class="">@@ -25,20 +28,18 @@ CreateEnvironmentBuffer(const Args &env,<br class=""> if (env.GetArgumentCount() == 0)<br class=""> return;<br class=""><br class="">- int bytes = 0;<br class="">- for (int i = 0; i < env.GetArgumentCount(); ++i)<br class="">- bytes += strlen(env.GetArgumentAtIndex(i)) + sizeof(char);<br class="">- bytes += sizeof(char);<br class="">- buffer.resize(bytes);<br class="">- char *cur_entry = &buffer[0];<br class="">+ // Environment buffer is a null terminated list of null terminated strings<br class=""> for (int i = 0; i < env.GetArgumentCount(); ++i)<br class=""> {<br class="">- ::strcpy(cur_entry, env.GetArgumentAtIndex(i));<br class="">- cur_entry += strlen(cur_entry) + sizeof(char);<br class="">+ std::wstring warg;<br class="">+ if (llvm::ConvertUTF8toWide(env.GetArgumentAtIndex(i), warg))<br class="">+ {<br class="">+ buffer.insert(buffer.end(), (char *)warg.c_str(), (char *)(warg.c_str() + warg.size() + 1));<br class="">+ }<br class=""> }<br class="">- // Environment buffer is a null terminated list of null terminated<br class="">- // strings, so it is terminated by two null bytes.<br class="">- buffer.back() = 0;<br class="">+ // One null wchar_t (to end the block) is two null bytes<br class="">+ buffer.push_back(0);<br class="">+ buffer.push_back(0);<br class=""> }<br class=""> }<br class=""><br class="">@@ -70,7 +71,7 @@ ProcessLauncherWindows::LaunchProcess(co<br class=""> startupinfo.wShowWindow = SW_HIDE;<br class=""> }<br class=""><br class="">- DWORD flags = CREATE_NEW_CONSOLE;<br class="">+ DWORD flags = CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT;<br class=""> if (launch_info.GetFlags().Test(eLaunchFlagDebug))<br class=""> flags |= DEBUG_ONLY_THIS_PROCESS;<br class=""><br class="">@@ -82,8 +83,15 @@ ProcessLauncherWindows::LaunchProcess(co<br class=""><br class=""> executable = launch_info.GetExecutableFile().GetPath();<br class=""> launch_info.GetArguments().GetQuotedCommandString(commandLine);<br class="">- BOOL result = ::CreateProcessA(executable.c_str(), const_cast<char *>(commandLine.c_str()), NULL, NULL, TRUE, flags,<br class="">- env_block, launch_info.GetWorkingDirectory().GetCString(), &startupinfo, &pi);<br class="">+<br class="">+ std::wstring wexecutable, wcommandLine, wworkingDirectory;<br class="">+ llvm::ConvertUTF8toWide(executable, wexecutable);<br class="">+ llvm::ConvertUTF8toWide(commandLine, wcommandLine);<br class="">+ llvm::ConvertUTF8toWide(launch_info.GetWorkingDirectory().GetCString(), wworkingDirectory);<br class="">+<br class="">+ wcommandLine.resize(PATH_MAX); // Needs to be over-allocated because CreateProcessW can modify it<br class="">+ BOOL result = ::CreateProcessW(wexecutable.c_str(), &wcommandLine[0], NULL, NULL, TRUE, flags, env_block,<br class="">+ wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(), &startupinfo, &pi);<br class=""> if (result)<br class=""> {<br class=""> // Do not call CloseHandle on pi.hProcess, since we want to pass that back through the HostProcess.<br class="">@@ -131,6 +139,8 @@ ProcessLauncherWindows::GetStdioHandle(c<br class=""> flags = FILE_FLAG_WRITE_THROUGH;<br class=""> }<br class=""><br class="">- HANDLE result = ::CreateFile(path, access, share, &secattr, create, flags, NULL);<br class="">+ std::wstring wpath;<br class="">+ llvm::ConvertUTF8toWide(path, wpath);<br class="">+ HANDLE result = ::CreateFileW(wpath.c_str(), access, share, &secattr, create, flags, NULL);<br class=""> return (result == INVALID_HANDLE_VALUE) ? NULL : result;<br class=""> }<br class=""><br class="">Modified: lldb/trunk/source/Host/windows/Windows.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Host/windows/Windows.cpp (original)<br class="">+++ lldb/trunk/source/Host/windows/Windows.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -12,6 +12,8 @@<br class=""> #include "lldb/Host/windows/windows.h"<br class=""> #include "lldb/Host/windows/win32.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class=""> #include <stdio.h><br class=""> #include <stdarg.h><br class=""> #include <string.h><br class="">@@ -27,6 +29,29 @@ extern "C"<br class=""> int _chdir(const char *path);<br class=""> }<br class=""><br class="">+namespace<br class="">+{<br class="">+bool<br class="">+utf8ToWide(const char *utf8, wchar_t *buf, size_t bufSize)<br class="">+{<br class="">+ const UTF8 *sourceStart = reinterpret_cast<const UTF8 *>(utf8);<br class="">+ size_t sourceLen = strlen(utf8) + 1 /* convert null too */;<br class="">+ UTF16 *target = reinterpret_cast<UTF16 *>(buf);<br class="">+ ConversionFlags flags = strictConversion;<br class="">+ return ConvertUTF8toUTF16(&sourceStart, sourceStart + sourceLen, &target, target + bufSize, flags) == conversionOK;<br class="">+}<br class="">+<br class="">+bool<br class="">+wideToUtf8(const wchar_t *wide, char *buf, size_t bufSize)<br class="">+{<br class="">+ const UTF16 *sourceStart = reinterpret_cast<const UTF16 *>(wide);<br class="">+ size_t sourceLen = wcslen(wide) + 1 /* convert null too */;<br class="">+ UTF8 *target = reinterpret_cast<UTF8 *>(buf);<br class="">+ ConversionFlags flags = strictConversion;<br class="">+ return ConvertUTF16toUTF8(&sourceStart, sourceStart + sourceLen, &target, target + bufSize, flags) == conversionOK;<br class="">+}<br class="">+}<br class="">+<br class=""> int vasprintf(char **ret, const char *fmt, va_list ap)<br class=""> {<br class=""> char *buf;<br class="">@@ -75,81 +100,90 @@ char* strcasestr(const char *s, const ch<br class=""><br class=""> char* realpath(const char * name, char * resolved)<br class=""> {<br class="">- char *retname = NULL; /* we will return this, if we fail */<br class="">+ char *retname = NULL;<br class=""><br class=""> /* SUSv3 says we must set `errno = EINVAL', and return NULL,<br class=""> * if `name' is passed as a NULL pointer.<br class=""> */<br class="">-<br class=""> if (name == NULL)<br class="">+ {<br class=""> errno = EINVAL;<br class="">+ return NULL;<br class="">+ }<br class=""><br class=""> /* Otherwise, `name' must refer to a readable filesystem object,<br class=""> * if we are going to resolve its absolute path name.<br class=""> */<br class="">-<br class="">- else if (access(name, 4) == 0)<br class="">+ wchar_t wideNameBuffer[PATH_MAX];<br class="">+ wchar_t *wideName = wideNameBuffer;<br class="">+ if (!utf8ToWide(name, wideName, PATH_MAX))<br class=""> {<br class="">- /* If `name' didn't point to an existing entity,<br class="">- * then we don't get to here; we simply fall past this block,<br class="">- * returning NULL, with `errno' appropriately set by `access'.<br class="">- *<br class="">- * When we _do_ get to here, then we can use `_fullpath' to<br class="">- * resolve the full path for `name' into `resolved', but first,<br class="">- * check that we have a suitable buffer, in which to return it.<br class="">- */<br class="">+ errno = EINVAL;<br class="">+ return NULL;<br class="">+ }<br class=""><br class="">- if ((retname = resolved) == NULL)<br class="">- {<br class="">- /* Caller didn't give us a buffer, so we'll exercise the<br class="">- * option granted by SUSv3, and allocate one.<br class="">- *<br class="">- * `_fullpath' would do this for us, but it uses `malloc', and<br class="">- * Microsoft's implementation doesn't set `errno' on failure.<br class="">- * If we don't do this explicitly ourselves, then we will not<br class="">- * know if `_fullpath' fails on `malloc' failure, or for some<br class="">- * other reason, and we want to set `errno = ENOMEM' for the<br class="">- * `malloc' failure case.<br class="">- */<br class="">+ if (_waccess(wideName, 4) != 0)<br class="">+ return NULL;<br class=""><br class="">- retname = (char*) malloc(_MAX_PATH);<br class="">- }<br class="">+ /* If `name' didn't point to an existing entity,<br class="">+ * then we don't get to here; we simply fall past this block,<br class="">+ * returning NULL, with `errno' appropriately set by `access'.<br class="">+ *<br class="">+ * When we _do_ get to here, then we can use `_fullpath' to<br class="">+ * resolve the full path for `name' into `resolved', but first,<br class="">+ * check that we have a suitable buffer, in which to return it.<br class="">+ */<br class=""><br class="">- /* By now, we should have a valid buffer.<br class="">- * If we don't, then we know that `malloc' failed,<br class="">- * so we can set `errno = ENOMEM' appropriately.<br class="">+ if ((retname = resolved) == NULL)<br class="">+ {<br class="">+ /* Caller didn't give us a buffer, so we'll exercise the<br class="">+ * option granted by SUSv3, and allocate one.<br class="">+ *<br class="">+ * `_fullpath' would do this for us, but it uses `malloc', and<br class="">+ * Microsoft's implementation doesn't set `errno' on failure.<br class="">+ * If we don't do this explicitly ourselves, then we will not<br class="">+ * know if `_fullpath' fails on `malloc' failure, or for some<br class="">+ * other reason, and we want to set `errno = ENOMEM' for the<br class="">+ * `malloc' failure case.<br class=""> */<br class=""><br class="">+ retname = (char *)malloc(PATH_MAX);<br class=""> if (retname == NULL)<br class="">+ {<br class=""> errno = ENOMEM;<br class="">+ return NULL;<br class="">+ }<br class="">+ }<br class=""><br class="">- /* Otherwise, when we do have a valid buffer,<br class="">- * `_fullpath' should only fail if the path name is too long.<br class="">- */<br class="">+ /* Otherwise, when we do have a valid buffer,<br class="">+ * `_fullpath' should only fail if the path name is too long.<br class="">+ */<br class=""><br class="">- else if ((retname = _fullpath(retname, name, _MAX_PATH)) == NULL)<br class="">- errno = ENAMETOOLONG;<br class="">+ wchar_t wideFullPathBuffer[PATH_MAX];<br class="">+ wchar_t *wideFullPath;<br class="">+ if ((wideFullPath = _wfullpath(wideFullPathBuffer, wideName, PATH_MAX)) == NULL)<br class="">+ {<br class="">+ errno = ENAMETOOLONG;<br class="">+ return NULL;<br class=""> }<br class=""><br class="">- /* By the time we get to here,<br class="">- * `retname' either points to the required resolved path name,<br class="">- * or it is NULL, with `errno' set appropriately, either of which<br class="">- * is our required return condition.<br class="">- */<br class="">+ // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS<br class="">+ // FIXME: Check for failure<br class="">+ size_t initialLength = wcslen(wideFullPath);<br class="">+ GetShortPathNameW(wideFullPath, wideNameBuffer, PATH_MAX);<br class="">+ GetLongPathNameW(wideNameBuffer, wideFullPathBuffer, initialLength + 1);<br class=""><br class="">- if (retname != NULL)<br class="">+ // Convert back to UTF-8<br class="">+ if (!wideToUtf8(wideFullPathBuffer, retname, PATH_MAX))<br class=""> {<br class="">- // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS<br class="">- int initialLength = strlen(retname);<br class="">- TCHAR buffer[MAX_PATH];<br class="">- GetShortPathName(retname, buffer, MAX_PATH);<br class="">- GetLongPathName(buffer, retname, initialLength + 1);<br class="">-<br class="">- // Force drive to be upper case<br class="">- if (retname[1] == ':')<br class="">- retname[0] = toupper(retname[0]);<br class="">+ errno = EINVAL;<br class="">+ return NULL;<br class=""> }<br class=""><br class="">+ // Force drive to be upper case<br class="">+ if (retname[1] == ':')<br class="">+ retname[0] = toupper(retname[0]);<br class="">+<br class=""> return retname;<br class=""> }<br class=""><br class="">@@ -167,7 +201,27 @@ char* basename(char *path)<br class=""> // use _getcwd() instead of GetCurrentDirectory() because it updates errno<br class=""> char* getcwd(char* path, int max)<br class=""> {<br class="">- return _getcwd(path, max);<br class="">+ assert(path == NULL || max <= PATH_MAX);<br class="">+ wchar_t wpath[PATH_MAX];<br class="">+ if (wchar_t *wresult = _wgetcwd(wpath, PATH_MAX))<br class="">+ {<br class="">+ // Caller is allowed to pass in NULL for `path`.<br class="">+ // In that case, we're supposed to allocate a<br class="">+ // buffer on the caller's behalf.<br class="">+ if (path == NULL)<br class="">+ {<br class="">+ max = UNI_MAX_UTF8_BYTES_PER_CODE_POINT * wcslen(wresult) + 1;<br class="">+ path = (char *)malloc(max);<br class="">+ if (path == NULL)<br class="">+ {<br class="">+ errno = ENOMEM;<br class="">+ return NULL;<br class="">+ }<br class="">+ }<br class="">+ if (wideToUtf8(wresult, path, max))<br class="">+ return path;<br class="">+ }<br class="">+ return NULL;<br class=""> }<br class=""><br class=""> // use _chdir() instead of SetCurrentDirectory() because it updates errno<br class=""><br class="">Modified: lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp (original)<br class="">+++ lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -27,6 +27,7 @@<br class=""> #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"<br class=""><br class=""> #include "llvm/ADT/STLExtras.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/raw_ostream.h"<br class=""><br class=""> using namespace lldb;<br class="">@@ -484,13 +485,15 @@ DebuggerThread::HandleLoadDllEvent(const<br class=""> return DBG_CONTINUE;<br class=""> }<br class=""><br class="">- std::vector<char> buffer(1);<br class="">- DWORD required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);<br class="">+ std::vector<wchar_t> buffer(1);<br class="">+ DWORD required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);<br class=""> if (required_size > 0)<br class=""> {<br class=""> buffer.resize(required_size + 1);<br class="">- required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], required_size + 1, VOLUME_NAME_DOS);<br class="">- llvm::StringRef path_str(&buffer[0]);<br class="">+ required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], required_size, VOLUME_NAME_DOS);<br class="">+ std::string path_str_utf8;<br class="">+ llvm::convertWideToUTF8(buffer.data(), path_str_utf8);<br class="">+ llvm::StringRef path_str = path_str_utf8;<br class=""> const char *path = path_str.data();<br class=""> if (path_str.startswith("\\\\?\\"))<br class=""> path += 4;<br class=""><br class="">Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp (original)<br class="">+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -47,6 +47,7 @@<br class=""> #include "ProcessWindowsLive.h"<br class=""> #include "TargetThreadWindowsLive.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""> #include "llvm/Support/Format.h"<br class=""> #include "llvm/Support/raw_ostream.h"<br class=""><br class="">@@ -61,17 +62,19 @@ namespace<br class=""> std::string<br class=""> GetProcessExecutableName(HANDLE process_handle)<br class=""> {<br class="">- std::vector<char> file_name;<br class="">+ std::vector<wchar_t> file_name;<br class=""> DWORD file_name_size = MAX_PATH; // first guess, not an absolute limit<br class=""> DWORD copied = 0;<br class=""> do<br class=""> {<br class=""> file_name_size *= 2;<br class=""> file_name.resize(file_name_size);<br class="">- copied = ::GetModuleFileNameEx(process_handle, NULL, file_name.data(), file_name_size);<br class="">+ copied = ::GetModuleFileNameExW(process_handle, NULL, file_name.data(), file_name_size);<br class=""> } while (copied >= file_name_size);<br class=""> file_name.resize(copied);<br class="">- return std::string(file_name.begin(), file_name.end());<br class="">+ std::string result;<br class="">+ llvm::convertWideToUTF8(file_name.data(), result);<br class="">+ return result;<br class=""> }<br class=""><br class=""> std::string<br class=""><br class="">Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp (original)<br class="">+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -370,14 +370,21 @@ ProcessWinMiniDump::Impl::MapMiniDumpInt<br class=""> {<br class=""> Error error;<br class=""> const char *file = m_core_file.GetCString();<br class="">- m_dump_file = ::CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br class="">+ std::wstring wfile;<br class="">+ if (!llvm::ConvertUTF8toWide(file, wfile))<br class="">+ {<br class="">+ error.SetErrorString("Error converting path to UTF-16");<br class="">+ return error;<br class="">+ }<br class="">+ m_dump_file =<br class="">+ ::CreateFileW(wfile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br class=""> if (m_dump_file == INVALID_HANDLE_VALUE)<br class=""> {<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class=""> return error;<br class=""> }<br class=""><br class="">- m_mapping = ::CreateFileMapping(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL);<br class="">+ m_mapping = ::CreateFileMappingW(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL);<br class=""> if (m_mapping == NULL)<br class=""> {<br class=""> error.SetError(::GetLastError(), lldb::eErrorTypeWin32);<br class="">@@ -509,7 +516,7 @@ ProcessWinMiniDump::Impl::GetMiniDumpStr<br class=""> auto source_start = reinterpret_cast<const UTF16 *>(md_string->Buffer);<br class=""> const auto source_length = ::wcslen(md_string->Buffer);<br class=""> const auto source_end = source_start + source_length;<br class="">- result.resize(4 * source_length); // worst case length<br class="">+ result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length); // worst case length<br class=""> auto result_start = reinterpret_cast<UTF8 *>(&result[0]);<br class=""> const auto result_end = result_start + result.size();<br class=""> ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, strictConversion);<br class=""><br class="">Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (original)<br class="">+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -19,8 +19,11 @@<br class=""><br class=""> #include "lldb/Core/Stream.h"<br class=""> #include "lldb/Host/File.h"<br class="">+#include "lldb/Host/FileSystem.h"<br class=""> #include "lldb/Interpreter/ScriptInterpreter.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class=""> #include <stdio.h><br class=""><br class=""> #include "llvm/ADT/StringSwitch.h"<br class="">@@ -1162,9 +1165,7 @@ PythonFile::PythonFile(File &file, const<br class=""><br class=""> PythonFile::PythonFile(const char *path, const char *mode)<br class=""> {<br class="">- FILE *fp = nullptr;<br class="">- fp = fopen(path, mode);<br class="">- lldb_private::File file(fp, true);<br class="">+ lldb_private::File file(path, GetOptionsFromMode(mode));<br class=""> Reset(file, mode);<br class=""> }<br class=""><br class=""><br class="">Modified: lldb/trunk/source/Target/ProcessLaunchInfo.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Target/ProcessLaunchInfo.cpp (original)<br class="">+++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -13,14 +13,21 @@<br class=""><br class=""> // Other libraries and framework includes<br class=""> // Project includes<br class="">-#include "lldb/Host/Config.h"<br class=""> #include "lldb/Core/Debugger.h"<br class=""> #include "lldb/Core/Log.h"<br class="">+#include "lldb/Host/Config.h"<br class=""> #include "lldb/Host/FileSystem.h"<br class="">-#include "lldb/Target/ProcessLaunchInfo.h"<br class="">+#include "lldb/Host/HostInfo.h"<br class=""> #include "lldb/Target/FileAction.h"<br class="">+#include "lldb/Target/ProcessLaunchInfo.h"<br class=""> #include "lldb/Target/Target.h"<br class=""><br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+<br class="">+#if !defined(_WIN32)<br class="">+#include <limits.h><br class="">+#endif<br class="">+<br class=""> using namespace lldb;<br class=""> using namespace lldb_private;<br class=""><br class="">@@ -449,8 +456,8 @@ ProcessLaunchInfo::ConvertArgumentsForLa<br class=""> if (cwd && cwd[0])<br class=""> new_path += cwd;<br class=""> }<br class="">- const char *curr_path = getenv("PATH");<br class="">- if (curr_path)<br class="">+ std::string curr_path;<br class="">+ if (HostInfo::GetEnvironmentVar("PATH", curr_path))<br class=""> {<br class=""> if (new_path.size() > empty_path_len)<br class=""> new_path += ':';<br class=""><br class="">Modified: lldb/trunk/tools/driver/Driver.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/tools/driver/Driver.cpp (original)<br class="">+++ lldb/trunk/tools/driver/Driver.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -27,7 +27,6 @@<br class=""><br class=""> #include <string><br class=""><br class="">-#include <thread><br class=""> #include "lldb/API/SBBreakpoint.h"<br class=""> #include "lldb/API/SBCommandInterpreter.h"<br class=""> #include "lldb/API/SBCommandReturnObject.h"<br class="">@@ -37,11 +36,13 @@<br class=""> #include "lldb/API/SBHostOS.h"<br class=""> #include "lldb/API/SBLanguageRuntime.h"<br class=""> #include "lldb/API/SBListener.h"<br class="">+#include "lldb/API/SBProcess.h"<br class=""> #include "lldb/API/SBStream.h"<br class=""> #include "lldb/API/SBStringList.h"<br class=""> #include "lldb/API/SBTarget.h"<br class=""> #include "lldb/API/SBThread.h"<br class="">-#include "lldb/API/SBProcess.h"<br class="">+#include "llvm/Support/ConvertUTF.h"<br class="">+#include <thread><br class=""><br class=""> #if !defined(__APPLE__)<br class=""> #include "llvm/Support/DataTypes.h"<br class="">@@ -1298,7 +1299,11 @@ sigcont_handler (int signo)<br class=""> }<br class=""><br class=""> int<br class="">-main (int argc, char const *argv[], const char *envp[])<br class="">+#ifdef WIN32<br class="">+wmain(int argc, wchar_t const *wargv[])<br class="">+#else<br class="">+main(int argc, char const *argv[])<br class="">+#endif<br class=""> {<br class=""> #ifdef _MSC_VER<br class=""> <span class="Apple-tab-span" style="white-space:pre"> </span>// disable buffering on windows<br class="">@@ -1306,37 +1311,49 @@ main (int argc, char const *argv[], cons<br class=""> <span class="Apple-tab-span" style="white-space:pre"> </span>setvbuf(stdin , NULL, _IONBF, 0);<br class=""> #endif<br class=""><br class="">- SBDebugger::Initialize();<br class="">- <br class="">- SBHostOS::ThreadCreated ("<lldb.driver.main-thread>");<br class="">-<br class="">- signal(SIGINT, sigint_handler);<br class="">-#ifndef _MSC_VER<br class="">- signal (SIGPIPE, SIG_IGN);<br class="">- signal (SIGWINCH, sigwinch_handler);<br class="">- signal (SIGTSTP, sigtstp_handler);<br class="">- signal (SIGCONT, sigcont_handler);<br class="">+#ifdef _WIN32<br class="">+ // Convert wide arguments to UTF-8<br class="">+ std::vector<std::string> argvStrings(argc);<br class="">+ std::vector<const char *> argvPointers(argc);<br class="">+ for (int i = 0; i != argc; ++i)<br class="">+ {<br class="">+ llvm::convertWideToUTF8(wargv[i], argvStrings[i]);<br class="">+ argvPointers[i] = argvStrings[i].c_str();<br class="">+ }<br class="">+ const char **argv = argvPointers.data();<br class=""> #endif<br class=""><br class="">- // Create a scope for driver so that the driver object will destroy itself<br class="">- // before SBDebugger::Terminate() is called.<br class="">- {<br class="">- Driver driver;<br class="">+ SBDebugger::Initialize();<br class=""><br class="">- bool exiting = false;<br class="">- SBError error (driver.ParseArgs (argc, argv, stdout, exiting));<br class="">- if (error.Fail())<br class="">- {<br class="">- const char *error_cstr = error.GetCString ();<br class="">- if (error_cstr)<br class="">- ::fprintf (stderr, "error: %s\n", error_cstr);<br class="">- }<br class="">- else if (!exiting)<br class="">+ SBHostOS::ThreadCreated("<lldb.driver.main-thread>");<br class="">+<br class="">+ signal(SIGINT, sigint_handler);<br class="">+#if !defined(_MSC_VER)<br class="">+ signal(SIGPIPE, SIG_IGN);<br class="">+ signal(SIGWINCH, sigwinch_handler);<br class="">+ signal(SIGTSTP, sigtstp_handler);<br class="">+ signal(SIGCONT, sigcont_handler);<br class="">+#endif<br class="">+<br class="">+ // Create a scope for driver so that the driver object will destroy itself<br class="">+ // before SBDebugger::Terminate() is called.<br class=""> {<br class="">- driver.MainLoop ();<br class="">+ Driver driver;<br class="">+<br class="">+ bool exiting = false;<br class="">+ SBError error(driver.ParseArgs(argc, argv, stdout, exiting));<br class="">+ if (error.Fail())<br class="">+ {<br class="">+ const char *error_cstr = error.GetCString();<br class="">+ if (error_cstr)<br class="">+ ::fprintf(stderr, "error: %s\n", error_cstr);<br class="">+ }<br class="">+ else if (!exiting)<br class="">+ {<br class="">+ driver.MainLoop();<br class="">+ }<br class=""> }<br class="">- }<br class=""><br class="">- SBDebugger::Terminate();<br class="">- return 0;<br class="">+ SBDebugger::Terminate();<br class="">+ return 0;<br class=""> }<br class=""><br class="">Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp (original)<br class="">+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -18,15 +18,16 @@<br class=""> #include "lldb/API/SBBreakpointLocation.h"<br class=""><br class=""> // In-house headers:<br class="">+#include "MICmdData.h"<br class=""> #include "MICmnLLDBDebugSessionInfo.h"<br class=""> #include "MICmnLLDBDebugger.h"<br class="">-#include "MICmnResources.h"<br class="">+#include "MICmnLLDBUtilSBValue.h"<br class=""> #include "MICmnMIResultRecord.h"<br class=""> #include "MICmnMIValueConst.h"<br class=""> #include "MICmnMIValueList.h"<br class=""> #include "MICmnMIValueTuple.h"<br class="">-#include "MICmdData.h"<br class="">-#include "MICmnLLDBUtilSBValue.h"<br class="">+#include "MICmnResources.h"<br class="">+#include "Platform.h"<br class=""><br class=""> //++ ------------------------------------------------------------------------------------<br class=""> // Details: CMICmnLLDBDebugSessionInfo constructor.<br class="">@@ -614,7 +615,7 @@ CMICmnLLDBDebugSessionInfo::GetFrameInfo<br class=""> {<br class=""> lldb::SBFrame &rFrame = const_cast<lldb::SBFrame &>(vrFrame);<br class=""><br class="">- static char pBuffer[MAX_PATH];<br class="">+ static char pBuffer[PATH_MAX];<br class=""> const MIuint nBytes = rFrame.GetLineEntry().GetFileSpec().GetPath(&pBuffer[0], sizeof(pBuffer));<br class=""> MIunused(nBytes);<br class=""> CMIUtilString strResolvedPath(&pBuffer[0]);<br class=""><br class="">Modified: lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp (original)<br class="">+++ lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp Tue Mar 22 12:58:09 2016<br class="">@@ -14,8 +14,11 @@<br class=""> #include <cerrno><br class=""><br class=""> // In-house headers:<br class="">-#include "MIUtilFileStd.h"<br class=""> #include "MICmnResources.h"<br class="">+#include "MIUtilFileStd.h"<br class="">+#include "lldb/Host/FileSystem.h"<br class="">+<br class="">+#include "llvm/Support/ConvertUTF.h"<br class=""><br class=""> //++ ------------------------------------------------------------------------------------<br class=""> // Details: CMIUtilFileStd constructor.<br class="">@@ -82,7 +85,14 @@ CMIUtilFileStd::CreateWrite(const CMIUti<br class=""> m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");<br class=""> #else<br class=""> // Open a file with exclusive write and shared read permissions<br class="">- m_pFileHandle = ::_fsopen(vFileNamePath.c_str(), "wb", _SH_DENYWR);<br class="">+ std::wstring path;<br class="">+ if (llvm::ConvertUTF8toWide(vFileNamePath.c_str(), path))<br class="">+ m_pFileHandle = ::_wfsopen(path.c_str(), L"wb", _SH_DENYWR);<br class="">+ else<br class="">+ {<br class="">+ errno = EINVAL;<br class="">+ m_pFileHandle = nullptr;<br class="">+ }<br class=""> #endif // !defined( _MSC_VER )<br class=""><br class=""> if (m_pFileHandle == nullptr)<br class="">@@ -221,8 +231,7 @@ CMIUtilFileStd::IsFileExist(const CMIUti<br class=""> if (vFileNamePath.empty())<br class=""> return false;<br class=""><br class="">- FILE *pTmp = nullptr;<br class="">- pTmp = ::fopen(vFileNamePath.c_str(), "wb");<br class="">+ FILE *pTmp = lldb_private::FileSystem::Fopen(vFileNamePath.c_str(), "wb");<br class=""> if (pTmp != nullptr)<br class=""> {<br class=""> ::fclose(pTmp);<br class=""><br class="">Modified: lldb/trunk/tools/lldb-mi/Platform.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/Platform.h?rev=264074&r1=264073&r2=264074&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/Platform.h?rev=264074&r1=264073&r2=264074&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/tools/lldb-mi/Platform.h (original)<br class="">+++ lldb/trunk/tools/lldb-mi/Platform.h Tue Mar 22 12:58:09 2016<br class="">@@ -58,7 +58,7 @@ struct termios<br class=""> typedef long pid_t;<br class=""><br class=""> #define STDIN_FILENO 0<br class="">-#define PATH_MAX MAX_PATH<br class="">+#define PATH_MAX 32768<br class=""> #define snprintf _snprintf<br class=""><br class=""> extern int ioctl(int d, int request, ...);<br class=""><br class=""><br class="">_______________________________________________<br class="">lldb-commits mailing list<br class=""><a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>