win: Work towards getting 'minidump' to compile
- dbghelp.h requires windows.h to be included before it (ick!). Add a stub one for non_win to make this work. - convert __attribute__ -> macro that can work work with MSVC; - a handful of narrowing casts. R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/883773005
This commit is contained in:
Родитель
409742cd40
Коммит
429a3368d4
|
@ -28,6 +28,7 @@
|
|||
'non_win/minwinbase.h',
|
||||
'non_win/timezoneapi.h',
|
||||
'non_win/verrsrc.h',
|
||||
'non_win/windows.h',
|
||||
'non_win/winnt.h',
|
||||
'win/sys/types.h',
|
||||
],
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// dbghelp.h on Windows requires inclusion of windows.h before it. To avoid
|
||||
// cluttering all inclusions of dbghelp.h with #ifdefs, always include windows.h
|
||||
// and have an empty one on non-Windows platforms.
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2015 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_COMPAT_WIN_SYS_TIME_H_
|
||||
#define CRASHPAD_COMPAT_WIN_SYS_TIME_H_
|
||||
|
||||
struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
#endif // CRASHPAD_COMPAT_WIN_SYS_TIME_H_
|
|
@ -21,7 +21,9 @@
|
|||
#ifdef _WIN64
|
||||
typedef __int64 ssize_t;
|
||||
#else
|
||||
typedef _W64 int ssize_t;
|
||||
typedef __w64 int ssize_t;
|
||||
#endif
|
||||
|
||||
typedef unsigned long pid_t;
|
||||
|
||||
#endif // CRASHPAD_COMPAT_WIN_SYS_TYPES_H_
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "snapshot/cpu_context.h"
|
||||
#include "util/numeric/int128.h"
|
||||
|
||||
|
@ -187,7 +188,7 @@ struct MinidumpContextX86 {
|
|||
CPUContextX86::Fxsave fxsave;
|
||||
};
|
||||
|
||||
//! \brief x86_64-specifc flags for MinidumpContextAMD64::context_flags.
|
||||
//! \brief x86_64-specific flags for MinidumpContextAMD64::context_flags.
|
||||
enum MinidumpContextAMD64Flags : uint32_t {
|
||||
//! \brief Identifies the context structure as x86_64. This is the same as
|
||||
//! `CONTEXT_AMD64` on Windows for this architecture.
|
||||
|
@ -253,7 +254,7 @@ enum MinidumpContextAMD64Flags : uint32_t {
|
|||
//! normally alias `dr6` and `dr7`, respectively. See Intel Software
|
||||
//! Developer’s Manual, Volume 3B: System Programming, Part 2 (253669-052),
|
||||
//! 17.2.2 “Debug Registers DR4 and DR5”.
|
||||
struct __attribute__((aligned(16))) MinidumpContextAMD64 {
|
||||
struct ALIGNAS(16) MinidumpContextAMD64 {
|
||||
//! \brief Register parameter home address.
|
||||
//!
|
||||
//! On Windows, this field may contain the “home” address (on-stack, in the
|
||||
|
|
|
@ -160,7 +160,8 @@ void MinidumpContextAMD64Writer::InitializeFromSnapshot(
|
|||
context_.cs = context_snapshot->cs;
|
||||
context_.fs = context_snapshot->fs;
|
||||
context_.gs = context_snapshot->gs;
|
||||
context_.eflags = context_snapshot->rflags;
|
||||
// The top 32 bits of rflags are reserved/unused.
|
||||
context_.eflags = static_cast<uint32_t>(context_snapshot->rflags);
|
||||
context_.dr0 = context_snapshot->dr0;
|
||||
context_.dr1 = context_snapshot->dr1;
|
||||
context_.dr2 = context_snapshot->dr2;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_crashpad_info_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_EXCEPTION_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_EXCEPTION_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_exception_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -15,12 +15,22 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "build/build_config.h"
|
||||
#include "util/misc/uuid.h"
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
#define PACKED
|
||||
#pragma pack(push, 1)
|
||||
#else
|
||||
#define PACKED __attribute__((packed))
|
||||
#endif // COMPILER_MSVC
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
//! \brief Minidump stream type values for MINIDUMP_DIRECTORY::StreamType. Each
|
||||
|
@ -69,7 +79,7 @@ enum MinidumpStreamType : uint32_t {
|
|||
//! file.
|
||||
//!
|
||||
//! \sa MINIDUMP_STRING
|
||||
struct __attribute__((packed, aligned(4))) MinidumpUTF8String {
|
||||
struct ALIGNAS(4) PACKED MinidumpUTF8String {
|
||||
// The field names do not conform to typical style, they match the names used
|
||||
// in MINIDUMP_STRING. This makes it easier to operate on MINIDUMP_STRING (for
|
||||
// UTF-16 strings) and MinidumpUTF8String using templates.
|
||||
|
@ -297,7 +307,7 @@ struct MinidumpModuleCodeViewRecordPDB70 {
|
|||
};
|
||||
|
||||
//! \brief A list of ::RVA pointers.
|
||||
struct __attribute__((packed, aligned(4))) MinidumpRVAList {
|
||||
struct ALIGNAS(4) PACKED MinidumpRVAList {
|
||||
//! \brief The number of children present in the #children array.
|
||||
uint32_t count;
|
||||
|
||||
|
@ -306,7 +316,7 @@ struct __attribute__((packed, aligned(4))) MinidumpRVAList {
|
|||
};
|
||||
|
||||
//! \brief A list of MINIDUMP_LOCATION_DESCRIPTOR objects.
|
||||
struct __attribute__((packed, aligned(4))) MinidumpLocationDescriptorList {
|
||||
struct ALIGNAS(4) PACKED MinidumpLocationDescriptorList {
|
||||
//! \brief The number of children present in the #children array.
|
||||
uint32_t count;
|
||||
|
||||
|
@ -315,7 +325,7 @@ struct __attribute__((packed, aligned(4))) MinidumpLocationDescriptorList {
|
|||
};
|
||||
|
||||
//! \brief A key-value pair.
|
||||
struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionaryEntry {
|
||||
struct ALIGNAS(4) PACKED MinidumpSimpleStringDictionaryEntry {
|
||||
//! \brief ::RVA of a MinidumpUTF8String containing the key of a key-value
|
||||
//! pair.
|
||||
RVA key;
|
||||
|
@ -326,7 +336,7 @@ struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionaryEntry {
|
|||
};
|
||||
|
||||
//! \brief A list of key-value pairs.
|
||||
struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionary {
|
||||
struct ALIGNAS(4) PACKED MinidumpSimpleStringDictionary {
|
||||
//! \brief The number of key-value pairs present.
|
||||
uint32_t count;
|
||||
|
||||
|
@ -349,7 +359,7 @@ struct __attribute__((packed, aligned(4))) MinidumpSimpleStringDictionary {
|
|||
//! fields are valid or not.
|
||||
//!
|
||||
//! \sa #MinidumpModuleCrashpadInfoList
|
||||
struct __attribute__((packed, aligned(4))) MinidumpModuleCrashpadInfo {
|
||||
struct ALIGNAS(4) PACKED MinidumpModuleCrashpadInfo {
|
||||
//! \brief The structure’s currently-defined version number.
|
||||
//!
|
||||
//! \sa version
|
||||
|
@ -422,7 +432,7 @@ using MinidumpModuleCrashpadInfoList = MinidumpLocationDescriptorList;
|
|||
//! structure. Revise #kVersion and document each field’s validity based on
|
||||
//! #version, so that newer parsers will be able to determine whether the added
|
||||
//! fields are valid or not.
|
||||
struct __attribute__((packed, aligned(4))) MinidumpCrashpadInfo {
|
||||
struct ALIGNAS(4) PACKED MinidumpCrashpadInfo {
|
||||
//! \brief The structure’s currently-defined version number.
|
||||
//!
|
||||
//! \sa version
|
||||
|
@ -445,6 +455,11 @@ struct __attribute__((packed, aligned(4))) MinidumpCrashpadInfo {
|
|||
MINIDUMP_LOCATION_DESCRIPTOR module_list;
|
||||
};
|
||||
|
||||
#if defined(COMPILER_MSVC)
|
||||
#pragma pack(pop)
|
||||
#endif // COMPILER_MSVC
|
||||
#undef PACKED
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_MINIDUMP_EXTENSIONS_H_
|
||||
|
|
|
@ -125,7 +125,7 @@ void MinidumpFileWriter::AddStream(
|
|||
bool MinidumpFileWriter::WriteEverything(FileWriterInterface* file_writer) {
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
|
||||
off_t start_offset = file_writer->Seek(0, SEEK_CUR);
|
||||
FileOffset start_offset = file_writer->Seek(0, SEEK_CUR);
|
||||
if (start_offset < 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ bool MinidumpFileWriter::WriteEverything(FileWriterInterface* file_writer) {
|
|||
return false;
|
||||
}
|
||||
|
||||
off_t end_offset = file_writer->Seek(0, SEEK_CUR);
|
||||
FileOffset end_offset = file_writer->Seek(0, SEEK_CUR);
|
||||
if (end_offset < 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_FILE_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_FILE_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_file_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_memory_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
|||
uint32_t TimevalToRoundedSeconds(const timeval& tv) {
|
||||
uint32_t seconds =
|
||||
InRangeCast<uint32_t>(tv.tv_sec, std::numeric_limits<uint32_t>::max());
|
||||
const int kMicrosecondsPerSecond = 1E6;
|
||||
const int kMicrosecondsPerSecond = static_cast<int>(1E6);
|
||||
if (tv.tv_usec >= kMicrosecondsPerSecond / 2 &&
|
||||
seconds != std::numeric_limits<uint32_t>::max()) {
|
||||
++seconds;
|
||||
|
@ -101,6 +101,8 @@ std::string MinidumpMiscInfoDebugBuildString() {
|
|||
const char kOS[] = "mac";
|
||||
#elif defined(OS_LINUX)
|
||||
const char kOS[] = "linux";
|
||||
#elif defined(OS_WIN)
|
||||
const char kOS[] = "win";
|
||||
#else
|
||||
#error define kOS for this operating system
|
||||
#endif
|
||||
|
@ -150,7 +152,7 @@ void MinidumpMiscInfoWriter::InitializeFromSnapshot(
|
|||
uint64_t current_mhz;
|
||||
uint64_t max_mhz;
|
||||
system_snapshot->CPUFrequency(¤t_mhz, &max_mhz);
|
||||
const uint32_t kHzPerMHz = 1E6;
|
||||
const uint32_t kHzPerMHz = static_cast<const uint32_t>(1E6);
|
||||
SetProcessorPowerInfo(
|
||||
InRangeCast<uint32_t>(current_mhz / kHzPerMHz,
|
||||
std::numeric_limits<uint32_t>::max()),
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_MISC_INFO_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_MISC_INFO_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_misc_info_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_module_crashpad_info_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_MODULE_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_MODULE_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_module_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_STREAM_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_STREAM_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_string_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_system_info_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -36,7 +36,7 @@ void BuildMinidumpThreadIDMap(
|
|||
for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
|
||||
uint64_t thread_id_64 = thread_snapshot->ThreadID();
|
||||
if (thread_id_map->find(thread_id_64) == thread_id_map->end()) {
|
||||
uint32_t thread_id_32 = thread_id_64;
|
||||
uint32_t thread_id_32 = static_cast<uint32_t>(thread_id_64);
|
||||
if (thread_ids_32.find(thread_id_32) != thread_ids_32.end()) {
|
||||
collision = true;
|
||||
break;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_THREAD_WRITER_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_THREAD_WRITER_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/minidump_thread_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_
|
||||
#define CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void MinidumpWriterUtil::AssignTimeT(uint32_t* destination, time_t source) {
|
|||
LOG(WARNING) << "timestamp " << source << " out of range";
|
||||
}
|
||||
|
||||
*destination = source;
|
||||
*destination = static_cast<uint32_t>(source);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_FILE_WRITER_TEST_UTIL_H_
|
||||
#define CRASHPAD_MINIDUMP_TEST_MINIDUMP_FILE_WRITER_TEST_UTIL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/test/minidump_location_descriptor_list_test_util.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "minidump/minidump_extensions.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "minidump/minidump_memory_writer.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "minidump/test/minidump_rva_list_test_util.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "minidump/minidump_extensions.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_
|
||||
#define CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_
|
||||
#define CRASHPAD_MINIDUMP_TEST_MINIDUMP_WRITABLE_TEST_UTIL_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
|
Загрузка…
Ссылка в новой задаче