mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
win: fixes for Windows x64
Mostly size_t <-> unsigned int warnings, but I also had a mistake in PROCESS_BASIC_INFORMATION, the pids are 32-on-32 and 64-on-64. The Windows build is still x86 until https://codereview.chromium.org/981333002/. I don't think I'll bother maintaining the x86 build for now, though we will probably need it for x86 OSs in the future. It should be straightforward to revive it once we need it, and have bots to support it. R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/983103004
This commit is contained in:
parent
64b87325b9
commit
07fcf63c21
@ -390,7 +390,7 @@ void Metadata::Read() {
|
|||||||
|
|
||||||
base::CheckedNumeric<uint32_t> records_size =
|
base::CheckedNumeric<uint32_t> records_size =
|
||||||
base::CheckedNumeric<uint32_t>(header.num_records) *
|
base::CheckedNumeric<uint32_t>(header.num_records) *
|
||||||
sizeof(MetadataFileReportRecord);
|
static_cast<uint32_t>(sizeof(MetadataFileReportRecord));
|
||||||
if (!records_size.IsValid()) {
|
if (!records_size.IsValid()) {
|
||||||
LOG(ERROR) << "record size out of range";
|
LOG(ERROR) << "record size out of range";
|
||||||
return;
|
return;
|
||||||
|
@ -18,12 +18,15 @@
|
|||||||
// This is intended to be roughly equivalent to #include_next.
|
// This is intended to be roughly equivalent to #include_next.
|
||||||
#include <../include/sys/types.h>
|
#include <../include/sys/types.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
typedef __int64 ssize_t;
|
typedef int64_t ssize_t;
|
||||||
|
typedef uint64_t pid_t;
|
||||||
#else
|
#else
|
||||||
typedef __w64 int ssize_t;
|
typedef __w64 int ssize_t;
|
||||||
|
typedef __w64 unsigned int pid_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned long pid_t;
|
|
||||||
|
|
||||||
#endif // CRASHPAD_COMPAT_WIN_SYS_TYPES_H_
|
#endif // CRASHPAD_COMPAT_WIN_SYS_TYPES_H_
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "minidump/minidump_context_writer.h"
|
#include "minidump/minidump_context_writer.h"
|
||||||
#include "snapshot/exception_snapshot.h"
|
#include "snapshot/exception_snapshot.h"
|
||||||
#include "util/file/file_writer.h"
|
#include "util/file/file_writer.h"
|
||||||
@ -66,7 +67,8 @@ void MinidumpExceptionWriter::SetExceptionInformation(
|
|||||||
arraysize(exception_.ExceptionRecord.ExceptionInformation);
|
arraysize(exception_.ExceptionRecord.ExceptionInformation);
|
||||||
CHECK_LE(parameters, kMaxParameters);
|
CHECK_LE(parameters, kMaxParameters);
|
||||||
|
|
||||||
exception_.ExceptionRecord.NumberParameters = parameters;
|
exception_.ExceptionRecord.NumberParameters =
|
||||||
|
base::checked_cast<uint32_t>(parameters);
|
||||||
size_t parameter = 0;
|
size_t parameter = 0;
|
||||||
for (; parameter < parameters; ++parameter) {
|
for (; parameter < parameters; ++parameter) {
|
||||||
exception_.ExceptionRecord.ExceptionInformation[parameter] =
|
exception_.ExceptionRecord.ExceptionInformation[parameter] =
|
||||||
|
@ -181,7 +181,7 @@ TEST(MinidumpExceptionWriter, Standard) {
|
|||||||
expected_exception_stream.ExceptionRecord.ExceptionAddress =
|
expected_exception_stream.ExceptionRecord.ExceptionAddress =
|
||||||
kExceptionAddress;
|
kExceptionAddress;
|
||||||
expected_exception_stream.ExceptionRecord.NumberParameters =
|
expected_exception_stream.ExceptionRecord.NumberParameters =
|
||||||
exception_information.size();
|
static_cast<uint32_t>(exception_information.size());
|
||||||
for (size_t index = 0; index < exception_information.size(); ++index) {
|
for (size_t index = 0; index < exception_information.size(); ++index) {
|
||||||
expected_exception_stream.ExceptionRecord.ExceptionInformation[index] =
|
expected_exception_stream.ExceptionRecord.ExceptionInformation[index] =
|
||||||
exception_information[index];
|
exception_information[index];
|
||||||
@ -209,7 +209,8 @@ TEST(MinidumpExceptionWriter, InitializeFromSnapshot) {
|
|||||||
expect_exception.ExceptionRecord.ExceptionCode = 100;
|
expect_exception.ExceptionRecord.ExceptionCode = 100;
|
||||||
expect_exception.ExceptionRecord.ExceptionFlags = 1;
|
expect_exception.ExceptionRecord.ExceptionFlags = 1;
|
||||||
expect_exception.ExceptionRecord.ExceptionAddress = 0xfedcba9876543210;
|
expect_exception.ExceptionRecord.ExceptionAddress = 0xfedcba9876543210;
|
||||||
expect_exception.ExceptionRecord.NumberParameters = exception_codes.size();
|
expect_exception.ExceptionRecord.NumberParameters =
|
||||||
|
static_cast<uint32_t>(exception_codes.size());
|
||||||
for (size_t index = 0; index < exception_codes.size(); ++index) {
|
for (size_t index = 0; index < exception_codes.size(); ++index) {
|
||||||
expect_exception.ExceptionRecord.ExceptionInformation[index] =
|
expect_exception.ExceptionRecord.ExceptionInformation[index] =
|
||||||
exception_codes[index];
|
exception_codes[index];
|
||||||
|
@ -194,7 +194,7 @@ std::vector<internal::MinidumpWritable*> MinidumpFileWriter::Children() {
|
|||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinidumpFileWriter::WillWriteAtOffsetImpl(off_t offset) {
|
bool MinidumpFileWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
||||||
DCHECK_EQ(state(), kStateFrozen);
|
DCHECK_EQ(state(), kStateFrozen);
|
||||||
DCHECK_EQ(offset, 0);
|
DCHECK_EQ(offset, 0);
|
||||||
DCHECK_EQ(streams_.size(), stream_types_.size());
|
DCHECK_EQ(streams_.size(), stream_types_.size());
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "minidump/minidump_extensions.h"
|
#include "minidump/minidump_extensions.h"
|
||||||
#include "minidump/minidump_stream_writer.h"
|
#include "minidump/minidump_stream_writer.h"
|
||||||
#include "minidump/minidump_writable.h"
|
#include "minidump/minidump_writable.h"
|
||||||
|
#include "util/file/file_io.h"
|
||||||
#include "util/stdlib/pointer_container.h"
|
#include "util/stdlib/pointer_container.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -105,7 +106,7 @@ class MinidumpFileWriter final : public internal::MinidumpWritable {
|
|||||||
bool Freeze() override;
|
bool Freeze() override;
|
||||||
size_t SizeOfObject() override;
|
size_t SizeOfObject() override;
|
||||||
std::vector<MinidumpWritable*> Children() override;
|
std::vector<MinidumpWritable*> Children() override;
|
||||||
bool WillWriteAtOffsetImpl(off_t offset) override;
|
bool WillWriteAtOffsetImpl(FileOffset offset) override;
|
||||||
bool WriteObject(FileWriterInterface* file_writer) override;
|
bool WriteObject(FileWriterInterface* file_writer) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -129,7 +129,7 @@ size_t MinidumpMemoryWriter::SizeOfObject() {
|
|||||||
return MemoryRangeSize();
|
return MemoryRangeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinidumpMemoryWriter::WillWriteAtOffsetImpl(off_t offset) {
|
bool MinidumpMemoryWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
||||||
DCHECK_EQ(state(), kStateFrozen);
|
DCHECK_EQ(state(), kStateFrozen);
|
||||||
|
|
||||||
// There will always be at least one registered descriptor, the one for this
|
// There will always be at least one registered descriptor, the one for this
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "minidump/minidump_stream_writer.h"
|
#include "minidump/minidump_stream_writer.h"
|
||||||
#include "minidump/minidump_writable.h"
|
#include "minidump/minidump_writable.h"
|
||||||
|
#include "util/file/file_io.h"
|
||||||
#include "util/stdlib/pointer_container.h"
|
#include "util/stdlib/pointer_container.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -105,7 +106,7 @@ class MinidumpMemoryWriter : public internal::MinidumpWritable {
|
|||||||
//! \note Valid in #kStateFrozen or any subsequent state.
|
//! \note Valid in #kStateFrozen or any subsequent state.
|
||||||
size_t Alignment() override;
|
size_t Alignment() override;
|
||||||
|
|
||||||
bool WillWriteAtOffsetImpl(off_t offset) override;
|
bool WillWriteAtOffsetImpl(FileOffset offset) override;
|
||||||
|
|
||||||
//! \brief Returns the object’s desired write phase.
|
//! \brief Returns the object’s desired write phase.
|
||||||
//!
|
//!
|
||||||
|
@ -34,8 +34,9 @@ const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart(
|
|||||||
const std::string& file_contents,
|
const std::string& file_contents,
|
||||||
size_t count) {
|
size_t count) {
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
||||||
location_descriptor.DataSize = sizeof(MinidumpModuleCrashpadInfoList) +
|
location_descriptor.DataSize =
|
||||||
count * sizeof(MinidumpModuleCrashpadInfoLink);
|
static_cast<uint32_t>(sizeof(MinidumpModuleCrashpadInfoList) +
|
||||||
|
count * sizeof(MinidumpModuleCrashpadInfoLink));
|
||||||
location_descriptor.Rva = 0;
|
location_descriptor.Rva = 0;
|
||||||
|
|
||||||
const MinidumpModuleCrashpadInfoList* list =
|
const MinidumpModuleCrashpadInfoList* list =
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "minidump/minidump_string_writer.h"
|
#include "minidump/minidump_string_writer.h"
|
||||||
#include "minidump/minidump_writer_util.h"
|
#include "minidump/minidump_writer_util.h"
|
||||||
#include "snapshot/module_snapshot.h"
|
#include "snapshot/module_snapshot.h"
|
||||||
@ -154,13 +155,14 @@ bool MinidumpModuleMiscDebugRecordWriter::Freeze() {
|
|||||||
// NUL-terminate.
|
// NUL-terminate.
|
||||||
if (!image_debug_misc_.Unicode) {
|
if (!image_debug_misc_.Unicode) {
|
||||||
DCHECK(data_utf16_.empty());
|
DCHECK(data_utf16_.empty());
|
||||||
image_debug_misc_.Length = offsetof(decltype(image_debug_misc_), Data) +
|
image_debug_misc_.Length = base::checked_cast<uint32_t>(
|
||||||
(data_.size() + 1) * sizeof(data_[0]);
|
offsetof(decltype(image_debug_misc_), Data) +
|
||||||
|
(data_.size() + 1) * sizeof(data_[0]));
|
||||||
} else {
|
} else {
|
||||||
DCHECK(data_.empty());
|
DCHECK(data_.empty());
|
||||||
image_debug_misc_.Length =
|
image_debug_misc_.Length = base::checked_cast<uint32_t>(
|
||||||
offsetof(decltype(image_debug_misc_), Data) +
|
offsetof(decltype(image_debug_misc_), Data) +
|
||||||
(data_utf16_.size() + 1) * sizeof(data_utf16_[0]);
|
(data_utf16_.size() + 1) * sizeof(data_utf16_[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -31,9 +31,9 @@ const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart(
|
|||||||
const std::string& file_contents,
|
const std::string& file_contents,
|
||||||
size_t count) {
|
size_t count) {
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
||||||
location_descriptor.DataSize =
|
location_descriptor.DataSize = static_cast<uint32_t>(
|
||||||
sizeof(MinidumpSimpleStringDictionary) +
|
sizeof(MinidumpSimpleStringDictionary) +
|
||||||
count * sizeof(MinidumpSimpleStringDictionaryEntry);
|
count * sizeof(MinidumpSimpleStringDictionaryEntry));
|
||||||
location_descriptor.Rva = 0;
|
location_descriptor.Rva = 0;
|
||||||
return MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
|
return MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
|
||||||
file_contents, location_descriptor);
|
file_contents, location_descriptor);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "snapshot/thread_snapshot.h"
|
#include "snapshot/thread_snapshot.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -54,7 +55,8 @@ void BuildMinidumpThreadIDMap(
|
|||||||
for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
|
for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
|
||||||
uint64_t thread_id_64 = thread_snapshot->ThreadID();
|
uint64_t thread_id_64 = thread_snapshot->ThreadID();
|
||||||
if (thread_id_map->find(thread_id_64) == thread_id_map->end()) {
|
if (thread_id_map->find(thread_id_64) == thread_id_map->end()) {
|
||||||
uint32_t thread_id_32 = thread_id_map->size();
|
uint32_t thread_id_32 =
|
||||||
|
base::checked_cast<uint32_t>(thread_id_map->size());
|
||||||
thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32));
|
thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ bool MinidumpWritable::WriteEverything(FileWriterInterface* file_writer) {
|
|||||||
|
|
||||||
DCHECK_EQ(state_, kStateFrozen);
|
DCHECK_EQ(state_, kStateFrozen);
|
||||||
|
|
||||||
off_t offset = 0;
|
FileOffset offset = 0;
|
||||||
std::vector<MinidumpWritable*> write_sequence;
|
std::vector<MinidumpWritable*> write_sequence;
|
||||||
size_t size = WillWriteAtOffset(kPhaseEarly, &offset, &write_sequence);
|
size_t size = WillWriteAtOffset(kPhaseEarly, &offset, &write_sequence);
|
||||||
if (size == kInvalidSize) {
|
if (size == kInvalidSize) {
|
||||||
@ -124,9 +124,9 @@ MinidumpWritable::Phase MinidumpWritable::WritePhase() {
|
|||||||
|
|
||||||
size_t MinidumpWritable::WillWriteAtOffset(
|
size_t MinidumpWritable::WillWriteAtOffset(
|
||||||
Phase phase,
|
Phase phase,
|
||||||
off_t* offset,
|
FileOffset* offset,
|
||||||
std::vector<MinidumpWritable*>* write_sequence) {
|
std::vector<MinidumpWritable*>* write_sequence) {
|
||||||
off_t local_offset = *offset;
|
FileOffset local_offset = *offset;
|
||||||
CHECK_GE(local_offset, 0);
|
CHECK_GE(local_offset, 0);
|
||||||
|
|
||||||
size_t leading_pad_bytes_this_phase;
|
size_t leading_pad_bytes_this_phase;
|
||||||
@ -218,10 +218,10 @@ size_t MinidumpWritable::WillWriteAtOffset(
|
|||||||
std::vector<MinidumpWritable*> children = Children();
|
std::vector<MinidumpWritable*> children = Children();
|
||||||
for (MinidumpWritable* child : children) {
|
for (MinidumpWritable* child : children) {
|
||||||
// Use “auto” here because it’s impossible to know whether size_t (size) or
|
// Use “auto” here because it’s impossible to know whether size_t (size) or
|
||||||
// off_t (local_offset) is the wider type, and thus what type the result of
|
// FileOffset (local_offset) is the wider type, and thus what type the
|
||||||
// adding these two variables will have.
|
// result of adding these two variables will have.
|
||||||
auto unaligned_child_offset = local_offset + size;
|
auto unaligned_child_offset = local_offset + size;
|
||||||
off_t child_offset;
|
FileOffset child_offset;
|
||||||
if (!AssignIfInRange(&child_offset, unaligned_child_offset)) {
|
if (!AssignIfInRange(&child_offset, unaligned_child_offset)) {
|
||||||
LOG(ERROR) << "offset " << unaligned_child_offset << " out of range";
|
LOG(ERROR) << "offset " << unaligned_child_offset << " out of range";
|
||||||
return kInvalidSize;
|
return kInvalidSize;
|
||||||
@ -239,7 +239,7 @@ size_t MinidumpWritable::WillWriteAtOffset(
|
|||||||
return leading_pad_bytes_this_phase + size;
|
return leading_pad_bytes_this_phase + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinidumpWritable::WillWriteAtOffsetImpl(off_t offset) {
|
bool MinidumpWritable::WillWriteAtOffsetImpl(FileOffset offset) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
#include "util/file/file_io.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ class MinidumpWritable {
|
|||||||
//! processing when an object transitions to #kStateWritable should
|
//! processing when an object transitions to #kStateWritable should
|
||||||
//! implement WillWriteAtOffsetImpl(), which is called by this method.
|
//! implement WillWriteAtOffsetImpl(), which is called by this method.
|
||||||
size_t WillWriteAtOffset(Phase phase,
|
size_t WillWriteAtOffset(Phase phase,
|
||||||
off_t* offset,
|
FileOffset* offset,
|
||||||
std::vector<MinidumpWritable*>* write_sequence);
|
std::vector<MinidumpWritable*>* write_sequence);
|
||||||
|
|
||||||
//! \brief Called once an object’s writable file offset is determined, as it
|
//! \brief Called once an object’s writable file offset is determined, as it
|
||||||
@ -232,7 +233,7 @@ class MinidumpWritable {
|
|||||||
//!
|
//!
|
||||||
//! \note Valid in #kStateFrozen. The object will transition to
|
//! \note Valid in #kStateFrozen. The object will transition to
|
||||||
//! #kStateWritable after this method returns.
|
//! #kStateWritable after this method returns.
|
||||||
virtual bool WillWriteAtOffsetImpl(off_t offset);
|
virtual bool WillWriteAtOffsetImpl(FileOffset offset);
|
||||||
|
|
||||||
//! \brief Writes the object, transitioning it from #kStateWritable to
|
//! \brief Writes the object, transitioning it from #kStateWritable to
|
||||||
//! #kStateWritten.
|
//! #kStateWritten.
|
||||||
|
@ -89,7 +89,7 @@ class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable {
|
|||||||
return has_phase_ ? phase_ : MinidumpWritable::Phase();
|
return has_phase_ ? phase_ : MinidumpWritable::Phase();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WillWriteAtOffsetImpl(off_t offset) override {
|
bool WillWriteAtOffsetImpl(FileOffset offset) override {
|
||||||
EXPECT_EQ(state(), kStateFrozen);
|
EXPECT_EQ(state(), kStateFrozen);
|
||||||
expected_offset_ = offset;
|
expected_offset_ = offset;
|
||||||
bool rv = MinidumpWritable::WillWriteAtOffsetImpl(offset);
|
bool rv = MinidumpWritable::WillWriteAtOffsetImpl(offset);
|
||||||
@ -107,7 +107,7 @@ class BaseTestMinidumpWritable : public crashpad::internal::MinidumpWritable {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<BaseTestMinidumpWritable*> children_;
|
std::vector<BaseTestMinidumpWritable*> children_;
|
||||||
off_t expected_offset_;
|
FileOffset expected_offset_;
|
||||||
size_t alignment_;
|
size_t alignment_;
|
||||||
Phase phase_;
|
Phase phase_;
|
||||||
bool has_alignment_;
|
bool has_alignment_;
|
||||||
|
@ -42,7 +42,7 @@ size_t TestMinidumpMemoryWriter::MemoryRangeSize() const {
|
|||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestMinidumpMemoryWriter::WillWriteAtOffsetImpl(off_t offset) {
|
bool TestMinidumpMemoryWriter::WillWriteAtOffsetImpl(FileOffset offset) {
|
||||||
EXPECT_EQ(state(), kStateFrozen);
|
EXPECT_EQ(state(), kStateFrozen);
|
||||||
expected_offset_ = offset;
|
expected_offset_ = offset;
|
||||||
bool rv = MinidumpMemoryWriter::WillWriteAtOffsetImpl(offset);
|
bool rv = MinidumpMemoryWriter::WillWriteAtOffsetImpl(offset);
|
||||||
|
@ -44,12 +44,12 @@ class TestMinidumpMemoryWriter final : public MinidumpMemoryWriter {
|
|||||||
size_t MemoryRangeSize() const override;
|
size_t MemoryRangeSize() const override;
|
||||||
|
|
||||||
// MinidumpWritable:
|
// MinidumpWritable:
|
||||||
bool WillWriteAtOffsetImpl(off_t offset) override;
|
bool WillWriteAtOffsetImpl(FileOffset offset) override;
|
||||||
bool WriteObject(FileWriterInterface* file_writer) override;
|
bool WriteObject(FileWriterInterface* file_writer) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t base_address_;
|
uint64_t base_address_;
|
||||||
off_t expected_offset_;
|
FileOffset expected_offset_;
|
||||||
size_t size_;
|
size_t size_;
|
||||||
uint8_t value_;
|
uint8_t value_;
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ namespace test {
|
|||||||
const MinidumpRVAList* MinidumpRVAListAtStart(const std::string& file_contents,
|
const MinidumpRVAList* MinidumpRVAListAtStart(const std::string& file_contents,
|
||||||
size_t count) {
|
size_t count) {
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
|
||||||
location_descriptor.DataSize = sizeof(MinidumpRVAList) + count * sizeof(RVA);
|
location_descriptor.DataSize =
|
||||||
|
static_cast<uint32_t>(sizeof(MinidumpRVAList) + count * sizeof(RVA));
|
||||||
location_descriptor.Rva = 0;
|
location_descriptor.Rva = 0;
|
||||||
|
|
||||||
const MinidumpRVAList* list =
|
const MinidumpRVAList* list =
|
||||||
|
@ -63,7 +63,7 @@ TEST(ProcessSnapshotMinidump, Empty) {
|
|||||||
RVA WriteString(FileWriterInterface* writer, const std::string& string) {
|
RVA WriteString(FileWriterInterface* writer, const std::string& string) {
|
||||||
RVA rva = static_cast<RVA>(writer->SeekGet());
|
RVA rva = static_cast<RVA>(writer->SeekGet());
|
||||||
|
|
||||||
uint32_t string_size = string.size();
|
uint32_t string_size = static_cast<uint32_t>(string.size());
|
||||||
EXPECT_TRUE(writer->Write(&string_size, sizeof(string_size)));
|
EXPECT_TRUE(writer->Write(&string_size, sizeof(string_size)));
|
||||||
|
|
||||||
// Include the trailing NUL character.
|
// Include the trailing NUL character.
|
||||||
@ -88,16 +88,17 @@ void WriteMinidumpSimpleStringDictionary(
|
|||||||
|
|
||||||
location->Rva = static_cast<RVA>(writer->SeekGet());
|
location->Rva = static_cast<RVA>(writer->SeekGet());
|
||||||
|
|
||||||
const uint32_t simple_string_dictionary_entries = entries.size();
|
const uint32_t simple_string_dictionary_entries =
|
||||||
|
static_cast<uint32_t>(entries.size());
|
||||||
EXPECT_TRUE(writer->Write(&simple_string_dictionary_entries,
|
EXPECT_TRUE(writer->Write(&simple_string_dictionary_entries,
|
||||||
sizeof(simple_string_dictionary_entries)));
|
sizeof(simple_string_dictionary_entries)));
|
||||||
for (const MinidumpSimpleStringDictionaryEntry& entry : entries) {
|
for (const MinidumpSimpleStringDictionaryEntry& entry : entries) {
|
||||||
EXPECT_TRUE(writer->Write(&entry, sizeof(entry)));
|
EXPECT_TRUE(writer->Write(&entry, sizeof(entry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
location->DataSize =
|
location->DataSize = static_cast<uint32_t>(
|
||||||
sizeof(simple_string_dictionary_entries) +
|
sizeof(simple_string_dictionary_entries) +
|
||||||
entries.size() * sizeof(MinidumpSimpleStringDictionaryEntry);
|
entries.size() * sizeof(MinidumpSimpleStringDictionaryEntry));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writes |strings| to |writer| as a MinidumpRVAList referencing
|
// Writes |strings| to |writer| as a MinidumpRVAList referencing
|
||||||
@ -113,13 +114,14 @@ void WriteMinidumpStringList(MINIDUMP_LOCATION_DESCRIPTOR* location,
|
|||||||
|
|
||||||
location->Rva = static_cast<RVA>(writer->SeekGet());
|
location->Rva = static_cast<RVA>(writer->SeekGet());
|
||||||
|
|
||||||
const uint32_t string_list_entries = rvas.size();
|
const uint32_t string_list_entries = static_cast<uint32_t>(rvas.size());
|
||||||
EXPECT_TRUE(writer->Write(&string_list_entries, sizeof(string_list_entries)));
|
EXPECT_TRUE(writer->Write(&string_list_entries, sizeof(string_list_entries)));
|
||||||
for (RVA rva : rvas) {
|
for (RVA rva : rvas) {
|
||||||
EXPECT_TRUE(writer->Write(&rva, sizeof(rva)));
|
EXPECT_TRUE(writer->Write(&rva, sizeof(rva)));
|
||||||
}
|
}
|
||||||
|
|
||||||
location->DataSize = sizeof(string_list_entries) + rvas.size() * sizeof(RVA);
|
location->DataSize = static_cast<uint32_t>(sizeof(string_list_entries) +
|
||||||
|
rvas.size() * sizeof(RVA));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) {
|
TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) {
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
ProcessReaderWin::ProcessReaderWin()
|
ProcessReaderWin::ProcessReaderWin() : process_info_(), initialized_() {
|
||||||
: initialized_(),
|
|
||||||
is_64_bit_(false) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessReaderWin::~ProcessReaderWin() {
|
ProcessReaderWin::~ProcessReaderWin() {
|
||||||
@ -27,6 +25,8 @@ ProcessReaderWin::~ProcessReaderWin() {
|
|||||||
bool ProcessReaderWin::Initialize(HANDLE process) {
|
bool ProcessReaderWin::Initialize(HANDLE process) {
|
||||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||||
|
|
||||||
|
process_info_.Initialize(process);
|
||||||
|
|
||||||
INITIALIZATION_STATE_SET_VALID(initialized_);
|
INITIALIZATION_STATE_SET_VALID(initialized_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "util/misc/initialization_state_dcheck.h"
|
#include "util/misc/initialization_state_dcheck.h"
|
||||||
|
#include "util/win/process_info.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -39,10 +40,10 @@ class ProcessReaderWin {
|
|||||||
bool Initialize(HANDLE process);
|
bool Initialize(HANDLE process);
|
||||||
|
|
||||||
//! \return `true` if the target task is a 64-bit process.
|
//! \return `true` if the target task is a 64-bit process.
|
||||||
bool Is64Bit() const { return is_64_bit_; }
|
bool Is64Bit() const { return process_info_.Is64Bit(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_64_bit_;
|
ProcessInfo process_info_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin);
|
DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin);
|
||||||
|
@ -46,7 +46,8 @@ std::string GenerateBoundaryString() {
|
|||||||
for (int index = 0; index < 32; ++index) {
|
for (int index = 0; index < 32; ++index) {
|
||||||
const char kCharacters[] =
|
const char kCharacters[] =
|
||||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
int random_value = base::RandInt(0, strlen(kCharacters) - 1);
|
int random_value =
|
||||||
|
base::RandInt(0, static_cast<int>(strlen(kCharacters)) - 1);
|
||||||
boundary_string += kCharacters[random_value];
|
boundary_string += kCharacters[random_value];
|
||||||
}
|
}
|
||||||
boundary_string += "---";
|
boundary_string += "---";
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <winhttp.h>
|
#include <winhttp.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/scoped_generic.h"
|
#include "base/scoped_generic.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"
|
||||||
@ -149,10 +150,11 @@ bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
|
|||||||
for (const auto& pair : headers()) {
|
for (const auto& pair : headers()) {
|
||||||
std::wstring header_string =
|
std::wstring header_string =
|
||||||
base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second);
|
base::UTF8ToUTF16(pair.first) + L": " + base::UTF8ToUTF16(pair.second);
|
||||||
if (!WinHttpAddRequestHeaders(request.get(),
|
if (!WinHttpAddRequestHeaders(
|
||||||
header_string.c_str(),
|
request.get(),
|
||||||
header_string.size(),
|
header_string.c_str(),
|
||||||
WINHTTP_ADDREQ_FLAG_ADD)) {
|
base::checked_cast<DWORD>(header_string.size()),
|
||||||
|
WINHTTP_ADDREQ_FLAG_ADD)) {
|
||||||
LogErrorWinHttpMessage("WinHttpAddRequestHeaders");
|
LogErrorWinHttpMessage("WinHttpAddRequestHeaders");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -178,8 +180,8 @@ bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
|
|||||||
WINHTTP_NO_ADDITIONAL_HEADERS,
|
WINHTTP_NO_ADDITIONAL_HEADERS,
|
||||||
0,
|
0,
|
||||||
&post_data[0],
|
&post_data[0],
|
||||||
post_data.size(),
|
base::checked_cast<DWORD>(post_data.size()),
|
||||||
post_data.size(),
|
base::checked_cast<DWORD>(post_data.size()),
|
||||||
0)) {
|
0)) {
|
||||||
LogErrorWinHttpMessage("WinHttpSendRequest");
|
LogErrorWinHttpMessage("WinHttpSendRequest");
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,8 +37,8 @@ struct FULL_PROCESS_BASIC_INFORMATION {
|
|||||||
PPEB PebBaseAddress;
|
PPEB PebBaseAddress;
|
||||||
KAFFINITY AffinityMask;
|
KAFFINITY AffinityMask;
|
||||||
PVOID BasePriority;
|
PVOID BasePriority;
|
||||||
ULONG UniqueProcessId;
|
ULONG_PTR UniqueProcessId;
|
||||||
ULONG InheritedFromUniqueProcessId;
|
ULONG_PTR InheritedFromUniqueProcessId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user