mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Remove base's arraysize from Crashpad.
BUG=837308 R=mark@chromium.org Change-Id: Ibecbfc7bc2d61ee54bc1114e4b20978adbc77db2 Reviewed-on: https://chromium-review.googlesource.com/c/1393921 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org>
This commit is contained in:
parent
8f5d83b9e3
commit
c8a016b99d
@ -35,6 +35,7 @@
|
|||||||
#include "client/settings.h"
|
#include "client/settings.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/mac/xattr.h"
|
#include "util/mac/xattr.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/initialization_state_dcheck.h"
|
#include "util/misc/initialization_state_dcheck.h"
|
||||||
#include "util/misc/metrics.h"
|
#include "util/misc/metrics.h"
|
||||||
|
|
||||||
@ -279,7 +280,7 @@ bool CrashReportDatabaseMac::Initialize(bool may_create) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the three processing directories for the database.
|
// Create the three processing directories for the database.
|
||||||
for (size_t i = 0; i < arraysize(kReportDirectories); ++i) {
|
for (size_t i = 0; i < ArraySize(kReportDirectories); ++i) {
|
||||||
if (!CreateOrEnsureDirectoryExists(base_dir_.Append(kReportDirectories[i])))
|
if (!CreateOrEnsureDirectoryExists(base_dir_.Append(kReportDirectories[i])))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/test_paths.h"
|
#include "test/test_paths.h"
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/mach_logging.h"
|
#include "base/mac/mach_logging.h"
|
||||||
#include "base/mac/scoped_mach_port.h"
|
#include "base/mac/scoped_mach_port.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "util/mach/exc_client_variants.h"
|
#include "util/mach/exc_client_variants.h"
|
||||||
#include "util/mach/exception_behaviors.h"
|
#include "util/mach/exception_behaviors.h"
|
||||||
#include "util/mach/exception_ports.h"
|
#include "util/mach/exception_ports.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -191,7 +191,7 @@ void SimulateCrash(const NativeCPUContext& cpu_context) {
|
|||||||
base::mac::ScopedMachSendRight thread(mach_thread_self());
|
base::mac::ScopedMachSendRight thread(mach_thread_self());
|
||||||
exception_type_t exception = kMachExceptionSimulated;
|
exception_type_t exception = kMachExceptionSimulated;
|
||||||
mach_exception_data_type_t codes[] = {0, 0};
|
mach_exception_data_type_t codes[] = {0, 0};
|
||||||
mach_msg_type_number_t code_count = arraysize(codes);
|
mach_msg_type_number_t code_count = ArraySize(codes);
|
||||||
|
|
||||||
// Look up the handler for EXC_CRASH exceptions in the same way that the
|
// Look up the handler for EXC_CRASH exceptions in the same way that the
|
||||||
// kernel would: try a thread handler, then a task handler, and finally a host
|
// kernel would: try a thread handler, then a task handler, and finally a host
|
||||||
@ -213,7 +213,7 @@ void SimulateCrash(const NativeCPUContext& cpu_context) {
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
for (size_t target_type_index = 0;
|
for (size_t target_type_index = 0;
|
||||||
!success && target_type_index < arraysize(kTargetTypes);
|
!success && target_type_index < ArraySize(kTargetTypes);
|
||||||
++target_type_index) {
|
++target_type_index) {
|
||||||
ExceptionPorts::ExceptionHandlerVector handlers;
|
ExceptionPorts::ExceptionHandlerVector handlers;
|
||||||
ExceptionPorts exception_ports(kTargetTypes[target_type_index],
|
ExceptionPorts exception_ports(kTargetTypes[target_type_index],
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
#include "util/mach/mach_message_server.h"
|
#include "util/mach/mach_message_server.h"
|
||||||
#include "util/mach/symbolic_constants_mach.h"
|
#include "util/mach/symbolic_constants_mach.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -342,15 +343,13 @@ TEST(SimulateCrash, SimulateCrash) {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t target_index = 0;
|
for (size_t target_index = 0; target_index < ArraySize(kTargets);
|
||||||
target_index < arraysize(kTargets);
|
|
||||||
++target_index) {
|
++target_index) {
|
||||||
TestSimulateCrashMac::ExceptionPortsTarget target = kTargets[target_index];
|
TestSimulateCrashMac::ExceptionPortsTarget target = kTargets[target_index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"target_index %zu, target %d", target_index, target));
|
"target_index %zu, target %d", target_index, target));
|
||||||
|
|
||||||
for (size_t behavior_index = 0;
|
for (size_t behavior_index = 0; behavior_index < ArraySize(kBehaviors);
|
||||||
behavior_index < arraysize(kBehaviors);
|
|
||||||
++behavior_index) {
|
++behavior_index) {
|
||||||
exception_behavior_t behavior = kBehaviors[behavior_index];
|
exception_behavior_t behavior = kBehaviors[behavior_index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
@ -364,8 +363,7 @@ TEST(SimulateCrash, SimulateCrash) {
|
|||||||
target, behavior, THREAD_STATE_NONE);
|
target, behavior, THREAD_STATE_NONE);
|
||||||
test_simulate_crash_mac.Run();
|
test_simulate_crash_mac.Run();
|
||||||
} else {
|
} else {
|
||||||
for (size_t flavor_index = 0;
|
for (size_t flavor_index = 0; flavor_index < ArraySize(kFlavors);
|
||||||
flavor_index < arraysize(kFlavors);
|
|
||||||
++flavor_index) {
|
++flavor_index) {
|
||||||
thread_state_flavor_t flavor = kFlavors[flavor_index];
|
thread_state_flavor_t flavor = kFlavors[flavor_index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
|
@ -24,10 +24,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
#include "client/simple_string_dictionary.h"
|
#include "client/simple_string_dictionary.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/posix/scoped_dir.h"
|
#include "util/posix/scoped_dir.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -108,7 +108,7 @@ void RecordFileLimitAnnotation() {
|
|||||||
int mib[] = {CTL_KERN, KERN_MAXFILES};
|
int mib[] = {CTL_KERN, KERN_MAXFILES};
|
||||||
size = sizeof(value);
|
size = sizeof(value);
|
||||||
std::string max_files = FormatFromSysctl(
|
std::string max_files = FormatFromSysctl(
|
||||||
sysctl(mib, arraysize(mib), &value, &size, nullptr, 0), &value, &size);
|
sysctl(mib, ArraySize(mib), &value, &size, nullptr, 0), &value, &size);
|
||||||
|
|
||||||
std::string open_files = CountOpenFileDescriptors();
|
std::string open_files = CountOpenFileDescriptors();
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "client/crashpad_client.h"
|
#include "client/crashpad_client.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/win/critical_section_with_debug_info.h"
|
#include "util/win/critical_section_with_debug_info.h"
|
||||||
#include "util/win/get_function.h"
|
#include "util/win/get_function.h"
|
||||||
|
|
||||||
@ -83,11 +83,11 @@ void AllocateMemoryOfVariousProtections() {
|
|||||||
// All of these allocations are leaked, we want to view them in windbg via
|
// All of these allocations are leaked, we want to view them in windbg via
|
||||||
// !vprot.
|
// !vprot.
|
||||||
void* reserve = VirtualAlloc(
|
void* reserve = VirtualAlloc(
|
||||||
nullptr, arraysize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
|
nullptr, ArraySize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
|
||||||
PCHECK(reserve) << "VirtualAlloc MEM_RESERVE";
|
PCHECK(reserve) << "VirtualAlloc MEM_RESERVE";
|
||||||
uintptr_t reserve_as_int = reinterpret_cast<uintptr_t>(reserve);
|
uintptr_t reserve_as_int = reinterpret_cast<uintptr_t>(reserve);
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(kPageTypes); ++i) {
|
for (size_t i = 0; i < ArraySize(kPageTypes); ++i) {
|
||||||
void* result =
|
void* result =
|
||||||
VirtualAlloc(reinterpret_cast<void*>(reserve_as_int + (kPageSize * i)),
|
VirtualAlloc(reinterpret_cast<void*>(reserve_as_int + (kPageSize * i)),
|
||||||
kPageSize,
|
kPageSize,
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
#include "base/debug/alias.h"
|
#include "base/debug/alias.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.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"
|
||||||
#include "client/crashpad_client.h"
|
#include "client/crashpad_client.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -123,8 +123,8 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
// This is not expected to return.
|
// This is not expected to return.
|
||||||
DWORD count =
|
DWORD count = WaitForMultipleObjects(
|
||||||
WaitForMultipleObjects(arraysize(threads), threads, true, INFINITE);
|
static_cast<DWORD>(ArraySize(threads)), threads, true, INFINITE);
|
||||||
if (count == WAIT_FAILED) {
|
if (count == WAIT_FAILED) {
|
||||||
PLOG(ERROR) << "WaitForMultipleObjects";
|
PLOG(ERROR) << "WaitForMultipleObjects";
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "minidump/minidump_extensions.h"
|
#include "minidump/minidump_extensions.h"
|
||||||
#include "minidump/test/minidump_byte_array_writer_test_util.h"
|
#include "minidump/test/minidump_byte_array_writer_test_util.h"
|
||||||
#include "minidump/test/minidump_string_writer_test_util.h"
|
#include "minidump/test/minidump_string_writer_test_util.h"
|
||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -107,7 +107,7 @@ TEST(MinidumpAnnotationWriter, ThreeItems) {
|
|||||||
|
|
||||||
MinidumpAnnotationListWriter list_writer;
|
MinidumpAnnotationListWriter list_writer;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(kNames); ++i) {
|
for (size_t i = 0; i < ArraySize(kNames); ++i) {
|
||||||
auto annotation = std::make_unique<MinidumpAnnotationWriter>();
|
auto annotation = std::make_unique<MinidumpAnnotationWriter>();
|
||||||
annotation->InitializeWithData(kNames[i], kTypes[i], kValues[i]);
|
annotation->InitializeWithData(kNames[i], kTypes[i], kValues[i]);
|
||||||
list_writer.AddObject(std::move(annotation));
|
list_writer.AddObject(std::move(annotation));
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -34,7 +35,7 @@ TEST(MinidumpByteArrayWriter, Write) {
|
|||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(kTests); ++i) {
|
for (size_t i = 0; i < ArraySize(kTests); ++i) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
|
||||||
|
|
||||||
StringFile string_file;
|
StringFile string_file;
|
||||||
@ -66,7 +67,7 @@ TEST(MinidumpByteArrayWriter, SetData) {
|
|||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(kTests); ++i) {
|
for (size_t i = 0; i < ArraySize(kTests); ++i) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, i));
|
||||||
|
|
||||||
crashpad::MinidumpByteArrayWriter writer;
|
crashpad::MinidumpByteArrayWriter writer;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#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"
|
||||||
#include "util/misc/arraysize_unsafe.h"
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ void MinidumpExceptionWriter::SetExceptionInformation(
|
|||||||
|
|
||||||
const size_t parameters = exception_information.size();
|
const size_t parameters = exception_information.size();
|
||||||
constexpr size_t kMaxParameters =
|
constexpr size_t kMaxParameters =
|
||||||
ARRAYSIZE_UNSAFE(exception_.ExceptionRecord.ExceptionInformation);
|
ArraySize(exception_.ExceptionRecord.ExceptionInformation);
|
||||||
CHECK_LE(parameters, kMaxParameters);
|
CHECK_LE(parameters, kMaxParameters);
|
||||||
|
|
||||||
exception_.ExceptionRecord.NumberParameters =
|
exception_.ExceptionRecord.NumberParameters =
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "snapshot/test/test_exception_snapshot.h"
|
#include "snapshot/test/test_exception_snapshot.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -80,7 +81,7 @@ void ExpectExceptionStream(const MINIDUMP_EXCEPTION_STREAM* expected,
|
|||||||
expected->ExceptionRecord.NumberParameters);
|
expected->ExceptionRecord.NumberParameters);
|
||||||
EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u);
|
EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u);
|
||||||
for (size_t index = 0;
|
for (size_t index = 0;
|
||||||
index < arraysize(observed->ExceptionRecord.ExceptionInformation);
|
index < ArraySize(observed->ExceptionRecord.ExceptionInformation);
|
||||||
++index) {
|
++index) {
|
||||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionInformation[index],
|
EXPECT_EQ(observed->ExceptionRecord.ExceptionInformation[index],
|
||||||
expected->ExceptionRecord.ExceptionInformation[index]);
|
expected->ExceptionRecord.ExceptionInformation[index]);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "snapshot/test/test_thread_snapshot.h"
|
#include "snapshot/test/test_thread_snapshot.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -134,7 +135,7 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
|||||||
minidump_file.SetTimestamp(kTimestamp);
|
minidump_file.SetTimestamp(kTimestamp);
|
||||||
|
|
||||||
static constexpr uint8_t kStreamData[] = "Hello World!";
|
static constexpr uint8_t kStreamData[] = "Hello World!";
|
||||||
constexpr size_t kStreamSize = arraysize(kStreamData);
|
constexpr size_t kStreamSize = ArraySize(kStreamData);
|
||||||
constexpr MinidumpStreamType kStreamType =
|
constexpr MinidumpStreamType kStreamType =
|
||||||
static_cast<MinidumpStreamType>(0x4d);
|
static_cast<MinidumpStreamType>(0x4d);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "snapshot/test/test_memory_snapshot.h"
|
#include "snapshot/test/test_memory_snapshot.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -340,7 +341,7 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
|
|||||||
|
|
||||||
TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[3] = {};
|
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[3] = {};
|
||||||
uint8_t values[arraysize(expect_memory_descriptors)] = {};
|
uint8_t values[ArraySize(expect_memory_descriptors)] = {};
|
||||||
|
|
||||||
expect_memory_descriptors[0].StartOfMemoryRange = 0;
|
expect_memory_descriptors[0].StartOfMemoryRange = 0;
|
||||||
expect_memory_descriptors[0].Memory.DataSize = 0x1000;
|
expect_memory_descriptors[0].Memory.DataSize = 0x1000;
|
||||||
@ -356,8 +357,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<TestMemorySnapshot>> memory_snapshots_owner;
|
std::vector<std::unique_ptr<TestMemorySnapshot>> memory_snapshots_owner;
|
||||||
std::vector<const MemorySnapshot*> memory_snapshots;
|
std::vector<const MemorySnapshot*> memory_snapshots;
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(expect_memory_descriptors);
|
||||||
index < arraysize(expect_memory_descriptors);
|
|
||||||
++index) {
|
++index) {
|
||||||
memory_snapshots_owner.push_back(std::make_unique<TestMemorySnapshot>());
|
memory_snapshots_owner.push_back(std::make_unique<TestMemorySnapshot>());
|
||||||
TestMemorySnapshot* memory_snapshot = memory_snapshots_owner.back().get();
|
TestMemorySnapshot* memory_snapshot = memory_snapshots_owner.back().get();
|
||||||
@ -396,7 +396,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
|||||||
|
|
||||||
TEST(MinidumpMemoryWriter, CoalesceExplicitMultiple) {
|
TEST(MinidumpMemoryWriter, CoalesceExplicitMultiple) {
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[4] = {};
|
MINIDUMP_MEMORY_DESCRIPTOR expect_memory_descriptors[4] = {};
|
||||||
uint8_t values[arraysize(expect_memory_descriptors)] = {};
|
uint8_t values[ArraySize(expect_memory_descriptors)] = {};
|
||||||
|
|
||||||
expect_memory_descriptors[0].StartOfMemoryRange = 0;
|
expect_memory_descriptors[0].StartOfMemoryRange = 0;
|
||||||
expect_memory_descriptors[0].Memory.DataSize = 1000;
|
expect_memory_descriptors[0].Memory.DataSize = 1000;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "snapshot/process_snapshot.h"
|
#include "snapshot/process_snapshot.h"
|
||||||
#include "snapshot/system_snapshot.h"
|
#include "snapshot/system_snapshot.h"
|
||||||
#include "util/file/file_writer.h"
|
#include "util/file/file_writer.h"
|
||||||
#include "util/misc/arraysize_unsafe.h"
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/numeric/in_range_cast.h"
|
#include "util/numeric/in_range_cast.h"
|
||||||
#include "util/numeric/safe_assignment.h"
|
#include "util/numeric/safe_assignment.h"
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id,
|
|||||||
|
|
||||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||||
misc_info_.TimeZone.StandardName,
|
misc_info_.TimeZone.StandardName,
|
||||||
ARRAYSIZE_UNSAFE(misc_info_.TimeZone.StandardName),
|
ArraySize(misc_info_.TimeZone.StandardName),
|
||||||
standard_name);
|
standard_name);
|
||||||
|
|
||||||
misc_info_.TimeZone.StandardDate = standard_date;
|
misc_info_.TimeZone.StandardDate = standard_date;
|
||||||
@ -310,7 +310,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id,
|
|||||||
|
|
||||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||||
misc_info_.TimeZone.DaylightName,
|
misc_info_.TimeZone.DaylightName,
|
||||||
ARRAYSIZE_UNSAFE(misc_info_.TimeZone.DaylightName),
|
ArraySize(misc_info_.TimeZone.DaylightName),
|
||||||
daylight_name);
|
daylight_name);
|
||||||
|
|
||||||
misc_info_.TimeZone.DaylightDate = daylight_date;
|
misc_info_.TimeZone.DaylightDate = daylight_date;
|
||||||
@ -327,12 +327,10 @@ void MinidumpMiscInfoWriter::SetBuildString(
|
|||||||
misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
|
misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
|
||||||
|
|
||||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||||
misc_info_.BuildString,
|
misc_info_.BuildString, ArraySize(misc_info_.BuildString), build_string);
|
||||||
ARRAYSIZE_UNSAFE(misc_info_.BuildString),
|
|
||||||
build_string);
|
|
||||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||||
misc_info_.DbgBldStr,
|
misc_info_.DbgBldStr,
|
||||||
ARRAYSIZE_UNSAFE(misc_info_.DbgBldStr),
|
ArraySize(misc_info_.DbgBldStr),
|
||||||
debug_build_string);
|
debug_build_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "snapshot/test/test_process_snapshot.h"
|
#include "snapshot/test/test_process_snapshot.h"
|
||||||
#include "snapshot/test/test_system_snapshot.h"
|
#include "snapshot/test/test_system_snapshot.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
#include "util/misc/arraysize_unsafe.h"
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/stdlib/strlcpy.h"
|
#include "util/stdlib/strlcpy.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -127,7 +127,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
|
|||||||
SCOPED_TRACE("Standard");
|
SCOPED_TRACE("Standard");
|
||||||
ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
|
ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
|
||||||
observed->TimeZone.StandardName,
|
observed->TimeZone.StandardName,
|
||||||
arraysize(expected->TimeZone.StandardName));
|
ArraySize(expected->TimeZone.StandardName));
|
||||||
ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
|
ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
|
||||||
&observed->TimeZone.StandardDate);
|
&observed->TimeZone.StandardDate);
|
||||||
EXPECT_EQ(observed->TimeZone.StandardBias, expected->TimeZone.StandardBias);
|
EXPECT_EQ(observed->TimeZone.StandardBias, expected->TimeZone.StandardBias);
|
||||||
@ -136,7 +136,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
|
|||||||
SCOPED_TRACE("Daylight");
|
SCOPED_TRACE("Daylight");
|
||||||
ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
|
ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
|
||||||
observed->TimeZone.DaylightName,
|
observed->TimeZone.DaylightName,
|
||||||
arraysize(expected->TimeZone.DaylightName));
|
ArraySize(expected->TimeZone.DaylightName));
|
||||||
ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
|
ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
|
||||||
&observed->TimeZone.DaylightDate);
|
&observed->TimeZone.DaylightDate);
|
||||||
EXPECT_EQ(observed->TimeZone.DaylightBias, expected->TimeZone.DaylightBias);
|
EXPECT_EQ(observed->TimeZone.DaylightBias, expected->TimeZone.DaylightBias);
|
||||||
@ -154,13 +154,13 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_4>(
|
|||||||
SCOPED_TRACE("BuildString");
|
SCOPED_TRACE("BuildString");
|
||||||
ExpectNULPaddedString16Equal(expected->BuildString,
|
ExpectNULPaddedString16Equal(expected->BuildString,
|
||||||
observed->BuildString,
|
observed->BuildString,
|
||||||
arraysize(expected->BuildString));
|
ArraySize(expected->BuildString));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SCOPED_TRACE("DbgBldStr");
|
SCOPED_TRACE("DbgBldStr");
|
||||||
ExpectNULPaddedString16Equal(expected->DbgBldStr,
|
ExpectNULPaddedString16Equal(expected->DbgBldStr,
|
||||||
observed->DbgBldStr,
|
observed->DbgBldStr,
|
||||||
arraysize(expected->DbgBldStr));
|
ArraySize(expected->DbgBldStr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_5>(
|
|||||||
EXPECT_EQ(observed->XStateData.EnabledFeatures,
|
EXPECT_EQ(observed->XStateData.EnabledFeatures,
|
||||||
expected->XStateData.EnabledFeatures);
|
expected->XStateData.EnabledFeatures);
|
||||||
for (size_t feature_index = 0;
|
for (size_t feature_index = 0;
|
||||||
feature_index < arraysize(observed->XStateData.Features);
|
feature_index < ArraySize(observed->XStateData.Features);
|
||||||
++feature_index) {
|
++feature_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index));
|
SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index));
|
||||||
EXPECT_EQ(observed->XStateData.Features[feature_index].Offset,
|
EXPECT_EQ(observed->XStateData.Features[feature_index].Offset,
|
||||||
@ -396,7 +396,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
|||||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||||
c16lcpy(expected.TimeZone.StandardName,
|
c16lcpy(expected.TimeZone.StandardName,
|
||||||
standard_name_utf16.c_str(),
|
standard_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
ArraySize(expected.TimeZone.StandardName));
|
||||||
memcpy(&expected.TimeZone.StandardDate,
|
memcpy(&expected.TimeZone.StandardDate,
|
||||||
&kStandardDate,
|
&kStandardDate,
|
||||||
sizeof(expected.TimeZone.StandardDate));
|
sizeof(expected.TimeZone.StandardDate));
|
||||||
@ -404,7 +404,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
|||||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||||
c16lcpy(expected.TimeZone.DaylightName,
|
c16lcpy(expected.TimeZone.DaylightName,
|
||||||
daylight_name_utf16.c_str(),
|
daylight_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
ArraySize(expected.TimeZone.DaylightName));
|
||||||
memcpy(&expected.TimeZone.DaylightDate,
|
memcpy(&expected.TimeZone.DaylightDate,
|
||||||
&kDaylightDate,
|
&kDaylightDate,
|
||||||
sizeof(expected.TimeZone.DaylightDate));
|
sizeof(expected.TimeZone.DaylightDate));
|
||||||
@ -424,10 +424,9 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
|||||||
constexpr int32_t kBias = 300;
|
constexpr int32_t kBias = 300;
|
||||||
MINIDUMP_MISC_INFO_N tmp;
|
MINIDUMP_MISC_INFO_N tmp;
|
||||||
ALLOW_UNUSED_LOCAL(tmp);
|
ALLOW_UNUSED_LOCAL(tmp);
|
||||||
std::string standard_name(ARRAYSIZE_UNSAFE(tmp.TimeZone.StandardName) + 1,
|
std::string standard_name(ArraySize(tmp.TimeZone.StandardName) + 1, 's');
|
||||||
's');
|
|
||||||
constexpr int32_t kStandardBias = 0;
|
constexpr int32_t kStandardBias = 0;
|
||||||
std::string daylight_name(ARRAYSIZE_UNSAFE(tmp.TimeZone.DaylightName), 'd');
|
std::string daylight_name(ArraySize(tmp.TimeZone.DaylightName), 'd');
|
||||||
constexpr int32_t kDaylightBias = -60;
|
constexpr int32_t kDaylightBias = -60;
|
||||||
|
|
||||||
// Test using kSystemTimeZero, because not all platforms will be able to
|
// Test using kSystemTimeZero, because not all platforms will be able to
|
||||||
@ -458,7 +457,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
|||||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
|
base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
|
||||||
c16lcpy(expected.TimeZone.StandardName,
|
c16lcpy(expected.TimeZone.StandardName,
|
||||||
standard_name_utf16.c_str(),
|
standard_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
ArraySize(expected.TimeZone.StandardName));
|
||||||
memcpy(&expected.TimeZone.StandardDate,
|
memcpy(&expected.TimeZone.StandardDate,
|
||||||
&kSystemTimeZero,
|
&kSystemTimeZero,
|
||||||
sizeof(expected.TimeZone.StandardDate));
|
sizeof(expected.TimeZone.StandardDate));
|
||||||
@ -466,7 +465,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
|||||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
|
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
|
||||||
c16lcpy(expected.TimeZone.DaylightName,
|
c16lcpy(expected.TimeZone.DaylightName,
|
||||||
daylight_name_utf16.c_str(),
|
daylight_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
ArraySize(expected.TimeZone.DaylightName));
|
||||||
memcpy(&expected.TimeZone.DaylightDate,
|
memcpy(&expected.TimeZone.DaylightDate,
|
||||||
&kSystemTimeZero,
|
&kSystemTimeZero,
|
||||||
sizeof(expected.TimeZone.DaylightDate));
|
sizeof(expected.TimeZone.DaylightDate));
|
||||||
@ -497,12 +496,12 @@ TEST(MinidumpMiscInfoWriter, BuildStrings) {
|
|||||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||||
c16lcpy(expected.BuildString,
|
c16lcpy(expected.BuildString,
|
||||||
build_string_utf16.c_str(),
|
build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
ArraySize(expected.BuildString));
|
||||||
base::string16 debug_build_string_utf16 =
|
base::string16 debug_build_string_utf16 =
|
||||||
base::UTF8ToUTF16(kDebugBuildString);
|
base::UTF8ToUTF16(kDebugBuildString);
|
||||||
c16lcpy(expected.DbgBldStr,
|
c16lcpy(expected.DbgBldStr,
|
||||||
debug_build_string_utf16.c_str(),
|
debug_build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
ArraySize(expected.DbgBldStr));
|
||||||
|
|
||||||
ExpectMiscInfoEqual(&expected, observed);
|
ExpectMiscInfoEqual(&expected, observed);
|
||||||
}
|
}
|
||||||
@ -516,8 +515,8 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
|
|||||||
|
|
||||||
MINIDUMP_MISC_INFO_N tmp;
|
MINIDUMP_MISC_INFO_N tmp;
|
||||||
ALLOW_UNUSED_LOCAL(tmp);
|
ALLOW_UNUSED_LOCAL(tmp);
|
||||||
std::string build_string(ARRAYSIZE_UNSAFE(tmp.BuildString) + 1, 'B');
|
std::string build_string(ArraySize(tmp.BuildString) + 1, 'B');
|
||||||
std::string debug_build_string(ARRAYSIZE_UNSAFE(tmp.DbgBldStr), 'D');
|
std::string debug_build_string(ArraySize(tmp.DbgBldStr), 'D');
|
||||||
|
|
||||||
misc_info_writer->SetBuildString(build_string, debug_build_string);
|
misc_info_writer->SetBuildString(build_string, debug_build_string);
|
||||||
|
|
||||||
@ -534,12 +533,12 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
|
|||||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
|
base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
|
||||||
c16lcpy(expected.BuildString,
|
c16lcpy(expected.BuildString,
|
||||||
build_string_utf16.c_str(),
|
build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
ArraySize(expected.BuildString));
|
||||||
base::string16 debug_build_string_utf16 =
|
base::string16 debug_build_string_utf16 =
|
||||||
base::UTF8ToUTF16(debug_build_string);
|
base::UTF8ToUTF16(debug_build_string);
|
||||||
c16lcpy(expected.DbgBldStr,
|
c16lcpy(expected.DbgBldStr,
|
||||||
debug_build_string_utf16.c_str(),
|
debug_build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
ArraySize(expected.DbgBldStr));
|
||||||
|
|
||||||
ExpectMiscInfoEqual(&expected, observed);
|
ExpectMiscInfoEqual(&expected, observed);
|
||||||
}
|
}
|
||||||
@ -679,7 +678,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
|||||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||||
c16lcpy(expected.TimeZone.StandardName,
|
c16lcpy(expected.TimeZone.StandardName,
|
||||||
standard_name_utf16.c_str(),
|
standard_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
ArraySize(expected.TimeZone.StandardName));
|
||||||
memcpy(&expected.TimeZone.StandardDate,
|
memcpy(&expected.TimeZone.StandardDate,
|
||||||
&kSystemTimeZero,
|
&kSystemTimeZero,
|
||||||
sizeof(expected.TimeZone.StandardDate));
|
sizeof(expected.TimeZone.StandardDate));
|
||||||
@ -687,7 +686,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
|||||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||||
c16lcpy(expected.TimeZone.DaylightName,
|
c16lcpy(expected.TimeZone.DaylightName,
|
||||||
daylight_name_utf16.c_str(),
|
daylight_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
ArraySize(expected.TimeZone.DaylightName));
|
||||||
memcpy(&expected.TimeZone.DaylightDate,
|
memcpy(&expected.TimeZone.DaylightDate,
|
||||||
&kSystemTimeZero,
|
&kSystemTimeZero,
|
||||||
sizeof(expected.TimeZone.DaylightDate));
|
sizeof(expected.TimeZone.DaylightDate));
|
||||||
@ -695,12 +694,12 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
|||||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||||
c16lcpy(expected.BuildString,
|
c16lcpy(expected.BuildString,
|
||||||
build_string_utf16.c_str(),
|
build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
ArraySize(expected.BuildString));
|
||||||
base::string16 debug_build_string_utf16 =
|
base::string16 debug_build_string_utf16 =
|
||||||
base::UTF8ToUTF16(kDebugBuildString);
|
base::UTF8ToUTF16(kDebugBuildString);
|
||||||
c16lcpy(expected.DbgBldStr,
|
c16lcpy(expected.DbgBldStr,
|
||||||
debug_build_string_utf16.c_str(),
|
debug_build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
ArraySize(expected.DbgBldStr));
|
||||||
|
|
||||||
ExpectMiscInfoEqual(&expected, observed);
|
ExpectMiscInfoEqual(&expected, observed);
|
||||||
}
|
}
|
||||||
@ -744,18 +743,18 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) {
|
|||||||
expect_misc_info.TimeZone.Bias = 300;
|
expect_misc_info.TimeZone.Bias = 300;
|
||||||
c16lcpy(expect_misc_info.TimeZone.StandardName,
|
c16lcpy(expect_misc_info.TimeZone.StandardName,
|
||||||
standard_time_name_utf16.c_str(),
|
standard_time_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expect_misc_info.TimeZone.StandardName));
|
ArraySize(expect_misc_info.TimeZone.StandardName));
|
||||||
expect_misc_info.TimeZone.StandardBias = 0;
|
expect_misc_info.TimeZone.StandardBias = 0;
|
||||||
c16lcpy(expect_misc_info.TimeZone.DaylightName,
|
c16lcpy(expect_misc_info.TimeZone.DaylightName,
|
||||||
daylight_time_name_utf16.c_str(),
|
daylight_time_name_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expect_misc_info.TimeZone.DaylightName));
|
ArraySize(expect_misc_info.TimeZone.DaylightName));
|
||||||
expect_misc_info.TimeZone.DaylightBias = -60;
|
expect_misc_info.TimeZone.DaylightBias = -60;
|
||||||
c16lcpy(expect_misc_info.BuildString,
|
c16lcpy(expect_misc_info.BuildString,
|
||||||
build_string_utf16.c_str(),
|
build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expect_misc_info.BuildString));
|
ArraySize(expect_misc_info.BuildString));
|
||||||
c16lcpy(expect_misc_info.DbgBldStr,
|
c16lcpy(expect_misc_info.DbgBldStr,
|
||||||
debug_build_string_utf16.c_str(),
|
debug_build_string_utf16.c_str(),
|
||||||
ARRAYSIZE_UNSAFE(expect_misc_info.DbgBldStr));
|
ArraySize(expect_misc_info.DbgBldStr));
|
||||||
|
|
||||||
const timeval kStartTime =
|
const timeval kStartTime =
|
||||||
{ static_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 };
|
{ static_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 };
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "snapshot/test/test_module_snapshot.h"
|
#include "snapshot/test/test_module_snapshot.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -154,9 +155,9 @@ TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
|
|||||||
sizeof(MinidumpSimpleStringDictionaryEntry) +
|
sizeof(MinidumpSimpleStringDictionaryEntry) +
|
||||||
sizeof(MinidumpAnnotationList) + 2 + // padding
|
sizeof(MinidumpAnnotationList) + 2 + // padding
|
||||||
sizeof(MinidumpAnnotation) + sizeof(MinidumpUTF8String) +
|
sizeof(MinidumpAnnotation) + sizeof(MinidumpUTF8String) +
|
||||||
arraysize(kEntry) + 2 + // padding
|
ArraySize(kEntry) + 2 + // padding
|
||||||
sizeof(MinidumpUTF8String) + arraysize(kKey) +
|
sizeof(MinidumpUTF8String) + ArraySize(kKey) +
|
||||||
sizeof(MinidumpUTF8String) + arraysize(kValue) +
|
sizeof(MinidumpUTF8String) + ArraySize(kValue) +
|
||||||
sizeof(MinidumpUTF8String) + annotation.name.size() + 1 +
|
sizeof(MinidumpUTF8String) + annotation.name.size() + 1 +
|
||||||
sizeof(MinidumpByteArray) + annotation.value.size());
|
sizeof(MinidumpByteArray) + annotation.value.size());
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "snapshot/test/test_module_snapshot.h"
|
#include "snapshot/test/test_module_snapshot.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
#include "util/misc/uuid.h"
|
#include "util/misc/uuid.h"
|
||||||
|
|
||||||
@ -650,10 +651,10 @@ void InitializeTestModuleSnapshotFromMinidumpModule(
|
|||||||
|
|
||||||
TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
||||||
MINIDUMP_MODULE expect_modules[3] = {};
|
MINIDUMP_MODULE expect_modules[3] = {};
|
||||||
const char* module_paths[arraysize(expect_modules)] = {};
|
const char* module_paths[ArraySize(expect_modules)] = {};
|
||||||
const char* module_pdbs[arraysize(expect_modules)] = {};
|
const char* module_pdbs[ArraySize(expect_modules)] = {};
|
||||||
UUID uuids[arraysize(expect_modules)] = {};
|
UUID uuids[ArraySize(expect_modules)] = {};
|
||||||
uint32_t ages[arraysize(expect_modules)] = {};
|
uint32_t ages[ArraySize(expect_modules)] = {};
|
||||||
|
|
||||||
expect_modules[0].BaseOfImage = 0x100101000;
|
expect_modules[0].BaseOfImage = 0x100101000;
|
||||||
expect_modules[0].SizeOfImage = 0xf000;
|
expect_modules[0].SizeOfImage = 0xf000;
|
||||||
@ -705,7 +706,7 @@ TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<TestModuleSnapshot>> module_snapshots_owner;
|
std::vector<std::unique_ptr<TestModuleSnapshot>> module_snapshots_owner;
|
||||||
std::vector<const ModuleSnapshot*> module_snapshots;
|
std::vector<const ModuleSnapshot*> module_snapshots;
|
||||||
for (size_t index = 0; index < arraysize(expect_modules); ++index) {
|
for (size_t index = 0; index < ArraySize(expect_modules); ++index) {
|
||||||
module_snapshots_owner.push_back(std::make_unique<TestModuleSnapshot>());
|
module_snapshots_owner.push_back(std::make_unique<TestModuleSnapshot>());
|
||||||
TestModuleSnapshot* module_snapshot = module_snapshots_owner.back().get();
|
TestModuleSnapshot* module_snapshot = module_snapshots_owner.back().get();
|
||||||
InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot,
|
InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot,
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "minidump/test/minidump_rva_list_test_util.h"
|
#include "minidump/test/minidump_rva_list_test_util.h"
|
||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -86,10 +87,10 @@ TEST(MinidumpRVAListWriter, ThreeChildren) {
|
|||||||
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
||||||
|
|
||||||
const MinidumpRVAList* list =
|
const MinidumpRVAList* list =
|
||||||
MinidumpRVAListAtStart(string_file.string(), arraysize(kValues));
|
MinidumpRVAListAtStart(string_file.string(), ArraySize(kValues));
|
||||||
ASSERT_TRUE(list);
|
ASSERT_TRUE(list);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kValues); ++index) {
|
for (size_t index = 0; index < ArraySize(kValues); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index));
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index));
|
||||||
|
|
||||||
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
|
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "minidump/test/minidump_string_writer_test_util.h"
|
#include "minidump/test/minidump_string_writer_test_util.h"
|
||||||
#include "minidump/test/minidump_writable_test_util.h"
|
#include "minidump/test/minidump_writable_test_util.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -66,14 +67,14 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
|||||||
{4, "\360\220\204\202", 2, {0xd800, 0xdd02}}, // 𐄂 (non-BMP)
|
{4, "\360\220\204\202", 2, {0xd800, 0xdd02}}, // 𐄂 (non-BMP)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ", input %s", index, kTestData[index].input_string));
|
"index %" PRIuS ", input %s", index, kTestData[index].input_string));
|
||||||
|
|
||||||
// Make sure that the expected output string with its NUL terminator fits in
|
// Make sure that the expected output string with its NUL terminator fits in
|
||||||
// the space provided.
|
// the space provided.
|
||||||
ASSERT_EQ(kTestData[index]
|
ASSERT_EQ(kTestData[index]
|
||||||
.output_string[arraysize(kTestData[index].output_string) - 1],
|
.output_string[ArraySize(kTestData[index].output_string) - 1],
|
||||||
0);
|
0);
|
||||||
|
|
||||||
string_file.Reset();
|
string_file.Reset();
|
||||||
@ -118,7 +119,7 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
|
|||||||
"\303\0\251", // NUL in middle of valid sequence
|
"\303\0\251", // NUL in middle of valid sequence
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ", input %s", index, kTestData[index]));
|
"index %" PRIuS ", input %s", index, kTestData[index]));
|
||||||
string_file.Reset();
|
string_file.Reset();
|
||||||
@ -181,7 +182,7 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
|
|||||||
{4, "\360\220\204\202"}, // 𐄂 (non-BMP)
|
{4, "\360\220\204\202"}, // 𐄂 (non-BMP)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ", input %s", index, kTestData[index].string));
|
"index %" PRIuS ", input %s", index, kTestData[index].string));
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "minidump/minidump_string_writer.h"
|
#include "minidump/minidump_string_writer.h"
|
||||||
#include "snapshot/system_snapshot.h"
|
#include "snapshot/system_snapshot.h"
|
||||||
#include "util/file/file_writer.h"
|
#include "util/file/file_writer.h"
|
||||||
#include "util/misc/arraysize_unsafe.h"
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -212,7 +212,7 @@ void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx,
|
|||||||
system_info_.ProcessorArchitecture ==
|
system_info_.ProcessorArchitecture ==
|
||||||
kMinidumpCPUArchitectureX86Win64);
|
kMinidumpCPUArchitectureX86Win64);
|
||||||
|
|
||||||
static_assert(ARRAYSIZE_UNSAFE(system_info_.Cpu.X86CpuInfo.VendorId) == 3,
|
static_assert(ArraySize(system_info_.Cpu.X86CpuInfo.VendorId) == 3,
|
||||||
"VendorId must have 3 elements");
|
"VendorId must have 3 elements");
|
||||||
|
|
||||||
system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx;
|
system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx;
|
||||||
@ -230,7 +230,7 @@ void MinidumpSystemInfoWriter::SetCPUX86VendorString(
|
|||||||
sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId),
|
sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId),
|
||||||
"VendorId sizes must be equal");
|
"VendorId sizes must be equal");
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(registers); ++index) {
|
for (size_t index = 0; index < ArraySize(registers); ++index) {
|
||||||
memcpy(®isters[index],
|
memcpy(®isters[index],
|
||||||
&vendor[index * sizeof(*registers)],
|
&vendor[index * sizeof(*registers)],
|
||||||
sizeof(*registers));
|
sizeof(*registers));
|
||||||
@ -270,9 +270,8 @@ void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0,
|
|||||||
system_info_.ProcessorArchitecture !=
|
system_info_.ProcessorArchitecture !=
|
||||||
kMinidumpCPUArchitectureX86Win64);
|
kMinidumpCPUArchitectureX86Win64);
|
||||||
|
|
||||||
static_assert(
|
static_assert(ArraySize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2,
|
||||||
ARRAYSIZE_UNSAFE(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2,
|
"ProcessorFeatures must have 2 elements");
|
||||||
"ProcessorFeatures must have 2 elements");
|
|
||||||
|
|
||||||
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0;
|
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0;
|
||||||
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1;
|
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "snapshot/test/test_thread_snapshot.h"
|
#include "snapshot/test/test_thread_snapshot.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -38,7 +39,7 @@ class MinidumpThreadIDMapTest : public testing::Test {
|
|||||||
|
|
||||||
// testing::Test:
|
// testing::Test:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
for (size_t index = 0; index < arraysize(test_thread_snapshots_); ++index) {
|
for (size_t index = 0; index < ArraySize(test_thread_snapshots_); ++index) {
|
||||||
thread_snapshots_.push_back(&test_thread_snapshots_[index]);
|
thread_snapshots_.push_back(&test_thread_snapshots_[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ class MinidumpThreadIDMapTest : public testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetThreadID(size_t index, uint64_t thread_id) {
|
void SetThreadID(size_t index, uint64_t thread_id) {
|
||||||
ASSERT_LT(index, arraysize(test_thread_snapshots_));
|
ASSERT_LT(index, ArraySize(test_thread_snapshots_));
|
||||||
test_thread_snapshots_[index].SetThreadID(thread_id);
|
test_thread_snapshots_[index].SetThreadID(thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "snapshot/test/test_thread_snapshot.h"
|
#include "snapshot/test/test_thread_snapshot.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -522,10 +523,10 @@ template <typename Traits>
|
|||||||
void RunInitializeFromSnapshotTest(bool thread_id_collision) {
|
void RunInitializeFromSnapshotTest(bool thread_id_collision) {
|
||||||
using MinidumpContextType = typename Traits::MinidumpContextType;
|
using MinidumpContextType = typename Traits::MinidumpContextType;
|
||||||
MINIDUMP_THREAD expect_threads[3] = {};
|
MINIDUMP_THREAD expect_threads[3] = {};
|
||||||
uint64_t thread_ids[arraysize(expect_threads)] = {};
|
uint64_t thread_ids[ArraySize(expect_threads)] = {};
|
||||||
uint8_t memory_values[arraysize(expect_threads)] = {};
|
uint8_t memory_values[ArraySize(expect_threads)] = {};
|
||||||
uint32_t context_seeds[arraysize(expect_threads)] = {};
|
uint32_t context_seeds[ArraySize(expect_threads)] = {};
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR tebs[arraysize(expect_threads)] = {};
|
MINIDUMP_MEMORY_DESCRIPTOR tebs[ArraySize(expect_threads)] = {};
|
||||||
|
|
||||||
constexpr size_t kTebSize = 1024;
|
constexpr size_t kTebSize = 1024;
|
||||||
|
|
||||||
@ -581,7 +582,7 @@ void RunInitializeFromSnapshotTest(bool thread_id_collision) {
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<TestThreadSnapshot>> thread_snapshots_owner;
|
std::vector<std::unique_ptr<TestThreadSnapshot>> thread_snapshots_owner;
|
||||||
std::vector<const ThreadSnapshot*> thread_snapshots;
|
std::vector<const ThreadSnapshot*> thread_snapshots;
|
||||||
for (size_t index = 0; index < arraysize(expect_threads); ++index) {
|
for (size_t index = 0; index < ArraySize(expect_threads); ++index) {
|
||||||
thread_snapshots_owner.push_back(std::make_unique<TestThreadSnapshot>());
|
thread_snapshots_owner.push_back(std::make_unique<TestThreadSnapshot>());
|
||||||
TestThreadSnapshot* thread_snapshot = thread_snapshots_owner.back().get();
|
TestThreadSnapshot* thread_snapshot = thread_snapshots_owner.back().get();
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "util/file/file_writer.h"
|
#include "util/file/file_writer.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/numeric/safe_assignment.h"
|
#include "util/numeric/safe_assignment.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -244,7 +245,7 @@ bool MinidumpWritable::WritePaddingAndObject(FileWriterInterface* file_writer) {
|
|||||||
// The number of elements in kZeroes must be at least one less than the
|
// The number of elements in kZeroes must be at least one less than the
|
||||||
// maximum Alignment() ever encountered.
|
// maximum Alignment() ever encountered.
|
||||||
static constexpr uint8_t kZeroes[kMaximumAlignment - 1] = {};
|
static constexpr uint8_t kZeroes[kMaximumAlignment - 1] = {};
|
||||||
DCHECK_LE(leading_pad_bytes_, arraysize(kZeroes));
|
DCHECK_LE(leading_pad_bytes_, ArraySize(kZeroes));
|
||||||
|
|
||||||
if (leading_pad_bytes_) {
|
if (leading_pad_bytes_) {
|
||||||
if (!file_writer->Write(&kZeroes, leading_pad_bytes_)) {
|
if (!file_writer->Write(&kZeroes, leading_pad_bytes_)) {
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "snapshot/cpu_context.h"
|
#include "snapshot/cpu_context.h"
|
||||||
#include "snapshot/test/test_cpu_context.h"
|
#include "snapshot/test/test_cpu_context.h"
|
||||||
#include "test/hex_string.h"
|
#include "test/hex_string.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -128,7 +128,7 @@ void InitializeMinidumpContextAMD64(MinidumpContextAMD64* context,
|
|||||||
context->ds = static_cast<uint16_t>(value++);
|
context->ds = static_cast<uint16_t>(value++);
|
||||||
context->es = static_cast<uint16_t>(value++);
|
context->es = static_cast<uint16_t>(value++);
|
||||||
context->ss = static_cast<uint16_t>(value++);
|
context->ss = static_cast<uint16_t>(value++);
|
||||||
for (size_t index = 0; index < arraysize(context->vector_register); ++index) {
|
for (size_t index = 0; index < ArraySize(context->vector_register); ++index) {
|
||||||
context->vector_register[index].lo = value++;
|
context->vector_register[index].lo = value++;
|
||||||
context->vector_register[index].hi = value++;
|
context->vector_register[index].hi = value++;
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ void InitializeMinidumpContextARM(MinidumpContextARM* context, uint32_t seed) {
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->regs); ++index) {
|
||||||
context->regs[index] = value++;
|
context->regs[index] = value++;
|
||||||
}
|
}
|
||||||
context->fp = value++;
|
context->fp = value++;
|
||||||
@ -162,7 +162,7 @@ void InitializeMinidumpContextARM(MinidumpContextARM* context, uint32_t seed) {
|
|||||||
context->pc = value++;
|
context->pc = value++;
|
||||||
context->cpsr = value++;
|
context->cpsr = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->vfp); ++index) {
|
for (size_t index = 0; index < ArraySize(context->vfp); ++index) {
|
||||||
context->vfp[index] = value++;
|
context->vfp[index] = value++;
|
||||||
}
|
}
|
||||||
context->fpscr = value++;
|
context->fpscr = value++;
|
||||||
@ -180,7 +180,7 @@ void InitializeMinidumpContextARM64(MinidumpContextARM64* context,
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->regs); ++index) {
|
||||||
context->regs[index] = value++;
|
context->regs[index] = value++;
|
||||||
}
|
}
|
||||||
context->fp = value++;
|
context->fp = value++;
|
||||||
@ -189,7 +189,7 @@ void InitializeMinidumpContextARM64(MinidumpContextARM64* context,
|
|||||||
context->pc = value++;
|
context->pc = value++;
|
||||||
context->cpsr = value++;
|
context->cpsr = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->fpsimd); ++index) {
|
for (size_t index = 0; index < ArraySize(context->fpsimd); ++index) {
|
||||||
context->fpsimd[index].lo = value++;
|
context->fpsimd[index].lo = value++;
|
||||||
context->fpsimd[index].hi = value++;
|
context->fpsimd[index].hi = value++;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ void InitializeMinidumpContextMIPS(MinidumpContextMIPS* context,
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->regs); ++index) {
|
||||||
context->regs[index] = value++;
|
context->regs[index] = value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ void InitializeMinidumpContextMIPS(MinidumpContextMIPS* context,
|
|||||||
context->status = value++;
|
context->status = value++;
|
||||||
context->cause = value++;
|
context->cause = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->fpregs.fregs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->fpregs.fregs); ++index) {
|
||||||
context->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
|
context->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void InitializeMinidumpContextMIPS64(MinidumpContextMIPS64* context,
|
|||||||
|
|
||||||
uint64_t value = seed;
|
uint64_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->regs); ++index) {
|
||||||
context->regs[index] = value++;
|
context->regs[index] = value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void InitializeMinidumpContextMIPS64(MinidumpContextMIPS64* context,
|
|||||||
context->status = value++;
|
context->status = value++;
|
||||||
context->cause = value++;
|
context->cause = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->fpregs.dregs); ++index) {
|
for (size_t index = 0; index < ArraySize(context->fpregs.dregs); ++index) {
|
||||||
context->fpregs.dregs[index] = static_cast<double>(value++);
|
context->fpregs.dregs[index] = static_cast<double>(value++);
|
||||||
}
|
}
|
||||||
context->fpcsr = value++;
|
context->fpcsr = value++;
|
||||||
@ -293,35 +293,33 @@ void ExpectMinidumpContextFxsave(const FxsaveType* expected,
|
|||||||
EXPECT_EQ(observed->reserved_3, expected->reserved_3);
|
EXPECT_EQ(observed->reserved_3, expected->reserved_3);
|
||||||
EXPECT_EQ(observed->mxcsr, expected->mxcsr);
|
EXPECT_EQ(observed->mxcsr, expected->mxcsr);
|
||||||
EXPECT_EQ(observed->mxcsr_mask, expected->mxcsr_mask);
|
EXPECT_EQ(observed->mxcsr_mask, expected->mxcsr_mask);
|
||||||
for (size_t st_mm_index = 0;
|
for (size_t st_mm_index = 0; st_mm_index < ArraySize(expected->st_mm);
|
||||||
st_mm_index < arraysize(expected->st_mm);
|
|
||||||
++st_mm_index) {
|
++st_mm_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("st_mm_index %" PRIuS, st_mm_index));
|
SCOPED_TRACE(base::StringPrintf("st_mm_index %" PRIuS, st_mm_index));
|
||||||
EXPECT_EQ(BytesToHexString(observed->st_mm[st_mm_index].st,
|
EXPECT_EQ(BytesToHexString(observed->st_mm[st_mm_index].st,
|
||||||
arraysize(observed->st_mm[st_mm_index].st)),
|
ArraySize(observed->st_mm[st_mm_index].st)),
|
||||||
BytesToHexString(expected->st_mm[st_mm_index].st,
|
BytesToHexString(expected->st_mm[st_mm_index].st,
|
||||||
arraysize(expected->st_mm[st_mm_index].st)));
|
ArraySize(expected->st_mm[st_mm_index].st)));
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
BytesToHexString(observed->st_mm[st_mm_index].st_reserved,
|
BytesToHexString(observed->st_mm[st_mm_index].st_reserved,
|
||||||
arraysize(observed->st_mm[st_mm_index].st_reserved)),
|
ArraySize(observed->st_mm[st_mm_index].st_reserved)),
|
||||||
BytesToHexString(expected->st_mm[st_mm_index].st_reserved,
|
BytesToHexString(expected->st_mm[st_mm_index].st_reserved,
|
||||||
arraysize(expected->st_mm[st_mm_index].st_reserved)));
|
ArraySize(expected->st_mm[st_mm_index].st_reserved)));
|
||||||
}
|
}
|
||||||
for (size_t xmm_index = 0;
|
for (size_t xmm_index = 0; xmm_index < ArraySize(expected->xmm);
|
||||||
xmm_index < arraysize(expected->xmm);
|
|
||||||
++xmm_index) {
|
++xmm_index) {
|
||||||
EXPECT_EQ(BytesToHexString(observed->xmm[xmm_index],
|
EXPECT_EQ(BytesToHexString(observed->xmm[xmm_index],
|
||||||
arraysize(observed->xmm[xmm_index])),
|
ArraySize(observed->xmm[xmm_index])),
|
||||||
BytesToHexString(expected->xmm[xmm_index],
|
BytesToHexString(expected->xmm[xmm_index],
|
||||||
arraysize(expected->xmm[xmm_index])))
|
ArraySize(expected->xmm[xmm_index])))
|
||||||
<< "xmm_index " << xmm_index;
|
<< "xmm_index " << xmm_index;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
BytesToHexString(observed->reserved_4, arraysize(observed->reserved_4)),
|
BytesToHexString(observed->reserved_4, ArraySize(observed->reserved_4)),
|
||||||
BytesToHexString(expected->reserved_4, arraysize(expected->reserved_4)));
|
BytesToHexString(expected->reserved_4, ArraySize(expected->reserved_4)));
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
BytesToHexString(observed->available, arraysize(observed->available)),
|
BytesToHexString(observed->available, ArraySize(observed->available)),
|
||||||
BytesToHexString(expected->available, arraysize(expected->available)));
|
BytesToHexString(expected->available, ArraySize(expected->available)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -346,11 +344,11 @@ void ExpectMinidumpContextX86(
|
|||||||
EXPECT_EQ(observed->fsave.fpu_cs, expected.fsave.fpu_cs);
|
EXPECT_EQ(observed->fsave.fpu_cs, expected.fsave.fpu_cs);
|
||||||
EXPECT_EQ(observed->fsave.fpu_dp, expected.fsave.fpu_dp);
|
EXPECT_EQ(observed->fsave.fpu_dp, expected.fsave.fpu_dp);
|
||||||
EXPECT_EQ(observed->fsave.fpu_ds, expected.fsave.fpu_ds);
|
EXPECT_EQ(observed->fsave.fpu_ds, expected.fsave.fpu_ds);
|
||||||
for (size_t index = 0; index < arraysize(expected.fsave.st); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.fsave.st); ++index) {
|
||||||
EXPECT_EQ(BytesToHexString(observed->fsave.st[index],
|
EXPECT_EQ(BytesToHexString(observed->fsave.st[index],
|
||||||
arraysize(observed->fsave.st[index])),
|
ArraySize(observed->fsave.st[index])),
|
||||||
BytesToHexString(expected.fsave.st[index],
|
BytesToHexString(expected.fsave.st[index],
|
||||||
arraysize(expected.fsave.st[index])))
|
ArraySize(expected.fsave.st[index])))
|
||||||
<< "index " << index;
|
<< "index " << index;
|
||||||
}
|
}
|
||||||
if (snapshot) {
|
if (snapshot) {
|
||||||
@ -449,7 +447,7 @@ void ExpectMinidumpContextAMD64(
|
|||||||
|
|
||||||
ExpectMinidumpContextFxsave(&expected.fxsave, &observed->fxsave);
|
ExpectMinidumpContextFxsave(&expected.fxsave, &observed->fxsave);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.vector_register); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.vector_register); ++index) {
|
||||||
if (snapshot) {
|
if (snapshot) {
|
||||||
EXPECT_EQ(observed->vector_register[index].lo, 0u) << "index " << index;
|
EXPECT_EQ(observed->vector_register[index].lo, 0u) << "index " << index;
|
||||||
EXPECT_EQ(observed->vector_register[index].hi, 0u) << "index " << index;
|
EXPECT_EQ(observed->vector_register[index].hi, 0u) << "index " << index;
|
||||||
@ -489,7 +487,7 @@ void ExpectMinidumpContextARM(uint32_t expect_seed,
|
|||||||
|
|
||||||
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.regs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
|
||||||
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(observed->fp, expected.fp);
|
EXPECT_EQ(observed->fp, expected.fp);
|
||||||
@ -500,10 +498,10 @@ void ExpectMinidumpContextARM(uint32_t expect_seed,
|
|||||||
EXPECT_EQ(observed->cpsr, expected.cpsr);
|
EXPECT_EQ(observed->cpsr, expected.cpsr);
|
||||||
|
|
||||||
EXPECT_EQ(observed->fpscr, expected.fpscr);
|
EXPECT_EQ(observed->fpscr, expected.fpscr);
|
||||||
for (size_t index = 0; index < arraysize(expected.vfp); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.vfp); ++index) {
|
||||||
EXPECT_EQ(observed->vfp[index], expected.vfp[index]);
|
EXPECT_EQ(observed->vfp[index], expected.vfp[index]);
|
||||||
}
|
}
|
||||||
for (size_t index = 0; index < arraysize(expected.extra); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.extra); ++index) {
|
||||||
EXPECT_EQ(observed->extra[index], snapshot ? 0 : expected.extra[index]);
|
EXPECT_EQ(observed->extra[index], snapshot ? 0 : expected.extra[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,14 +514,14 @@ void ExpectMinidumpContextARM64(uint32_t expect_seed,
|
|||||||
|
|
||||||
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.regs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
|
||||||
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(observed->cpsr, expected.cpsr);
|
EXPECT_EQ(observed->cpsr, expected.cpsr);
|
||||||
|
|
||||||
EXPECT_EQ(observed->fpsr, expected.fpsr);
|
EXPECT_EQ(observed->fpsr, expected.fpsr);
|
||||||
EXPECT_EQ(observed->fpcr, expected.fpcr);
|
EXPECT_EQ(observed->fpcr, expected.fpcr);
|
||||||
for (size_t index = 0; index < arraysize(expected.fpsimd); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.fpsimd); ++index) {
|
||||||
EXPECT_EQ(observed->fpsimd[index].lo, expected.fpsimd[index].lo);
|
EXPECT_EQ(observed->fpsimd[index].lo, expected.fpsimd[index].lo);
|
||||||
EXPECT_EQ(observed->fpsimd[index].hi, expected.fpsimd[index].hi);
|
EXPECT_EQ(observed->fpsimd[index].hi, expected.fpsimd[index].hi);
|
||||||
}
|
}
|
||||||
@ -537,7 +535,7 @@ void ExpectMinidumpContextMIPS(uint32_t expect_seed,
|
|||||||
|
|
||||||
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.regs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
|
||||||
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +546,7 @@ void ExpectMinidumpContextMIPS(uint32_t expect_seed,
|
|||||||
EXPECT_EQ(observed->status, expected.status);
|
EXPECT_EQ(observed->status, expected.status);
|
||||||
EXPECT_EQ(observed->cause, expected.cause);
|
EXPECT_EQ(observed->cause, expected.cause);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.fpregs.fregs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.fpregs.fregs); ++index) {
|
||||||
EXPECT_EQ(observed->fpregs.fregs[index]._fp_fregs,
|
EXPECT_EQ(observed->fpregs.fregs[index]._fp_fregs,
|
||||||
expected.fpregs.fregs[index]._fp_fregs);
|
expected.fpregs.fregs[index]._fp_fregs);
|
||||||
}
|
}
|
||||||
@ -570,7 +568,7 @@ void ExpectMinidumpContextMIPS64(uint32_t expect_seed,
|
|||||||
|
|
||||||
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
EXPECT_EQ(observed->context_flags, expected.context_flags);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.regs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.regs); ++index) {
|
||||||
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
EXPECT_EQ(observed->regs[index], expected.regs[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +579,7 @@ void ExpectMinidumpContextMIPS64(uint32_t expect_seed,
|
|||||||
EXPECT_EQ(observed->status, expected.status);
|
EXPECT_EQ(observed->status, expected.status);
|
||||||
EXPECT_EQ(observed->cause, expected.cause);
|
EXPECT_EQ(observed->cause, expected.cause);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(expected.fpregs.dregs); ++index) {
|
for (size_t index = 0; index < ArraySize(expected.fpregs.dregs); ++index) {
|
||||||
EXPECT_EQ(observed->fpregs.dregs[index], expected.fpregs.dregs[index]);
|
EXPECT_EQ(observed->fpregs.dregs[index], expected.fpregs.dregs[index]);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(observed->fpcsr, expected.fpcsr);
|
EXPECT_EQ(observed->fpcsr, expected.fpcsr);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "snapshot/memory_snapshot.h"
|
#include "snapshot/memory_snapshot.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -97,17 +98,17 @@ void CaptureMemory::PointedToByContext(const CPUContext& context,
|
|||||||
#elif defined(ARCH_CPU_ARM_FAMILY)
|
#elif defined(ARCH_CPU_ARM_FAMILY)
|
||||||
if (context.architecture == kCPUArchitectureARM64) {
|
if (context.architecture == kCPUArchitectureARM64) {
|
||||||
MaybeCaptureMemoryAround(delegate, context.arm64->pc);
|
MaybeCaptureMemoryAround(delegate, context.arm64->pc);
|
||||||
for (size_t i = 0; i < arraysize(context.arm64->regs); ++i) {
|
for (size_t i = 0; i < ArraySize(context.arm64->regs); ++i) {
|
||||||
MaybeCaptureMemoryAround(delegate, context.arm64->regs[i]);
|
MaybeCaptureMemoryAround(delegate, context.arm64->regs[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MaybeCaptureMemoryAround(delegate, context.arm->pc);
|
MaybeCaptureMemoryAround(delegate, context.arm->pc);
|
||||||
for (size_t i = 0; i < arraysize(context.arm->regs); ++i) {
|
for (size_t i = 0; i < ArraySize(context.arm->regs); ++i) {
|
||||||
MaybeCaptureMemoryAround(delegate, context.arm->regs[i]);
|
MaybeCaptureMemoryAround(delegate, context.arm->regs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||||
for (size_t i = 0; i < arraysize(context.mipsel->regs); ++i) {
|
for (size_t i = 0; i < ArraySize(context.mipsel->regs); ++i) {
|
||||||
MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
|
MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -55,9 +55,9 @@ void CPUContextX86::FxsaveToFsave(const Fxsave& fxsave, Fsave* fsave) {
|
|||||||
fsave->fpu_dp = fxsave.fpu_dp;
|
fsave->fpu_dp = fxsave.fpu_dp;
|
||||||
fsave->fpu_ds = fxsave.fpu_ds;
|
fsave->fpu_ds = fxsave.fpu_ds;
|
||||||
fsave->reserved_4 = 0;
|
fsave->reserved_4 = 0;
|
||||||
static_assert(arraysize(fsave->st) == arraysize(fxsave.st_mm),
|
static_assert(ArraySize(fsave->st) == ArraySize(fxsave.st_mm),
|
||||||
"FPU stack registers must be equivalent");
|
"FPU stack registers must be equivalent");
|
||||||
for (size_t index = 0; index < arraysize(fsave->st); ++index) {
|
for (size_t index = 0; index < ArraySize(fsave->st); ++index) {
|
||||||
memcpy(fsave->st[index], fxsave.st_mm[index].st, sizeof(fsave->st[index]));
|
memcpy(fsave->st[index], fxsave.st_mm[index].st, sizeof(fsave->st[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,9 +77,9 @@ void CPUContextX86::FsaveToFxsave(const Fsave& fsave, Fxsave* fxsave) {
|
|||||||
fxsave->reserved_3 = 0;
|
fxsave->reserved_3 = 0;
|
||||||
fxsave->mxcsr = 0;
|
fxsave->mxcsr = 0;
|
||||||
fxsave->mxcsr_mask = 0;
|
fxsave->mxcsr_mask = 0;
|
||||||
static_assert(arraysize(fxsave->st_mm) == arraysize(fsave.st),
|
static_assert(ArraySize(fxsave->st_mm) == ArraySize(fsave.st),
|
||||||
"FPU stack registers must be equivalent");
|
"FPU stack registers must be equivalent");
|
||||||
for (size_t index = 0; index < arraysize(fsave.st); ++index) {
|
for (size_t index = 0; index < ArraySize(fsave.st); ++index) {
|
||||||
memcpy(fxsave->st_mm[index].st, fsave.st[index], sizeof(fsave.st[index]));
|
memcpy(fxsave->st_mm[index].st, fsave.st[index], sizeof(fsave.st[index]));
|
||||||
memset(fxsave->st_mm[index].st_reserved,
|
memset(fxsave->st_mm[index].st_reserved,
|
||||||
0,
|
0,
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/hex_string.h"
|
#include "test/hex_string.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -124,7 +124,7 @@ TEST(CPUContextX86, FxsaveToFsave) {
|
|||||||
&fxsave.st_mm[6].st, kExponentAllZero, false, kFractionAllZero);
|
&fxsave.st_mm[6].st, kExponentAllZero, false, kFractionAllZero);
|
||||||
SetX87Register(
|
SetX87Register(
|
||||||
&fxsave.st_mm[7].st, kExponentNormal, true, kFractionNormal); // valid
|
&fxsave.st_mm[7].st, kExponentNormal, true, kFractionNormal); // valid
|
||||||
for (size_t index = 0; index < arraysize(fxsave.st_mm); ++index) {
|
for (size_t index = 0; index < ArraySize(fxsave.st_mm); ++index) {
|
||||||
memset(&fxsave.st_mm[index].st_reserved,
|
memset(&fxsave.st_mm[index].st_reserved,
|
||||||
0x5a,
|
0x5a,
|
||||||
sizeof(fxsave.st_mm[index].st_reserved));
|
sizeof(fxsave.st_mm[index].st_reserved));
|
||||||
@ -148,10 +148,10 @@ TEST(CPUContextX86, FxsaveToFsave) {
|
|||||||
EXPECT_EQ(fsave.fpu_dp, fxsave.fpu_dp);
|
EXPECT_EQ(fsave.fpu_dp, fxsave.fpu_dp);
|
||||||
EXPECT_EQ(fsave.fpu_ds, fxsave.fpu_ds);
|
EXPECT_EQ(fsave.fpu_ds, fxsave.fpu_ds);
|
||||||
EXPECT_EQ(fsave.reserved_4, 0);
|
EXPECT_EQ(fsave.reserved_4, 0);
|
||||||
for (size_t index = 0; index < arraysize(fsave.st); ++index) {
|
for (size_t index = 0; index < ArraySize(fsave.st); ++index) {
|
||||||
EXPECT_EQ(BytesToHexString(fsave.st[index], arraysize(fsave.st[index])),
|
EXPECT_EQ(BytesToHexString(fsave.st[index], ArraySize(fsave.st[index])),
|
||||||
BytesToHexString(fxsave.st_mm[index].st,
|
BytesToHexString(fxsave.st_mm[index].st,
|
||||||
arraysize(fxsave.st_mm[index].st)))
|
ArraySize(fxsave.st_mm[index].st)))
|
||||||
<< "index " << index;
|
<< "index " << index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,14 +204,14 @@ TEST(CPUContextX86, FsaveToFxsave) {
|
|||||||
EXPECT_EQ(fxsave.reserved_3, 0);
|
EXPECT_EQ(fxsave.reserved_3, 0);
|
||||||
EXPECT_EQ(fxsave.mxcsr, 0u);
|
EXPECT_EQ(fxsave.mxcsr, 0u);
|
||||||
EXPECT_EQ(fxsave.mxcsr_mask, 0u);
|
EXPECT_EQ(fxsave.mxcsr_mask, 0u);
|
||||||
for (size_t index = 0; index < arraysize(fxsave.st_mm); ++index) {
|
for (size_t index = 0; index < ArraySize(fxsave.st_mm); ++index) {
|
||||||
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st,
|
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st,
|
||||||
arraysize(fxsave.st_mm[index].st)),
|
ArraySize(fxsave.st_mm[index].st)),
|
||||||
BytesToHexString(fsave.st[index], arraysize(fsave.st[index])))
|
BytesToHexString(fsave.st[index], ArraySize(fsave.st[index])))
|
||||||
<< "index " << index;
|
<< "index " << index;
|
||||||
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st_reserved,
|
EXPECT_EQ(BytesToHexString(fxsave.st_mm[index].st_reserved,
|
||||||
arraysize(fxsave.st_mm[index].st_reserved)),
|
ArraySize(fxsave.st_mm[index].st_reserved)),
|
||||||
std::string(arraysize(fxsave.st_mm[index].st_reserved) * 2, '0'))
|
std::string(ArraySize(fxsave.st_mm[index].st_reserved) * 2, '0'))
|
||||||
<< "index " << index;
|
<< "index " << index;
|
||||||
}
|
}
|
||||||
size_t unused_len = sizeof(fxsave) - offsetof(decltype(fxsave), xmm);
|
size_t unused_len = sizeof(fxsave) - offsetof(decltype(fxsave), xmm);
|
||||||
@ -318,7 +318,7 @@ TEST(CPUContextX86, FxsaveToFsaveTagWord) {
|
|||||||
// In this set, everything is valid.
|
// In this set, everything is valid.
|
||||||
fsw = 0 << 11; // top = 0: logical 0-7 maps to physical 0-7
|
fsw = 0 << 11; // top = 0: logical 0-7 maps to physical 0-7
|
||||||
fxsave_tag = 0xff; // nothing empty
|
fxsave_tag = 0xff; // nothing empty
|
||||||
for (size_t index = 0; index < arraysize(st_mm); ++index) {
|
for (size_t index = 0; index < ArraySize(st_mm); ++index) {
|
||||||
SetX87OrMMXRegister(&st_mm[index], kExponentNormal, true, kFractionAllZero);
|
SetX87OrMMXRegister(&st_mm[index], kExponentNormal, true, kFractionAllZero);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(CPUContextX86::FxsaveToFsaveTagWord(fsw, fxsave_tag, st_mm), 0);
|
EXPECT_EQ(CPUContextX86::FxsaveToFsaveTagWord(fsw, fxsave_tag, st_mm), 0);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h"
|
#include "snapshot/fuchsia/memory_map_region_snapshot_fuchsia.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -49,7 +50,7 @@ uint32_t MmuFlagsToProtectFlags(zx_vm_option_t flags) {
|
|||||||
|
|
||||||
const uint32_t index =
|
const uint32_t index =
|
||||||
flags & (ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_PERM_EXECUTE);
|
flags & (ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_PERM_EXECUTE);
|
||||||
DCHECK_LT(index, arraysize(mapping));
|
DCHECK_LT(index, ArraySize(mapping));
|
||||||
|
|
||||||
const uint32_t protect_flags = mapping[index];
|
const uint32_t protect_flags = mapping[index];
|
||||||
DCHECK_NE(protect_flags, 0u);
|
DCHECK_NE(protect_flags, 0u);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "test/multiprocess_exec.h"
|
#include "test/multiprocess_exec.h"
|
||||||
#include "test/test_paths.h"
|
#include "test/test_paths.h"
|
||||||
#include "util/fuchsia/scoped_task_suspend.h"
|
#include "util/fuchsia/scoped_task_suspend.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -34,7 +35,7 @@ TEST(ProcessReaderFuchsia, SelfBasic) {
|
|||||||
ASSERT_TRUE(process_reader.Initialize(*zx::process::self()));
|
ASSERT_TRUE(process_reader.Initialize(*zx::process::self()));
|
||||||
|
|
||||||
static constexpr char kTestMemory[] = "Some test memory";
|
static constexpr char kTestMemory[] = "Some test memory";
|
||||||
char buffer[arraysize(kTestMemory)];
|
char buffer[ArraySize(kTestMemory)];
|
||||||
ASSERT_TRUE(process_reader.Memory()->Read(
|
ASSERT_TRUE(process_reader.Memory()->Read(
|
||||||
reinterpret_cast<zx_vaddr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
|
reinterpret_cast<zx_vaddr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
|
||||||
EXPECT_STREQ(kTestMemory, buffer);
|
EXPECT_STREQ(kTestMemory, buffer);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
|
#include "snapshot/fuchsia/process_snapshot_fuchsia.h"
|
||||||
#include "test/multiprocess_exec.h"
|
#include "test/multiprocess_exec.h"
|
||||||
#include "util/fuchsia/scoped_task_suspend.h"
|
#include "util/fuchsia/scoped_task_suspend.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -103,8 +104,8 @@ class AddressSpaceTest : public MultiprocessExec {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void MultiprocessParent() override {
|
void MultiprocessParent() override {
|
||||||
uintptr_t test_addresses[arraysize(kTestMappingPermAndSizes)];
|
uintptr_t test_addresses[ArraySize(kTestMappingPermAndSizes)];
|
||||||
for (size_t i = 0; i < arraysize(test_addresses); ++i) {
|
for (size_t i = 0; i < ArraySize(test_addresses); ++i) {
|
||||||
ASSERT_TRUE(ReadFileExactly(
|
ASSERT_TRUE(ReadFileExactly(
|
||||||
ReadPipeHandle(), &test_addresses[i], sizeof(test_addresses[i])));
|
ReadPipeHandle(), &test_addresses[i], sizeof(test_addresses[i])));
|
||||||
}
|
}
|
||||||
@ -114,7 +115,7 @@ class AddressSpaceTest : public MultiprocessExec {
|
|||||||
ProcessSnapshotFuchsia process_snapshot;
|
ProcessSnapshotFuchsia process_snapshot;
|
||||||
ASSERT_TRUE(process_snapshot.Initialize(*ChildProcess()));
|
ASSERT_TRUE(process_snapshot.Initialize(*ChildProcess()));
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(test_addresses); ++i) {
|
for (size_t i = 0; i < ArraySize(test_addresses); ++i) {
|
||||||
const auto& t = kTestMappingPermAndSizes[i];
|
const auto& t = kTestMappingPermAndSizes[i];
|
||||||
EXPECT_TRUE(HasSingleMatchingMapping(process_snapshot.MemoryMap(),
|
EXPECT_TRUE(HasSingleMatchingMapping(process_snapshot.MemoryMap(),
|
||||||
test_addresses[i],
|
test_addresses[i],
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
#include "test/linux/fake_ptrace_connection.h"
|
#include "test/linux/fake_ptrace_connection.h"
|
||||||
#include "util/linux/address_types.h"
|
#include "util/linux/address_types.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/clock.h"
|
#include "util/misc/clock.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/posix/signals.h"
|
#include "util/posix/signals.h"
|
||||||
@ -170,7 +171,7 @@ void InitializeContext(NativeCPUContext* context) {
|
|||||||
test_context->vfp.head.magic = VFP_MAGIC;
|
test_context->vfp.head.magic = VFP_MAGIC;
|
||||||
test_context->vfp.head.size = sizeof(test_context->vfp);
|
test_context->vfp.head.size = sizeof(test_context->vfp);
|
||||||
memset(&test_context->vfp.context, 'v', sizeof(test_context->vfp.context));
|
memset(&test_context->vfp.context, 'v', sizeof(test_context->vfp.context));
|
||||||
for (size_t reg = 0; reg < arraysize(test_context->vfp.context.vfp.fpregs);
|
for (size_t reg = 0; reg < ArraySize(test_context->vfp.context.vfp.fpregs);
|
||||||
++reg) {
|
++reg) {
|
||||||
test_context->vfp.context.vfp.fpregs[reg] = reg;
|
test_context->vfp.context.vfp.fpregs[reg] = reg;
|
||||||
}
|
}
|
||||||
@ -218,7 +219,7 @@ struct TestCoprocessorContext {
|
|||||||
void InitializeContext(NativeCPUContext* context) {
|
void InitializeContext(NativeCPUContext* context) {
|
||||||
memset(context, 'x', sizeof(*context));
|
memset(context, 'x', sizeof(*context));
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(context->uc_mcontext.regs);
|
for (size_t index = 0; index < ArraySize(context->uc_mcontext.regs);
|
||||||
++index) {
|
++index) {
|
||||||
context->uc_mcontext.regs[index] = index;
|
context->uc_mcontext.regs[index] = index;
|
||||||
}
|
}
|
||||||
@ -237,7 +238,7 @@ void InitializeContext(NativeCPUContext* context) {
|
|||||||
test_context->fpsimd.head.size = sizeof(test_context->fpsimd);
|
test_context->fpsimd.head.size = sizeof(test_context->fpsimd);
|
||||||
test_context->fpsimd.fpsr = 1;
|
test_context->fpsimd.fpsr = 1;
|
||||||
test_context->fpsimd.fpcr = 2;
|
test_context->fpsimd.fpcr = 2;
|
||||||
for (size_t reg = 0; reg < arraysize(test_context->fpsimd.vregs); ++reg) {
|
for (size_t reg = 0; reg < ArraySize(test_context->fpsimd.vregs); ++reg) {
|
||||||
test_context->fpsimd.vregs[reg] = reg;
|
test_context->fpsimd.vregs[reg] = reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ void ExpectContext(const CPUContext& actual, const NativeCPUContext& expected) {
|
|||||||
using NativeCPUContext = ucontext_t;
|
using NativeCPUContext = ucontext_t;
|
||||||
|
|
||||||
void InitializeContext(NativeCPUContext* context) {
|
void InitializeContext(NativeCPUContext* context) {
|
||||||
for (size_t reg = 0; reg < arraysize(context->uc_mcontext.gregs); ++reg) {
|
for (size_t reg = 0; reg < ArraySize(context->uc_mcontext.gregs); ++reg) {
|
||||||
context->uc_mcontext.gregs[reg] = reg;
|
context->uc_mcontext.gregs[reg] = reg;
|
||||||
}
|
}
|
||||||
memset(&context->uc_mcontext.fpregs, 44, sizeof(context->uc_mcontext.fpregs));
|
memset(&context->uc_mcontext.fpregs, 44, sizeof(context->uc_mcontext.fpregs));
|
||||||
@ -285,7 +286,7 @@ void ExpectContext(const CPUContext& actual, const NativeCPUContext& expected) {
|
|||||||
#define CPU_ARCH_NAME mips64
|
#define CPU_ARCH_NAME mips64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (size_t reg = 0; reg < arraysize(expected.uc_mcontext.gregs); ++reg) {
|
for (size_t reg = 0; reg < ArraySize(expected.uc_mcontext.gregs); ++reg) {
|
||||||
EXPECT_EQ(actual.CPU_ARCH_NAME->regs[reg], expected.uc_mcontext.gregs[reg]);
|
EXPECT_EQ(actual.CPU_ARCH_NAME->regs[reg], expected.uc_mcontext.gregs[reg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "util/file/filesystem.h"
|
#include "util/file/filesystem.h"
|
||||||
#include "util/linux/direct_ptrace_connection.h"
|
#include "util/linux/direct_ptrace_connection.h"
|
||||||
#include "util/misc/address_sanitizer.h"
|
#include "util/misc/address_sanitizer.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/synchronization/semaphore.h"
|
#include "util/synchronization/semaphore.h"
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ TEST(ProcessReaderLinux, SelfBasic) {
|
|||||||
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
|
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
|
||||||
|
|
||||||
static constexpr char kTestMemory[] = "Some test memory";
|
static constexpr char kTestMemory[] = "Some test memory";
|
||||||
char buffer[arraysize(kTestMemory)];
|
char buffer[ArraySize(kTestMemory)];
|
||||||
ASSERT_TRUE(process_reader.Memory()->Read(
|
ASSERT_TRUE(process_reader.Memory()->Read(
|
||||||
reinterpret_cast<LinuxVMAddress>(kTestMemory),
|
reinterpret_cast<LinuxVMAddress>(kTestMemory),
|
||||||
sizeof(kTestMemory),
|
sizeof(kTestMemory),
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
|
#include "snapshot/mac/mach_o_image_symbol_table_reader.h"
|
||||||
#include "snapshot/mac/process_reader_mac.h"
|
#include "snapshot/mac/process_reader_mac.h"
|
||||||
#include "util/mac/checked_mach_address_range.h"
|
#include "util/mac/checked_mach_address_range.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -182,7 +183,7 @@ bool MachOImageReader::Initialize(ProcessReaderMac* process_reader,
|
|||||||
// This vector is parallel to the kLoadCommandReaders array, and tracks
|
// This vector is parallel to the kLoadCommandReaders array, and tracks
|
||||||
// whether a singleton load command matching the |command| field has been
|
// whether a singleton load command matching the |command| field has been
|
||||||
// found yet.
|
// found yet.
|
||||||
std::vector<uint32_t> singleton_indices(arraysize(kLoadCommandReaders),
|
std::vector<uint32_t> singleton_indices(ArraySize(kLoadCommandReaders),
|
||||||
kInvalidSegmentIndex);
|
kInvalidSegmentIndex);
|
||||||
|
|
||||||
size_t offset = mach_header.Size();
|
size_t offset = mach_header.Size();
|
||||||
@ -235,8 +236,7 @@ bool MachOImageReader::Initialize(ProcessReaderMac* process_reader,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t reader_index = 0;
|
for (size_t reader_index = 0; reader_index < ArraySize(kLoadCommandReaders);
|
||||||
reader_index < arraysize(kLoadCommandReaders);
|
|
||||||
++reader_index) {
|
++reader_index) {
|
||||||
if (load_command.cmd != kLoadCommandReaders[reader_index].command) {
|
if (load_command.cmd != kLoadCommandReaders[reader_index].command) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
#include <mach-o/loader.h>
|
#include <mach-o/loader.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -63,7 +63,7 @@ TEST(MachOImageSegmentReader, SegmentNameString) {
|
|||||||
SEG_IMPORT,
|
SEG_IMPORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kSegmentTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kSegmentTestData); ++index) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
MachOImageSegmentReader::SegmentNameString(kSegmentTestData[index]),
|
MachOImageSegmentReader::SegmentNameString(kSegmentTestData[index]),
|
||||||
kSegmentTestData[index])
|
kSegmentTestData[index])
|
||||||
@ -106,7 +106,7 @@ TEST(MachOImageSegmentReader, SectionNameString) {
|
|||||||
SECT_ICON_TIFF,
|
SECT_ICON_TIFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kSectionTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kSectionTestData); ++index) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
MachOImageSegmentReader::SectionNameString(kSectionTestData[index]),
|
MachOImageSegmentReader::SectionNameString(kSectionTestData[index]),
|
||||||
kSectionTestData[index])
|
kSectionTestData[index])
|
||||||
@ -169,7 +169,7 @@ TEST(MachOImageSegmentReader, SegmentAndSectionNameString) {
|
|||||||
{SEG_IMPORT, "", "__IMPORT,"},
|
{SEG_IMPORT, "", "__IMPORT,"},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kSegmentAndSectionTestData);
|
for (size_t index = 0; index < ArraySize(kSegmentAndSectionTestData);
|
||||||
++index) {
|
++index) {
|
||||||
const auto& test = kSegmentAndSectionTestData[index];
|
const auto& test = kSegmentAndSectionTestData[index];
|
||||||
EXPECT_EQ(MachOImageSegmentReader::SegmentAndSectionNameString(
|
EXPECT_EQ(MachOImageSegmentReader::SegmentAndSectionNameString(
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/mac/mac_util.h"
|
#include "util/mac/mac_util.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/synchronization/semaphore.h"
|
#include "util/synchronization/semaphore.h"
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ TEST(ProcessReaderMac, SelfBasic) {
|
|||||||
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
|
EXPECT_EQ(process_reader.ParentProcessID(), getppid());
|
||||||
|
|
||||||
static constexpr char kTestMemory[] = "Some test memory";
|
static constexpr char kTestMemory[] = "Some test memory";
|
||||||
char buffer[arraysize(kTestMemory)];
|
char buffer[ArraySize(kTestMemory)];
|
||||||
ASSERT_TRUE(process_reader.Memory()->Read(
|
ASSERT_TRUE(process_reader.Memory()->Read(
|
||||||
FromPointerCast<mach_vm_address_t>(kTestMemory),
|
FromPointerCast<mach_vm_address_t>(kTestMemory),
|
||||||
sizeof(kTestMemory),
|
sizeof(kTestMemory),
|
||||||
@ -612,11 +613,11 @@ class ScopedOpenCLNoOpKernel {
|
|||||||
const size_t source_lengths[] = {
|
const size_t source_lengths[] = {
|
||||||
strlen(sources[0]),
|
strlen(sources[0]),
|
||||||
};
|
};
|
||||||
static_assert(arraysize(sources) == arraysize(source_lengths),
|
static_assert(ArraySize(sources) == ArraySize(source_lengths),
|
||||||
"arrays must be parallel");
|
"arrays must be parallel");
|
||||||
|
|
||||||
program_ = clCreateProgramWithSource(
|
program_ = clCreateProgramWithSource(
|
||||||
context_, arraysize(sources), sources, source_lengths, &rv);
|
context_, ArraySize(sources), sources, source_lengths, &rv);
|
||||||
ASSERT_EQ(rv, CL_SUCCESS) << "clCreateProgramWithSource";
|
ASSERT_EQ(rv, CL_SUCCESS) << "clCreateProgramWithSource";
|
||||||
|
|
||||||
rv = clBuildProgram(
|
rv = clBuildProgram(
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "snapshot/mac/process_types/internal.h"
|
#include "snapshot/mac/process_types/internal.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/process/process_memory_mac.h"
|
#include "util/process/process_memory_mac.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -74,7 +74,7 @@ using UInt64Array4 = uint64_t[4];
|
|||||||
template <>
|
template <>
|
||||||
inline void Assign<UInt64Array4, UInt32Array4>(UInt64Array4* destination,
|
inline void Assign<UInt64Array4, UInt32Array4>(UInt64Array4* destination,
|
||||||
const UInt32Array4& source) {
|
const UInt32Array4& source) {
|
||||||
for (size_t index = 0; index < arraysize(source); ++index) {
|
for (size_t index = 0; index < ArraySize(source); ++index) {
|
||||||
(*destination)[index] = source[index];
|
(*destination)[index] = source[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "base/numerics/safe_math.h"
|
#include "base/numerics/safe_math.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "snapshot/mac/process_types/internal.h"
|
#include "snapshot/mac/process_types/internal.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/process/process_memory_mac.h"
|
#include "util/process/process_memory_mac.h"
|
||||||
|
|
||||||
#if !DOXYGEN
|
#if !DOXYGEN
|
||||||
@ -144,8 +145,8 @@ size_t dyld_all_image_infos<Traits>::ExpectedSizeForVersion(
|
|||||||
sizeof(dyld_all_image_infos<Traits>), // 16
|
sizeof(dyld_all_image_infos<Traits>), // 16
|
||||||
};
|
};
|
||||||
|
|
||||||
if (version >= arraysize(kSizeForVersion)) {
|
if (version >= ArraySize(kSizeForVersion)) {
|
||||||
return kSizeForVersion[arraysize(kSizeForVersion) - 1];
|
return kSizeForVersion[ArraySize(kSizeForVersion) - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(std::is_unsigned<decltype(version)>::value,
|
static_assert(std::is_unsigned<decltype(version)>::value,
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "snapshot/mac/process_types/internal.h"
|
#include "snapshot/mac/process_types/internal.h"
|
||||||
#include "test/mac/dyld.h"
|
#include "test/mac/dyld.h"
|
||||||
#include "util/mac/mac_util.h"
|
#include "util/mac/mac_util.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
|||||||
{15, 164, 304},
|
{15, 164, 304},
|
||||||
{16, 176, 320},
|
{16, 176, 320},
|
||||||
};
|
};
|
||||||
for (size_t index = 0; index < arraysize(kVersionsAndSizes); ++index) {
|
for (size_t index = 0; index < ArraySize(kVersionsAndSizes); ++index) {
|
||||||
uint32_t version = kVersionsAndSizes[index].version;
|
uint32_t version = kVersionsAndSizes[index].version;
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, version %u", index, version));
|
SCOPED_TRACE(base::StringPrintf("index %zu, version %u", index, version));
|
||||||
|
|
||||||
@ -268,8 +268,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
|||||||
self_image_infos->sharedCacheBaseAddress);
|
self_image_infos->sharedCacheBaseAddress);
|
||||||
EXPECT_EQ(proctype_image_infos.dyldPath,
|
EXPECT_EQ(proctype_image_infos.dyldPath,
|
||||||
reinterpret_cast<uint64_t>(self_image_infos->dyldPath));
|
reinterpret_cast<uint64_t>(self_image_infos->dyldPath));
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(self_image_infos->notifyPorts);
|
||||||
index < arraysize(self_image_infos->notifyPorts);
|
|
||||||
++index) {
|
++index) {
|
||||||
EXPECT_EQ(proctype_image_infos.notifyPorts[index],
|
EXPECT_EQ(proctype_image_infos.notifyPorts[index],
|
||||||
self_image_infos->notifyPorts[index])
|
self_image_infos->notifyPorts[index])
|
||||||
@ -289,8 +288,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
|||||||
// process_types version. It’s difficult to compare the reserved fields in
|
// process_types version. It’s difficult to compare the reserved fields in
|
||||||
// these older SDKs, so only do it where the declarations match.
|
// these older SDKs, so only do it where the declarations match.
|
||||||
if (proctype_image_infos.version >= 14) {
|
if (proctype_image_infos.version >= 14) {
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(proctype_image_infos.reserved);
|
||||||
index < arraysize(proctype_image_infos.reserved);
|
|
||||||
++index) {
|
++index) {
|
||||||
EXPECT_EQ(proctype_image_infos.reserved[index],
|
EXPECT_EQ(proctype_image_infos.reserved[index],
|
||||||
implicit_cast<uint64_t>(self_image_infos->reserved[index]))
|
implicit_cast<uint64_t>(self_image_infos->reserved[index]))
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "snapshot/minidump/minidump_annotation_reader.h"
|
#include "snapshot/minidump/minidump_annotation_reader.h"
|
||||||
#include "snapshot/module_snapshot.h"
|
#include "snapshot/module_snapshot.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/pdb_structures.h"
|
#include "util/misc/pdb_structures.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -858,27 +859,27 @@ TEST(ProcessSnapshotMinidump, ThreadContextX86_64) {
|
|||||||
minidump_context.fxsave.fpu_ip_64 = 42;
|
minidump_context.fxsave.fpu_ip_64 = 42;
|
||||||
minidump_context.fxsave.fpu_dp_64 = 43;
|
minidump_context.fxsave.fpu_dp_64 = 43;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(minidump_context.vector_register); i++) {
|
for (size_t i = 0; i < ArraySize(minidump_context.vector_register); i++) {
|
||||||
minidump_context.vector_register[i].lo = i * 2 + 44;
|
minidump_context.vector_register[i].lo = i * 2 + 44;
|
||||||
minidump_context.vector_register[i].hi = i * 2 + 45;
|
minidump_context.vector_register[i].hi = i * 2 + 45;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < arraysize(minidump_context.fxsave.reserved_4); i++) {
|
for (uint8_t i = 0; i < ArraySize(minidump_context.fxsave.reserved_4); i++) {
|
||||||
minidump_context.fxsave.reserved_4[i] = i * 2 + 115;
|
minidump_context.fxsave.reserved_4[i] = i * 2 + 115;
|
||||||
minidump_context.fxsave.available[i] = i * 2 + 116;
|
minidump_context.fxsave.available[i] = i * 2 + 116;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(minidump_context.fxsave.st_mm); i++) {
|
for (size_t i = 0; i < ArraySize(minidump_context.fxsave.st_mm); i++) {
|
||||||
for (uint8_t j = 0;
|
for (uint8_t j = 0;
|
||||||
j < arraysize(minidump_context.fxsave.st_mm[0].mm_value);
|
j < ArraySize(minidump_context.fxsave.st_mm[0].mm_value);
|
||||||
j++) {
|
j++) {
|
||||||
minidump_context.fxsave.st_mm[i].mm_value[j] = j + 1;
|
minidump_context.fxsave.st_mm[i].mm_value[j] = j + 1;
|
||||||
minidump_context.fxsave.st_mm[i].mm_reserved[j] = j + 1;
|
minidump_context.fxsave.st_mm[i].mm_reserved[j] = j + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(minidump_context.fxsave.xmm); i++) {
|
for (size_t i = 0; i < ArraySize(minidump_context.fxsave.xmm); i++) {
|
||||||
for (uint8_t j = 0; j < arraysize(minidump_context.fxsave.xmm[0]); j++) {
|
for (uint8_t j = 0; j < ArraySize(minidump_context.fxsave.xmm[0]); j++) {
|
||||||
minidump_context.fxsave.xmm[i][j] = j + 1;
|
minidump_context.fxsave.xmm[i][j] = j + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -961,22 +962,20 @@ TEST(ProcessSnapshotMinidump, ThreadContextX86_64) {
|
|||||||
EXPECT_EQ(ctx->fxsave.fpu_ip_64, 42U);
|
EXPECT_EQ(ctx->fxsave.fpu_ip_64, 42U);
|
||||||
EXPECT_EQ(ctx->fxsave.fpu_dp_64, 43U);
|
EXPECT_EQ(ctx->fxsave.fpu_dp_64, 43U);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < arraysize(ctx->fxsave.reserved_4); i++) {
|
for (uint8_t i = 0; i < ArraySize(ctx->fxsave.reserved_4); i++) {
|
||||||
EXPECT_EQ(ctx->fxsave.reserved_4[i], i * 2 + 115);
|
EXPECT_EQ(ctx->fxsave.reserved_4[i], i * 2 + 115);
|
||||||
EXPECT_EQ(ctx->fxsave.available[i], i * 2 + 116);
|
EXPECT_EQ(ctx->fxsave.available[i], i * 2 + 116);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(ctx->fxsave.st_mm); i++) {
|
for (size_t i = 0; i < ArraySize(ctx->fxsave.st_mm); i++) {
|
||||||
for (uint8_t j = 0;
|
for (uint8_t j = 0; j < ArraySize(ctx->fxsave.st_mm[0].mm_value); j++) {
|
||||||
j < arraysize(ctx->fxsave.st_mm[0].mm_value);
|
|
||||||
j++) {
|
|
||||||
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_value[j], j + 1);
|
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_value[j], j + 1);
|
||||||
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_reserved[j], j + 1);
|
EXPECT_EQ(ctx->fxsave.st_mm[i].mm_reserved[j], j + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(ctx->fxsave.xmm); i++) {
|
for (size_t i = 0; i < ArraySize(ctx->fxsave.xmm); i++) {
|
||||||
for (uint8_t j = 0; j < arraysize(ctx->fxsave.xmm[0]); j++) {
|
for (uint8_t j = 0; j < ArraySize(ctx->fxsave.xmm[0]); j++) {
|
||||||
EXPECT_EQ(ctx->fxsave.xmm[i][j], j + 1);
|
EXPECT_EQ(ctx->fxsave.xmm[i][j], j + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "minidump/minidump_context.h"
|
#include "minidump/minidump_context.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -192,7 +193,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->regs); i++) {
|
for (size_t i = 0; i < ArraySize(src->regs); i++) {
|
||||||
context_.arm->regs[i] = src->regs[i];
|
context_.arm->regs[i] = src->regs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +205,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
context_.arm->cpsr = src->cpsr;
|
context_.arm->cpsr = src->cpsr;
|
||||||
context_.arm->vfp_regs.fpscr = src->fpscr;
|
context_.arm->vfp_regs.fpscr = src->fpscr;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->vfp); i++) {
|
for (size_t i = 0; i < ArraySize(src->vfp); i++) {
|
||||||
context_.arm->vfp_regs.vfp[i] = src->vfp[i];
|
context_.arm->vfp_regs.vfp[i] = src->vfp[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,14 +225,14 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->regs); i++) {
|
for (size_t i = 0; i < ArraySize(src->regs); i++) {
|
||||||
context_.arm64->regs[i] = src->regs[i];
|
context_.arm64->regs[i] = src->regs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
context_.arm64->regs[29] = src->fp;
|
context_.arm64->regs[29] = src->fp;
|
||||||
context_.arm64->regs[30] = src->lr;
|
context_.arm64->regs[30] = src->lr;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->fpsimd); i++) {
|
for (size_t i = 0; i < ArraySize(src->fpsimd); i++) {
|
||||||
context_.arm64->fpsimd[i] = src->fpsimd[i];
|
context_.arm64->fpsimd[i] = src->fpsimd[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +255,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->regs); i++) {
|
for (size_t i = 0; i < ArraySize(src->regs); i++) {
|
||||||
context_.mipsel->regs[i] = src->regs[i];
|
context_.mipsel->regs[i] = src->regs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +263,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
context_.mipsel->mdlo = static_cast<uint32_t>(src->mdlo);
|
context_.mipsel->mdlo = static_cast<uint32_t>(src->mdlo);
|
||||||
context_.mipsel->dsp_control = src->dsp_control;
|
context_.mipsel->dsp_control = src->dsp_control;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->hi); i++) {
|
for (size_t i = 0; i < ArraySize(src->hi); i++) {
|
||||||
context_.mipsel->hi[i] = src->hi[i];
|
context_.mipsel->hi[i] = src->hi[i];
|
||||||
context_.mipsel->lo[i] = src->lo[i];
|
context_.mipsel->lo[i] = src->lo[i];
|
||||||
}
|
}
|
||||||
@ -291,7 +292,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->regs); i++) {
|
for (size_t i = 0; i < ArraySize(src->regs); i++) {
|
||||||
context_.mips64->regs[i] = src->regs[i];
|
context_.mips64->regs[i] = src->regs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +300,7 @@ bool ThreadSnapshotMinidump::InitializeContext(
|
|||||||
context_.mips64->mdlo = src->mdlo;
|
context_.mips64->mdlo = src->mdlo;
|
||||||
context_.mips64->dsp_control = src->dsp_control;
|
context_.mips64->dsp_control = src->dsp_control;
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(src->hi); i++) {
|
for (size_t i = 0; i < ArraySize(src->hi); i++) {
|
||||||
context_.mips64->hi[i] = src->hi[i];
|
context_.mips64->hi[i] = src->hi[i];
|
||||||
context_.mips64->lo[i] = src->lo[i];
|
context_.mips64->lo[i] = src->lo[i];
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -59,8 +60,7 @@ void TimeZone(const timeval& snapshot_time,
|
|||||||
static constexpr int kMonthDeltas[] =
|
static constexpr int kMonthDeltas[] =
|
||||||
{0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6,
|
{0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6,
|
||||||
7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12};
|
7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12};
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(kMonthDeltas) && !found_transition;
|
||||||
index < arraysize(kMonthDeltas) && !found_transition;
|
|
||||||
++index) {
|
++index) {
|
||||||
// Look at a day of each month at local noon. Set tm_isdst to -1 to avoid
|
// Look at a day of each month at local noon. Set tm_isdst to -1 to avoid
|
||||||
// giving mktime() any hints about whether to consider daylight saving
|
// giving mktime() any hints about whether to consider daylight saving
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -154,7 +155,7 @@ TEST(TimeZone, Basic) {
|
|||||||
{"UTC", false, 0, 0, "UTC", "UTC"},
|
{"UTC", false, 0, 0, "UTC", "UTC"},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestTimeZones); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestTimeZones); ++index) {
|
||||||
const auto& test_time_zone = kTestTimeZones[index];
|
const auto& test_time_zone = kTestTimeZones[index];
|
||||||
const char* tz = test_time_zone.tz;
|
const char* tz = test_time_zone.tz;
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, tz %s", index, tz));
|
SCOPED_TRACE(base::StringPrintf("index %zu, tz %s", index, tz));
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/process/process_memory_linux.h"
|
#include "util/process/process_memory_linux.h"
|
||||||
|
|
||||||
@ -59,8 +60,8 @@ const char* const kNonEmptyWhitelist[] = {"string1",
|
|||||||
|
|
||||||
TEST_F(WhitelistTest, NonEmptyWhitelist) {
|
TEST_F(WhitelistTest, NonEmptyWhitelist) {
|
||||||
ASSERT_TRUE(ReadWhitelist(kNonEmptyWhitelist));
|
ASSERT_TRUE(ReadWhitelist(kNonEmptyWhitelist));
|
||||||
ASSERT_EQ(whitelist_.size(), arraysize(kNonEmptyWhitelist) - 1);
|
ASSERT_EQ(whitelist_.size(), ArraySize(kNonEmptyWhitelist) - 1);
|
||||||
for (size_t index = 0; index < arraysize(kNonEmptyWhitelist) - 1; ++index) {
|
for (size_t index = 0; index < ArraySize(kNonEmptyWhitelist) - 1; ++index) {
|
||||||
EXPECT_EQ(whitelist_[index], kNonEmptyWhitelist[index]);
|
EXPECT_EQ(whitelist_[index], kNonEmptyWhitelist[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -44,28 +44,28 @@ void InitializeCPUContextFxsave(FxsaveType* fxsave, uint32_t* seed) {
|
|||||||
fxsave->reserved_3 = static_cast<uint16_t>(value++);
|
fxsave->reserved_3 = static_cast<uint16_t>(value++);
|
||||||
fxsave->mxcsr = value++;
|
fxsave->mxcsr = value++;
|
||||||
fxsave->mxcsr_mask = value++;
|
fxsave->mxcsr_mask = value++;
|
||||||
for (size_t st_mm_index = 0; st_mm_index < arraysize(fxsave->st_mm);
|
for (size_t st_mm_index = 0; st_mm_index < ArraySize(fxsave->st_mm);
|
||||||
++st_mm_index) {
|
++st_mm_index) {
|
||||||
for (size_t byte = 0; byte < arraysize(fxsave->st_mm[st_mm_index].st);
|
for (size_t byte = 0; byte < ArraySize(fxsave->st_mm[st_mm_index].st);
|
||||||
++byte) {
|
++byte) {
|
||||||
fxsave->st_mm[st_mm_index].st[byte] = static_cast<uint8_t>(value++);
|
fxsave->st_mm[st_mm_index].st[byte] = static_cast<uint8_t>(value++);
|
||||||
}
|
}
|
||||||
for (size_t byte = 0;
|
for (size_t byte = 0;
|
||||||
byte < arraysize(fxsave->st_mm[st_mm_index].st_reserved);
|
byte < ArraySize(fxsave->st_mm[st_mm_index].st_reserved);
|
||||||
++byte) {
|
++byte) {
|
||||||
fxsave->st_mm[st_mm_index].st_reserved[byte] =
|
fxsave->st_mm[st_mm_index].st_reserved[byte] =
|
||||||
static_cast<uint8_t>(value);
|
static_cast<uint8_t>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t xmm_index = 0; xmm_index < arraysize(fxsave->xmm); ++xmm_index) {
|
for (size_t xmm_index = 0; xmm_index < ArraySize(fxsave->xmm); ++xmm_index) {
|
||||||
for (size_t byte = 0; byte < arraysize(fxsave->xmm[xmm_index]); ++byte) {
|
for (size_t byte = 0; byte < ArraySize(fxsave->xmm[xmm_index]); ++byte) {
|
||||||
fxsave->xmm[xmm_index][byte] = static_cast<uint8_t>(value++);
|
fxsave->xmm[xmm_index][byte] = static_cast<uint8_t>(value++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t byte = 0; byte < arraysize(fxsave->reserved_4); ++byte) {
|
for (size_t byte = 0; byte < ArraySize(fxsave->reserved_4); ++byte) {
|
||||||
fxsave->reserved_4[byte] = static_cast<uint8_t>(value++);
|
fxsave->reserved_4[byte] = static_cast<uint8_t>(value++);
|
||||||
}
|
}
|
||||||
for (size_t byte = 0; byte < arraysize(fxsave->available); ++byte) {
|
for (size_t byte = 0; byte < ArraySize(fxsave->available); ++byte) {
|
||||||
fxsave->available[byte] = static_cast<uint8_t>(value++);
|
fxsave->available[byte] = static_cast<uint8_t>(value++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void InitializeCPUContextARM(CPUContext* context, uint32_t seed) {
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(arm->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(arm->regs); ++index) {
|
||||||
arm->regs[index] = value++;
|
arm->regs[index] = value++;
|
||||||
}
|
}
|
||||||
arm->fp = value++;
|
arm->fp = value++;
|
||||||
@ -185,7 +185,7 @@ void InitializeCPUContextARM(CPUContext* context, uint32_t seed) {
|
|||||||
arm->pc = value++;
|
arm->pc = value++;
|
||||||
arm->cpsr = value++;
|
arm->cpsr = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(arm->vfp_regs.vfp); ++index) {
|
for (size_t index = 0; index < ArraySize(arm->vfp_regs.vfp); ++index) {
|
||||||
arm->vfp_regs.vfp[index] = value++;
|
arm->vfp_regs.vfp[index] = value++;
|
||||||
}
|
}
|
||||||
arm->vfp_regs.fpscr = value++;
|
arm->vfp_regs.fpscr = value++;
|
||||||
@ -205,14 +205,14 @@ void InitializeCPUContextARM64(CPUContext* context, uint32_t seed) {
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(arm64->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(arm64->regs); ++index) {
|
||||||
arm64->regs[index] = value++;
|
arm64->regs[index] = value++;
|
||||||
}
|
}
|
||||||
arm64->sp = value++;
|
arm64->sp = value++;
|
||||||
arm64->pc = value++;
|
arm64->pc = value++;
|
||||||
arm64->spsr = value++;
|
arm64->spsr = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(arm64->fpsimd); ++index) {
|
for (size_t index = 0; index < ArraySize(arm64->fpsimd); ++index) {
|
||||||
arm64->fpsimd[index].lo = value++;
|
arm64->fpsimd[index].lo = value++;
|
||||||
arm64->fpsimd[index].hi = value++;
|
arm64->fpsimd[index].hi = value++;
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ void InitializeCPUContextMIPS(CPUContext* context, uint32_t seed) {
|
|||||||
|
|
||||||
uint32_t value = seed;
|
uint32_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(mipsel->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(mipsel->regs); ++index) {
|
||||||
mipsel->regs[index] = value++;
|
mipsel->regs[index] = value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ void InitializeCPUContextMIPS(CPUContext* context, uint32_t seed) {
|
|||||||
mipsel->cp0_status = value++;
|
mipsel->cp0_status = value++;
|
||||||
mipsel->cp0_cause = value++;
|
mipsel->cp0_cause = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(mipsel->fpregs.fregs); ++index) {
|
for (size_t index = 0; index < ArraySize(mipsel->fpregs.fregs); ++index) {
|
||||||
mipsel->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
|
mipsel->fpregs.fregs[index]._fp_fregs = static_cast<float>(value++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ void InitializeCPUContextMIPS64(CPUContext* context, uint32_t seed) {
|
|||||||
|
|
||||||
uint64_t value = seed;
|
uint64_t value = seed;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(mips64->regs); ++index) {
|
for (size_t index = 0; index < ArraySize(mips64->regs); ++index) {
|
||||||
mips64->regs[index] = value++;
|
mips64->regs[index] = value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ void InitializeCPUContextMIPS64(CPUContext* context, uint32_t seed) {
|
|||||||
mips64->cp0_status = value++;
|
mips64->cp0_status = value++;
|
||||||
mips64->cp0_cause = value++;
|
mips64->cp0_cause = value++;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(mips64->fpregs.dregs); ++index) {
|
for (size_t index = 0; index < ArraySize(mips64->fpregs.dregs); ++index) {
|
||||||
mips64->fpregs.dregs[index] = static_cast<double>(value++);
|
mips64->fpregs.dregs[index] = static_cast<double>(value++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/hex_string.h"
|
|
||||||
#include "snapshot/cpu_context.h"
|
#include "snapshot/cpu_context.h"
|
||||||
|
#include "test/hex_string.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -87,13 +87,13 @@ void TestInitializeX86Context_FsaveWithoutFxsave() {
|
|||||||
for (size_t st_mm = 0; st_mm < 7; ++st_mm) {
|
for (size_t st_mm = 0; st_mm < 7; ++st_mm) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
BytesToHexString(cpu_context_x86.fxsave.st_mm[st_mm].st,
|
BytesToHexString(cpu_context_x86.fxsave.st_mm[st_mm].st,
|
||||||
arraysize(cpu_context_x86.fxsave.st_mm[st_mm].st)),
|
ArraySize(cpu_context_x86.fxsave.st_mm[st_mm].st)),
|
||||||
std::string(arraysize(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2,
|
std::string(ArraySize(cpu_context_x86.fxsave.st_mm[st_mm].st) * 2,
|
||||||
'0'))
|
'0'))
|
||||||
<< "st_mm " << st_mm;
|
<< "st_mm " << st_mm;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(BytesToHexString(cpu_context_x86.fxsave.st_mm[7].st,
|
EXPECT_EQ(BytesToHexString(cpu_context_x86.fxsave.st_mm[7].st,
|
||||||
arraysize(cpu_context_x86.fxsave.st_mm[7].st)),
|
ArraySize(cpu_context_x86.fxsave.st_mm[7].st)),
|
||||||
"0000000000000080ff7f");
|
"0000000000000080ff7f");
|
||||||
|
|
||||||
EXPECT_EQ(cpu_context_x86.dr0, 3u);
|
EXPECT_EQ(cpu_context_x86.dr0, 3u);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/synchronization/semaphore.h"
|
#include "util/synchronization/semaphore.h"
|
||||||
#include "util/win/scoped_handle.h"
|
#include "util/win/scoped_handle.h"
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ DWORD WINAPI LotsOfReferencesThreadProc(void* param) {
|
|||||||
|
|
||||||
// Allocate a bunch of pointers to things on the stack.
|
// Allocate a bunch of pointers to things on the stack.
|
||||||
int* pointers[1000];
|
int* pointers[1000];
|
||||||
for (size_t i = 0; i < arraysize(pointers); ++i) {
|
for (size_t i = 0; i < ArraySize(pointers); ++i) {
|
||||||
pointers[i] = new int[2048];
|
pointers[i] = new int[2048];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||||||
// verify the cap on pointed-to memory.
|
// verify the cap on pointed-to memory.
|
||||||
crashpad::Semaphore semaphore(0);
|
crashpad::Semaphore semaphore(0);
|
||||||
crashpad::ScopedKernelHANDLE threads[100];
|
crashpad::ScopedKernelHANDLE threads[100];
|
||||||
for (size_t i = 0; i < arraysize(threads); ++i) {
|
for (size_t i = 0; i < ArraySize(threads); ++i) {
|
||||||
threads[i].reset(CreateThread(nullptr,
|
threads[i].reset(CreateThread(nullptr,
|
||||||
0,
|
0,
|
||||||
&LotsOfReferencesThreadProc,
|
&LotsOfReferencesThreadProc,
|
||||||
@ -65,7 +66,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(threads); ++i) {
|
for (size_t i = 0; i < ArraySize(threads); ++i) {
|
||||||
semaphore.Wait();
|
semaphore.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "snapshot/snapshot_constants.h"
|
#include "snapshot/snapshot_constants.h"
|
||||||
#include "snapshot/win/pe_image_reader.h"
|
#include "snapshot/win/pe_image_reader.h"
|
||||||
#include "snapshot/win/process_reader_win.h"
|
#include "snapshot/win/process_reader_win.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/win/process_structs.h"
|
#include "util/win/process_structs.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -155,7 +156,7 @@ void PEImageAnnotationsReader::ReadCrashpadAnnotationsList(
|
|||||||
snapshot.type = current.type;
|
snapshot.type = current.type;
|
||||||
|
|
||||||
char name[Annotation::kNameMaxLength];
|
char name[Annotation::kNameMaxLength];
|
||||||
if (!process_reader_->Memory()->Read(current.name, arraysize(name), name)) {
|
if (!process_reader_->Memory()->Read(current.name, ArraySize(name), name)) {
|
||||||
LOG(WARNING) << "could not read annotation name at index " << index
|
LOG(WARNING) << "could not read annotation name at index " << index
|
||||||
<< " in " << base::UTF16ToUTF8(name_);
|
<< " in " << base::UTF16ToUTF8(name_);
|
||||||
continue;
|
continue;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "client/crashpad_info.h"
|
#include "client/crashpad_info.h"
|
||||||
#include "snapshot/win/pe_image_resource_reader.h"
|
#include "snapshot/win/pe_image_resource_reader.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/misc/pdb_structures.h"
|
#include "util/misc/pdb_structures.h"
|
||||||
#include "util/win/process_structs.h"
|
#include "util/win/process_structs.h"
|
||||||
@ -275,7 +276,7 @@ bool PEImageReader::VSFixedFileInfo(
|
|||||||
version_info.wType != 0 ||
|
version_info.wType != 0 ||
|
||||||
wcsncmp(version_info.szKey,
|
wcsncmp(version_info.szKey,
|
||||||
L"VS_VERSION_INFO",
|
L"VS_VERSION_INFO",
|
||||||
arraysize(version_info.szKey)) != 0) {
|
ArraySize(version_info.szKey)) != 0) {
|
||||||
LOG(WARNING) << "unexpected VS_VERSIONINFO in "
|
LOG(WARNING) << "unexpected VS_VERSIONINFO in "
|
||||||
<< module_subrange_reader_.name();
|
<< module_subrange_reader_.name();
|
||||||
return false;
|
return false;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/win/win_multiprocess.h"
|
#include "test/win/win_multiprocess.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/synchronization/semaphore.h"
|
#include "util/synchronization/semaphore.h"
|
||||||
#include "util/thread/thread.h"
|
#include "util/thread/thread.h"
|
||||||
@ -43,7 +44,7 @@ TEST(ProcessReaderWin, SelfBasic) {
|
|||||||
EXPECT_EQ(process_reader.GetProcessInfo().ProcessID(), GetCurrentProcessId());
|
EXPECT_EQ(process_reader.GetProcessInfo().ProcessID(), GetCurrentProcessId());
|
||||||
|
|
||||||
static constexpr char kTestMemory[] = "Some test memory";
|
static constexpr char kTestMemory[] = "Some test memory";
|
||||||
char buffer[arraysize(kTestMemory)];
|
char buffer[ArraySize(kTestMemory)];
|
||||||
ASSERT_TRUE(process_reader.Memory()->Read(
|
ASSERT_TRUE(process_reader.Memory()->Read(
|
||||||
reinterpret_cast<uintptr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
|
reinterpret_cast<uintptr_t>(kTestMemory), sizeof(kTestMemory), &buffer));
|
||||||
EXPECT_STREQ(kTestMemory, buffer);
|
EXPECT_STREQ(kTestMemory, buffer);
|
||||||
@ -184,7 +185,7 @@ class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess {
|
|||||||
// the pipe.
|
// the pipe.
|
||||||
CheckedReadFileAtEOF(ReadPipeHandle());
|
CheckedReadFileAtEOF(ReadPipeHandle());
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(threads); ++i)
|
for (size_t i = 0; i < ArraySize(threads); ++i)
|
||||||
done.Signal();
|
done.Signal();
|
||||||
for (auto& thread : threads)
|
for (auto& thread : threads)
|
||||||
thread.Join();
|
thread.Join();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/misc/time.h"
|
#include "util/misc/time.h"
|
||||||
#include "util/win/nt_internals.h"
|
#include "util/win/nt_internals.h"
|
||||||
@ -334,7 +335,7 @@ void ProcessSnapshotWin::InitializeUnloadedModules() {
|
|||||||
uet.TimeDateStamp,
|
uet.TimeDateStamp,
|
||||||
base::UTF16ToUTF8(base::StringPiece16(
|
base::UTF16ToUTF8(base::StringPiece16(
|
||||||
uet.ImageName,
|
uet.ImageName,
|
||||||
wcsnlen(uet.ImageName, arraysize(uet.ImageName))))));
|
wcsnlen(uet.ImageName, ArraySize(uet.ImageName))))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,9 +535,9 @@ WinVMSize ProcessSnapshotWin::DetermineSizeOfEnvironmentBlock(
|
|||||||
env_block.resize(
|
env_block.resize(
|
||||||
static_cast<unsigned int>(bytes_read / sizeof(env_block[0])));
|
static_cast<unsigned int>(bytes_read / sizeof(env_block[0])));
|
||||||
static constexpr wchar_t terminator[] = {0, 0};
|
static constexpr wchar_t terminator[] = {0, 0};
|
||||||
size_t at = env_block.find(std::wstring(terminator, arraysize(terminator)));
|
size_t at = env_block.find(std::wstring(terminator, ArraySize(terminator)));
|
||||||
if (at != std::wstring::npos)
|
if (at != std::wstring::npos)
|
||||||
env_block.resize(at + arraysize(terminator));
|
env_block.resize(at + ArraySize(terminator));
|
||||||
|
|
||||||
return env_block.size() * sizeof(env_block[0]);
|
return env_block.size() * sizeof(env_block[0]);
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ namespace test {
|
|||||||
//! uint8_t expected[10];
|
//! uint8_t expected[10];
|
||||||
//! uint8_t observed[10];
|
//! uint8_t observed[10];
|
||||||
//! // …
|
//! // …
|
||||||
//! EXPECT_EQ(BytesToHexString(observed, arraysize(observed)),
|
//! EXPECT_EQ(BytesToHexString(observed, ArraySize(observed)),
|
||||||
//! BytesToHexString(expected, arraysize(expected)));
|
//! BytesToHexString(expected, ArraySize(expected)));
|
||||||
//! \endcode
|
//! \endcode
|
||||||
std::string BytesToHexString(const void* bytes, size_t length);
|
std::string BytesToHexString(const void* bytes, size_t length);
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
#include "test/hex_string.h"
|
#include "test/hex_string.h"
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -25,7 +25,7 @@ TEST(HexString, HexString) {
|
|||||||
EXPECT_EQ(BytesToHexString(nullptr, 0), "");
|
EXPECT_EQ(BytesToHexString(nullptr, 0), "");
|
||||||
|
|
||||||
static constexpr char kBytes[] = "Abc123xyz \x0a\x7f\xf0\x9f\x92\xa9_";
|
static constexpr char kBytes[] = "Abc123xyz \x0a\x7f\xf0\x9f\x92\xa9_";
|
||||||
EXPECT_EQ(BytesToHexString(kBytes, arraysize(kBytes)),
|
EXPECT_EQ(BytesToHexString(kBytes, ArraySize(kBytes)),
|
||||||
"41626331323378797a200a7ff09f92a95f00");
|
"41626331323378797a200a7ff09f92a95f00");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@ -37,6 +36,7 @@
|
|||||||
#include "tools/tool_support.h"
|
#include "tools/tool_support.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/file/file_reader.h"
|
#include "util/file/file_reader.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/uuid.h"
|
#include "util/misc/uuid.h"
|
||||||
#include "util/stdlib/string_number_conversion.h"
|
#include "util/stdlib/string_number_conversion.h"
|
||||||
|
|
||||||
@ -109,14 +109,14 @@ bool StringToBool(const char* string, bool* boolean) {
|
|||||||
"set",
|
"set",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kFalseWords); ++index) {
|
for (size_t index = 0; index < ArraySize(kFalseWords); ++index) {
|
||||||
if (strcasecmp(string, kFalseWords[index]) == 0) {
|
if (strcasecmp(string, kFalseWords[index]) == 0) {
|
||||||
*boolean = false;
|
*boolean = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTrueWords); ++index) {
|
for (size_t index = 0; index < ArraySize(kTrueWords); ++index) {
|
||||||
if (strcasecmp(string, kTrueWords[index]) == 0) {
|
if (strcasecmp(string, kTrueWords[index]) == 0) {
|
||||||
*boolean = true;
|
*boolean = true;
|
||||||
return true;
|
return true;
|
||||||
@ -159,7 +159,7 @@ bool StringToTime(const char* string, time_t* out_time, bool utc) {
|
|||||||
"%+",
|
"%+",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kFormats); ++index) {
|
for (size_t index = 0; index < ArraySize(kFormats); ++index) {
|
||||||
tm time_tm;
|
tm time_tm;
|
||||||
const char* strptime_result = strptime(string, kFormats[index], &time_tm);
|
const char* strptime_result = strptime(string, kFormats[index], &time_tm);
|
||||||
if (strptime_result == end) {
|
if (strptime_result == end) {
|
||||||
@ -214,7 +214,7 @@ std::string TimeToString(time_t out_time, bool utc) {
|
|||||||
|
|
||||||
char string[64];
|
char string[64];
|
||||||
CHECK_NE(
|
CHECK_NE(
|
||||||
strftime(string, arraysize(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm),
|
strftime(string, ArraySize(string), "%Y-%m-%d %H:%M:%S %Z", &time_tm),
|
||||||
0u);
|
0u);
|
||||||
|
|
||||||
return std::string(string);
|
return std::string(string);
|
||||||
|
@ -86,7 +86,7 @@ static_library("util") {
|
|||||||
"file/string_file.h",
|
"file/string_file.h",
|
||||||
"misc/address_sanitizer.h",
|
"misc/address_sanitizer.h",
|
||||||
"misc/address_types.h",
|
"misc/address_types.h",
|
||||||
"misc/arraysize_unsafe.h",
|
"misc/arraysize.h",
|
||||||
"misc/as_underlying_type.h",
|
"misc/as_underlying_type.h",
|
||||||
"misc/capture_context.h",
|
"misc/capture_context.h",
|
||||||
"misc/clock.h",
|
"misc/clock.h",
|
||||||
@ -530,7 +530,7 @@ source_set("util_test") {
|
|||||||
"file/file_reader_test.cc",
|
"file/file_reader_test.cc",
|
||||||
"file/filesystem_test.cc",
|
"file/filesystem_test.cc",
|
||||||
"file/string_file_test.cc",
|
"file/string_file_test.cc",
|
||||||
"misc/arraysize_unsafe_test.cc",
|
"misc/arraysize_test.cc",
|
||||||
"misc/capture_context_test.cc",
|
"misc/capture_context_test.cc",
|
||||||
"misc/capture_context_test_util.h",
|
"misc/capture_context_test_util.h",
|
||||||
"misc/clock_test.cc",
|
"misc/clock_test.cc",
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ DelimitedFileReader::Result DelimitedFileReader::GetDelim(char delimiter,
|
|||||||
return Result::kEndOfFile;
|
return Result::kEndOfFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK_LE(static_cast<size_t>(read_result), arraysize(buf_));
|
DCHECK_LE(static_cast<size_t>(read_result), ArraySize(buf_));
|
||||||
DCHECK(
|
DCHECK(
|
||||||
base::IsValueInRangeForNumericType<decltype(buf_len_)>(read_result));
|
base::IsValueInRangeForNumericType<decltype(buf_len_)>(read_result));
|
||||||
buf_len_ = static_cast<decltype(buf_len_)>(read_result);
|
buf_len_ = static_cast<decltype(buf_len_)>(read_result);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "util/file/string_file.h"
|
#include "util/file/string_file.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -259,7 +260,7 @@ TEST(DelimitedFileReader, ReallyLongMultiLineFile) {
|
|||||||
TEST(DelimitedFileReader, EmbeddedNUL) {
|
TEST(DelimitedFileReader, EmbeddedNUL) {
|
||||||
static constexpr char kString[] = "embedded\0NUL\n";
|
static constexpr char kString[] = "embedded\0NUL\n";
|
||||||
StringFile string_file;
|
StringFile string_file;
|
||||||
string_file.SetString(std::string(kString, arraysize(kString) - 1));
|
string_file.SetString(std::string(kString, ArraySize(kString) - 1));
|
||||||
DelimitedFileReader delimited_file_reader(&string_file);
|
DelimitedFileReader delimited_file_reader(&string_file);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
@ -277,7 +278,7 @@ TEST(DelimitedFileReader, EmbeddedNUL) {
|
|||||||
TEST(DelimitedFileReader, NULDelimiter) {
|
TEST(DelimitedFileReader, NULDelimiter) {
|
||||||
static constexpr char kString[] = "aa\0b\0ccc\0";
|
static constexpr char kString[] = "aa\0b\0ccc\0";
|
||||||
StringFile string_file;
|
StringFile string_file;
|
||||||
string_file.SetString(std::string(kString, arraysize(kString) - 1));
|
string_file.SetString(std::string(kString, ArraySize(kString) - 1));
|
||||||
DelimitedFileReader delimited_file_reader(&string_file);
|
DelimitedFileReader delimited_file_reader(&string_file);
|
||||||
|
|
||||||
std::string field;
|
std::string field;
|
||||||
@ -301,7 +302,7 @@ TEST(DelimitedFileReader, NULDelimiter) {
|
|||||||
TEST(DelimitedFileReader, EdgeCases) {
|
TEST(DelimitedFileReader, EdgeCases) {
|
||||||
static constexpr size_t kSizes[] =
|
static constexpr size_t kSizes[] =
|
||||||
{4094, 4095, 4096, 4097, 8190, 8191, 8192, 8193};
|
{4094, 4095, 4096, 4097, 8190, 8191, 8192, 8193};
|
||||||
for (size_t index = 0; index < arraysize(kSizes); ++index) {
|
for (size_t index = 0; index < ArraySize(kSizes); ++index) {
|
||||||
size_t size = kSizes[index];
|
size_t size = kSizes[index];
|
||||||
SCOPED_TRACE(
|
SCOPED_TRACE(
|
||||||
base::StringPrintf("index %" PRIuS ", size %" PRIuS, index, size));
|
base::StringPrintf("index %" PRIuS ", size %" PRIuS, index, size));
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
#include "test/file.h"
|
#include "test/file.h"
|
||||||
#include "test/scoped_temp_dir.h"
|
#include "test/scoped_temp_dir.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
#include "util/thread/thread.h"
|
#include "util/thread/thread.h"
|
||||||
|
|
||||||
@ -612,7 +613,7 @@ void LockingTest(FileLocking main_lock, FileLocking other_locks) {
|
|||||||
|
|
||||||
LockingTestThread threads[20];
|
LockingTestThread threads[20];
|
||||||
int expected_iterations = 0;
|
int expected_iterations = 0;
|
||||||
for (size_t index = 0; index < arraysize(threads); ++index) {
|
for (size_t index = 0; index < ArraySize(threads); ++index) {
|
||||||
int iterations_for_this_thread = static_cast<int>(index * 10);
|
int iterations_for_this_thread = static_cast<int>(index * 10);
|
||||||
threads[index].Init(
|
threads[index].Init(
|
||||||
(other_locks == FileLocking::kShared)
|
(other_locks == FileLocking::kShared)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "util/file/directory_reader.h"
|
#include "util/file/directory_reader.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/as_underlying_type.h"
|
#include "util/misc/as_underlying_type.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -92,7 +93,7 @@ bool DirectPtraceConnection::Threads(std::vector<pid_t>* threads) {
|
|||||||
DCHECK(threads->empty());
|
DCHECK(threads->empty());
|
||||||
|
|
||||||
char path[32];
|
char path[32];
|
||||||
snprintf(path, arraysize(path), "/proc/%d/task", pid_);
|
snprintf(path, ArraySize(path), "/proc/%d/task", pid_);
|
||||||
DirectoryReader reader;
|
DirectoryReader reader;
|
||||||
if (!reader.Open(base::FilePath(path))) {
|
if (!reader.Open(base::FilePath(path))) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/lexing.h"
|
#include "util/misc/lexing.h"
|
||||||
#include "util/misc/time.h"
|
#include "util/misc/time.h"
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ bool ProcStatReader::Initialize(PtraceConnection* connection, pid_t tid) {
|
|||||||
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
|
||||||
|
|
||||||
char path[32];
|
char path[32];
|
||||||
snprintf(path, arraysize(path), "/proc/%d/stat", tid);
|
snprintf(path, ArraySize(path), "/proc/%d/stat", tid);
|
||||||
if (!connection->ReadFileContents(base::FilePath(path), &contents_)) {
|
if (!connection->ReadFileContents(base::FilePath(path), &contents_)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/linux/ptrace_broker.h"
|
#include "util/linux/ptrace_broker.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/process/process_memory_linux.h"
|
#include "util/process/process_memory_linux.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -270,7 +271,7 @@ bool PtraceClient::Threads(std::vector<pid_t>* threads) {
|
|||||||
threads->push_back(pid_);
|
threads->push_back(pid_);
|
||||||
|
|
||||||
char path[32];
|
char path[32];
|
||||||
snprintf(path, arraysize(path), "/proc/%d/task", pid_);
|
snprintf(path, ArraySize(path), "/proc/%d/task", pid_);
|
||||||
|
|
||||||
PtraceBroker::Request request;
|
PtraceBroker::Request request;
|
||||||
request.type = PtraceBroker::Request::kTypeListDirectory;
|
request.type = PtraceBroker::Request::kTypeListDirectory;
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -116,7 +116,7 @@ TEST(CheckedMachAddressRange, IsValid) {
|
|||||||
{0xffffffffffffffff, 1, kInvalid},
|
{0xffffffffffffffff, 1, kInvalid},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
|
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
|
||||||
index,
|
index,
|
||||||
@ -166,7 +166,7 @@ TEST(CheckedMachAddressRange, ContainsValue) {
|
|||||||
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range_32.IsValid());
|
ASSERT_TRUE(parent_range_32.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(
|
SCOPED_TRACE(
|
||||||
base::StringPrintf("index %zu, value 0x%llx", index, testcase.value));
|
base::StringPrintf("index %zu, value 0x%llx", index, testcase.value));
|
||||||
@ -223,7 +223,7 @@ TEST(CheckedMachAddressRange, ContainsRange) {
|
|||||||
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
CheckedMachAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range_32.IsValid());
|
ASSERT_TRUE(parent_range_32.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
|
SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%llx, size 0x%llx",
|
||||||
index,
|
index,
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/mac/scoped_launch_data.h"
|
#include "base/mac/scoped_launch_data.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/stdlib/objc.h"
|
#include "util/stdlib/objc.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -58,7 +58,7 @@ TEST(Launchd, CFPropertyToLaunchData_Integer) {
|
|||||||
@0xfedcba9876543210,
|
@0xfedcba9876543210,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(integer_nses); ++index) {
|
for (size_t index = 0; index < ArraySize(integer_nses); ++index) {
|
||||||
NSNumber* integer_ns = integer_nses[index];
|
NSNumber* integer_ns = integer_nses[index];
|
||||||
launch_data.reset(CFPropertyToLaunchData(integer_ns));
|
launch_data.reset(CFPropertyToLaunchData(integer_ns));
|
||||||
ASSERT_TRUE(launch_data.get());
|
ASSERT_TRUE(launch_data.get());
|
||||||
@ -88,7 +88,7 @@ TEST(Launchd, CFPropertyToLaunchData_FloatingPoint) {
|
|||||||
[NSNumber numberWithDouble:std::numeric_limits<double>::signaling_NaN()],
|
[NSNumber numberWithDouble:std::numeric_limits<double>::signaling_NaN()],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(double_nses); ++index) {
|
for (size_t index = 0; index < ArraySize(double_nses); ++index) {
|
||||||
NSNumber* double_ns = double_nses[index];
|
NSNumber* double_ns = double_nses[index];
|
||||||
launch_data.reset(CFPropertyToLaunchData(double_ns));
|
launch_data.reset(CFPropertyToLaunchData(double_ns));
|
||||||
ASSERT_TRUE(launch_data.get());
|
ASSERT_TRUE(launch_data.get());
|
||||||
@ -114,7 +114,7 @@ TEST(Launchd, CFPropertyToLaunchData_Boolean) {
|
|||||||
@YES,
|
@YES,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(bool_nses); ++index) {
|
for (size_t index = 0; index < ArraySize(bool_nses); ++index) {
|
||||||
NSNumber* bool_ns = bool_nses[index];
|
NSNumber* bool_ns = bool_nses[index];
|
||||||
launch_data.reset(CFPropertyToLaunchData(bool_ns));
|
launch_data.reset(CFPropertyToLaunchData(bool_ns));
|
||||||
ASSERT_TRUE(launch_data.get());
|
ASSERT_TRUE(launch_data.get());
|
||||||
@ -138,7 +138,7 @@ TEST(Launchd, CFPropertyToLaunchData_String) {
|
|||||||
@"Üñîçø∂é",
|
@"Üñîçø∂é",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(string_nses); ++index) {
|
for (size_t index = 0; index < ArraySize(string_nses); ++index) {
|
||||||
NSString* string_ns = string_nses[index];
|
NSString* string_ns = string_nses[index];
|
||||||
launch_data.reset(CFPropertyToLaunchData(string_ns));
|
launch_data.reset(CFPropertyToLaunchData(string_ns));
|
||||||
ASSERT_TRUE(launch_data.get());
|
ASSERT_TRUE(launch_data.get());
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
#include "util/mach/mach_message_server.h"
|
#include "util/mach/mach_message_server.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
#include "util/misc/random_string.h"
|
#include "util/misc/random_string.h"
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ mach_port_t ChildPortHandshakeServer::RunServer(
|
|||||||
0,
|
0,
|
||||||
nullptr);
|
nullptr);
|
||||||
int rv = HANDLE_EINTR(
|
int rv = HANDLE_EINTR(
|
||||||
kevent(kq.get(), changelist, arraysize(changelist), nullptr, 0, nullptr));
|
kevent(kq.get(), changelist, ArraySize(changelist), nullptr, 0, nullptr));
|
||||||
PCHECK(rv != -1) << "kevent";
|
PCHECK(rv != -1) << "kevent";
|
||||||
|
|
||||||
ChildPortServer child_port_server(this);
|
ChildPortServer child_port_server(this);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "util/mach/child_portServer.h"
|
#include "util/mach/child_portServer.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ std::set<mach_msg_id_t> ChildPortServer::MachMessageServerRequestIDs() {
|
|||||||
static constexpr mach_msg_id_t request_ids[] =
|
static constexpr mach_msg_id_t request_ids[] =
|
||||||
{kMachMessageIDChildPortCheckIn};
|
{kMachMessageIDChildPortCheckIn};
|
||||||
return std::set<mach_msg_id_t>(&request_ids[0],
|
return std::set<mach_msg_id_t>(&request_ids[0],
|
||||||
&request_ids[arraysize(request_ids)]);
|
&request_ids[ArraySize(request_ids)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() {
|
mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -196,7 +197,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
TestMachMessageHandler handlers[3];
|
TestMachMessageHandler handlers[3];
|
||||||
std::set<mach_msg_id_t> expect_request_ids;
|
std::set<mach_msg_id_t> expect_request_ids;
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs0); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs0); ++index) {
|
||||||
const mach_msg_id_t request_id = kRequestIDs0[index];
|
const mach_msg_id_t request_id = kRequestIDs0[index];
|
||||||
handlers[0].AddRequestID(request_id);
|
handlers[0].AddRequestID(request_id);
|
||||||
expect_request_ids.insert(request_id);
|
expect_request_ids.insert(request_id);
|
||||||
@ -205,7 +206,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
handlers[0].SetReplySize(sizeof(mig_reply_error_t));
|
handlers[0].SetReplySize(sizeof(mig_reply_error_t));
|
||||||
handlers[0].SetReturnCodes(true, kReturnCode0, false);
|
handlers[0].SetReturnCodes(true, kReturnCode0, false);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs1); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs1); ++index) {
|
||||||
const mach_msg_id_t request_id = kRequestIDs1[index];
|
const mach_msg_id_t request_id = kRequestIDs1[index];
|
||||||
handlers[1].AddRequestID(request_id);
|
handlers[1].AddRequestID(request_id);
|
||||||
expect_request_ids.insert(request_id);
|
expect_request_ids.insert(request_id);
|
||||||
@ -214,7 +215,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
handlers[1].SetReplySize(200);
|
handlers[1].SetReplySize(200);
|
||||||
handlers[1].SetReturnCodes(false, kReturnCode1, true);
|
handlers[1].SetReturnCodes(false, kReturnCode1, true);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs2); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs2); ++index) {
|
||||||
const mach_msg_id_t request_id = kRequestIDs2[index];
|
const mach_msg_id_t request_id = kRequestIDs2[index];
|
||||||
handlers[2].AddRequestID(request_id);
|
handlers[2].AddRequestID(request_id);
|
||||||
expect_request_ids.insert(request_id);
|
expect_request_ids.insert(request_id);
|
||||||
@ -252,7 +253,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
|
|
||||||
// Send messages with known request IDs.
|
// Send messages with known request IDs.
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs0); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs0); ++index) {
|
||||||
request.header.msgh_id = kRequestIDs0[index];
|
request.header.msgh_id = kRequestIDs0[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"handler 0, index %zu, id %d", index, request.header.msgh_id));
|
"handler 0, index %zu, id %d", index, request.header.msgh_id));
|
||||||
@ -263,7 +264,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
EXPECT_FALSE(destroy_complex_request);
|
EXPECT_FALSE(destroy_complex_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs1); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs1); ++index) {
|
||||||
request.header.msgh_id = kRequestIDs1[index];
|
request.header.msgh_id = kRequestIDs1[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"handler 1, index %zu, id %d", index, request.header.msgh_id));
|
"handler 1, index %zu, id %d", index, request.header.msgh_id));
|
||||||
@ -274,7 +275,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
|||||||
EXPECT_TRUE(destroy_complex_request);
|
EXPECT_TRUE(destroy_complex_request);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kRequestIDs2); ++index) {
|
for (size_t index = 0; index < ArraySize(kRequestIDs2); ++index) {
|
||||||
request.header.msgh_id = kRequestIDs2[index];
|
request.header.msgh_id = kRequestIDs2[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"handler 2, index %zu, id %d", index, request.header.msgh_id));
|
"handler 2, index %zu, id %d", index, request.header.msgh_id));
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
#include "util/mach/mach_message_server.h"
|
#include "util/mach/mach_message_server.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -181,11 +182,11 @@ class TestExcClientVariants : public MachMultiprocess,
|
|||||||
// These aren’t real flavors, it’s just for testing.
|
// These aren’t real flavors, it’s just for testing.
|
||||||
flavor = exception_ + 10;
|
flavor = exception_ + 10;
|
||||||
flavor_p = &flavor;
|
flavor_p = &flavor;
|
||||||
for (size_t index = 0; index < arraysize(old_state); ++index) {
|
for (size_t index = 0; index < ArraySize(old_state); ++index) {
|
||||||
old_state[index] = index;
|
old_state[index] = index;
|
||||||
}
|
}
|
||||||
old_state_p = reinterpret_cast<thread_state_t>(&old_state);
|
old_state_p = reinterpret_cast<thread_state_t>(&old_state);
|
||||||
old_state_count = arraysize(old_state);
|
old_state_count = ArraySize(old_state);
|
||||||
|
|
||||||
// new_state and new_state_count are out parameters that the server should
|
// new_state and new_state_count are out parameters that the server should
|
||||||
// never see or use, so set them to bogus values. The call to the server
|
// never see or use, so set them to bogus values. The call to the server
|
||||||
@ -202,7 +203,7 @@ class TestExcClientVariants : public MachMultiprocess,
|
|||||||
task,
|
task,
|
||||||
exception,
|
exception,
|
||||||
code,
|
code,
|
||||||
arraysize(code),
|
ArraySize(code),
|
||||||
flavor_p,
|
flavor_p,
|
||||||
old_state_p,
|
old_state_p,
|
||||||
old_state_count,
|
old_state_count,
|
||||||
@ -273,7 +274,7 @@ TEST(ExcClientVariants, UniversalExceptionRaise) {
|
|||||||
kMachExceptionCodes | EXCEPTION_STATE_IDENTITY,
|
kMachExceptionCodes | EXCEPTION_STATE_IDENTITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kBehaviors); ++index) {
|
for (size_t index = 0; index < ArraySize(kBehaviors); ++index) {
|
||||||
exception_behavior_t behavior = kBehaviors[index];
|
exception_behavior_t behavior = kBehaviors[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, behavior %d", index, behavior));
|
SCOPED_TRACE(base::StringPrintf("index %zu, behavior %d", index, behavior));
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "util/mach/mach_exc.h"
|
#include "util/mach/mach_exc.h"
|
||||||
#include "util/mach/mach_excServer.h"
|
#include "util/mach/mach_excServer.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -242,7 +243,7 @@ class ExcServer : public MachMessageServer::Interface {
|
|||||||
Traits::kMachMessageIDExceptionRaiseStateIdentity,
|
Traits::kMachMessageIDExceptionRaiseStateIdentity,
|
||||||
};
|
};
|
||||||
return std::set<mach_msg_id_t>(&request_ids[0],
|
return std::set<mach_msg_id_t>(&request_ids[0],
|
||||||
&request_ids[arraysize(request_ids)]);
|
&request_ids[ArraySize(request_ids)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_size_t MachMessageServerRequestSize() override {
|
mach_msg_size_t MachMessageServerRequestSize() override {
|
||||||
@ -319,7 +320,7 @@ bool ExcServer<Traits>::MachMessageServerFunction(
|
|||||||
using Reply = typename Traits::ExceptionRaiseStateReply;
|
using Reply = typename Traits::ExceptionRaiseStateReply;
|
||||||
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
|
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
|
||||||
out_reply->flavor = in_request_1->flavor;
|
out_reply->flavor = in_request_1->flavor;
|
||||||
out_reply->new_stateCnt = arraysize(out_reply->new_state);
|
out_reply->new_stateCnt = ArraySize(out_reply->new_state);
|
||||||
out_reply->RetCode =
|
out_reply->RetCode =
|
||||||
interface_->CatchExceptionRaiseState(in_header->msgh_local_port,
|
interface_->CatchExceptionRaiseState(in_header->msgh_local_port,
|
||||||
in_request->exception,
|
in_request->exception,
|
||||||
@ -362,7 +363,7 @@ bool ExcServer<Traits>::MachMessageServerFunction(
|
|||||||
using Reply = typename Traits::ExceptionRaiseStateIdentityReply;
|
using Reply = typename Traits::ExceptionRaiseStateIdentityReply;
|
||||||
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
|
Reply* out_reply = reinterpret_cast<Reply*>(out_header);
|
||||||
out_reply->flavor = in_request_1->flavor;
|
out_reply->flavor = in_request_1->flavor;
|
||||||
out_reply->new_stateCnt = arraysize(out_reply->new_state);
|
out_reply->new_stateCnt = ArraySize(out_reply->new_state);
|
||||||
out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity(
|
out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity(
|
||||||
in_header->msgh_local_port,
|
in_header->msgh_local_port,
|
||||||
in_request->thread.name,
|
in_request->thread.name,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "util/mach/exception_behaviors.h"
|
#include "util/mach/exception_behaviors.h"
|
||||||
#include "util/mach/exception_types.h"
|
#include "util/mach/exception_types.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -228,7 +229,7 @@ struct __attribute__((packed, aligned(4))) ExceptionRaiseStateReply {
|
|||||||
EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
|
EXPECT_EQ(memcmp(&NDR, &NDR_record, sizeof(NDR)), 0);
|
||||||
EXPECT_EQ(RetCode, KERN_SUCCESS);
|
EXPECT_EQ(RetCode, KERN_SUCCESS);
|
||||||
EXPECT_EQ(flavor, kThreadStateFlavor);
|
EXPECT_EQ(flavor, kThreadStateFlavor);
|
||||||
EXPECT_EQ(new_stateCnt, arraysize(new_state));
|
EXPECT_EQ(new_stateCnt, ArraySize(new_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_header_t Head;
|
mach_msg_header_t Head;
|
||||||
@ -659,7 +660,7 @@ TEST(ExcServerVariants, MockExceptionRaiseState) {
|
|||||||
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
|
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
|
||||||
Pointee(Eq(kThreadStateFlavor)),
|
Pointee(Eq(kThreadStateFlavor)),
|
||||||
IsThreadStateAndCount(kThreadStateFlavorCount),
|
IsThreadStateAndCount(kThreadStateFlavorCount),
|
||||||
IsThreadStateAndCount(arraysize(reply.new_state)),
|
IsThreadStateAndCount(ArraySize(reply.new_state)),
|
||||||
Eq(request.Trailer())))
|
Eq(request.Trailer())))
|
||||||
.WillOnce(Return(KERN_SUCCESS))
|
.WillOnce(Return(KERN_SUCCESS))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
@ -708,7 +709,7 @@ TEST(ExcServerVariants, MockExceptionRaiseStateIdentity) {
|
|||||||
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
|
AreExceptionCodes(kTestExceptonCodes[0], kTestExceptonCodes[1]),
|
||||||
Pointee(Eq(kThreadStateFlavor)),
|
Pointee(Eq(kThreadStateFlavor)),
|
||||||
IsThreadStateAndCount(kThreadStateFlavorCount),
|
IsThreadStateAndCount(kThreadStateFlavorCount),
|
||||||
IsThreadStateAndCount(arraysize(reply.new_state)),
|
IsThreadStateAndCount(ArraySize(reply.new_state)),
|
||||||
Eq(request.Trailer())))
|
Eq(request.Trailer())))
|
||||||
.WillOnce(Return(KERN_SUCCESS))
|
.WillOnce(Return(KERN_SUCCESS))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
@ -802,7 +803,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseState) {
|
|||||||
kTestMachExceptionCodes[1]),
|
kTestMachExceptionCodes[1]),
|
||||||
Pointee(Eq(kThreadStateFlavor)),
|
Pointee(Eq(kThreadStateFlavor)),
|
||||||
IsThreadStateAndCount(kThreadStateFlavorCount),
|
IsThreadStateAndCount(kThreadStateFlavorCount),
|
||||||
IsThreadStateAndCount(arraysize(reply.new_state)),
|
IsThreadStateAndCount(ArraySize(reply.new_state)),
|
||||||
Eq(request.Trailer())))
|
Eq(request.Trailer())))
|
||||||
.WillOnce(Return(KERN_SUCCESS))
|
.WillOnce(Return(KERN_SUCCESS))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
@ -852,7 +853,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseStateIdentity) {
|
|||||||
kTestMachExceptionCodes[1]),
|
kTestMachExceptionCodes[1]),
|
||||||
Pointee(Eq(kThreadStateFlavor)),
|
Pointee(Eq(kThreadStateFlavor)),
|
||||||
IsThreadStateAndCount(kThreadStateFlavorCount),
|
IsThreadStateAndCount(kThreadStateFlavorCount),
|
||||||
IsThreadStateAndCount(arraysize(reply.new_state)),
|
IsThreadStateAndCount(ArraySize(reply.new_state)),
|
||||||
Eq(request.Trailer())))
|
Eq(request.Trailer())))
|
||||||
.WillOnce(Return(KERN_SUCCESS))
|
.WillOnce(Return(KERN_SUCCESS))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
@ -906,7 +907,7 @@ TEST(ExcServerVariants, MockUnknownID) {
|
|||||||
2508,
|
2508,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(unknown_ids); ++index) {
|
for (size_t index = 0; index < ArraySize(unknown_ids); ++index) {
|
||||||
mach_msg_id_t id = unknown_ids[index];
|
mach_msg_id_t id = unknown_ids[index];
|
||||||
|
|
||||||
SCOPED_TRACE(base::StringPrintf("unknown id %d", id));
|
SCOPED_TRACE(base::StringPrintf("unknown id %d", id));
|
||||||
@ -1179,7 +1180,7 @@ TEST(ExcServerVariants, ThreadStates) {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(test_data); ++index) {
|
for (size_t index = 0; index < ArraySize(test_data); ++index) {
|
||||||
const auto& test = test_data[index];
|
const auto& test = test_data[index];
|
||||||
SCOPED_TRACE(
|
SCOPED_TRACE(
|
||||||
base::StringPrintf("index %zu, flavor %d", index, test.flavor));
|
base::StringPrintf("index %zu, flavor %d", index, test.flavor));
|
||||||
@ -1252,7 +1253,7 @@ TEST(ExcServerVariants, ExcServerSuccessfulReturnValue) {
|
|||||||
KERN_SUCCESS},
|
KERN_SUCCESS},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& test_data = kTestData[index];
|
const auto& test_data = kTestData[index];
|
||||||
SCOPED_TRACE(
|
SCOPED_TRACE(
|
||||||
base::StringPrintf("index %zu, behavior %d, set_thread_state %s",
|
base::StringPrintf("index %zu, behavior %d, set_thread_state %s",
|
||||||
@ -1271,8 +1272,8 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
|||||||
static constexpr natural_t old_state[] = {1, 2, 3, 4, 5};
|
static constexpr natural_t old_state[] = {1, 2, 3, 4, 5};
|
||||||
natural_t new_state[10] = {};
|
natural_t new_state[10] = {};
|
||||||
|
|
||||||
constexpr mach_msg_type_number_t old_state_count = arraysize(old_state);
|
constexpr mach_msg_type_number_t old_state_count = ArraySize(old_state);
|
||||||
mach_msg_type_number_t new_state_count = arraysize(new_state);
|
mach_msg_type_number_t new_state_count = ArraySize(new_state);
|
||||||
|
|
||||||
// EXCEPTION_DEFAULT (with or without MACH_EXCEPTION_CODES) is not
|
// EXCEPTION_DEFAULT (with or without MACH_EXCEPTION_CODES) is not
|
||||||
// state-carrying. new_state and new_state_count should be untouched.
|
// state-carrying. new_state and new_state_count should be untouched.
|
||||||
@ -1281,8 +1282,8 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
|||||||
old_state_count,
|
old_state_count,
|
||||||
new_state,
|
new_state,
|
||||||
&new_state_count);
|
&new_state_count);
|
||||||
EXPECT_EQ(new_state_count, arraysize(new_state));
|
EXPECT_EQ(new_state_count, ArraySize(new_state));
|
||||||
for (size_t i = 0; i < arraysize(new_state); ++i) {
|
for (size_t i = 0; i < ArraySize(new_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,8 +1292,8 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
|||||||
old_state_count,
|
old_state_count,
|
||||||
new_state,
|
new_state,
|
||||||
&new_state_count);
|
&new_state_count);
|
||||||
EXPECT_EQ(new_state_count, arraysize(new_state));
|
EXPECT_EQ(new_state_count, ArraySize(new_state));
|
||||||
for (size_t i = 0; i < arraysize(new_state); ++i) {
|
for (size_t i = 0; i < ArraySize(new_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,7 +1305,7 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
|||||||
for (size_t i = 0; i < copy_limit; ++i) {
|
for (size_t i = 0; i < copy_limit; ++i) {
|
||||||
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
||||||
}
|
}
|
||||||
for (size_t i = copy_limit; i < arraysize(new_state); ++i) {
|
for (size_t i = copy_limit; i < ArraySize(new_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1320,23 +1321,23 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
|||||||
for (size_t i = 0; i < copy_limit; ++i) {
|
for (size_t i = 0; i < copy_limit; ++i) {
|
||||||
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
||||||
}
|
}
|
||||||
for (size_t i = copy_limit; i < arraysize(new_state); ++i) {
|
for (size_t i = copy_limit; i < ArraySize(new_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a state-carrying exception where all of old_state is copied to
|
// This is a state-carrying exception where all of old_state is copied to
|
||||||
// new_state, which is large enough to receive it and then some.
|
// new_state, which is large enough to receive it and then some.
|
||||||
new_state_count = arraysize(new_state);
|
new_state_count = ArraySize(new_state);
|
||||||
ExcServerCopyState(MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY,
|
ExcServerCopyState(MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY,
|
||||||
old_state,
|
old_state,
|
||||||
old_state_count,
|
old_state_count,
|
||||||
new_state,
|
new_state,
|
||||||
&new_state_count);
|
&new_state_count);
|
||||||
EXPECT_EQ(new_state_count, old_state_count);
|
EXPECT_EQ(new_state_count, old_state_count);
|
||||||
for (size_t i = 0; i < arraysize(old_state); ++i) {
|
for (size_t i = 0; i < ArraySize(old_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
EXPECT_EQ(new_state[i], old_state[i]) << "i " << i;
|
||||||
}
|
}
|
||||||
for (size_t i = arraysize(old_state); i < arraysize(new_state); ++i) {
|
for (size_t i = ArraySize(old_state); i < ArraySize(new_state); ++i) {
|
||||||
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
EXPECT_EQ(new_state[i], 0u) << "i " << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -53,7 +53,7 @@ TEST(ExceptionBehaviors, ExceptionBehaviors) {
|
|||||||
EXCEPTION_STATE_IDENTITY},
|
EXCEPTION_STATE_IDENTITY},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& test_data = kTestData[index];
|
const auto& test_data = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %zu, behavior %d", index, test_data.behavior));
|
"index %zu, behavior %d", index, test_data.behavior));
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "util/mac/mac_util.h"
|
#include "util/mac/mac_util.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -67,7 +67,7 @@ TEST(ExceptionTypes, ExcCrashRecoverOriginalException) {
|
|||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& test_data = kTestData[index];
|
const auto& test_data = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %zu, code_0 0x%llx", index, test_data.code_0));
|
"index %zu, code_0 0x%llx", index, test_data.code_0));
|
||||||
@ -84,7 +84,7 @@ TEST(ExceptionTypes, ExcCrashRecoverOriginalException) {
|
|||||||
|
|
||||||
// Now make sure that ExcCrashRecoverOriginalException() properly ignores
|
// Now make sure that ExcCrashRecoverOriginalException() properly ignores
|
||||||
// optional arguments.
|
// optional arguments.
|
||||||
static_assert(arraysize(kTestData) >= 1, "must have something to test");
|
static_assert(ArraySize(kTestData) >= 1, "must have something to test");
|
||||||
const auto& test_data = kTestData[0];
|
const auto& test_data = kTestData[0];
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
ExcCrashRecoverOriginalException(test_data.code_0, nullptr, nullptr),
|
ExcCrashRecoverOriginalException(test_data.code_0, nullptr, nullptr),
|
||||||
@ -238,7 +238,7 @@ TEST(ExceptionTypes, ExceptionCodeForMetrics) {
|
|||||||
{0x00010000, 0x00010000, static_cast<int32_t>(0xffffffff)},
|
{0x00010000, 0x00010000, static_cast<int32_t>(0xffffffff)},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& test_data = kTestData[index];
|
const auto& test_data = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu, exception 0x%x, code_0 0x%llx",
|
SCOPED_TRACE(base::StringPrintf("index %zu, exception 0x%x, code_0 0x%llx",
|
||||||
index,
|
index,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -281,7 +282,7 @@ class TestMachMessageServer : public MachMessageServer::Interface,
|
|||||||
std::set<mach_msg_id_t> MachMessageServerRequestIDs() override {
|
std::set<mach_msg_id_t> MachMessageServerRequestIDs() override {
|
||||||
static constexpr mach_msg_id_t request_ids[] = {kRequestMessageID};
|
static constexpr mach_msg_id_t request_ids[] = {kRequestMessageID};
|
||||||
return std::set<mach_msg_id_t>(&request_ids[0],
|
return std::set<mach_msg_id_t>(&request_ids[0],
|
||||||
&request_ids[arraysize(request_ids)]);
|
&request_ids[ArraySize(request_ids)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_size_t MachMessageServerRequestSize() override {
|
mach_msg_size_t MachMessageServerRequestSize() override {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "base/mac/scoped_mach_port.h"
|
#include "base/mac/scoped_mach_port.h"
|
||||||
|
#include "base/macros.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/mac/mach_errors.h"
|
#include "test/mac/mach_errors.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "util/mach/mach_message.h"
|
#include "util/mach/mach_message.h"
|
||||||
#include "util/mach/notifyServer.h"
|
#include "util/mach/notifyServer.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -227,7 +228,7 @@ std::set<mach_msg_id_t> NotifyServer::MachMessageServerRequestIDs() {
|
|||||||
MACH_NOTIFY_DEAD_NAME,
|
MACH_NOTIFY_DEAD_NAME,
|
||||||
};
|
};
|
||||||
return std::set<mach_msg_id_t>(&request_ids[0],
|
return std::set<mach_msg_id_t>(&request_ids[0],
|
||||||
&request_ids[arraysize(request_ids)]);
|
&request_ids[ArraySize(request_ids)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_size_t NotifyServer::MachMessageServerRequestSize() {
|
mach_msg_size_t NotifyServer::MachMessageServerRequestSize() {
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "util/mach/exception_behaviors.h"
|
#include "util/mach/exception_behaviors.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
#include "util/stdlib/string_number_conversion.h"
|
#include "util/stdlib/string_number_conversion.h"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ constexpr const char* kExceptionNames[] = {
|
|||||||
"GUARD",
|
"GUARD",
|
||||||
"CORPSE_NOTIFY",
|
"CORPSE_NOTIFY",
|
||||||
};
|
};
|
||||||
static_assert(arraysize(kExceptionNames) == EXC_TYPES_COUNT,
|
static_assert(ArraySize(kExceptionNames) == EXC_TYPES_COUNT,
|
||||||
"kExceptionNames length");
|
"kExceptionNames length");
|
||||||
|
|
||||||
constexpr char kExcPrefix[] = "EXC_";
|
constexpr char kExcPrefix[] = "EXC_";
|
||||||
@ -170,8 +170,7 @@ std::string ThreadStateFlavorFullToShort(const base::StringPiece& flavor) {
|
|||||||
{"_STATE32", "32"},
|
{"_STATE32", "32"},
|
||||||
{"_STATE64", "64"},
|
{"_STATE64", "64"},
|
||||||
};
|
};
|
||||||
for (size_t suffix_index = 0;
|
for (size_t suffix_index = 0; suffix_index < ArraySize(kStateSuffixes);
|
||||||
suffix_index < arraysize(kStateSuffixes);
|
|
||||||
++suffix_index) {
|
++suffix_index) {
|
||||||
const char* suffix = kStateSuffixes[suffix_index].orig;
|
const char* suffix = kStateSuffixes[suffix_index].orig;
|
||||||
size_t suffix_len = strlen(suffix);
|
size_t suffix_len = strlen(suffix);
|
||||||
@ -195,7 +194,7 @@ namespace crashpad {
|
|||||||
std::string ExceptionToString(exception_type_t exception,
|
std::string ExceptionToString(exception_type_t exception,
|
||||||
SymbolicConstantToStringOptions options) {
|
SymbolicConstantToStringOptions options) {
|
||||||
const char* exception_name =
|
const char* exception_name =
|
||||||
implicit_cast<size_t>(exception) < arraysize(kExceptionNames)
|
implicit_cast<size_t>(exception) < ArraySize(kExceptionNames)
|
||||||
? kExceptionNames[exception]
|
? kExceptionNames[exception]
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (!exception_name) {
|
if (!exception_name) {
|
||||||
@ -221,7 +220,7 @@ bool StringToException(const base::StringPiece& string,
|
|||||||
base::StringPiece short_string =
|
base::StringPiece short_string =
|
||||||
can_match_full ? string.substr(strlen(kExcPrefix)) : string;
|
can_match_full ? string.substr(strlen(kExcPrefix)) : string;
|
||||||
for (exception_type_t index = 0;
|
for (exception_type_t index = 0;
|
||||||
index < implicit_cast<exception_type_t>(arraysize(kExceptionNames));
|
index < implicit_cast<exception_type_t>(ArraySize(kExceptionNames));
|
||||||
++index) {
|
++index) {
|
||||||
const char* exception_name = kExceptionNames[index];
|
const char* exception_name = kExceptionNames[index];
|
||||||
if (!exception_name) {
|
if (!exception_name) {
|
||||||
@ -251,8 +250,7 @@ std::string ExceptionMaskToString(exception_mask_t exception_mask,
|
|||||||
exception_mask_t local_exception_mask = exception_mask;
|
exception_mask_t local_exception_mask = exception_mask;
|
||||||
std::string mask_string;
|
std::string mask_string;
|
||||||
bool has_forbidden_or = false;
|
bool has_forbidden_or = false;
|
||||||
for (size_t exception = 0;
|
for (size_t exception = 0; exception < ArraySize(kExceptionNames);
|
||||||
exception < arraysize(kExceptionNames);
|
|
||||||
++exception) {
|
++exception) {
|
||||||
const char* exception_name = kExceptionNames[exception];
|
const char* exception_name = kExceptionNames[exception];
|
||||||
exception_mask_t exception_mask_value = 1 << exception;
|
exception_mask_t exception_mask_value = 1 << exception;
|
||||||
@ -326,7 +324,7 @@ bool StringToExceptionMask(const base::StringPiece& string,
|
|||||||
base::StringPiece short_string =
|
base::StringPiece short_string =
|
||||||
can_match_full ? string.substr(strlen(kExcMaskPrefix)) : string;
|
can_match_full ? string.substr(strlen(kExcMaskPrefix)) : string;
|
||||||
for (exception_type_t index = 0;
|
for (exception_type_t index = 0;
|
||||||
index < implicit_cast<exception_type_t>(arraysize(kExceptionNames));
|
index < implicit_cast<exception_type_t>(ArraySize(kExceptionNames));
|
||||||
++index) {
|
++index) {
|
||||||
const char* exception_name = kExceptionNames[index];
|
const char* exception_name = kExceptionNames[index];
|
||||||
if (!exception_name) {
|
if (!exception_name) {
|
||||||
@ -365,7 +363,7 @@ std::string ExceptionBehaviorToString(exception_behavior_t behavior,
|
|||||||
const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior);
|
const exception_behavior_t basic_behavior = ExceptionBehaviorBasic(behavior);
|
||||||
|
|
||||||
const char* behavior_name =
|
const char* behavior_name =
|
||||||
implicit_cast<size_t>(basic_behavior) < arraysize(kBehaviorNames)
|
implicit_cast<size_t>(basic_behavior) < ArraySize(kBehaviorNames)
|
||||||
? kBehaviorNames[basic_behavior]
|
? kBehaviorNames[basic_behavior]
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (!behavior_name) {
|
if (!behavior_name) {
|
||||||
@ -432,7 +430,7 @@ bool StringToExceptionBehavior(const base::StringPiece& string,
|
|||||||
base::StringPiece short_string =
|
base::StringPiece short_string =
|
||||||
can_match_full ? sp.substr(strlen(kBehaviorPrefix)) : sp;
|
can_match_full ? sp.substr(strlen(kBehaviorPrefix)) : sp;
|
||||||
for (exception_behavior_t index = 0;
|
for (exception_behavior_t index = 0;
|
||||||
index < implicit_cast<exception_behavior_t>(arraysize(kBehaviorNames));
|
index < implicit_cast<exception_behavior_t>(ArraySize(kBehaviorNames));
|
||||||
++index) {
|
++index) {
|
||||||
const char* behavior_name = kBehaviorNames[index];
|
const char* behavior_name = kBehaviorNames[index];
|
||||||
if (!behavior_name) {
|
if (!behavior_name) {
|
||||||
@ -468,13 +466,13 @@ bool StringToExceptionBehavior(const base::StringPiece& string,
|
|||||||
std::string ThreadStateFlavorToString(thread_state_flavor_t flavor,
|
std::string ThreadStateFlavorToString(thread_state_flavor_t flavor,
|
||||||
SymbolicConstantToStringOptions options) {
|
SymbolicConstantToStringOptions options) {
|
||||||
const char* flavor_name =
|
const char* flavor_name =
|
||||||
implicit_cast<size_t>(flavor) < arraysize(kFlavorNames)
|
implicit_cast<size_t>(flavor) < ArraySize(kFlavorNames)
|
||||||
? kFlavorNames[flavor]
|
? kFlavorNames[flavor]
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
if (!flavor_name) {
|
if (!flavor_name) {
|
||||||
for (size_t generic_flavor_index = 0;
|
for (size_t generic_flavor_index = 0;
|
||||||
generic_flavor_index < arraysize(kGenericFlavorNames);
|
generic_flavor_index < ArraySize(kGenericFlavorNames);
|
||||||
++generic_flavor_index) {
|
++generic_flavor_index) {
|
||||||
if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) {
|
if (flavor == kGenericFlavorNames[generic_flavor_index].flavor) {
|
||||||
flavor_name = kGenericFlavorNames[generic_flavor_index].name;
|
flavor_name = kGenericFlavorNames[generic_flavor_index].name;
|
||||||
@ -501,7 +499,7 @@ bool StringToThreadStateFlavor(const base::StringPiece& string,
|
|||||||
thread_state_flavor_t* flavor) {
|
thread_state_flavor_t* flavor) {
|
||||||
if ((options & kAllowFullName) || (options & kAllowShortName)) {
|
if ((options & kAllowFullName) || (options & kAllowShortName)) {
|
||||||
for (thread_state_flavor_t index = 0;
|
for (thread_state_flavor_t index = 0;
|
||||||
index < implicit_cast<thread_state_flavor_t>(arraysize(kFlavorNames));
|
index < implicit_cast<thread_state_flavor_t>(ArraySize(kFlavorNames));
|
||||||
++index) {
|
++index) {
|
||||||
const char* flavor_name = kFlavorNames[index];
|
const char* flavor_name = kFlavorNames[index];
|
||||||
if (!flavor_name) {
|
if (!flavor_name) {
|
||||||
@ -521,7 +519,7 @@ bool StringToThreadStateFlavor(const base::StringPiece& string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t generic_flavor_index = 0;
|
for (size_t generic_flavor_index = 0;
|
||||||
generic_flavor_index < arraysize(kGenericFlavorNames);
|
generic_flavor_index < ArraySize(kGenericFlavorNames);
|
||||||
++generic_flavor_index) {
|
++generic_flavor_index) {
|
||||||
const char* flavor_name = kGenericFlavorNames[generic_flavor_index].name;
|
const char* flavor_name = kGenericFlavorNames[generic_flavor_index].name;
|
||||||
thread_state_flavor_t flavor_number =
|
thread_state_flavor_t flavor_number =
|
||||||
|
@ -18,14 +18,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/string_piece.h"
|
#include "base/strings/string_piece.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "util/mach/mach_extensions.h"
|
#include "util/mach/mach_extensions.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
#define NUL_TEST_DATA(string) { string, arraysize(string) - 1 }
|
#define NUL_TEST_DATA(string) \
|
||||||
|
{ string, ArraySize(string) - 1 }
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -159,7 +160,7 @@ void TestExceptionToString(exception_type_t value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, ExceptionToString) {
|
TEST(SymbolicConstantsMach, ExceptionToString) {
|
||||||
for (size_t index = 0; index < arraysize(kExceptionTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kExceptionTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestExceptionToString(kExceptionTestData[index].exception,
|
TestExceptionToString(kExceptionTestData[index].exception,
|
||||||
kExceptionTestData[index].full_name,
|
kExceptionTestData[index].full_name,
|
||||||
@ -187,12 +188,11 @@ void TestStringToException(const base::StringPiece& string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, StringToException) {
|
TEST(SymbolicConstantsMach, StringToException) {
|
||||||
for (size_t option_index = 0;
|
for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
|
||||||
option_index < arraysize(kNormalOptions);
|
|
||||||
++option_index) {
|
++option_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
||||||
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
||||||
for (size_t index = 0; index < arraysize(kExceptionTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kExceptionTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
exception_type_t exception = kExceptionTestData[index].exception;
|
exception_type_t exception = kExceptionTestData[index].exception;
|
||||||
{
|
{
|
||||||
@ -230,7 +230,7 @@ TEST(SymbolicConstantsMach, StringToException) {
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNegativeTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToException(kNegativeTestData[index], options, false, 0);
|
TestStringToException(kNegativeTestData[index], options, false, 0);
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ TEST(SymbolicConstantsMach, StringToException) {
|
|||||||
NUL_TEST_DATA("1\0002"),
|
NUL_TEST_DATA("1\0002"),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNULTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
base::StringPiece string(kNULTestData[index].string,
|
base::StringPiece string(kNULTestData[index].string,
|
||||||
kNULTestData[index].length);
|
kNULTestData[index].length);
|
||||||
@ -334,7 +334,7 @@ void TestExceptionMaskToString(exception_mask_t value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, ExceptionMaskToString) {
|
TEST(SymbolicConstantsMach, ExceptionMaskToString) {
|
||||||
for (size_t index = 0; index < arraysize(kExceptionMaskTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kExceptionMaskTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestExceptionMaskToString(kExceptionMaskTestData[index].exception_mask,
|
TestExceptionMaskToString(kExceptionMaskTestData[index].exception_mask,
|
||||||
kExceptionMaskTestData[index].full_name,
|
kExceptionMaskTestData[index].full_name,
|
||||||
@ -389,12 +389,11 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) {
|
|||||||
kAllowFullName | kAllowShortName | kAllowNumber | kAllowOr,
|
kAllowFullName | kAllowShortName | kAllowNumber | kAllowOr,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t option_index = 0;
|
for (size_t option_index = 0; option_index < ArraySize(kOptions);
|
||||||
option_index < arraysize(kOptions);
|
|
||||||
++option_index) {
|
++option_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
||||||
StringToSymbolicConstantOptions options = kOptions[option_index];
|
StringToSymbolicConstantOptions options = kOptions[option_index];
|
||||||
for (size_t index = 0; index < arraysize(kExceptionMaskTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kExceptionMaskTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
exception_mask_t exception_mask =
|
exception_mask_t exception_mask =
|
||||||
kExceptionMaskTestData[index].exception_mask;
|
kExceptionMaskTestData[index].exception_mask;
|
||||||
@ -445,7 +444,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) {
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNegativeTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToExceptionMask(kNegativeTestData[index], options, false, 0);
|
TestStringToExceptionMask(kNegativeTestData[index], options, false, 0);
|
||||||
}
|
}
|
||||||
@ -471,7 +470,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) {
|
|||||||
NUL_TEST_DATA("ARITHMETIC|\0EMULATION"),
|
NUL_TEST_DATA("ARITHMETIC|\0EMULATION"),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNULTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
base::StringPiece string(kNULTestData[index].string,
|
base::StringPiece string(kNULTestData[index].string,
|
||||||
kNULTestData[index].length);
|
kNULTestData[index].length);
|
||||||
@ -506,7 +505,7 @@ TEST(SymbolicConstantsMach, StringToExceptionMask) {
|
|||||||
EXC_MASK_SYSCALL | 0x100},
|
EXC_MASK_SYSCALL | 0x100},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNonCanonicalTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNonCanonicalTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToExceptionMask(kNonCanonicalTestData[index].string,
|
TestStringToExceptionMask(kNonCanonicalTestData[index].string,
|
||||||
kNonCanonicalTestData[index].options,
|
kNonCanonicalTestData[index].options,
|
||||||
@ -577,8 +576,7 @@ void TestExceptionBehaviorToString(exception_behavior_t value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, ExceptionBehaviorToString) {
|
TEST(SymbolicConstantsMach, ExceptionBehaviorToString) {
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(kExceptionBehaviorTestData);
|
||||||
index < arraysize(kExceptionBehaviorTestData);
|
|
||||||
++index) {
|
++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestExceptionBehaviorToString(kExceptionBehaviorTestData[index].behavior,
|
TestExceptionBehaviorToString(kExceptionBehaviorTestData[index].behavior,
|
||||||
@ -608,13 +606,11 @@ void TestStringToExceptionBehavior(const base::StringPiece& string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
|
TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
|
||||||
for (size_t option_index = 0;
|
for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
|
||||||
option_index < arraysize(kNormalOptions);
|
|
||||||
++option_index) {
|
++option_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
||||||
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(kExceptionBehaviorTestData);
|
||||||
index < arraysize(kExceptionBehaviorTestData);
|
|
||||||
++index) {
|
++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
exception_behavior_t behavior =
|
exception_behavior_t behavior =
|
||||||
@ -660,7 +656,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNegativeTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToExceptionBehavior(
|
TestStringToExceptionBehavior(
|
||||||
kNegativeTestData[index], options, false, 0);
|
kNegativeTestData[index], options, false, 0);
|
||||||
@ -686,7 +682,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
|
|||||||
NUL_TEST_DATA("STATE_IDENTITY|\0MACH"),
|
NUL_TEST_DATA("STATE_IDENTITY|\0MACH"),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNULTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
base::StringPiece string(kNULTestData[index].string,
|
base::StringPiece string(kNULTestData[index].string,
|
||||||
kNULTestData[index].length);
|
kNULTestData[index].length);
|
||||||
@ -723,7 +719,7 @@ TEST(SymbolicConstantsMach, StringToExceptionBehavior) {
|
|||||||
implicit_cast<exception_behavior_t>(MACH_EXCEPTION_CODES | 0x2)},
|
implicit_cast<exception_behavior_t>(MACH_EXCEPTION_CODES | 0x2)},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNonCanonicalTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNonCanonicalTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToExceptionBehavior(kNonCanonicalTestData[index].string,
|
TestStringToExceptionBehavior(kNonCanonicalTestData[index].string,
|
||||||
kNonCanonicalTestData[index].options,
|
kNonCanonicalTestData[index].options,
|
||||||
@ -840,8 +836,7 @@ void TestThreadStateFlavorToString(exception_type_t value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, ThreadStateFlavorToString) {
|
TEST(SymbolicConstantsMach, ThreadStateFlavorToString) {
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(kThreadStateFlavorTestData);
|
||||||
index < arraysize(kThreadStateFlavorTestData);
|
|
||||||
++index) {
|
++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestThreadStateFlavorToString(kThreadStateFlavorTestData[index].flavor,
|
TestThreadStateFlavorToString(kThreadStateFlavorTestData[index].flavor,
|
||||||
@ -883,13 +878,11 @@ void TestStringToThreadStateFlavor(const base::StringPiece& string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsMach, StringToThreadStateFlavor) {
|
TEST(SymbolicConstantsMach, StringToThreadStateFlavor) {
|
||||||
for (size_t option_index = 0;
|
for (size_t option_index = 0; option_index < ArraySize(kNormalOptions);
|
||||||
option_index < arraysize(kNormalOptions);
|
|
||||||
++option_index) {
|
++option_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
||||||
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
StringToSymbolicConstantOptions options = kNormalOptions[option_index];
|
||||||
for (size_t index = 0;
|
for (size_t index = 0; index < ArraySize(kThreadStateFlavorTestData);
|
||||||
index < arraysize(kThreadStateFlavorTestData);
|
|
||||||
++index) {
|
++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
thread_state_flavor_t flavor = kThreadStateFlavorTestData[index].flavor;
|
thread_state_flavor_t flavor = kThreadStateFlavorTestData[index].flavor;
|
||||||
@ -959,7 +952,7 @@ TEST(SymbolicConstantsMach, StringToThreadStateFlavor) {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNegativeTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToThreadStateFlavor(
|
TestStringToThreadStateFlavor(
|
||||||
kNegativeTestData[index], options, false, 0);
|
kNegativeTestData[index], options, false, 0);
|
||||||
@ -1025,7 +1018,7 @@ TEST(SymbolicConstantsMach, StringToThreadStateFlavor) {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNULTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
base::StringPiece string(kNULTestData[index].string,
|
base::StringPiece string(kNULTestData[index].string,
|
||||||
kNULTestData[index].length);
|
kNULTestData[index].length);
|
||||||
|
39
util/misc/arraysize.h
Normal file
39
util/misc/arraysize.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright 2019 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_UTIL_MISC_ARRAYSIZE_H_
|
||||||
|
#define CRASHPAD_UTIL_MISC_ARRAYSIZE_H_
|
||||||
|
|
||||||
|
#include <sys/types.h> // For size_t.
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
namespace crashpad {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
//! \brief A helper to implement ArraySize.
|
||||||
|
template <typename ArrayType>
|
||||||
|
constexpr size_t ArraySizeHelper() noexcept {
|
||||||
|
return std::extent<typename std::remove_reference<ArrayType>::type>::value;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace crashpad
|
||||||
|
|
||||||
|
//! \brief A way of computing an array’s size.
|
||||||
|
#define ArraySize(array) crashpad::internal::ArraySizeHelper<decltype(array)>()
|
||||||
|
|
||||||
|
#endif // CRASHPAD_UTIL_MISC_ARRAYSIZE_H_
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "util/misc/arraysize_unsafe.h"
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
@ -21,37 +21,37 @@ namespace crashpad {
|
|||||||
namespace test {
|
namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(ArraySizeUnsafe, ArraySizeUnsafe) {
|
TEST(ArraySize, ArraySize) {
|
||||||
char c1[1];
|
char c1[1];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(c1) == 1, "c1");
|
static_assert(ArraySize(c1) == 1, "c1");
|
||||||
ALLOW_UNUSED_LOCAL(c1);
|
ALLOW_UNUSED_LOCAL(c1);
|
||||||
|
|
||||||
char c2[2];
|
char c2[2];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(c2) == 2, "c2");
|
static_assert(ArraySize(c2) == 2, "c2");
|
||||||
ALLOW_UNUSED_LOCAL(c2);
|
ALLOW_UNUSED_LOCAL(c2);
|
||||||
|
|
||||||
char c4[4];
|
char c4[4];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(c4) == 4, "c4");
|
static_assert(ArraySize(c4) == 4, "c4");
|
||||||
ALLOW_UNUSED_LOCAL(c4);
|
ALLOW_UNUSED_LOCAL(c4);
|
||||||
|
|
||||||
int i1[1];
|
int i1[1];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(i1) == 1, "i1");
|
static_assert(ArraySize(i1) == 1, "i1");
|
||||||
ALLOW_UNUSED_LOCAL(i1);
|
ALLOW_UNUSED_LOCAL(i1);
|
||||||
|
|
||||||
int i2[2];
|
int i2[2];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(i2) == 2, "i2");
|
static_assert(ArraySize(i2) == 2, "i2");
|
||||||
ALLOW_UNUSED_LOCAL(i2);
|
ALLOW_UNUSED_LOCAL(i2);
|
||||||
|
|
||||||
int i4[4];
|
int i4[4];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(i4) == 4, "i4");
|
static_assert(ArraySize(i4) == 4, "i4");
|
||||||
ALLOW_UNUSED_LOCAL(i4);
|
ALLOW_UNUSED_LOCAL(i4);
|
||||||
|
|
||||||
long l8[8];
|
long l8[8];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(l8) == 8, "l8");
|
static_assert(ArraySize(l8) == 8, "l8");
|
||||||
ALLOW_UNUSED_LOCAL(l8);
|
ALLOW_UNUSED_LOCAL(l8);
|
||||||
|
|
||||||
int l9[9];
|
int l9[9];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(l9) == 9, "l9");
|
static_assert(ArraySize(l9) == 9, "l9");
|
||||||
ALLOW_UNUSED_LOCAL(l9);
|
ALLOW_UNUSED_LOCAL(l9);
|
||||||
|
|
||||||
struct S {
|
struct S {
|
||||||
@ -62,11 +62,11 @@ TEST(ArraySizeUnsafe, ArraySizeUnsafe) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
S s1[1];
|
S s1[1];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(s1) == 1, "s1");
|
static_assert(ArraySize(s1) == 1, "s1");
|
||||||
ALLOW_UNUSED_LOCAL(s1);
|
ALLOW_UNUSED_LOCAL(s1);
|
||||||
|
|
||||||
S s10[10];
|
S s10[10];
|
||||||
static_assert(ARRAYSIZE_UNSAFE(s10) == 10, "s10");
|
static_assert(ArraySize(s10) == 10, "s10");
|
||||||
ALLOW_UNUSED_LOCAL(s10);
|
ALLOW_UNUSED_LOCAL(s10);
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2016 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_UTIL_MISC_ARRAYSIZE_UNSAFE_H_
|
|
||||||
#define CRASHPAD_UTIL_MISC_ARRAYSIZE_UNSAFE_H_
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
//! \brief Not the safest way of computing an array’s size…
|
|
||||||
//!
|
|
||||||
//! `#%include "base/macros.h"` and use its `arraysize()` instead. This macro
|
|
||||||
//! should only be used in rare situations where `arraysize()` does not
|
|
||||||
//! function.
|
|
||||||
#define ARRAYSIZE_UNSAFE(array) (sizeof(array) / sizeof(array[0]))
|
|
||||||
|
|
||||||
#endif // CRASHPAD_UTIL_MISC_ARRAYSIZE_UNSAFE_H_
|
|
@ -15,8 +15,8 @@
|
|||||||
#include "util/misc/capture_context_test_util.h"
|
#include "util/misc/capture_context_test_util.h"
|
||||||
#include "util/win/context_wrappers.h"
|
#include "util/win/context_wrappers.h"
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -59,7 +59,7 @@ void SanityCheckContext(const NativeCPUContext& context) {
|
|||||||
|
|
||||||
#if defined(ARCH_CPU_X86)
|
#if defined(ARCH_CPU_X86)
|
||||||
// fxsave doesn’t write these bytes.
|
// fxsave doesn’t write these bytes.
|
||||||
for (size_t i = 464; i < arraysize(context.ExtendedRegisters); ++i) {
|
for (size_t i = 464; i < ArraySize(context.ExtendedRegisters); ++i) {
|
||||||
SCOPED_TRACE(i);
|
SCOPED_TRACE(i);
|
||||||
EXPECT_EQ(context.ExtendedRegisters[i], 0);
|
EXPECT_EQ(context.ExtendedRegisters[i], 0);
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ void SanityCheckContext(const NativeCPUContext& context) {
|
|||||||
EXPECT_EQ(context.FltSave.MxCsr, context.MxCsr);
|
EXPECT_EQ(context.FltSave.MxCsr, context.MxCsr);
|
||||||
|
|
||||||
// fxsave doesn’t write these bytes.
|
// fxsave doesn’t write these bytes.
|
||||||
for (size_t i = 0; i < arraysize(context.FltSave.Reserved4); ++i) {
|
for (size_t i = 0; i < ArraySize(context.FltSave.Reserved4); ++i) {
|
||||||
SCOPED_TRACE(i);
|
SCOPED_TRACE(i);
|
||||||
EXPECT_EQ(context.FltSave.Reserved4[i], 0);
|
EXPECT_EQ(context.FltSave.Reserved4[i], 0);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void SanityCheckContext(const NativeCPUContext& context) {
|
|||||||
EXPECT_EQ(context.P4Home, 0u);
|
EXPECT_EQ(context.P4Home, 0u);
|
||||||
EXPECT_EQ(context.P5Home, 0u);
|
EXPECT_EQ(context.P5Home, 0u);
|
||||||
EXPECT_EQ(context.P6Home, 0u);
|
EXPECT_EQ(context.P6Home, 0u);
|
||||||
for (size_t i = 0; i < arraysize(context.VectorRegister); ++i) {
|
for (size_t i = 0; i < ArraySize(context.VectorRegister); ++i) {
|
||||||
SCOPED_TRACE(i);
|
SCOPED_TRACE(i);
|
||||||
EXPECT_EQ(context.VectorRegister[i].Low, 0u);
|
EXPECT_EQ(context.VectorRegister[i].Low, 0u);
|
||||||
EXPECT_EQ(context.VectorRegister[i].High, 0u);
|
EXPECT_EQ(context.VectorRegister[i].High, 0u);
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -83,7 +83,7 @@ TEST(Clock, SleepNanoseconds) {
|
|||||||
static_cast<uint64_t>(5E7), // 50 milliseconds
|
static_cast<uint64_t>(5E7), // 50 milliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const uint64_t nanoseconds = kTestData[index];
|
const uint64_t nanoseconds = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %zu, nanoseconds %" PRIu64, index, nanoseconds));
|
"index %zu, nanoseconds %" PRIu64, index, nanoseconds));
|
||||||
|
@ -17,18 +17,19 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool Paths::Executable(base::FilePath* path) {
|
bool Paths::Executable(base::FilePath* path) {
|
||||||
wchar_t executable_path[_MAX_PATH];
|
wchar_t executable_path[_MAX_PATH];
|
||||||
unsigned int len =
|
unsigned int len = GetModuleFileName(
|
||||||
GetModuleFileName(nullptr, executable_path, arraysize(executable_path));
|
nullptr, executable_path, static_cast<DWORD>(ArraySize(executable_path)));
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
PLOG(ERROR) << "GetModuleFileName";
|
PLOG(ERROR) << "GetModuleFileName";
|
||||||
return false;
|
return false;
|
||||||
} else if (len >= arraysize(executable_path)) {
|
} else if (len >= ArraySize(executable_path)) {
|
||||||
LOG(ERROR) << "GetModuleFileName";
|
LOG(ERROR) << "GetModuleFileName";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -33,7 +33,7 @@ TEST(RandomString, RandomString) {
|
|||||||
const std::string allowed_characters("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
const std::string allowed_characters("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
|
|
||||||
size_t character_counts[26] = {};
|
size_t character_counts[26] = {};
|
||||||
ASSERT_EQ(allowed_characters.size(), arraysize(character_counts));
|
ASSERT_EQ(allowed_characters.size(), ArraySize(character_counts));
|
||||||
|
|
||||||
std::set<std::string> strings;
|
std::set<std::string> strings;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ TEST(RandomString, RandomString) {
|
|||||||
// Make sure every character appears at least once. It is possible, but
|
// Make sure every character appears at least once. It is possible, but
|
||||||
// extremely unlikely, for a character to not appear at all.
|
// extremely unlikely, for a character to not appear at all.
|
||||||
for (size_t character_index = 0;
|
for (size_t character_index = 0;
|
||||||
character_index < arraysize(character_counts);
|
character_index < ArraySize(character_counts);
|
||||||
++character_index) {
|
++character_index) {
|
||||||
EXPECT_GT(character_counts[character_index], 0u)
|
EXPECT_GT(character_counts[character_index], 0u)
|
||||||
<< allowed_characters[character_index];
|
<< allowed_characters[character_index];
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/scoped_generic.h"
|
#include "base/scoped_generic.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -95,12 +95,12 @@ TEST(UUID, UUID) {
|
|||||||
++uuid.data_3;
|
++uuid.data_3;
|
||||||
EXPECT_NE(uuid, uuid_2);
|
EXPECT_NE(uuid, uuid_2);
|
||||||
--uuid.data_3;
|
--uuid.data_3;
|
||||||
for (size_t index = 0; index < arraysize(uuid.data_4); ++index) {
|
for (size_t index = 0; index < ArraySize(uuid.data_4); ++index) {
|
||||||
++uuid.data_4[index];
|
++uuid.data_4[index];
|
||||||
EXPECT_NE(uuid, uuid_2);
|
EXPECT_NE(uuid, uuid_2);
|
||||||
--uuid.data_4[index];
|
--uuid.data_4[index];
|
||||||
}
|
}
|
||||||
for (size_t index = 0; index < arraysize(uuid.data_5); ++index) {
|
for (size_t index = 0; index < ArraySize(uuid.data_5); ++index) {
|
||||||
++uuid.data_5[index];
|
++uuid.data_5[index];
|
||||||
EXPECT_NE(uuid, uuid_2);
|
EXPECT_NE(uuid, uuid_2);
|
||||||
--uuid.data_5[index];
|
--uuid.data_5[index];
|
||||||
@ -190,7 +190,7 @@ TEST(UUID, FromString) {
|
|||||||
uuid_zero.InitializeToZero();
|
uuid_zero.InitializeToZero();
|
||||||
const std::string empty_uuid = uuid_zero.ToString();
|
const std::string empty_uuid = uuid_zero.ToString();
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kCases); ++index) {
|
for (size_t index = 0; index < ArraySize(kCases); ++index) {
|
||||||
const TestCase& test_case = kCases[index];
|
const TestCase& test_case = kCases[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ": %s", index, test_case.uuid_string));
|
"index %" PRIuS ": %s", index, test_case.uuid_string));
|
||||||
@ -226,7 +226,7 @@ TEST(UUID, FromString) {
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
EXPECT_TRUE(uuid.InitializeFromString(
|
EXPECT_TRUE(uuid.InitializeFromString(
|
||||||
base::StringPiece16(kChar16UUID, arraysize(kChar16UUID))));
|
base::StringPiece16(kChar16UUID, ArraySize(kChar16UUID))));
|
||||||
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-333ffd33b333");
|
EXPECT_EQ(uuid.ToString(), "f32e5bdc-2681-4c73-a4e6-333ffd33b333");
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/net/http_body.h"
|
#include "util/net/http_body.h"
|
||||||
#include "util/net/url.h"
|
#include "util/net/url.h"
|
||||||
#include "util/stdlib/string_number_conversion.h"
|
#include "util/stdlib/string_number_conversion.h"
|
||||||
@ -365,7 +366,7 @@ bool WriteRequest(Stream* stream,
|
|||||||
|
|
||||||
FileOperationResult data_bytes;
|
FileOperationResult data_bytes;
|
||||||
do {
|
do {
|
||||||
constexpr size_t kCRLFSize = arraysize(kCRLFTerminator) - 1;
|
constexpr size_t kCRLFSize = ArraySize(kCRLFTerminator) - 1;
|
||||||
struct __attribute__((packed)) {
|
struct __attribute__((packed)) {
|
||||||
char size[8];
|
char size[8];
|
||||||
char crlf[2];
|
char crlf[2];
|
||||||
|
@ -31,8 +31,9 @@
|
|||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "util/file/file_io.h"
|
#include "util/file/file_io.h"
|
||||||
#include "util/numeric/safe_assignment.h"
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/net/http_body.h"
|
#include "util/net/http_body.h"
|
||||||
|
#include "util/numeric/safe_assignment.h"
|
||||||
#include "util/win/module_version.h"
|
#include "util/win/module_version.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -95,7 +96,7 @@ std::string WinHttpMessage(const char* extra) {
|
|||||||
error_code,
|
error_code,
|
||||||
0,
|
0,
|
||||||
msgbuf,
|
msgbuf,
|
||||||
arraysize(msgbuf),
|
static_cast<DWORD>(ArraySize(msgbuf)),
|
||||||
NULL);
|
NULL);
|
||||||
if (!len) {
|
if (!len) {
|
||||||
return base::StringPrintf("%s: error 0x%lx while retrieving error 0x%lx",
|
return base::StringPrintf("%s: error 0x%lx while retrieving error 0x%lx",
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -119,7 +119,7 @@ TEST(CheckedAddressRange, IsValid) {
|
|||||||
{0xffffffffffffffff, 1, kInvalid},
|
{0xffffffffffffffff, 1, kInvalid},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
|
||||||
", base 0x%" PRIx64 ", size 0x%" PRIx64,
|
", base 0x%" PRIx64 ", size 0x%" PRIx64,
|
||||||
@ -170,7 +170,7 @@ TEST(CheckedAddressRange, ContainsValue) {
|
|||||||
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
|
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range_32.IsValid());
|
ASSERT_TRUE(parent_range_32.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ", value 0x%" PRIx64, index, testcase.value));
|
"index %" PRIuS ", value 0x%" PRIx64, index, testcase.value));
|
||||||
@ -227,7 +227,7 @@ TEST(CheckedAddressRange, ContainsRange) {
|
|||||||
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
|
CheckedAddressRange parent_range_32(false, 0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range_32.IsValid());
|
ASSERT_TRUE(parent_range_32.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS
|
||||||
", base 0x%" PRIx64 ", size 0x%" PRIx64,
|
", base 0x%" PRIx64 ", size 0x%" PRIx64,
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -78,7 +78,7 @@ TEST(CheckedRange, IsValid) {
|
|||||||
{0xffffffff, 0xffffffff, false},
|
{0xffffffff, 0xffffffff, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kUnsignedTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kUnsignedTestData); ++index) {
|
||||||
const auto& testcase = kUnsignedTestData[index];
|
const auto& testcase = kUnsignedTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("unsigned index %" PRIuS
|
SCOPED_TRACE(base::StringPrintf("unsigned index %" PRIuS
|
||||||
", base 0x%x, size 0x%x",
|
", base 0x%x, size 0x%x",
|
||||||
@ -140,7 +140,7 @@ TEST(CheckedRange, IsValid) {
|
|||||||
{-1, 0xffffffff, false},
|
{-1, 0xffffffff, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kSignedTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kSignedTestData); ++index) {
|
||||||
const auto& testcase = kSignedTestData[index];
|
const auto& testcase = kSignedTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("signed index %" PRIuS
|
SCOPED_TRACE(base::StringPrintf("signed index %" PRIuS
|
||||||
", base 0x%x, size 0x%x",
|
", base 0x%x, size 0x%x",
|
||||||
@ -186,7 +186,7 @@ TEST(CheckedRange, ContainsValue) {
|
|||||||
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
|
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range.IsValid());
|
ASSERT_TRUE(parent_range.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %" PRIuS ", value 0x%x", index, testcase.value));
|
"index %" PRIuS ", value 0x%x", index, testcase.value));
|
||||||
@ -234,7 +234,7 @@ TEST(CheckedRange, ContainsRange) {
|
|||||||
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
|
CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
|
||||||
ASSERT_TRUE(parent_range.IsValid());
|
ASSERT_TRUE(parent_range.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
|
||||||
index,
|
index,
|
||||||
@ -287,7 +287,7 @@ TEST(CheckedRange, OverlapsRange) {
|
|||||||
CheckedRange<uint32_t> first_range(0x2000, 0x1000);
|
CheckedRange<uint32_t> first_range(0x2000, 0x1000);
|
||||||
ASSERT_TRUE(first_range.IsValid());
|
ASSERT_TRUE(first_range.IsValid());
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto& testcase = kTestData[index];
|
const auto& testcase = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
|
||||||
index,
|
index,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "util/file/directory_reader.h"
|
#include "util/file/directory_reader.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
@ -152,7 +153,7 @@ void CloseMultipleNowOrOnExec(int fd, int preserve_fd) {
|
|||||||
int maxfilesperproc;
|
int maxfilesperproc;
|
||||||
size_t maxfilesperproc_size = sizeof(maxfilesperproc);
|
size_t maxfilesperproc_size = sizeof(maxfilesperproc);
|
||||||
if (sysctl(oid,
|
if (sysctl(oid,
|
||||||
arraysize(oid),
|
ArraySize(oid),
|
||||||
&maxfilesperproc,
|
&maxfilesperproc,
|
||||||
&maxfilesperproc_size,
|
&maxfilesperproc_size,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "base/files/scoped_file.h"
|
#include "base/files/scoped_file.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/macros.h"
|
||||||
#include "base/posix/eintr_wrapper.h"
|
#include "base/posix/eintr_wrapper.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/mach_logging.h"
|
#include "base/mac/mach_logging.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ bool ProcessInfo::InitializeWithPid(pid_t pid) {
|
|||||||
|
|
||||||
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
|
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
|
||||||
size_t len = sizeof(kern_proc_info_);
|
size_t len = sizeof(kern_proc_info_);
|
||||||
if (sysctl(mib, arraysize(mib), &kern_proc_info_, &len, nullptr, 0) != 0) {
|
if (sysctl(mib, ArraySize(mib), &kern_proc_info_, &len, nullptr, 0) != 0) {
|
||||||
PLOG(ERROR) << "sysctl for pid " << pid;
|
PLOG(ERROR) << "sysctl for pid " << pid;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ std::set<gid_t> ProcessInfo::SupplementaryGroups() const {
|
|||||||
const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups;
|
const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups;
|
||||||
DCHECK_GE(ngroups, 0);
|
DCHECK_GE(ngroups, 0);
|
||||||
DCHECK_LE(static_cast<size_t>(ngroups),
|
DCHECK_LE(static_cast<size_t>(ngroups),
|
||||||
arraysize(kern_proc_info_.kp_eproc.e_ucred.cr_groups));
|
ArraySize(kern_proc_info_.kp_eproc.e_ucred.cr_groups));
|
||||||
|
|
||||||
const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups;
|
const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups;
|
||||||
return std::set<gid_t>(&groups[0], &groups[ngroups]);
|
return std::set<gid_t>(&groups[0], &groups[ngroups]);
|
||||||
@ -168,7 +169,7 @@ bool ProcessInfo::Arguments(std::vector<std::string>* argv) const {
|
|||||||
do {
|
do {
|
||||||
int mib[] = {CTL_KERN, KERN_PROCARGS2, pid};
|
int mib[] = {CTL_KERN, KERN_PROCARGS2, pid};
|
||||||
int rv =
|
int rv =
|
||||||
sysctl(mib, arraysize(mib), nullptr, &args_size_estimate, nullptr, 0);
|
sysctl(mib, ArraySize(mib), nullptr, &args_size_estimate, nullptr, 0);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
PLOG(ERROR) << "sysctl (size) for pid " << pid;
|
PLOG(ERROR) << "sysctl (size) for pid " << pid;
|
||||||
return false;
|
return false;
|
||||||
@ -176,7 +177,7 @@ bool ProcessInfo::Arguments(std::vector<std::string>* argv) const {
|
|||||||
|
|
||||||
args_size = args_size_estimate + 1;
|
args_size = args_size_estimate + 1;
|
||||||
args.resize(args_size);
|
args.resize(args_size);
|
||||||
rv = sysctl(mib, arraysize(mib), &args[0], &args_size, nullptr, 0);
|
rv = sysctl(mib, ArraySize(mib), &args[0], &args_size, nullptr, 0);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
PLOG(ERROR) << "sysctl (data) for pid " << pid;
|
PLOG(ERROR) << "sysctl (data) for pid " << pid;
|
||||||
return false;
|
return false;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/gtest_death.h"
|
#include "test/gtest_death.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -150,7 +151,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_Shrink) {
|
|||||||
EXPECT_EQ(mapping.len(), 3 * kPageSize);
|
EXPECT_EQ(mapping.len(), 3 * kPageSize);
|
||||||
|
|
||||||
TestCookie cookies[3];
|
TestCookie cookies[3];
|
||||||
for (size_t index = 0; index < arraysize(cookies); ++index) {
|
for (size_t index = 0; index < ArraySize(cookies); ++index) {
|
||||||
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
||||||
mapping.addr_as<uintptr_t>() + index * kPageSize));
|
mapping.addr_as<uintptr_t>() + index * kPageSize));
|
||||||
}
|
}
|
||||||
@ -185,7 +186,7 @@ TEST(ScopedMmap, ResetAddrLen_Grow) {
|
|||||||
EXPECT_EQ(mapping.len(), kPageSize);
|
EXPECT_EQ(mapping.len(), kPageSize);
|
||||||
|
|
||||||
TestCookie cookies[3];
|
TestCookie cookies[3];
|
||||||
for (size_t index = 0; index < arraysize(cookies); ++index) {
|
for (size_t index = 0; index < ArraySize(cookies); ++index) {
|
||||||
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
||||||
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
||||||
}
|
}
|
||||||
@ -196,7 +197,7 @@ TEST(ScopedMmap, ResetAddrLen_Grow) {
|
|||||||
EXPECT_EQ(mapping.addr(), pages);
|
EXPECT_EQ(mapping.addr(), pages);
|
||||||
EXPECT_EQ(mapping.len(), 3 * kPageSize);
|
EXPECT_EQ(mapping.len(), 3 * kPageSize);
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(cookies); ++index) {
|
for (size_t index = 0; index < ArraySize(cookies); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
EXPECT_EQ(cookies[index].Observed(), cookies[index].Expected());
|
EXPECT_EQ(cookies[index].Observed(), cookies[index].Expected());
|
||||||
}
|
}
|
||||||
@ -217,7 +218,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_MoveDownAndGrow) {
|
|||||||
EXPECT_EQ(mapping.len(), kPageSize);
|
EXPECT_EQ(mapping.len(), kPageSize);
|
||||||
|
|
||||||
TestCookie cookies[3];
|
TestCookie cookies[3];
|
||||||
for (size_t index = 0; index < arraysize(cookies); ++index) {
|
for (size_t index = 0; index < ArraySize(cookies); ++index) {
|
||||||
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
||||||
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
||||||
}
|
}
|
||||||
@ -248,7 +249,7 @@ TEST(ScopedMmapDeathTest, ResetAddrLen_MoveUpAndShrink) {
|
|||||||
EXPECT_EQ(mapping.len(), 2 * kPageSize);
|
EXPECT_EQ(mapping.len(), 2 * kPageSize);
|
||||||
|
|
||||||
TestCookie cookies[3];
|
TestCookie cookies[3];
|
||||||
for (size_t index = 0; index < arraysize(cookies); ++index) {
|
for (size_t index = 0; index < ArraySize(cookies); ++index) {
|
||||||
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
cookies[index].SetUp(reinterpret_cast<uint64_t*>(
|
||||||
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
reinterpret_cast<uintptr_t>(pages) + index * kPageSize));
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ bool IsSignalInSet(int sig, const int* set, size_t set_size) {
|
|||||||
struct sigaction* Signals::OldActions::ActionForSignal(int sig) {
|
struct sigaction* Signals::OldActions::ActionForSignal(int sig) {
|
||||||
DCHECK_GT(sig, 0);
|
DCHECK_GT(sig, 0);
|
||||||
const size_t slot = sig - 1;
|
const size_t slot = sig - 1;
|
||||||
DCHECK_LT(slot, arraysize(actions_));
|
DCHECK_LT(slot, ArraySize(actions_));
|
||||||
return &actions_[slot];
|
return &actions_[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ bool Signals::InstallCrashHandlers(Handler handler,
|
|||||||
int flags,
|
int flags,
|
||||||
OldActions* old_actions) {
|
OldActions* old_actions) {
|
||||||
return InstallHandlers(
|
return InstallHandlers(
|
||||||
std::vector<int>(kCrashSignals, kCrashSignals + arraysize(kCrashSignals)),
|
std::vector<int>(kCrashSignals, kCrashSignals + ArraySize(kCrashSignals)),
|
||||||
handler,
|
handler,
|
||||||
flags,
|
flags,
|
||||||
old_actions);
|
old_actions);
|
||||||
@ -164,7 +165,7 @@ bool Signals::InstallTerminateHandlers(Handler handler,
|
|||||||
OldActions* old_actions) {
|
OldActions* old_actions) {
|
||||||
return InstallHandlers(
|
return InstallHandlers(
|
||||||
std::vector<int>(kTerminateSignals,
|
std::vector<int>(kTerminateSignals,
|
||||||
kTerminateSignals + arraysize(kTerminateSignals)),
|
kTerminateSignals + ArraySize(kTerminateSignals)),
|
||||||
handler,
|
handler,
|
||||||
flags,
|
flags,
|
||||||
old_actions);
|
old_actions);
|
||||||
@ -279,12 +280,12 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn(
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool Signals::IsCrashSignal(int sig) {
|
bool Signals::IsCrashSignal(int sig) {
|
||||||
return IsSignalInSet(sig, kCrashSignals, arraysize(kCrashSignals));
|
return IsSignalInSet(sig, kCrashSignals, ArraySize(kCrashSignals));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool Signals::IsTerminateSignal(int sig) {
|
bool Signals::IsTerminateSignal(int sig) {
|
||||||
return IsSignalInSet(sig, kTerminateSignals, arraysize(kTerminateSignals));
|
return IsSignalInSet(sig, kTerminateSignals, ArraySize(kTerminateSignals));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace crashpad
|
} // namespace crashpad
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
#include "test/multiprocess.h"
|
#include "test/multiprocess.h"
|
||||||
#include "test/scoped_temp_dir.h"
|
#include "test/scoped_temp_dir.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/posix/scoped_mmap.h"
|
#include "util/posix/scoped_mmap.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -340,7 +341,7 @@ TEST(Signals, WillSignalReraiseAutonomously) {
|
|||||||
{SIGHUP, SEGV_MAPERR, false},
|
{SIGHUP, SEGV_MAPERR, false},
|
||||||
{SIGINT, SI_USER, false},
|
{SIGINT, SI_USER, false},
|
||||||
};
|
};
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
const auto test_data = kTestData[index];
|
const auto test_data = kTestData[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"index %zu, sig %d, code %d", index, test_data.sig, test_data.code));
|
"index %zu, sig %d, code %d", index, test_data.sig, test_data.code));
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/implicit_cast.h"
|
#include "util/misc/implicit_cast.h"
|
||||||
#include "util/stdlib/string_number_conversion.h"
|
#include "util/stdlib/string_number_conversion.h"
|
||||||
|
|
||||||
@ -137,9 +137,9 @@ constexpr const char* kSignalNames[] = {
|
|||||||
};
|
};
|
||||||
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
||||||
// NSIG is 64 to account for real-time signals.
|
// NSIG is 64 to account for real-time signals.
|
||||||
static_assert(arraysize(kSignalNames) == 32, "kSignalNames length");
|
static_assert(ArraySize(kSignalNames) == 32, "kSignalNames length");
|
||||||
#else
|
#else
|
||||||
static_assert(arraysize(kSignalNames) == NSIG, "kSignalNames length");
|
static_assert(ArraySize(kSignalNames) == NSIG, "kSignalNames length");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr char kSigPrefix[] = "SIG";
|
constexpr char kSigPrefix[] = "SIG";
|
||||||
@ -151,7 +151,7 @@ namespace crashpad {
|
|||||||
std::string SignalToString(int signal,
|
std::string SignalToString(int signal,
|
||||||
SymbolicConstantToStringOptions options) {
|
SymbolicConstantToStringOptions options) {
|
||||||
const char* signal_name =
|
const char* signal_name =
|
||||||
implicit_cast<size_t>(signal) < arraysize(kSignalNames)
|
implicit_cast<size_t>(signal) < ArraySize(kSignalNames)
|
||||||
? kSignalNames[signal]
|
? kSignalNames[signal]
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (!signal_name) {
|
if (!signal_name) {
|
||||||
@ -176,8 +176,7 @@ bool StringToSignal(const base::StringPiece& string,
|
|||||||
string.substr(0, strlen(kSigPrefix)).compare(kSigPrefix) == 0;
|
string.substr(0, strlen(kSigPrefix)).compare(kSigPrefix) == 0;
|
||||||
base::StringPiece short_string =
|
base::StringPiece short_string =
|
||||||
can_match_full ? string.substr(strlen(kSigPrefix)) : string;
|
can_match_full ? string.substr(strlen(kSigPrefix)) : string;
|
||||||
for (int index = 0;
|
for (int index = 0; index < implicit_cast<int>(ArraySize(kSignalNames));
|
||||||
index < implicit_cast<int>(arraysize(kSignalNames));
|
|
||||||
++index) {
|
++index) {
|
||||||
const char* signal_name = kSignalNames[index];
|
const char* signal_name = kSignalNames[index];
|
||||||
if (!signal_name) {
|
if (!signal_name) {
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/string_piece.h"
|
#include "base/strings/string_piece.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
#define NUL_TEST_DATA(string) { string, arraysize(string) - 1 }
|
#define NUL_TEST_DATA(string) \
|
||||||
|
{ string, ArraySize(string) - 1 }
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -115,7 +116,7 @@ void TestSignalToString(int value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(SymbolicConstantsPOSIX, SignalToString) {
|
TEST(SymbolicConstantsPOSIX, SignalToString) {
|
||||||
for (size_t index = 0; index < arraysize(kSignalTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kSignalTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestSignalToString(kSignalTestData[index].signal,
|
TestSignalToString(kSignalTestData[index].signal,
|
||||||
kSignalTestData[index].full_name,
|
kSignalTestData[index].full_name,
|
||||||
@ -170,12 +171,11 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) {
|
|||||||
kAllowFullName | kAllowShortName | kAllowNumber,
|
kAllowFullName | kAllowShortName | kAllowNumber,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t option_index = 0;
|
for (size_t option_index = 0; option_index < ArraySize(kOptions);
|
||||||
option_index < arraysize(kOptions);
|
|
||||||
++option_index) {
|
++option_index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
SCOPED_TRACE(base::StringPrintf("option_index %zu", option_index));
|
||||||
StringToSymbolicConstantOptions options = kOptions[option_index];
|
StringToSymbolicConstantOptions options = kOptions[option_index];
|
||||||
for (size_t index = 0; index < arraysize(kSignalTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kSignalTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
int signal = kSignalTestData[index].signal;
|
int signal = kSignalTestData[index].signal;
|
||||||
{
|
{
|
||||||
@ -213,7 +213,7 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) {
|
|||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNegativeTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNegativeTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
TestStringToSignal(kNegativeTestData[index], options, false, 0);
|
TestStringToSignal(kNegativeTestData[index], options, false, 0);
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ TEST(SymbolicConstantsPOSIX, StringToSignal) {
|
|||||||
NUL_TEST_DATA("1\0002"),
|
NUL_TEST_DATA("1\0002"),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kNULTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kNULTestData); ++index) {
|
||||||
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
SCOPED_TRACE(base::StringPrintf("index %zu", index));
|
||||||
base::StringPiece string(kNULTestData[index].string,
|
base::StringPiece string(kNULTestData[index].string,
|
||||||
kNULTestData[index].length);
|
kNULTestData[index].length);
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "test/process_type.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/process/process_memory_native.h"
|
#include "util/process/process_memory_native.h"
|
||||||
#include "test/process_type.h"
|
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -58,28 +59,28 @@ TEST(ProcessMemoryRange, Basic) {
|
|||||||
auto string1_addr = FromPointerCast<VMAddress>(kTestObject.string1);
|
auto string1_addr = FromPointerCast<VMAddress>(kTestObject.string1);
|
||||||
auto string2_addr = FromPointerCast<VMAddress>(kTestObject.string2);
|
auto string2_addr = FromPointerCast<VMAddress>(kTestObject.string2);
|
||||||
ASSERT_TRUE(range.ReadCStringSizeLimited(
|
ASSERT_TRUE(range.ReadCStringSizeLimited(
|
||||||
string1_addr, arraysize(kTestObject.string1), &string));
|
string1_addr, ArraySize(kTestObject.string1), &string));
|
||||||
EXPECT_STREQ(string.c_str(), kTestObject.string1);
|
EXPECT_STREQ(string.c_str(), kTestObject.string1);
|
||||||
|
|
||||||
ASSERT_TRUE(range.ReadCStringSizeLimited(
|
ASSERT_TRUE(range.ReadCStringSizeLimited(
|
||||||
string2_addr, arraysize(kTestObject.string2), &string));
|
string2_addr, ArraySize(kTestObject.string2), &string));
|
||||||
EXPECT_STREQ(string.c_str(), kTestObject.string2);
|
EXPECT_STREQ(string.c_str(), kTestObject.string2);
|
||||||
|
|
||||||
// Limit the range to remove access to string2.
|
// Limit the range to remove access to string2.
|
||||||
ProcessMemoryRange range2;
|
ProcessMemoryRange range2;
|
||||||
ASSERT_TRUE(range2.Initialize(range));
|
ASSERT_TRUE(range2.Initialize(range));
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
range2.RestrictRange(string1_addr, arraysize(kTestObject.string1)));
|
range2.RestrictRange(string1_addr, ArraySize(kTestObject.string1)));
|
||||||
EXPECT_TRUE(range2.ReadCStringSizeLimited(
|
EXPECT_TRUE(range2.ReadCStringSizeLimited(
|
||||||
string1_addr, arraysize(kTestObject.string1), &string));
|
string1_addr, ArraySize(kTestObject.string1), &string));
|
||||||
EXPECT_FALSE(range2.ReadCStringSizeLimited(
|
EXPECT_FALSE(range2.ReadCStringSizeLimited(
|
||||||
string2_addr, arraysize(kTestObject.string2), &string));
|
string2_addr, ArraySize(kTestObject.string2), &string));
|
||||||
EXPECT_FALSE(range2.Read(object_addr, sizeof(object), &object));
|
EXPECT_FALSE(range2.Read(object_addr, sizeof(object), &object));
|
||||||
|
|
||||||
// String reads fail if the NUL terminator is outside the range.
|
// String reads fail if the NUL terminator is outside the range.
|
||||||
ASSERT_TRUE(range2.RestrictRange(string1_addr, strlen(kTestObject.string1)));
|
ASSERT_TRUE(range2.RestrictRange(string1_addr, strlen(kTestObject.string1)));
|
||||||
EXPECT_FALSE(range2.ReadCStringSizeLimited(
|
EXPECT_FALSE(range2.ReadCStringSizeLimited(
|
||||||
string1_addr, arraysize(kTestObject.string1), &string));
|
string1_addr, ArraySize(kTestObject.string1), &string));
|
||||||
|
|
||||||
// New range outside the old range.
|
// New range outside the old range.
|
||||||
EXPECT_FALSE(range2.RestrictRange(string1_addr - 1, 1));
|
EXPECT_FALSE(range2.RestrictRange(string1_addr - 1, 1));
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -94,7 +94,7 @@ TEST(StringNumberConversion, StringToInt) {
|
|||||||
{"18446744073709551616", false, 0},
|
{"18446744073709551616", false, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
int value;
|
int value;
|
||||||
bool valid = StringToNumber(kTestData[index].string, &value);
|
bool valid = StringToNumber(kTestData[index].string, &value);
|
||||||
if (kTestData[index].valid) {
|
if (kTestData[index].valid) {
|
||||||
@ -114,7 +114,7 @@ TEST(StringNumberConversion, StringToInt) {
|
|||||||
// is split to avoid MSVC warning:
|
// is split to avoid MSVC warning:
|
||||||
// "decimal digit terminates octal escape sequence".
|
// "decimal digit terminates octal escape sequence".
|
||||||
static constexpr char input[] = "6\000" "6";
|
static constexpr char input[] = "6\000" "6";
|
||||||
std::string input_string(input, arraysize(input) - 1);
|
std::string input_string(input, ArraySize(input) - 1);
|
||||||
int output;
|
int output;
|
||||||
EXPECT_FALSE(StringToNumber(input_string, &output));
|
EXPECT_FALSE(StringToNumber(input_string, &output));
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ TEST(StringNumberConversion, StringToUnsignedInt) {
|
|||||||
{"18446744073709551616", false, 0},
|
{"18446744073709551616", false, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
bool valid = StringToNumber(kTestData[index].string, &value);
|
bool valid = StringToNumber(kTestData[index].string, &value);
|
||||||
if (kTestData[index].valid) {
|
if (kTestData[index].valid) {
|
||||||
@ -208,7 +208,7 @@ TEST(StringNumberConversion, StringToUnsignedInt) {
|
|||||||
// is split to avoid MSVC warning:
|
// is split to avoid MSVC warning:
|
||||||
// "decimal digit terminates octal escape sequence".
|
// "decimal digit terminates octal escape sequence".
|
||||||
static constexpr char input[] = "6\000" "6";
|
static constexpr char input[] = "6\000" "6";
|
||||||
std::string input_string(input, arraysize(input) - 1);
|
std::string input_string(input, ArraySize(input) - 1);
|
||||||
unsigned int output;
|
unsigned int output;
|
||||||
EXPECT_FALSE(StringToNumber(input_string, &output));
|
EXPECT_FALSE(StringToNumber(input_string, &output));
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ TEST(StringNumberConversion, StringToInt64) {
|
|||||||
{"0x7Fffffffffffffff", true, std::numeric_limits<int64_t>::max()},
|
{"0x7Fffffffffffffff", true, std::numeric_limits<int64_t>::max()},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
int64_t value;
|
int64_t value;
|
||||||
bool valid = StringToNumber(kTestData[index].string, &value);
|
bool valid = StringToNumber(kTestData[index].string, &value);
|
||||||
if (kTestData[index].valid) {
|
if (kTestData[index].valid) {
|
||||||
@ -295,7 +295,7 @@ TEST(StringNumberConversion, StringToUnsignedInt64) {
|
|||||||
{"0xFfffffffffffffff", true, std::numeric_limits<uint64_t>::max()},
|
{"0xFfffffffffffffff", true, std::numeric_limits<uint64_t>::max()},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(kTestData); ++index) {
|
for (size_t index = 0; index < ArraySize(kTestData); ++index) {
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
bool valid = StringToNumber(kTestData[index].string, &value);
|
bool valid = StringToNumber(kTestData[index].string, &value);
|
||||||
if (kTestData[index].valid) {
|
if (kTestData[index].valid) {
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -64,7 +64,7 @@ TEST(strlcpy, c16lcpy) {
|
|||||||
static constexpr base::char16 test_characters[] =
|
static constexpr base::char16 test_characters[] =
|
||||||
{0x4d, 0xe9, 0x100, 0x151, 0x1e18};
|
{0x4d, 0xe9, 0x100, 0x151, 0x1e18};
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(test_characters); ++index) {
|
for (size_t index = 0; index < ArraySize(test_characters); ++index) {
|
||||||
base::char16 test_character = test_characters[index];
|
base::char16 test_character = test_characters[index];
|
||||||
SCOPED_TRACE(base::StringPrintf(
|
SCOPED_TRACE(base::StringPrintf(
|
||||||
"character index %" PRIuS ", character 0x%x", index, test_character));
|
"character index %" PRIuS ", character 0x%x", index, test_character));
|
||||||
@ -78,13 +78,13 @@ TEST(strlcpy, c16lcpy) {
|
|||||||
|
|
||||||
EXPECT_EQ(c16lcpy(destination.data,
|
EXPECT_EQ(c16lcpy(destination.data,
|
||||||
test_string.c_str(),
|
test_string.c_str(),
|
||||||
arraysize(destination.data)),
|
ArraySize(destination.data)),
|
||||||
length);
|
length);
|
||||||
|
|
||||||
// Make sure that the destination buffer is NUL-terminated, and that as
|
// Make sure that the destination buffer is NUL-terminated, and that as
|
||||||
// much of the test string was copied as could fit.
|
// much of the test string was copied as could fit.
|
||||||
size_t expected_destination_length =
|
size_t expected_destination_length =
|
||||||
std::min(length, arraysize(destination.data) - 1);
|
std::min(length, ArraySize(destination.data) - 1);
|
||||||
|
|
||||||
EXPECT_EQ(destination.data[expected_destination_length], '\0');
|
EXPECT_EQ(destination.data[expected_destination_length], '\0');
|
||||||
EXPECT_EQ(C16Len(destination.data), expected_destination_length);
|
EXPECT_EQ(C16Len(destination.data), expected_destination_length);
|
||||||
@ -97,15 +97,15 @@ TEST(strlcpy, c16lcpy) {
|
|||||||
// of the buffer passed to c16lcpy.
|
// of the buffer passed to c16lcpy.
|
||||||
EXPECT_TRUE(C16Memcmp(expected_untouched.lead_guard,
|
EXPECT_TRUE(C16Memcmp(expected_untouched.lead_guard,
|
||||||
destination.lead_guard,
|
destination.lead_guard,
|
||||||
arraysize(destination.lead_guard)) == 0);
|
ArraySize(destination.lead_guard)) == 0);
|
||||||
size_t expected_untouched_length =
|
size_t expected_untouched_length =
|
||||||
arraysize(destination.data) - expected_destination_length - 1;
|
ArraySize(destination.data) - expected_destination_length - 1;
|
||||||
EXPECT_TRUE(C16Memcmp(expected_untouched.data,
|
EXPECT_TRUE(C16Memcmp(expected_untouched.data,
|
||||||
&destination.data[expected_destination_length + 1],
|
&destination.data[expected_destination_length + 1],
|
||||||
expected_untouched_length) == 0);
|
expected_untouched_length) == 0);
|
||||||
EXPECT_TRUE(C16Memcmp(expected_untouched.trail_guard,
|
EXPECT_TRUE(C16Memcmp(expected_untouched.trail_guard,
|
||||||
destination.trail_guard,
|
destination.trail_guard,
|
||||||
arraysize(destination.trail_guard)) == 0);
|
ArraySize(destination.trail_guard)) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "util/stdlib/thread_safe_vector.h"
|
#include "util/stdlib/thread_safe_vector.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "util/misc/arraysize.h"
|
||||||
#include "util/thread/thread.h"
|
#include "util/thread/thread.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -53,12 +54,12 @@ TEST(ThreadSafeVector, ThreadSafeVector) {
|
|||||||
EXPECT_TRUE(vector.empty());
|
EXPECT_TRUE(vector.empty());
|
||||||
|
|
||||||
ThreadSafeVectorTestThread threads[100];
|
ThreadSafeVectorTestThread threads[100];
|
||||||
for (size_t index = 0; index < arraysize(threads); ++index) {
|
for (size_t index = 0; index < ArraySize(threads); ++index) {
|
||||||
threads[index].SetTestParameters(
|
threads[index].SetTestParameters(
|
||||||
&thread_safe_vector, static_cast<int>(index * kElementsPerThread));
|
&thread_safe_vector, static_cast<int>(index * kElementsPerThread));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t index = 0; index < arraysize(threads); ++index) {
|
for (size_t index = 0; index < ArraySize(threads); ++index) {
|
||||||
threads[index].Start();
|
threads[index].Start();
|
||||||
|
|
||||||
if (index % 10 == 0) {
|
if (index % 10 == 0) {
|
||||||
@ -75,8 +76,8 @@ TEST(ThreadSafeVector, ThreadSafeVector) {
|
|||||||
|
|
||||||
std::vector<int> drained = thread_safe_vector.Drain();
|
std::vector<int> drained = thread_safe_vector.Drain();
|
||||||
vector.insert(vector.end(), drained.begin(), drained.end());
|
vector.insert(vector.end(), drained.begin(), drained.end());
|
||||||
bool found[arraysize(threads) * kElementsPerThread] = {};
|
bool found[ArraySize(threads) * kElementsPerThread] = {};
|
||||||
EXPECT_EQ(vector.size(), arraysize(found));
|
EXPECT_EQ(vector.size(), ArraySize(found));
|
||||||
for (int element : vector) {
|
for (int element : vector) {
|
||||||
EXPECT_FALSE(found[element]) << element;
|
EXPECT_FALSE(found[element]) << element;
|
||||||
found[element] = true;
|
found[element] = true;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user