[Lldb-commits] [lldb] r210035 - Fix most of the remaining Windows build warnings.
Todd Fiala
todd.fiala at gmail.com
Mon Jun 2 10:30:23 PDT 2014
Author: tfiala
Date: Mon Jun 2 12:30:22 2014
New Revision: 210035
URL: http://llvm.org/viewvc/llvm-project?rev=210035&view=rev
Log:
Fix most of the remaining Windows build warnings.
See http://reviews.llvm.org/D3944 for more details.
Change by Zachary Turner.
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h
lldb/trunk/source/Core/ConnectionSharedMemory.cpp
lldb/trunk/source/Core/DataBufferMemoryMap.cpp
lldb/trunk/source/Host/windows/Host.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Jun 2 12:30:22 2014
@@ -218,9 +218,7 @@ macro(add_lldb_library name)
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()
Modified: lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h (original)
+++ lldb/trunk/include/lldb/Core/DataBufferMemoryMap.h Mon Jun 2 12:30:22 2014
@@ -100,7 +100,12 @@ public:
/// @param[in] length
/// The size in bytes that should be mapped starting \a offset
/// bytes into the file. If \a length is \c SIZE_MAX, map
- /// as many bytes as possible.
+ /// as many bytes as possible. Even though it may be possible
+ /// for a 32-bit host debugger to debug a 64-bit target, size_t
+ /// still dictates the maximum possible size that can be mapped
+ /// into this process. For this kind of cross-arch debugging
+ /// scenario, mappings and views should be managed at a higher
+ /// level.
///
/// @return
/// The number of bytes mapped starting from the \a offset.
@@ -108,7 +113,7 @@ public:
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 +142,7 @@ public:
size_t
MemoryMapFromFileDescriptor (int fd,
lldb::offset_t offset,
- lldb::offset_t length,
+ size_t length,
bool write,
bool fd_is_file);
Modified: lldb/trunk/source/Core/ConnectionSharedMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionSharedMemory.cpp (original)
+++ lldb/trunk/source/Core/ConnectionSharedMemory.cpp Mon Jun 2 12:30:22 2014
@@ -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 @@ ConnectionSharedMemory::Open (bool creat
#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);
Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataBufferMemoryMap.cpp?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataBufferMemoryMap.cpp (original)
+++ lldb/trunk/source/Core/DataBufferMemoryMap.cpp Mon Jun 2 12:30:22 2014
@@ -18,6 +18,8 @@
#include <sys/mman.h>
#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 @@ DataBufferMemoryMap::Clear()
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 @@ DataBufferMemoryMap::MemoryMapFromFileSp
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 @@ DataBufferMemoryMap::MemoryMapFromFileSp
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 @@ void LoadWin32MemMapAlignment ()
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 @@ DataBufferMemoryMap::MemoryMapFromFileDe
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 @@ DataBufferMemoryMap::MemoryMapFromFileDe
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<lldb::offset_t>(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 @@ DataBufferMemoryMap::MemoryMapFromFileDe
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);
}
}
Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Mon Jun 2 12:30:22 2014
@@ -34,10 +34,15 @@ Host::GetOSVersion(uint32_t &major,
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;
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=210035&r1=210034&r2=210035&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Mon Jun 2 12:30:22 2014
@@ -628,19 +628,17 @@ PlatformWindows::GetStatus (Stream &strm
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
}
More information about the lldb-commits
mailing list