summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2014-06-02 17:30:22 +0000
committerTodd Fiala <todd.fiala@gmail.com>2014-06-02 17:30:22 +0000
commit4dc625281d0269513226cc2282f95f16a9b65e71 (patch)
tree8d65af268dfca845afa26bc25dc4061f82ee6cb2
parenta84189a2e4f9401501275f07c0f52e61df3e619c (diff)
downloadbcm5719-llvm-4dc625281d0269513226cc2282f95f16a9b65e71.tar.gz
bcm5719-llvm-4dc625281d0269513226cc2282f95f16a9b65e71.zip
Fix most of the remaining Windows build warnings.
See http://reviews.llvm.org/D3944 for more details. Change by Zachary Turner. llvm-svn: 210035
-rw-r--r--lldb/CMakeLists.txt4
-rw-r--r--lldb/include/lldb/Core/DataBufferMemoryMap.h11
-rw-r--r--lldb/source/Core/ConnectionSharedMemory.cpp12
-rw-r--r--lldb/source/Core/DataBufferMemoryMap.cpp81
-rw-r--r--lldb/source/Host/windows/Host.cpp7
-rw-r--r--lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp16
6 files changed, 70 insertions, 61 deletions
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index f758362e98f..bad83e81a35 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -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()
diff --git a/lldb/include/lldb/Core/DataBufferMemoryMap.h b/lldb/include/lldb/Core/DataBufferMemoryMap.h
index d4a448a5df5..944b975a318 100644
--- a/lldb/include/lldb/Core/DataBufferMemoryMap.h
+++ b/lldb/include/lldb/Core/DataBufferMemoryMap.h
@@ -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);
diff --git a/lldb/source/Core/ConnectionSharedMemory.cpp b/lldb/source/Core/ConnectionSharedMemory.cpp
index cd708c4868c..5db3d687cdb 100644
--- a/lldb/source/Core/ConnectionSharedMemory.cpp
+++ b/lldb/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 @@ ConnectionSharedMemory::Open (bool create, const char *name, size_t size, Error
#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);
diff --git a/lldb/source/Core/DataBufferMemoryMap.cpp b/lldb/source/Core/DataBufferMemoryMap.cpp
index 9dc536b9586..f707d23e7fa 100644
--- a/lldb/source/Core/DataBufferMemoryMap.cpp
+++ b/lldb/source/Core/DataBufferMemoryMap.cpp
@@ -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::MemoryMapFromFileSpec (const FileSpec* filespec,
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::MemoryMapFromFileSpec (const FileSpec* filespec,
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::MemoryMapFromFileDescriptor (int fd,
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::MemoryMapFromFileDescriptor (int fd,
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::MemoryMapFromFileDescriptor (int fd,
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);
}
}
diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
index 24f7e4bd896..28b4b08d88f 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -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;
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 4325abfd8e7..8ae1d8ab3cd 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -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
}
OpenPOWER on IntegriCloud