diff options
Diffstat (limited to 'lldb/source/Plugins/Process')
3 files changed, 23 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Process/Windows/Live/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/Live/DebuggerThread.cpp index d058a412c89..b5d2d002760 100644 --- a/lldb/source/Plugins/Process/Windows/Live/DebuggerThread.cpp +++ b/lldb/source/Plugins/Process/Windows/Live/DebuggerThread.cpp @@ -27,6 +27,7 @@ #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/raw_ostream.h" using namespace lldb; @@ -484,13 +485,15 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread return DBG_CONTINUE; } - std::vector<char> buffer(1); - DWORD required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS); + std::vector<wchar_t> buffer(1); + DWORD required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS); if (required_size > 0) { buffer.resize(required_size + 1); - required_size = GetFinalPathNameByHandle(info.hFile, &buffer[0], required_size + 1, VOLUME_NAME_DOS); - llvm::StringRef path_str(&buffer[0]); + required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], required_size, VOLUME_NAME_DOS); + std::string path_str_utf8; + llvm::convertWideToUTF8(buffer.data(), path_str_utf8); + llvm::StringRef path_str = path_str_utf8; const char *path = path_str.data(); if (path_str.startswith("\\\\?\\")) path += 4; diff --git a/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp index 9516040edc6..04cad37c263 100644 --- a/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp +++ b/lldb/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp @@ -47,6 +47,7 @@ #include "ProcessWindowsLive.h" #include "TargetThreadWindowsLive.h" +#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -61,17 +62,19 @@ namespace std::string GetProcessExecutableName(HANDLE process_handle) { - std::vector<char> file_name; + std::vector<wchar_t> file_name; DWORD file_name_size = MAX_PATH; // first guess, not an absolute limit DWORD copied = 0; do { file_name_size *= 2; file_name.resize(file_name_size); - copied = ::GetModuleFileNameEx(process_handle, NULL, file_name.data(), file_name_size); + copied = ::GetModuleFileNameExW(process_handle, NULL, file_name.data(), file_name_size); } while (copied >= file_name_size); file_name.resize(copied); - return std::string(file_name.begin(), file_name.end()); + std::string result; + llvm::convertWideToUTF8(file_name.data(), result); + return result; } std::string diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp index f0b5bbadd81..77566773262 100644 --- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp +++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp @@ -370,14 +370,21 @@ ProcessWinMiniDump::Impl::MapMiniDumpIntoMemory() { Error error; const char *file = m_core_file.GetCString(); - m_dump_file = ::CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + std::wstring wfile; + if (!llvm::ConvertUTF8toWide(file, wfile)) + { + error.SetErrorString("Error converting path to UTF-16"); + return error; + } + m_dump_file = + ::CreateFileW(wfile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (m_dump_file == INVALID_HANDLE_VALUE) { error.SetError(::GetLastError(), lldb::eErrorTypeWin32); return error; } - m_mapping = ::CreateFileMapping(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL); + m_mapping = ::CreateFileMappingW(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL); if (m_mapping == NULL) { error.SetError(::GetLastError(), lldb::eErrorTypeWin32); @@ -509,7 +516,7 @@ ProcessWinMiniDump::Impl::GetMiniDumpString(RVA rva) const auto source_start = reinterpret_cast<const UTF16 *>(md_string->Buffer); const auto source_length = ::wcslen(md_string->Buffer); const auto source_end = source_start + source_length; - result.resize(4 * source_length); // worst case length + result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length); // worst case length auto result_start = reinterpret_cast<UTF8 *>(&result[0]); const auto result_end = result_start + result.size(); ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, strictConversion); |