Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -218,9 +218,7 @@ endif () if(LLDB_USED_LIBS) - if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR - CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR - CMAKE_SYSTEM_NAME MATCHES "Windows") + if (LLVM_COMPILER_IS_GCC_COMPATIBLE) target_link_libraries(${name} ${cmake_2_8_12_PUBLIC} -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group) else() Index: include/lldb/Core/DataBufferMemoryMap.h =================================================================== --- include/lldb/Core/DataBufferMemoryMap.h +++ include/lldb/Core/DataBufferMemoryMap.h @@ -108,7 +108,7 @@ size_t MemoryMapFromFileSpec (const FileSpec* file, lldb::offset_t offset = 0, - lldb::offset_t length = SIZE_MAX, + size_t length = SIZE_MAX, bool writeable = false); //------------------------------------------------------------------ @@ -137,7 +137,7 @@ size_t MemoryMapFromFileDescriptor (int fd, lldb::offset_t offset, - lldb::offset_t length, + size_t length, bool write, bool fd_is_file); Index: source/Core/ConnectionSharedMemory.cpp =================================================================== --- source/Core/ConnectionSharedMemory.cpp +++ source/Core/ConnectionSharedMemory.cpp @@ -24,6 +24,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "llvm/Support/MathExtras.h" #include "lldb/lldb-private-log.h" #include "lldb/Core/Communication.h" #include "lldb/Core/Log.h" @@ -125,8 +126,15 @@ #ifdef _WIN32 HANDLE handle; - if (create) - handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, (DWORD)(size >> 32), (DWORD)(size), name); + if (create) { + handle = CreateFileMapping( + INVALID_HANDLE_VALUE, + NULL, + PAGE_READWRITE, + llvm::Hi_32(size), + llvm::Lo_32(size), + name); + } else handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name); Index: source/Core/DataBufferMemoryMap.cpp =================================================================== --- source/Core/DataBufferMemoryMap.cpp +++ source/Core/DataBufferMemoryMap.cpp @@ -18,6 +18,8 @@ #include #endif +#include "llvm/Support/MathExtras.h" + #include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/Error.h" #include "lldb/Host/File.h" @@ -113,7 +115,7 @@ size_t DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec, lldb::offset_t offset, - lldb::offset_t length, + size_t length, bool writeable) { if (filespec != NULL) @@ -124,7 +126,7 @@ log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(file=\"%s\", offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i", filespec->GetPath().c_str(), offset, - length, + (uint64_t)length, writeable); } char path[PATH_MAX]; @@ -147,16 +149,16 @@ Clear(); return 0; } - - -#ifdef _WIN32 -static size_t win32memmapalignment = 0; -void LoadWin32MemMapAlignment () -{ - SYSTEM_INFO data; - GetSystemInfo(&data); - win32memmapalignment = data.dwAllocationGranularity; -} + + +#ifdef _WIN32 +static size_t win32memmapalignment = 0; +void LoadWin32MemMapAlignment () +{ + SYSTEM_INFO data; + GetSystemInfo(&data); + win32memmapalignment = data.dwAllocationGranularity; +} #endif //---------------------------------------------------------------------- @@ -174,7 +176,7 @@ size_t DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, lldb::offset_t offset, - lldb::offset_t length, + size_t length, bool writeable, bool fd_is_file) { @@ -184,14 +186,10 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE)); if (log) { -#ifdef _WIN32 - log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%p, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)", -#else - log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)", -#endif + log->Printf("DataBufferMemoryMap::MemoryMapFromFileDescriptor(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)", fd, offset, - length, + (uint64_t)length, writeable, fd_is_file); } @@ -199,16 +197,13 @@ HANDLE handle = (HANDLE)_get_osfhandle(fd); DWORD file_size_low, file_size_high; file_size_low = GetFileSize(handle, &file_size_high); - const size_t file_size = (file_size_high << 32) | file_size_low; - const size_t max_bytes_available = file_size - offset; - if (length == SIZE_MAX) - { - length = max_bytes_available; - } - else if (length > max_bytes_available) + const lldb::offset_t file_size = llvm::Make_64(file_size_high, file_size_low); + const lldb::offset_t max_bytes_available = file_size - offset; + const size_t max_bytes_mappable = (size_t)std::min(SIZE_MAX, max_bytes_available); + if (length == SIZE_MAX || length > max_bytes_mappable) { // Cap the length if too much data was requested - length = max_bytes_available; + length = max_bytes_mappable; } if (length > 0) @@ -216,23 +211,23 @@ HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL); if (fileMapping != NULL) { - if (win32memmapalignment == 0) LoadWin32MemMapAlignment(); - lldb::offset_t realoffset = offset; - lldb::offset_t delta = 0; - if (realoffset % win32memmapalignment != 0) { - realoffset = realoffset / win32memmapalignment * win32memmapalignment; - delta = offset - realoffset; - } - - LPVOID data = MapViewOfFile(fileMapping, writeable ? FILE_MAP_WRITE : FILE_MAP_READ, 0, realoffset, length + delta); - m_mmap_addr = (uint8_t *)data; - if (!data) { - Error error; - error.SetErrorToErrno (); + if (win32memmapalignment == 0) LoadWin32MemMapAlignment(); + lldb::offset_t realoffset = offset; + lldb::offset_t delta = 0; + if (realoffset % win32memmapalignment != 0) { + realoffset = realoffset / win32memmapalignment * win32memmapalignment; + delta = offset - realoffset; + } + + LPVOID data = MapViewOfFile(fileMapping, writeable ? FILE_MAP_WRITE : FILE_MAP_READ, 0, realoffset, length + delta); + m_mmap_addr = (uint8_t *)data; + if (!data) { + Error error; + error.SetErrorToErrno (); } else { - m_data = m_mmap_addr + delta; - m_size = length; - } + m_data = m_mmap_addr + delta; + m_size = length; + } CloseHandle(fileMapping); } } Index: source/Host/windows/Host.cpp =================================================================== --- source/Host/windows/Host.cpp +++ source/Host/windows/Host.cpp @@ -34,10 +34,15 @@ ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - +#pragma warning(push) +#pragma warning(disable: 4996) + // Starting with Microsoft SDK for Windows 8.1, this function is deprecated in favor of the + // new Windows Version Helper APIs. Since we don't specify a minimum SDK version, it's easier + // to simply disable the warning rather than try to support both APIs. if (GetVersionEx((LPOSVERSIONINFO) &info) == 0) { return false; } +#pragma warning(pop) major = (uint32_t) info.dwMajorVersion; minor = (uint32_t) info.dwMinorVersion; Index: source/Plugins/Platform/Windows/PlatformWindows.cpp =================================================================== --- source/Plugins/Platform/Windows/PlatformWindows.cpp +++ source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -628,19 +628,17 @@ Platform::GetStatus(strm); #ifdef _WIN32 - OSVERSIONINFO info; - - ZeroMemory(&info, sizeof(OSVERSIONINFO)); - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - if (GetVersionEx(&info) == 0) + uint32_t major; + uint32_t minor; + uint32_t update; + if (!Host::GetOSVersion(major, minor, update)) { strm << "Windows"; return; } - strm << "Host: Windows " << (int) info.dwMajorVersion - << '.' << (int) info.dwMinorVersion - << " Build: " << (int) info.dwBuildNumber << '\n'; + strm << "Host: Windows " << major + << '.' << minor + << " Build: " << update << '\n'; #endif }