win: Get Crashpad compiling under VS2015

R=mark@chromium.org
BUG=crashpad:1, chromium:440500

Review URL: https://codereview.chromium.org/1357833002 .
This commit is contained in:
Scott Graham 2015-09-21 10:51:15 -07:00
parent 4a34a3dd89
commit 6082aed2f2
11 changed files with 39 additions and 25 deletions

View File

@ -118,8 +118,8 @@ bool CrashpadClient::SetHandler(const std::string& ipc_port) {
}
// The server returns these already duplicated to be valid in this process.
g_signal_exception =
reinterpret_cast<HANDLE>(response.registration.request_report_event);
g_signal_exception = reinterpret_cast<HANDLE>(
static_cast<uintptr_t>(response.registration.request_report_event));
return true;
}

View File

@ -16,7 +16,6 @@
#include <limits>
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "util/numeric/in_range_cast.h"
@ -40,7 +39,7 @@ void ScopedLockedFileHandleTraits::Free(FileHandle handle) {
} // namespace internal
struct ALIGNAS(4) Settings::Data {
struct Settings::Data {
static const uint32_t kSettingsMagic = 'CPds';
static const uint32_t kSettingsVersion = 1;

View File

@ -16,7 +16,11 @@
#define CRASHPAD_COMPAT_WIN_SYS_TYPES_H_
// This is intended to be roughly equivalent to #include_next.
#if _MSC_VER < 1900
#include <../include/sys/types.h>
#else
#include <../ucrt/sys/types.h>
#endif
#include <stdint.h>

View File

@ -15,7 +15,12 @@
#ifndef CRASHPAD_COMPAT_WIN_TIME_H_
#define CRASHPAD_COMPAT_WIN_TIME_H_
// This is intended to be roughly equivalent to #include_next.
#if _MSC_VER < 1900
#include <../include/time.h>
#else
#include <../ucrt/time.h>
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -290,6 +290,7 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
// but the test should complete without failure.
const uint32_t kSnapshotTime = 0xfd469ab8;
MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value.
MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion.
const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
TestProcessSnapshot process_snapshot;

View File

@ -123,6 +123,10 @@ TEST_F(SystemSnapshotWinTest, TimeZone) {
// |standard_offset_seconds| gives seconds east of UTC, and |timezone| gives
// seconds west of UTC.
#if _MSC_VER >= 1900
long timezone = 0;
_get_timezone(&timezone);
#endif
EXPECT_EQ(-timezone, standard_offset_seconds);
// In contemporary usage, most time zones have an integer hour offset from

View File

@ -152,8 +152,8 @@ WinChildProcess::WinChildProcess() {
unsigned int write, read;
CHECK(StringToNumber(left, &write));
CHECK(StringToNumber(right, &read));
pipe_write_.reset(reinterpret_cast<HANDLE>(write));
pipe_read_.reset(reinterpret_cast<HANDLE>(read));
pipe_write_.reset(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(write)));
pipe_read_.reset(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(read)));
// Notify the parent that it's OK to proceed. We only need to wait to get to
// the process entry point, but this is the easiest place we can notify.

View File

@ -17,6 +17,7 @@
#include <string.h>
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@ -351,7 +352,7 @@ bool ExceptionHandlerServer::ServiceClientConnection(
PLOG(ERROR) << "ImpersonateNamedPipeClient";
return false;
}
HANDLE client_process = OpenProcess(
client_process = OpenProcess(
kXPProcessAllAccess, false, message.registration.client_process_id);
PCHECK(RevertToSelf());
if (!client_process) {
@ -375,8 +376,9 @@ bool ExceptionHandlerServer::ServiceClientConnection(
// Duplicate the events back to the client so they can request a dump.
ServerToClientMessage response;
response.registration.request_report_event = reinterpret_cast<uint32_t>(
DuplicateEvent(client->process(), client->dump_requested_event()));
response.registration.request_report_event =
base::checked_cast<uint32_t>(reinterpret_cast<uintptr_t>(
DuplicateEvent(client->process(), client->dump_requested_event())));
if (!LoggingWriteFile(service_context.pipe(), &response, sizeof(response)))
return false;

View File

@ -35,11 +35,11 @@ bool GetModuleVersionAndType(const base::FilePath& path,
<< base::UTF16ToUTF8(path.value());
} else {
VS_FIXEDFILEINFO* fixed_file_info;
UINT size;
UINT ffi_size;
if (!VerQueryValue(data.get(),
L"\\",
reinterpret_cast<void**>(&fixed_file_info),
&size)) {
&ffi_size)) {
PLOG(WARNING) << "VerQueryValue";
} else {
*vs_fixedfileinfo = *fixed_file_info;

View File

@ -68,11 +68,12 @@ bool ReadUnicodeString(HANDLE process,
DCHECK_EQ(us.Length % sizeof(wchar_t), 0u);
result->resize(us.Length / sizeof(wchar_t));
SIZE_T bytes_read;
if (!ReadProcessMemory(process,
reinterpret_cast<const void*>(us.Buffer),
&result->operator[](0),
us.Length,
&bytes_read)) {
if (!ReadProcessMemory(
process,
reinterpret_cast<const void*>(static_cast<uintptr_t>(us.Buffer)),
&result->operator[](0),
us.Length,
&bytes_read)) {
PLOG(ERROR) << "ReadProcessMemory UNICODE_STRING";
return false;
}
@ -198,11 +199,10 @@ bool ReadProcessData(HANDLE process,
// Include the first module in the memory order list to get our the main
// executable's name, as it's not included in initialization order below.
if (!ReadStruct(process,
reinterpret_cast<WinVMAddress>(
reinterpret_cast<const char*>(
peb_ldr_data.InMemoryOrderModuleList.Flink) -
static_cast<WinVMAddress>(
peb_ldr_data.InMemoryOrderModuleList.Flink) -
offsetof(process_types::LDR_DATA_TABLE_ENTRY<Traits>,
InMemoryOrderLinks)),
InMemoryOrderLinks),
&ldr_data_table_entry)) {
return false;
}
@ -228,10 +228,9 @@ bool ReadProcessData(HANDLE process,
// to read from the target, and also offset back to the beginning of the
// structure.
if (!ReadStruct(process,
reinterpret_cast<WinVMAddress>(
reinterpret_cast<const char*>(cur) -
static_cast<WinVMAddress>(cur) -
offsetof(process_types::LDR_DATA_TABLE_ENTRY<Traits>,
InInitializationOrderLinks)),
InInitializationOrderLinks),
&ldr_data_table_entry)) {
break;
}

View File

@ -95,11 +95,11 @@ TEST(ScopedProcessSuspend, ScopedProcessSuspend) {
EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 0));
{
ScopedProcessSuspend suspend(handles->process.get());
ScopedProcessSuspend suspend0(handles->process.get());
EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 1));
{
ScopedProcessSuspend suspend(handles->process.get());
ScopedProcessSuspend suspend1(handles->process.get());
EXPECT_TRUE(SuspendCountMatches(handles->process.get(), 2));
}