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. // The server returns these already duplicated to be valid in this process.
g_signal_exception = g_signal_exception = reinterpret_cast<HANDLE>(
reinterpret_cast<HANDLE>(response.registration.request_report_event); static_cast<uintptr_t>(response.registration.request_report_event));
return true; return true;
} }

View File

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

View File

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

View File

@ -15,7 +15,12 @@
#ifndef CRASHPAD_COMPAT_WIN_TIME_H_ #ifndef CRASHPAD_COMPAT_WIN_TIME_H_
#define 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> #include <../include/time.h>
#else
#include <../ucrt/time.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

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

View File

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

View File

@ -152,8 +152,8 @@ WinChildProcess::WinChildProcess() {
unsigned int write, read; unsigned int write, read;
CHECK(StringToNumber(left, &write)); CHECK(StringToNumber(left, &write));
CHECK(StringToNumber(right, &read)); CHECK(StringToNumber(right, &read));
pipe_write_.reset(reinterpret_cast<HANDLE>(write)); pipe_write_.reset(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(write)));
pipe_read_.reset(reinterpret_cast<HANDLE>(read)); 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 // 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. // the process entry point, but this is the easiest place we can notify.

View File

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

View File

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

View File

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

View File

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