Index: lldb/trunk/include/lldb/Host/windows/HostProcessWindows.h =================================================================== --- lldb/trunk/include/lldb/Host/windows/HostProcessWindows.h +++ lldb/trunk/include/lldb/Host/windows/HostProcessWindows.h @@ -25,11 +25,11 @@ void SetOwnsHandle(bool owns); - virtual Error Terminate(); - virtual Error GetMainModule(FileSpec &file_spec) const; + Error Terminate() override; + Error GetMainModule(FileSpec &file_spec) const override; - virtual lldb::pid_t GetProcessId() const; - virtual bool IsRunning() const; + lldb::pid_t GetProcessId() const override; + bool IsRunning() const override; HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals) override; Index: lldb/trunk/include/lldb/Host/windows/PosixApi.h =================================================================== --- lldb/trunk/include/lldb/Host/windows/PosixApi.h +++ lldb/trunk/include/lldb/Host/windows/PosixApi.h @@ -57,10 +57,9 @@ typedef unsigned short mode_t; // pyconfig.h typedefs this. We require python headers to be included before -// any -// LLDB headers, but there's no way to prevent python's pid_t definition from -// leaking, so this is the best option. -#ifndef Py_CONFIG_H +// any LLDB headers, but there's no way to prevent python's pid_t definition +// from leaking, so this is the best option. +#ifndef NO_PID_T typedef uint32_t pid_t; #endif @@ -69,7 +68,10 @@ #define STDERR_FILENO 2 #define S_IFDIR _S_IFDIR + +#ifndef S_ISDIR #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) +#endif #endif // _MSC_VER Index: lldb/trunk/include/lldb/Utility/SelectHelper.h =================================================================== --- lldb/trunk/include/lldb/Utility/SelectHelper.h +++ lldb/trunk/include/lldb/Utility/SelectHelper.h @@ -37,17 +37,17 @@ // set the file descriptors that we will watch for when calling // select. This will cause FD_SET() to be called prior to calling select // using the "fd" provided. - void FDSetRead(int fd); - void FDSetWrite(int fd); - void FDSetError(int fd); + void FDSetRead(lldb::socket_t fd); + void FDSetWrite(lldb::socket_t fd); + void FDSetError(lldb::socket_t fd); // Call the FDIsSet*() functions after calling SelectHelper::Select() // to check which file descriptors are ready for read/write/error. This // will contain the result of FD_ISSET after calling select for a given // file descriptor. - bool FDIsSetRead(int fd) const; - bool FDIsSetWrite(int fd) const; - bool FDIsSetError(int fd) const; + bool FDIsSetRead(lldb::socket_t fd) const; + bool FDIsSetWrite(lldb::socket_t fd) const; + bool FDIsSetError(lldb::socket_t fd) const; // Call the system's select() to wait for descriptors using // timeout provided in a call the SelectHelper::SetTimeout(), @@ -69,7 +69,7 @@ bool read_set : 1, write_set : 1, error_set : 1, read_is_set : 1, write_is_set : 1, error_is_set : 1; }; - llvm::DenseMap m_fd_map; + llvm::DenseMap m_fd_map; llvm::Optional m_end_time; }; Index: lldb/trunk/source/Core/Mangled.cpp =================================================================== --- lldb/trunk/source/Core/Mangled.cpp +++ lldb/trunk/source/Core/Mangled.cpp @@ -259,7 +259,7 @@ log->Printf("demangled msvc: %s -> \"%s\"", mangled_name, demangled_name); else - log->Printf("demangled msvc: %s -> error: 0x%" PRIx64, mangled_name, + log->Printf("demangled msvc: %s -> error: 0x%lu", mangled_name, result); } Index: lldb/trunk/source/Core/SourceManager.cpp =================================================================== --- lldb/trunk/source/Core/SourceManager.cpp +++ lldb/trunk/source/Core/SourceManager.cpp @@ -654,7 +654,7 @@ } } if (!m_offsets.empty()) { - if (m_offsets.back() < end - start) + if (m_offsets.back() < size_t(end - start)) m_offsets.push_back(end - start); } return true; Index: lldb/trunk/source/DataFormatters/StringPrinter.cpp =================================================================== --- lldb/trunk/source/DataFormatters/StringPrinter.cpp +++ lldb/trunk/source/DataFormatters/StringPrinter.cpp @@ -135,7 +135,7 @@ unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer); - if (1 + buffer_end - buffer < utf8_encoded_len) { + if (1u + std::distance(buffer, buffer_end) < utf8_encoded_len) { // I don't have enough bytes - print whatever I have left retval = {buffer, static_cast(1 + buffer_end - buffer)}; next = buffer_end + 1; Index: lldb/trunk/source/Host/common/NativeBreakpointList.cpp =================================================================== --- lldb/trunk/source/Host/common/NativeBreakpointList.cpp +++ lldb/trunk/source/Host/common/NativeBreakpointList.cpp @@ -25,7 +25,7 @@ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - ", size_hint = %lu, hardware = %s", + ", size_hint = %zu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); std::lock_guard guard(m_mutex); @@ -47,7 +47,7 @@ if (log) log->Printf( "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 - ", size_hint = %lu, hardware = %s", + ", size_hint = %zu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); NativeBreakpointSP breakpoint_sp; @@ -56,7 +56,7 @@ if (log) log->Printf( "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 - ", size_hint = %lu, hardware = %s -- FAILED: %s", + ", size_hint = %zu, hardware = %s -- FAILED: %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false", error.AsCString()); return error; Index: lldb/trunk/source/Host/common/ProcessRunLock.cpp =================================================================== --- lldb/trunk/source/Host/common/ProcessRunLock.cpp +++ lldb/trunk/source/Host/common/ProcessRunLock.cpp @@ -1,5 +1,4 @@ #ifndef _WIN32 - #include "lldb/Host/ProcessRunLock.h" namespace lldb_private { Index: lldb/trunk/source/Host/common/SocketAddress.cpp =================================================================== --- lldb/trunk/source/Host/common/SocketAddress.cpp +++ lldb/trunk/source/Host/common/SocketAddress.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +#if defined(_MSC_VER) +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif + #include "lldb/Host/SocketAddress.h" #include #include @@ -41,7 +45,7 @@ case AF_INET: { { const char *formatted = inet_ntoa(*static_cast(src)); - if (formatted && strlen(formatted) < size) { + if (formatted && strlen(formatted) < static_cast(size)) { return ::strcpy(dst, formatted); } } Index: lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp =================================================================== --- lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp +++ lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp @@ -62,12 +62,12 @@ if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE) { if (log) - log->Printf("SoftwareBreakpoint::%s cannot support %lu trapcode bytes, " - "max size is %lu", + log->Printf("SoftwareBreakpoint::%s cannot support %zu trapcode bytes, " + "max size is %zu", __FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE); return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned too many trap opcode bytes: requires %lu but we " - "only support a max of %lu", + "returned too many trap opcode bytes: requires %zu but we " + "only support a max of %zu", bp_opcode_size, MAX_TRAP_OPCODE_SIZE); } @@ -135,13 +135,13 @@ if (bytes_read != bp_opcode_size) { if (log) log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: attempted to read %lu bytes " - "but only read %" PRIu64, - __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read); + "attempting to set breakpoint: attempted to read %zu bytes " + "but only read %zu", + __FUNCTION__, bp_opcode_size, bytes_read); return Error("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: attempted to read %lu bytes " - "but only read %" PRIu64, - __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read); + "attempting to set breakpoint: attempted to read %zu bytes " + "but only read %zu", + __FUNCTION__, bp_opcode_size, bytes_read); } // Log what we read. @@ -171,8 +171,8 @@ if (bytes_written != bp_opcode_size) { error.SetErrorStringWithFormat( "SoftwareBreakpoint::%s failed write memory while attempting to set " - "breakpoint: attempted to write %lu bytes but only wrote %" PRIu64, - __FUNCTION__, bp_opcode_size, (uint64_t)bytes_written); + "breakpoint: attempted to write %zu bytes but only wrote %zu", + __FUNCTION__, bp_opcode_size, bytes_written); if (log) log->PutCString(error.AsCString()); return error; @@ -194,13 +194,13 @@ if (verify_bytes_read != bp_opcode_size) { if (log) log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify breakpoint: attempted to read %lu " - "bytes but only read %" PRIu64, - __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read); + "attempting to verify breakpoint: attempted to read %zu " + "bytes but only read %zu", + __FUNCTION__, bp_opcode_size, verify_bytes_read); return Error("SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify breakpoint: attempted to read %lu bytes " - "but only read %" PRIu64, - __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read); + "attempting to verify breakpoint: attempted to read %zu bytes " + "but only read %zu", + __FUNCTION__, bp_opcode_size, verify_bytes_read); } if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0) { @@ -271,8 +271,8 @@ if (error.Success() && bytes_read < m_opcode_size) { error.SetErrorStringWithFormat( "SoftwareBreakpointr::%s addr=0x%" PRIx64 - ": tried to read %lu bytes but only read %" PRIu64, - __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_read); + ": tried to read %zu bytes but only read %zu", + __FUNCTION__, m_addr, m_opcode_size, bytes_read); } if (error.Success()) { bool verify = false; @@ -287,8 +287,8 @@ if (error.Success() && bytes_written < m_opcode_size) { error.SetErrorStringWithFormat( "SoftwareBreakpoint::%s addr=0x%" PRIx64 - ": tried to write %lu bytes but only wrote %" PRIu64, - __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_written); + ": tried to write %zu bytes but only wrote %zu", + __FUNCTION__, m_addr, m_opcode_size, bytes_written); } if (error.Success()) { verify = true; @@ -312,8 +312,8 @@ if (error.Success() && verify_bytes_read < m_opcode_size) { error.SetErrorStringWithFormat( "SoftwareBreakpoint::%s addr=0x%" PRIx64 - ": tried to read %lu verification bytes but only read %" PRIu64, - __FUNCTION__, m_addr, m_opcode_size, (uint64_t)verify_bytes_read); + ": tried to read %zu verification bytes but only read %zu", + __FUNCTION__, m_addr, m_opcode_size, verify_bytes_read); } if (error.Success()) { // compare the memory we just read with the original opcode Index: lldb/trunk/source/Host/common/TCPSocket.cpp =================================================================== --- lldb/trunk/source/Host/common/TCPSocket.cpp +++ lldb/trunk/source/Host/common/TCPSocket.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +#if defined(_MSC_VER) +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif + #include "lldb/Host/common/TCPSocket.h" #include "lldb/Core/Log.h" Index: lldb/trunk/source/Host/common/UDPSocket.cpp =================================================================== --- lldb/trunk/source/Host/common/UDPSocket.cpp +++ lldb/trunk/source/Host/common/UDPSocket.cpp @@ -102,7 +102,11 @@ &service_info_list); if (err != 0) { error.SetErrorStringWithFormat( +#if defined(_MSC_VER) && defined(UNICODE) + "getaddrinfo(%s, %s, &hints, &info) returned error %i (%S)", +#else "getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)", +#endif host_str.c_str(), port_str.c_str(), err, gai_strerror(err)); return error; } Index: lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp =================================================================== --- lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp +++ lldb/trunk/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -259,11 +259,9 @@ IncrementFilePointer(return_info.GetBytes()); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) { - log->Printf("%" PRIxPTR " ConnectionGenericFile::Read() handle = %" PRIxPTR - ", dst = %" PRIxPTR ", dst_len = %" PRIu64 ") => %" PRIu64 - ", error = %s", - this, m_file, dst, static_cast(dst_len), - static_cast(return_info.GetBytes()), + log->Printf("%p ConnectionGenericFile::Read() handle = %p, dst = %p, " + "dst_len = %zu) => %zu, error = %s", + this, m_file, dst, dst_len, return_info.GetBytes(), return_info.GetError().AsCString()); } @@ -310,12 +308,9 @@ IncrementFilePointer(return_info.GetBytes()); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) { - log->Printf("%" PRIxPTR - " ConnectionGenericFile::Write() handle = %" PRIxPTR - ", src = %" PRIxPTR ", src_len = %" PRIu64 ") => %" PRIu64 - ", error = %s", - this, m_file, src, static_cast(src_len), - static_cast(return_info.GetBytes()), + log->Printf("%p ConnectionGenericFile::Write() handle = %p, src = %p, " + "src_len = %zu) => %zu, error = %s", + this, m_file, src, src_len, return_info.GetBytes(), return_info.GetError().AsCString()); } return return_info.GetBytes(); Index: lldb/trunk/source/Host/windows/EditLineWin.cpp =================================================================== --- lldb/trunk/source/Host/windows/EditLineWin.cpp +++ lldb/trunk/source/Host/windows/EditLineWin.cpp @@ -266,8 +266,7 @@ const char *name = va_arg(vl, const char *); - for (int i = 0; i < _bindings.size(); i++) { - el_binding *bind = _bindings[i]; + for (auto bind : _bindings) { if (strcmp(bind->name, name) == 0) { bind->key = va_arg(vl, const char *); break; Index: lldb/trunk/source/Host/windows/FileSystem.cpp =================================================================== --- lldb/trunk/source/Host/windows/FileSystem.cpp +++ lldb/trunk/source/Host/windows/FileSystem.cpp @@ -65,7 +65,7 @@ path_buffer.push_back(0); path_buffer.push_back(0); - SHFILEOPSTRUCTW shfos = {0}; + SHFILEOPSTRUCTW shfos = {}; shfos.wFunc = FO_DELETE; shfos.pFrom = (LPCWSTR)path_buffer.data(); shfos.fFlags = FOF_NO_UI; Index: lldb/trunk/source/Host/windows/Host.cpp =================================================================== --- lldb/trunk/source/Host/windows/Host.cpp +++ lldb/trunk/source/Host/windows/Host.cpp @@ -159,7 +159,7 @@ if (!snapshot.IsValid()) return 0; - PROCESSENTRY32W pe = {0}; + PROCESSENTRY32W pe = {}; pe.dwSize = sizeof(PROCESSENTRY32W); if (Process32FirstW(snapshot.get(), &pe)) { do { Index: lldb/trunk/source/Host/windows/LockFileWindows.cpp =================================================================== --- lldb/trunk/source/Host/windows/LockFileWindows.cpp +++ lldb/trunk/source/Host/windows/LockFileWindows.cpp @@ -21,7 +21,7 @@ if (start != 0) return Error("Non-zero start lock regions are not supported"); - OVERLAPPED overlapped = {0}; + OVERLAPPED overlapped = {}; if (!::LockFileEx(file_handle, flags, 0, len, 0, &overlapped) && ::GetLastError() != ERROR_IO_PENDING) @@ -64,7 +64,7 @@ } Error LockFileWindows::DoUnlock() { - OVERLAPPED overlapped = {0}; + OVERLAPPED overlapped = {}; if (!::UnlockFileEx(m_file, 0, m_len, 0, &overlapped) && ::GetLastError() != ERROR_IO_PENDING) Index: lldb/trunk/source/Host/windows/PipeWindows.cpp =================================================================== --- lldb/trunk/source/Host/windows/PipeWindows.cpp +++ lldb/trunk/source/Host/windows/PipeWindows.cpp @@ -134,7 +134,7 @@ assert(is_read ? !CanRead() : !CanWrite()); - SECURITY_ATTRIBUTES attributes = {0}; + SECURITY_ATTRIBUTES attributes = {}; attributes.bInheritHandle = child_process_inherit; std::string pipe_path = "\\\\.\\Pipe\\"; Index: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp =================================================================== --- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp +++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp @@ -26,7 +26,7 @@ return; // Environment buffer is a null terminated list of null terminated strings - for (int i = 0; i < env.GetArgumentCount(); ++i) { + for (size_t i = 0; i < env.GetArgumentCount(); ++i) { std::wstring warg; if (llvm::ConvertUTF8toWide(env.GetArgumentAtIndex(i), warg)) { buffer.insert(buffer.end(), (char *)warg.c_str(), @@ -47,8 +47,8 @@ std::string executable; std::string commandLine; std::vector environment; - STARTUPINFO startupinfo = {0}; - PROCESS_INFORMATION pi = {0}; + STARTUPINFO startupinfo = {}; + PROCESS_INFORMATION pi = {}; HANDLE stdin_handle = GetStdioHandle(launch_info, STDIN_FILENO); HANDLE stdout_handle = GetStdioHandle(launch_info, STDOUT_FILENO); @@ -120,7 +120,7 @@ const FileAction *action = launch_info.GetFileActionForFD(fd); if (action == nullptr) return NULL; - SECURITY_ATTRIBUTES secattr = {0}; + SECURITY_ATTRIBUTES secattr = {}; secattr.nLength = sizeof(SECURITY_ATTRIBUTES); secattr.bInheritHandle = TRUE; Index: lldb/trunk/source/Host/windows/ProcessRunLock.cpp =================================================================== --- lldb/trunk/source/Host/windows/ProcessRunLock.cpp +++ lldb/trunk/source/Host/windows/ProcessRunLock.cpp @@ -46,7 +46,7 @@ InitializeSRWLock(GetLock(m_rwlock)); } -ProcessRunLock::~ProcessRunLock() { delete m_rwlock; } +ProcessRunLock::~ProcessRunLock() { delete static_cast(m_rwlock); } bool ProcessRunLock::ReadTryLock() { ::ReadLock(m_rwlock); Index: lldb/trunk/source/Interpreter/Args.cpp =================================================================== --- lldb/trunk/source/Interpreter/Args.cpp +++ lldb/trunk/source/Interpreter/Args.cpp @@ -275,7 +275,7 @@ // This happens because getopt_long_only may permute the order of the // arguments in argv, so we need to re-order the quotes and the refs array // to match. - for (int i = 0; i < m_argv.size() - 1; ++i) { + for (size_t i = 0; i < m_argv.size() - 1; ++i) { const char *argv = m_argv[i]; auto pos = std::find_if(m_entries.begin() + i, m_entries.end(), @@ -352,8 +352,8 @@ assert(m_argv.size() == m_entries.size() + 1); assert(m_argv.back() == nullptr); m_argv.pop_back(); - for (int i = 0; i < argc; ++i) { - m_entries.emplace_back(argv[i], '\0'); + for (auto arg : llvm::makeArrayRef(argv, argc)) { + m_entries.emplace_back(arg, '\0'); m_argv.push_back(m_entries.back().data()); } @@ -412,7 +412,7 @@ auto args = llvm::makeArrayRef(argv, argc); m_entries.resize(argc); m_argv.resize(argc + 1); - for (int i = 0; i < args.size(); ++i) { + for (size_t i = 0; i < args.size(); ++i) { char quote = ((args[i][0] == '\'') || (args[i][0] == '"') || (args[i][0] == '`')) ? args[i][0] Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp @@ -2597,7 +2597,8 @@ for (uint32_t i = 0; i < len; i++) { if ((text[i] == ' ' && ::strchr((text + i + 1), ' ') && - chars_left < ::strchr((text + i + 1), ' ') - (text + i)) || + chars_left < static_cast(::strchr((text + i + 1), ' ') - + (text + i))) || text[i] == '\n') { chars_left = max_columns - indent_size; strm.EOL(); Index: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp @@ -129,7 +129,7 @@ s->Indent(); const size_t num_archs = GetNumArchitectures(); const size_t num_objects = GetNumObjects(); - s->Printf("ObjectContainerUniversalMachO, num_archs = %lu, num_objects = %lu", + s->Printf("ObjectContainerUniversalMachO, num_archs = %zu, num_objects = %zu", num_archs, num_objects); uint32_t i; ArchSpec arch; Index: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp @@ -124,13 +124,12 @@ &m_context)) { WINERR_IFALL( WINDOWS_LOG_REGISTERS, - "GetThreadContext failed with error %u while caching register values.", + "GetThreadContext failed with error %lu while caching register values.", ::GetLastError()); return false; } WINLOG_IFALL(WINDOWS_LOG_REGISTERS, - "GetThreadContext successfully updated the register values.", - ::GetLastError()); + "GetThreadContext successfully updated the register values."); m_context_stale = false; return true; } Index: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp @@ -62,52 +62,72 @@ {ehframe_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_eax_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(ebx, nullptr), {ehframe_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_ebx_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(ecx, nullptr), {ehframe_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_ecx_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(edx, nullptr), {ehframe_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_edx_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(edi, nullptr), {ehframe_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_edi_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(esi, nullptr), {ehframe_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_esi_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(ebp, "fp"), {ehframe_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, lldb_ebp_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(esp, "sp"), {ehframe_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, lldb_esp_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR(eip, "pc"), {ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, lldb_eip_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, {DEFINE_GPR_BIN(eflags, "flags"), {ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, lldb_eflags_i386}, nullptr, - nullptr}, + nullptr, + nullptr, + 0u}, }; static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos); @@ -196,7 +216,7 @@ reg_name); return false; } - WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from %s", value, + WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%lx from %s", value, reg_name); reg_value.SetUInt32(value); return true; Index: lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h +++ lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h @@ -68,27 +68,31 @@ HostProcess m_process; // The process being debugged. HostThread m_main_thread; // The main thread of the inferior. - HANDLE m_image_file; // The image file of the process being debugged. - ExceptionRecordSP - m_active_exception; // The current exception waiting to be handled + // The image file of the process being debugged. + HANDLE m_image_file = nullptr; - Predicate - m_exception_pred; // A predicate which gets signalled when an exception - // is finished processing and the debug loop can be - // continued. - - HANDLE m_debugging_ended_event; // An event which gets signalled by the - // debugger thread when it - // exits the debugger loop and is detached from the inferior. - - std::atomic m_pid_to_detach; // Signals the loop to detach from the - // process (specified by pid). - std::atomic m_is_shutting_down; // Signals the debug loop to stop - // processing certain types of - // events that block shutdown. - bool m_detached; // Indicates we've detached from the inferior process and the - // debug loop can exit. + // The current exception waiting to be handled + ExceptionRecordSP m_active_exception; + + // A predicate which gets signalled when an exception is finished processing + // and the debug loop can be continued. + Predicate m_exception_pred; + + // An event which gets signalled by the debugger thread when it exits the + // debugger loop and is detached from the inferior. + HANDLE m_debugging_ended_event = nullptr; + + // Signals the loop to detach from the process (specified by pid). + std::atomic m_pid_to_detach; + + // Signals the debug loop to stop processing certain types of events that + // block shutdown. + std::atomic m_is_shutting_down; + + // Indicates we've detached from the inferior process and the debug loop can + // exit. + bool m_detached = false; static lldb::thread_result_t DebuggerThreadLaunchRoutine(void *data); lldb::thread_result_t @@ -99,5 +103,4 @@ const ProcessAttachInfo &launch_info); }; } - #endif Index: lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp @@ -54,9 +54,8 @@ } DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate) - : m_debug_delegate(debug_delegate), m_image_file(nullptr), - m_debugging_ended_event(nullptr), m_is_shutting_down(false), - m_pid_to_detach(0), m_detached(false) { + : m_debug_delegate(debug_delegate), m_pid_to_detach(0), + m_is_shutting_down(false) { m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); } @@ -85,7 +84,7 @@ Error DebuggerThread::DebugAttach(lldb::pid_t pid, const ProcessAttachInfo &attach_info) { WINLOG_IFALL(WINDOWS_LOG_PROCESS, - "DebuggerThread::DebugAttach attaching to '%u'", (DWORD)pid); + "DebuggerThread::DebugAttach attaching to '%llu'", pid); Error error; DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info); @@ -95,7 +94,7 @@ if (!error.Success()) { WINERR_IFALL(WINDOWS_LOG_PROCESS, - "DebugAttach couldn't attach to process '%u'. %s", (DWORD)pid, + "DebugAttach couldn't attach to process '%llu'. %s", pid, error.AsCString()); } @@ -157,8 +156,8 @@ std::shared_ptr this_ref(shared_from_this()); WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to attach to " - "process '%u' on background thread.", - (DWORD)pid); + "process '%llu' on background thread.", + pid); if (!DebugActiveProcess((DWORD)pid)) { Error error(::GetLastError(), eErrorTypeWin32); @@ -233,25 +232,25 @@ } } - WINLOG_IFALL(WINDOWS_LOG_PROCESS, - "StopDebugging waiting for detach from process %u to complete.", - pid); + WINLOG_IFALL( + WINDOWS_LOG_PROCESS, + "StopDebugging waiting for detach from process %llu to complete.", pid); DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000); if (wait_result != WAIT_OBJECT_0) { error.SetError(GetLastError(), eErrorTypeWin32); WINERR_IFALL(WINDOWS_LOG_PROCESS, - "StopDebugging WaitForSingleObject(0x%p, 5000) returned %u", + "StopDebugging WaitForSingleObject(0x%p, 5000) returned %lu", m_debugging_ended_event, wait_result); } else { - WINLOG_IFALL(WINDOWS_LOG_PROCESS, - "StopDebugging detach from process %u completed successfully.", - pid); + WINLOG_IFALL( + WINDOWS_LOG_PROCESS, + "StopDebugging detach from process %llu completed successfully.", pid); } if (!error.Success()) { WINERR_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging encountered an error " - "while trying to stop process %u. %s", + "while trying to stop process %llu. %s", pid, error.AsCString()); } return error; @@ -280,7 +279,7 @@ } void DebuggerThread::DebugLoop() { - DEBUG_EVENT dbe = {0}; + DEBUG_EVENT dbe = {}; bool should_debug = true; WINLOG_IFALL(WINDOWS_LOG_EVENT, "Entering WaitForDebugEvent loop"); while (should_debug) { @@ -335,7 +334,7 @@ WINLOGD_IFALL( WINDOWS_LOG_EVENT, - "DebugLoop calling ContinueDebugEvent(%u, %u, %u) on thread %u.", + "DebugLoop calling ContinueDebugEvent(%lu, %lu, %lu) on thread %lu.", dbe.dwProcessId, dbe.dwThreadId, continue_status, ::GetCurrentThreadId()); @@ -347,8 +346,8 @@ } else { WINERR_IFALL( WINDOWS_LOG_EVENT, - "DebugLoop returned FALSE from WaitForDebugEvent. Error = %u", - ::GetCurrentThreadId(), ::GetLastError()); + "DebugLoop returned FALSE from WaitForDebugEvent. Error = %lu", + ::GetLastError()); should_debug = false; } @@ -371,7 +370,7 @@ info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) { WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS, - "Breakpoint exception is cue to detach from process 0x%x", + "Breakpoint exception is cue to detach from process 0x%lx", m_pid_to_detach.load()); ::DebugActiveProcessStop(m_pid_to_detach); m_detached = true; @@ -388,8 +387,8 @@ m_active_exception.reset( new ExceptionRecord(info.ExceptionRecord, thread_id)); WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION, - "HandleExceptionEvent encountered %s chance exception 0x%x on " - "thread 0x%x", + "HandleExceptionEvent encountered %s chance exception 0x%lx on " + "thread 0x%lx", first_chance ? "first" : "second", info.ExceptionRecord.ExceptionCode, thread_id); @@ -415,7 +414,7 @@ DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id) { WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD, - "HandleCreateThreadEvent Thread 0x%x spawned in process %I64u", + "HandleCreateThreadEvent Thread 0x%lx spawned in process %llu", thread_id, m_process.GetProcessId()); HostThread thread(info.hThread); thread.GetNativeThread().SetOwnsHandle(false); @@ -456,7 +455,7 @@ DWORD thread_id) { WINLOG_IFANY( WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD, - "HandleExitThreadEvent Thread %u exited with code %u in process %I64u", + "HandleExitThreadEvent Thread %lu exited with code %lu in process %llu", thread_id, info.dwExitCode, m_process.GetProcessId()); m_debug_delegate->OnExitThread(thread_id, info.dwExitCode); return DBG_CONTINUE; @@ -466,7 +465,7 @@ DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id) { WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD, - "HandleExitProcessEvent process %I64u exited with code %u", + "HandleExitProcessEvent process %llu exited with code %lu", m_process.GetProcessId(), info.dwExitCode); m_debug_delegate->OnExitProcess(info.dwExitCode); @@ -480,7 +479,7 @@ DWORD thread_id) { if (info.hFile == nullptr) { // Not sure what this is, so just ignore it. - WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent has " + WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent has " "a NULL file handle, returning...", m_process.GetProcessId()); return DBG_CONTINUE; @@ -510,8 +509,8 @@ m_debug_delegate->OnLoadDll(module_spec, load_addr); } else { - WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent Error " - "%u occurred calling " + WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent Error " + "%lu occurred calling " "GetFinalPathNameByHandle", m_process.GetProcessId(), ::GetLastError()); } @@ -524,7 +523,7 @@ DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id) { WINLOG_IFALL(WINDOWS_LOG_EVENT, - "HandleUnloadDllEvent process %I64u unloading DLL at addr 0x%p.", + "HandleUnloadDllEvent process %llu unloading DLL at addr 0x%p.", m_process.GetProcessId(), info.lpBaseOfDll); m_debug_delegate->OnUnloadDll( @@ -540,8 +539,8 @@ DWORD DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) { - WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %u " - "(type=%u) in process %I64u thread %u", + WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %lu " + "(type=%lu) in process %llu thread %lu", info.dwError, info.dwType, m_process.GetProcessId(), thread_id); Error error(info.dwError, eErrorTypeWin32); Index: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h +++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h @@ -26,7 +26,7 @@ #include "llvm/Support/Mutex.h" -#include "plugins/Process/Windows/Common/ProcessWindows.h" +#include "Plugins/Process/Windows/Common/ProcessWindows.h" class ProcessMonitor; Index: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp +++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp @@ -94,9 +94,7 @@ // OS specific types and implementation details from a public header file. class ProcessWindowsData { public: - ProcessWindowsData(bool stop_at_entry) - : m_stop_at_entry(stop_at_entry), m_initial_stop_event(nullptr), - m_initial_stop_received(false) { + ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) { m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); } @@ -105,9 +103,9 @@ lldb_private::Error m_launch_error; lldb_private::DebuggerThreadSP m_debugger; StopInfoSP m_pending_stop_info; - HANDLE m_initial_stop_event; + HANDLE m_initial_stop_event = nullptr; + bool m_initial_stop_received = false; bool m_stop_at_entry; - bool m_initial_stop_received; std::map m_new_threads; std::set m_exited_threads; }; @@ -153,8 +151,8 @@ Error ProcessWindowsLive::EnableBreakpointSite(BreakpointSite *bp_site) { WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS, "EnableBreakpointSite called with bp_site 0x%p " - "(id=%d, addr=0x%x)", - bp_site->GetID(), bp_site->GetLoadAddress()); + "(id=%d, addr=0x%llx)", + bp_site, bp_site->GetID(), bp_site->GetLoadAddress()); Error error = EnableSoftwareBreakpoint(bp_site); if (!error.Success()) { @@ -167,7 +165,7 @@ Error ProcessWindowsLive::DisableBreakpointSite(BreakpointSite *bp_site) { WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS, "DisableBreakpointSite called with bp_site 0x%p " - "(id=%d, addr=0x%x)", + "(id=%d, addr=0x%llx)", bp_site, bp_site->GetID(), bp_site->GetLoadAddress()); Error error = DisableSoftwareBreakpoint(bp_site); @@ -199,12 +197,13 @@ ++continued_threads; WINLOGV_IFALL( WINDOWS_LOG_THREAD, - "UpdateThreadList - Thread %u was running and is still running.", + "UpdateThreadList - Thread %llu was running and is still running.", old_thread_id); } else { - WINLOGV_IFALL(WINDOWS_LOG_THREAD, - "UpdateThreadList - Thread %u was running and has exited.", - old_thread_id); + WINLOGV_IFALL( + WINDOWS_LOG_THREAD, + "UpdateThreadList - Thread %llu was running and has exited.", + old_thread_id); ++exited_threads; } } @@ -218,7 +217,7 @@ ++new_size; ++new_threads; WINLOGV_IFALL(WINDOWS_LOG_THREAD, - "UpdateThreadList - Thread %u is new since last update.", + "UpdateThreadList - Thread %llu is new since last update.", thread_info.first); } @@ -250,7 +249,7 @@ std::string message = stream.GetString(); result.SetErrorString(message.c_str()); - WINERR_IFALL(WINDOWS_LOG_PROCESS, message.c_str()); + WINERR_IFALL(WINDOWS_LOG_PROCESS, "%s", message.c_str()); return result; } @@ -328,7 +327,7 @@ WINLOG_IFALL( WINDOWS_LOG_PROCESS, - "DoAttachToProcessWithID successfully attached to process with pid=%u", + "DoAttachToProcessWithID successfully attached to process with pid=%lu", process_id); // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the @@ -385,7 +384,7 @@ WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_THREAD, "DoResume resuming %u threads.", m_thread_list.GetSize()); - for (int i = 0; i < m_thread_list.GetSize(); ++i) { + for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) { auto thread = std::static_pointer_cast( m_thread_list.GetThreadAtIndex(i)); thread->DoResume(); @@ -438,7 +437,7 @@ if (private_state != eStateExited && private_state != eStateDetached) { WINLOG_IFALL( WINDOWS_LOG_PROCESS, - "DoDetach called for process %I64u while state = %u. Detaching...", + "DoDetach called for process %p while state = %d. Detaching...", debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state); error = debugger_thread->StopDebugging(false); @@ -451,8 +450,8 @@ m_session_data.reset(); } else { WINERR_IFALL( - WINDOWS_LOG_PROCESS, "DoDetach called for process %I64u while state = " - "%u, but cannot destroy in this state.", + WINDOWS_LOG_PROCESS, "DoDetach called for process %p while state = " + "%d, but cannot destroy in this state.", debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state); } @@ -487,7 +486,7 @@ Error error; if (private_state != eStateExited && private_state != eStateDetached) { WINLOG_IFALL( - WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = " + WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = " "%u. Shutting down...", debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state); @@ -498,8 +497,8 @@ m_session_data.reset(); } else { WINERR_IFALL( - WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = " - "%u, but cannot destroy in this state.", + WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = " + "%d, but cannot destroy in this state.", debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state); } @@ -554,7 +553,7 @@ stop_thread->SetStopInfo(stop_info); } else { WINLOG_IFANY(WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP, - "RefreshStateAfterStop single stepping thread %u", + "RefreshStateAfterStop single stepping thread %llu", stop_thread->GetID()); stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread); stop_thread->SetStopInfo(stop_info); @@ -616,7 +615,7 @@ stop_info = StopInfo::CreateStopReasonWithException( *stop_thread, desc_stream.str().c_str()); stop_thread->SetStopInfo(stop_info); - WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, desc_stream.str().c_str()); + WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, "%s", desc_stream.str().c_str()); return; } } @@ -733,7 +732,7 @@ if (!m_session_data) { error.SetErrorString( "GetMemoryRegionInfo called with no debugging session."); - WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString()); + WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString()); return error; } HostProcess process = m_session_data->m_debugger->GetProcess(); @@ -741,7 +740,7 @@ if (handle == nullptr || handle == LLDB_INVALID_PROCESS) { error.SetErrorString( "GetMemoryRegionInfo called with an invalid target process."); - WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString()); + WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString()); return error; } @@ -749,7 +748,7 @@ "GetMemoryRegionInfo getting info for address 0x%I64x", vm_addr); void *addr = reinterpret_cast(vm_addr); - MEMORY_BASIC_INFORMATION mem_info = {0}; + MEMORY_BASIC_INFORMATION mem_info = {}; SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info)); if (result == 0) { if (::GetLastError() == ERROR_INVALID_PARAMETER) { @@ -812,10 +811,10 @@ } error.SetError(::GetLastError(), eErrorTypeWin32); - WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address 0x%I64u: " + WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address %llu: " "readable=%s, executable=%s, writable=%s", - BOOL_STR(info.GetReadable()), BOOL_STR(info.GetExecutable()), - BOOL_STR(info.GetWritable())); + vm_addr, BOOL_STR(info.GetReadable()), + BOOL_STR(info.GetExecutable()), BOOL_STR(info.GetWritable())); return error; } @@ -835,7 +834,7 @@ void ProcessWindowsLive::OnExitProcess(uint32_t exit_code) { // No need to acquire the lock since m_session_data isn't accessed. - WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %u exited with code %u", GetID(), + WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %llu exited with code %u", GetID(), exit_code); TargetSP target = m_target_sp.lock(); @@ -912,7 +911,7 @@ // lldb logs, and then add logging to the process plugin. if (!m_session_data) { WINERR_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception " - "0x%x at address 0x%I64x, but there is " + "0x%lx at address 0x%llu, but there is " "no session.", record.GetExceptionCode(), record.GetExceptionAddress()); return ExceptionResult::SendToApplication; @@ -949,7 +948,7 @@ break; default: WINLOG_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception " - "0x%x at address 0x%I64x " + "0x%lx at address 0x%llx " "(first_chance=%s)", record.GetExceptionCode(), record.GetExceptionAddress(), BOOL_STR(first_chance)); Index: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp +++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp @@ -162,25 +162,21 @@ if (m_is_wow64) { // On Windows, a 32-bit process can run on a 64-bit machine under - // WOW64. - // If the minidump was captured with a 64-bit debugger, then the - // CONTEXT - // we just grabbed from the mini_dump_thread is the one for the 64-bit - // "native" process rather than the 32-bit "guest" process we care - // about. - // In this case, we can get the 32-bit CONTEXT from the TEB (Thread - // Environment Block) of the 64-bit process. + // WOW64. If the minidump was captured with a 64-bit debugger, then + // the CONTEXT we just grabbed from the mini_dump_thread is the one + // for the 64-bit "native" process rather than the 32-bit "guest" + // process we care about. In this case, we can get the 32-bit CONTEXT + // from the TEB (Thread Environment Block) of the 64-bit process. Error error; - TEB64 wow64teb = {0}; + TEB64 wow64teb = {}; m_self->ReadMemory(mini_dump_thread.Teb, &wow64teb, sizeof(wow64teb), error); if (error.Success()) { // Slot 1 of the thread-local storage in the 64-bit TEB points to a - // structure - // that includes the 32-bit CONTEXT (after a ULONG). + // structure that includes the 32-bit CONTEXT (after a ULONG). // See: https://msdn.microsoft.com/en-us/library/ms681670.aspx - const size_t addr = wow64teb.TlsSlots[1]; - Range range = {0}; + const lldb::addr_t addr = wow64teb.TlsSlots[1]; + Range range = {}; if (FindMemoryRange(addr, &range)) { lldbassert(range.start <= addr); const size_t offset = addr - range.start + sizeof(ULONG); @@ -234,7 +230,7 @@ // ranges a mini dump typically has, so I'm not sure if searching for the // appropriate range linearly each time is stupid. Perhaps we should build // an index for faster lookups. - Range range = {0}; + Range range = {}; if (!FindMemoryRange(addr, &range)) { return 0; } @@ -275,7 +271,7 @@ const MINIDUMP_MEMORY_INFO *next_entry = nullptr; - for (int i = 0; i < list->NumberOfEntries; ++i) { + for (uint64_t i = 0; i < list->NumberOfEntries; ++i) { const auto entry = reinterpret_cast( reinterpret_cast(list) + list->SizeOfHeader + i * list->SizeOfEntry); Index: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -206,7 +206,7 @@ ByteOrder byteorder = data.GetByteOrder(); if (GetSize(arch) > data.GetByteSize()) { error.SetErrorStringWithFormat( - "NT_PRSTATUS size should be %lu, but the remaining bytes are: %" PRIu64, + "NT_PRSTATUS size should be %zu, but the remaining bytes are: %" PRIu64, GetSize(arch), data.GetByteSize()); return error; } @@ -271,7 +271,7 @@ ByteOrder byteorder = data.GetByteOrder(); if (GetSize(arch) > data.GetByteSize()) { error.SetErrorStringWithFormat( - "NT_PRPSINFO size should be %lu, but the remaining bytes are: %" PRIu64, + "NT_PRPSINFO size should be %zu, but the remaining bytes are: %" PRIu64, GetSize(arch), data.GetByteSize()); return error; } Index: lldb/trunk/source/Plugins/ScriptInterpreter/Python/lldb-python.h =================================================================== --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/lldb-python.h +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/lldb-python.h @@ -20,8 +20,9 @@ #include "llvm/Support/Compiler.h" #if defined(LLVM_ON_WIN32) // If anyone #includes Host/PosixApi.h later, it will try to typedef pid_t. We -// need to ensure -// this doesn't happen. +// need to ensure this doesn't happen. At the same time, Python.h will also try +// to redefine a bunch of stuff that PosixApi.h defines. So define it all now +// so that PosixApi.h doesn't redefine it. #define NO_PID_T #endif #if defined(__linux__) Index: lldb/trunk/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp +++ lldb/trunk/source/Symbol/ClangASTContext.cpp @@ -4317,6 +4317,8 @@ break; case clang::Type::Adjusted: break; + case clang::Type::ObjCTypeParam: + break; } // We don't know hot to display this type... return lldb::eTypeClassOther; @@ -5122,6 +5124,8 @@ // pointer type decayed from an array or function type. case clang::Type::Decayed: break; + case clang::Type::ObjCTypeParam: + break; } count = 0; return lldb::eEncodingInvalid; @@ -5269,6 +5273,8 @@ // pointer type decayed from an array or function type. case clang::Type::Decayed: break; + case clang::Type::ObjCTypeParam: + break; } // We don't know hot to display this type... return lldb::eFormatBytes; Index: lldb/trunk/source/Symbol/OCamlASTContext.cpp =================================================================== --- lldb/trunk/source/Symbol/OCamlASTContext.cpp +++ lldb/trunk/source/Symbol/OCamlASTContext.cpp @@ -621,7 +621,7 @@ } if (IsScalarType(type)) { - return data.Dump(s, byte_offset, format, byte_size, 1, UINT64_MAX, + return data.Dump(s, byte_offset, format, byte_size, 1, SIZE_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset, exe_scope); } Index: lldb/trunk/source/Target/Memory.cpp =================================================================== --- lldb/trunk/source/Target/Memory.cpp +++ lldb/trunk/source/Target/Memory.cpp @@ -288,7 +288,7 @@ if (log) log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u " "(0x%x)) => offset = 0x%x, %u %u bit chunks - " - "num_chunks %lu", + "num_chunks %zu", (void *)this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size()); addr = m_addr + last_offset; @@ -307,7 +307,7 @@ if (log) log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u " "(0x%x)) => offset = 0x%x, %u %u bit chunks - " - "num_chunks %lu", + "num_chunks %zu", (void *)this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size()); addr = m_addr + last_offset; @@ -389,7 +389,7 @@ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); if (log) log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64 - ") => %i, num_chunks: %lu", + ") => %i, num_chunks: %zu", (void *)this, (uint64_t)addr, success, m_offset_to_chunk_size.size()); return success; Index: lldb/trunk/source/Target/StackFrame.cpp =================================================================== --- lldb/trunk/source/Target/StackFrame.cpp +++ lldb/trunk/source/Target/StackFrame.cpp @@ -1279,6 +1279,7 @@ } } } + return std::make_pair(nullptr, 0); } std::pair Index: lldb/trunk/source/Utility/SelectHelper.cpp =================================================================== --- lldb/trunk/source/Utility/SelectHelper.cpp +++ lldb/trunk/source/Utility/SelectHelper.cpp @@ -45,13 +45,19 @@ m_end_time = steady_clock::time_point(steady_clock::now() + timeout); } -void SelectHelper::FDSetRead(int fd) { m_fd_map[fd].read_set = true; } +void SelectHelper::FDSetRead(lldb::socket_t fd) { + m_fd_map[fd].read_set = true; +} -void SelectHelper::FDSetWrite(int fd) { m_fd_map[fd].write_set = true; } +void SelectHelper::FDSetWrite(lldb::socket_t fd) { + m_fd_map[fd].write_set = true; +} -void SelectHelper::FDSetError(int fd) { m_fd_map[fd].error_set = true; } +void SelectHelper::FDSetError(lldb::socket_t fd) { + m_fd_map[fd].error_set = true; +} -bool SelectHelper::FDIsSetRead(int fd) const { +bool SelectHelper::FDIsSetRead(lldb::socket_t fd) const { auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.read_is_set; @@ -59,7 +65,7 @@ return false; } -bool SelectHelper::FDIsSetWrite(int fd) const { +bool SelectHelper::FDIsSetWrite(lldb::socket_t fd) const { auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.write_is_set; @@ -67,7 +73,7 @@ return false; } -bool SelectHelper::FDIsSetError(int fd) const { +bool SelectHelper::FDIsSetError(lldb::socket_t fd) const { auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.error_is_set; @@ -75,6 +81,14 @@ return false; } +static void updateMaxFd(llvm::Optional &vold, + lldb::socket_t vnew) { + if (!vold.hasValue()) + vold = vnew; + else + vold = std::max(*vold, vnew); +} + lldb_private::Error SelectHelper::Select() { lldb_private::Error error; #ifdef _MSC_VER @@ -85,13 +99,13 @@ return lldb_private::Error("Too many file descriptors for select()"); #endif - int max_read_fd = -1; - int max_write_fd = -1; - int max_error_fd = -1; - int max_fd = -1; + llvm::Optional max_read_fd; + llvm::Optional max_write_fd; + llvm::Optional max_error_fd; + llvm::Optional max_fd; for (auto &pair : m_fd_map) { pair.second.PrepareForSelect(); - const int fd = pair.first; + const lldb::socket_t fd = pair.first; #if !defined(__APPLE__) && !defined(_MSC_VER) lldbassert(fd < FD_SETSIZE); if (fd >= FD_SETSIZE) { @@ -99,26 +113,21 @@ return error; } #endif - if (pair.second.read_set) { - max_read_fd = std::max(fd, max_read_fd); - max_fd = std::max(fd, max_fd); - } - if (pair.second.write_set) { - max_write_fd = std::max(fd, max_write_fd); - max_fd = std::max(fd, max_fd); - } - if (pair.second.error_set) { - max_error_fd = std::max(fd, max_error_fd); - max_fd = std::max(fd, max_fd); - } + if (pair.second.read_set) + updateMaxFd(max_read_fd, fd); + if (pair.second.write_set) + updateMaxFd(max_write_fd, fd); + if (pair.second.error_set) + updateMaxFd(max_error_fd, fd); + updateMaxFd(max_fd, fd); } - if (max_fd == -1) { + if (!max_fd.hasValue()) { error.SetErrorString("no valid file descriptors"); return error; } - const int nfds = max_fd + 1; + const unsigned nfds = static_cast(*max_fd) + 1; fd_set *read_fdset_ptr = nullptr; fd_set *write_fdset_ptr = nullptr; fd_set *error_fdset_ptr = nullptr; @@ -130,15 +139,15 @@ llvm::SmallVector write_fdset; llvm::SmallVector error_fdset; - if (max_read_fd >= 0) { + if (max_read_fd.hasValue()) { read_fdset.resize((nfds / FD_SETSIZE) + 1); read_fdset_ptr = read_fdset.data(); } - if (max_write_fd >= 0) { + if (max_write_fd.hasValue()) { write_fdset.resize((nfds / FD_SETSIZE) + 1); write_fdset_ptr = write_fdset.data(); } - if (max_error_fd >= 0) { + if (max_error_fd.hasValue()) { error_fdset.resize((nfds / FD_SETSIZE) + 1); error_fdset_ptr = error_fdset.data(); } @@ -153,15 +162,15 @@ fd_set write_fdset; fd_set error_fdset; - if (max_read_fd >= 0) { + if (max_read_fd.hasValue()) { FD_ZERO(&read_fdset); read_fdset_ptr = &read_fdset; } - if (max_write_fd >= 0) { + if (max_write_fd.hasValue()) { FD_ZERO(&write_fdset); write_fdset_ptr = &write_fdset; } - if (max_error_fd >= 0) { + if (max_error_fd.hasValue()) { FD_ZERO(&error_fdset); error_fdset_ptr = &error_fdset; } @@ -170,7 +179,7 @@ // Set the FD bits in the fdsets for read/write/error //---------------------------------------------------------------------- for (auto &pair : m_fd_map) { - const int fd = pair.first; + const lldb::socket_t fd = pair.first; if (pair.second.read_set) FD_SET(fd, read_fdset_ptr); Index: lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp @@ -189,8 +189,7 @@ // Throws: None. //-- bool CMICmdCmdGdbInfo::PrintFnSharedLibrary() { - CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance(); - bool bOk = rStdout.TextToStdout( + bool bOk = CMICmnStreamStdout::TextToStdout( "~\"From To Syms Read Shared Object Library\""); CMICmnLLDBDebugSessionInfo &rSessionInfo( @@ -224,7 +223,7 @@ } } bOk = bOk && - rStdout.TextToStdout(CMIUtilString::Format( + CMICmnStreamStdout::TextToStdout(CMIUtilString::Format( "~\"0x%016" PRIx64 "\t0x%016" PRIx64 "\t%s\t\t%s\"", addrLoadS, addrLoadS + addrLoadSize, strHasSymbols.c_str(), strModuleFullPath.c_str())); Index: lldb/trunk/tools/lldb-mi/Platform.h =================================================================== --- lldb/trunk/tools/lldb-mi/Platform.h +++ lldb/trunk/tools/lldb-mi/Platform.h @@ -13,10 +13,11 @@ #include #include #include -#include -#include #include +#include "lldb/Host/HostGetOpt.h" +#include "lldb/Host/windows/windows.h" + // This is not used by MI struct timeval { long tv_sec;