mirror of
https://github.com/encounter/crashpad.git
synced 2026-03-30 11:04:28 -07: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:
@@ -35,6 +35,7 @@
|
||||
#include "client/settings.h"
|
||||
#include "util/file/file_io.h"
|
||||
#include "util/mac/xattr.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/misc/initialization_state_dcheck.h"
|
||||
#include "util/misc/metrics.h"
|
||||
|
||||
@@ -279,7 +280,7 @@ bool CrashReportDatabaseMac::Initialize(bool may_create) {
|
||||
}
|
||||
|
||||
// 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])))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/logging.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test/test_paths.h"
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/mac/mach_logging.h"
|
||||
#include "base/mac/scoped_mach_port.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "util/mach/exc_client_variants.h"
|
||||
#include "util/mach/exception_behaviors.h"
|
||||
#include "util/mach/exception_ports.h"
|
||||
#include "util/mach/mach_extensions.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
@@ -191,7 +191,7 @@ void SimulateCrash(const NativeCPUContext& cpu_context) {
|
||||
base::mac::ScopedMachSendRight thread(mach_thread_self());
|
||||
exception_type_t exception = kMachExceptionSimulated;
|
||||
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
|
||||
// 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;
|
||||
|
||||
for (size_t target_type_index = 0;
|
||||
!success && target_type_index < arraysize(kTargetTypes);
|
||||
!success && target_type_index < ArraySize(kTargetTypes);
|
||||
++target_type_index) {
|
||||
ExceptionPorts::ExceptionHandlerVector handlers;
|
||||
ExceptionPorts exception_ports(kTargetTypes[target_type_index],
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "util/mach/mach_message.h"
|
||||
#include "util/mach/mach_message_server.h"
|
||||
#include "util/mach/symbolic_constants_mach.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
@@ -342,15 +343,13 @@ TEST(SimulateCrash, SimulateCrash) {
|
||||
#endif
|
||||
};
|
||||
|
||||
for (size_t target_index = 0;
|
||||
target_index < arraysize(kTargets);
|
||||
for (size_t target_index = 0; target_index < ArraySize(kTargets);
|
||||
++target_index) {
|
||||
TestSimulateCrashMac::ExceptionPortsTarget target = kTargets[target_index];
|
||||
SCOPED_TRACE(base::StringPrintf(
|
||||
"target_index %zu, target %d", target_index, target));
|
||||
|
||||
for (size_t behavior_index = 0;
|
||||
behavior_index < arraysize(kBehaviors);
|
||||
for (size_t behavior_index = 0; behavior_index < ArraySize(kBehaviors);
|
||||
++behavior_index) {
|
||||
exception_behavior_t behavior = kBehaviors[behavior_index];
|
||||
SCOPED_TRACE(base::StringPrintf(
|
||||
@@ -364,8 +363,7 @@ TEST(SimulateCrash, SimulateCrash) {
|
||||
target, behavior, THREAD_STATE_NONE);
|
||||
test_simulate_crash_mac.Run();
|
||||
} else {
|
||||
for (size_t flavor_index = 0;
|
||||
flavor_index < arraysize(kFlavors);
|
||||
for (size_t flavor_index = 0; flavor_index < ArraySize(kFlavors);
|
||||
++flavor_index) {
|
||||
thread_state_flavor_t flavor = kFlavors[flavor_index];
|
||||
SCOPED_TRACE(base::StringPrintf(
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/format_macros.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "client/crashpad_info.h"
|
||||
#include "client/simple_string_dictionary.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/posix/scoped_dir.h"
|
||||
|
||||
namespace crashpad {
|
||||
@@ -108,7 +108,7 @@ void RecordFileLimitAnnotation() {
|
||||
int mib[] = {CTL_KERN, KERN_MAXFILES};
|
||||
size = sizeof(value);
|
||||
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();
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "client/crashpad_client.h"
|
||||
#include "client/crashpad_info.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/win/critical_section_with_debug_info.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
|
||||
// !vprot.
|
||||
void* reserve = VirtualAlloc(
|
||||
nullptr, arraysize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
|
||||
nullptr, ArraySize(kPageTypes) * kPageSize, MEM_RESERVE, PAGE_READWRITE);
|
||||
PCHECK(reserve) << "VirtualAlloc MEM_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 =
|
||||
VirtualAlloc(reinterpret_cast<void*>(reserve_as_int + (kPageSize * i)),
|
||||
kPageSize,
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "base/debug/alias.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "client/crashpad_client.h"
|
||||
#include "client/crashpad_info.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -123,8 +123,8 @@ int wmain(int argc, wchar_t* argv[]) {
|
||||
fflush(stdout);
|
||||
|
||||
// This is not expected to return.
|
||||
DWORD count =
|
||||
WaitForMultipleObjects(arraysize(threads), threads, true, INFINITE);
|
||||
DWORD count = WaitForMultipleObjects(
|
||||
static_cast<DWORD>(ArraySize(threads)), threads, true, INFINITE);
|
||||
if (count == WAIT_FAILED) {
|
||||
PLOG(ERROR) << "WaitForMultipleObjects";
|
||||
} else {
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "minidump/minidump_extensions.h"
|
||||
#include "minidump/test/minidump_byte_array_writer_test_util.h"
|
||||
#include "minidump/test/minidump_string_writer_test_util.h"
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -107,7 +107,7 @@ TEST(MinidumpAnnotationWriter, ThreeItems) {
|
||||
|
||||
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>();
|
||||
annotation->InitializeWithData(kNames[i], kTypes[i], kValues[i]);
|
||||
list_writer.AddObject(std::move(annotation));
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
crashpad::MinidumpByteArrayWriter writer;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "minidump/minidump_context_writer.h"
|
||||
#include "snapshot/exception_snapshot.h"
|
||||
#include "util/file/file_writer.h"
|
||||
#include "util/misc/arraysize_unsafe.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
@@ -65,7 +65,7 @@ void MinidumpExceptionWriter::SetExceptionInformation(
|
||||
|
||||
const size_t parameters = exception_information.size();
|
||||
constexpr size_t kMaxParameters =
|
||||
ARRAYSIZE_UNSAFE(exception_.ExceptionRecord.ExceptionInformation);
|
||||
ArraySize(exception_.ExceptionRecord.ExceptionInformation);
|
||||
CHECK_LE(parameters, kMaxParameters);
|
||||
|
||||
exception_.ExceptionRecord.NumberParameters =
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "snapshot/test/test_exception_snapshot.h"
|
||||
#include "test/gtest_death.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -80,7 +81,7 @@ void ExpectExceptionStream(const MINIDUMP_EXCEPTION_STREAM* expected,
|
||||
expected->ExceptionRecord.NumberParameters);
|
||||
EXPECT_EQ(observed->ExceptionRecord.__unusedAlignment, 0u);
|
||||
for (size_t index = 0;
|
||||
index < arraysize(observed->ExceptionRecord.ExceptionInformation);
|
||||
index < ArraySize(observed->ExceptionRecord.ExceptionInformation);
|
||||
++index) {
|
||||
EXPECT_EQ(observed->ExceptionRecord.ExceptionInformation[index],
|
||||
expected->ExceptionRecord.ExceptionInformation[index]);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "snapshot/test/test_thread_snapshot.h"
|
||||
#include "test/gtest_death.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -134,7 +135,7 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
||||
minidump_file.SetTimestamp(kTimestamp);
|
||||
|
||||
static constexpr uint8_t kStreamData[] = "Hello World!";
|
||||
constexpr size_t kStreamSize = arraysize(kStreamData);
|
||||
constexpr size_t kStreamSize = ArraySize(kStreamData);
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "snapshot/test/test_memory_snapshot.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -340,7 +341,7 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
|
||||
|
||||
TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
||||
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].Memory.DataSize = 0x1000;
|
||||
@@ -356,8 +357,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
||||
|
||||
std::vector<std::unique_ptr<TestMemorySnapshot>> memory_snapshots_owner;
|
||||
std::vector<const MemorySnapshot*> memory_snapshots;
|
||||
for (size_t index = 0;
|
||||
index < arraysize(expect_memory_descriptors);
|
||||
for (size_t index = 0; index < ArraySize(expect_memory_descriptors);
|
||||
++index) {
|
||||
memory_snapshots_owner.push_back(std::make_unique<TestMemorySnapshot>());
|
||||
TestMemorySnapshot* memory_snapshot = memory_snapshots_owner.back().get();
|
||||
@@ -396,7 +396,7 @@ TEST(MinidumpMemoryWriter, AddFromSnapshot) {
|
||||
|
||||
TEST(MinidumpMemoryWriter, CoalesceExplicitMultiple) {
|
||||
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].Memory.DataSize = 1000;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "snapshot/process_snapshot.h"
|
||||
#include "snapshot/system_snapshot.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/safe_assignment.h"
|
||||
|
||||
@@ -302,7 +302,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id,
|
||||
|
||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||
misc_info_.TimeZone.StandardName,
|
||||
ARRAYSIZE_UNSAFE(misc_info_.TimeZone.StandardName),
|
||||
ArraySize(misc_info_.TimeZone.StandardName),
|
||||
standard_name);
|
||||
|
||||
misc_info_.TimeZone.StandardDate = standard_date;
|
||||
@@ -310,7 +310,7 @@ void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id,
|
||||
|
||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||
misc_info_.TimeZone.DaylightName,
|
||||
ARRAYSIZE_UNSAFE(misc_info_.TimeZone.DaylightName),
|
||||
ArraySize(misc_info_.TimeZone.DaylightName),
|
||||
daylight_name);
|
||||
|
||||
misc_info_.TimeZone.DaylightDate = daylight_date;
|
||||
@@ -327,12 +327,10 @@ void MinidumpMiscInfoWriter::SetBuildString(
|
||||
misc_info_.Flags1 |= MINIDUMP_MISC4_BUILDSTRING;
|
||||
|
||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||
misc_info_.BuildString,
|
||||
ARRAYSIZE_UNSAFE(misc_info_.BuildString),
|
||||
build_string);
|
||||
misc_info_.BuildString, ArraySize(misc_info_.BuildString), build_string);
|
||||
internal::MinidumpWriterUtil::AssignUTF8ToUTF16(
|
||||
misc_info_.DbgBldStr,
|
||||
ARRAYSIZE_UNSAFE(misc_info_.DbgBldStr),
|
||||
ArraySize(misc_info_.DbgBldStr),
|
||||
debug_build_string);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "snapshot/test/test_process_snapshot.h"
|
||||
#include "snapshot/test/test_system_snapshot.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize_unsafe.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/stdlib/strlcpy.h"
|
||||
|
||||
namespace crashpad {
|
||||
@@ -127,7 +127,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
|
||||
SCOPED_TRACE("Standard");
|
||||
ExpectNULPaddedString16Equal(expected->TimeZone.StandardName,
|
||||
observed->TimeZone.StandardName,
|
||||
arraysize(expected->TimeZone.StandardName));
|
||||
ArraySize(expected->TimeZone.StandardName));
|
||||
ExpectSystemTimeEqual(&expected->TimeZone.StandardDate,
|
||||
&observed->TimeZone.StandardDate);
|
||||
EXPECT_EQ(observed->TimeZone.StandardBias, expected->TimeZone.StandardBias);
|
||||
@@ -136,7 +136,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_3>(
|
||||
SCOPED_TRACE("Daylight");
|
||||
ExpectNULPaddedString16Equal(expected->TimeZone.DaylightName,
|
||||
observed->TimeZone.DaylightName,
|
||||
arraysize(expected->TimeZone.DaylightName));
|
||||
ArraySize(expected->TimeZone.DaylightName));
|
||||
ExpectSystemTimeEqual(&expected->TimeZone.DaylightDate,
|
||||
&observed->TimeZone.DaylightDate);
|
||||
EXPECT_EQ(observed->TimeZone.DaylightBias, expected->TimeZone.DaylightBias);
|
||||
@@ -154,13 +154,13 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_4>(
|
||||
SCOPED_TRACE("BuildString");
|
||||
ExpectNULPaddedString16Equal(expected->BuildString,
|
||||
observed->BuildString,
|
||||
arraysize(expected->BuildString));
|
||||
ArraySize(expected->BuildString));
|
||||
}
|
||||
{
|
||||
SCOPED_TRACE("DbgBldStr");
|
||||
ExpectNULPaddedString16Equal(expected->DbgBldStr,
|
||||
observed->DbgBldStr,
|
||||
arraysize(expected->DbgBldStr));
|
||||
ArraySize(expected->DbgBldStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void ExpectMiscInfoEqual<MINIDUMP_MISC_INFO_5>(
|
||||
EXPECT_EQ(observed->XStateData.EnabledFeatures,
|
||||
expected->XStateData.EnabledFeatures);
|
||||
for (size_t feature_index = 0;
|
||||
feature_index < arraysize(observed->XStateData.Features);
|
||||
feature_index < ArraySize(observed->XStateData.Features);
|
||||
++feature_index) {
|
||||
SCOPED_TRACE(base::StringPrintf("feature_index %" PRIuS, feature_index));
|
||||
EXPECT_EQ(observed->XStateData.Features[feature_index].Offset,
|
||||
@@ -396,7 +396,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
||||
ArraySize(expected.TimeZone.StandardName));
|
||||
memcpy(&expected.TimeZone.StandardDate,
|
||||
&kStandardDate,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
@@ -404,7 +404,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
||||
ArraySize(expected.TimeZone.DaylightName));
|
||||
memcpy(&expected.TimeZone.DaylightDate,
|
||||
&kDaylightDate,
|
||||
sizeof(expected.TimeZone.DaylightDate));
|
||||
@@ -424,10 +424,9 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
||||
constexpr int32_t kBias = 300;
|
||||
MINIDUMP_MISC_INFO_N tmp;
|
||||
ALLOW_UNUSED_LOCAL(tmp);
|
||||
std::string standard_name(ARRAYSIZE_UNSAFE(tmp.TimeZone.StandardName) + 1,
|
||||
's');
|
||||
std::string standard_name(ArraySize(tmp.TimeZone.StandardName) + 1, 's');
|
||||
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;
|
||||
|
||||
// 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);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
||||
ArraySize(expected.TimeZone.StandardName));
|
||||
memcpy(&expected.TimeZone.StandardDate,
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
@@ -466,7 +465,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
||||
ArraySize(expected.TimeZone.DaylightName));
|
||||
memcpy(&expected.TimeZone.DaylightDate,
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.DaylightDate));
|
||||
@@ -497,12 +496,12 @@ TEST(MinidumpMiscInfoWriter, BuildStrings) {
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
||||
ArraySize(expected.BuildString));
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(kDebugBuildString);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
||||
ArraySize(expected.DbgBldStr));
|
||||
|
||||
ExpectMiscInfoEqual(&expected, observed);
|
||||
}
|
||||
@@ -516,8 +515,8 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
|
||||
|
||||
MINIDUMP_MISC_INFO_N tmp;
|
||||
ALLOW_UNUSED_LOCAL(tmp);
|
||||
std::string build_string(ARRAYSIZE_UNSAFE(tmp.BuildString) + 1, 'B');
|
||||
std::string debug_build_string(ARRAYSIZE_UNSAFE(tmp.DbgBldStr), 'D');
|
||||
std::string build_string(ArraySize(tmp.BuildString) + 1, 'B');
|
||||
std::string debug_build_string(ArraySize(tmp.DbgBldStr), 'D');
|
||||
|
||||
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);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
||||
ArraySize(expected.BuildString));
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(debug_build_string);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
||||
ArraySize(expected.DbgBldStr));
|
||||
|
||||
ExpectMiscInfoEqual(&expected, observed);
|
||||
}
|
||||
@@ -679,7 +678,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.StandardName));
|
||||
ArraySize(expected.TimeZone.StandardName));
|
||||
memcpy(&expected.TimeZone.StandardDate,
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
@@ -687,7 +686,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.TimeZone.DaylightName));
|
||||
ArraySize(expected.TimeZone.DaylightName));
|
||||
memcpy(&expected.TimeZone.DaylightDate,
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.DaylightDate));
|
||||
@@ -695,12 +694,12 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.BuildString));
|
||||
ArraySize(expected.BuildString));
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(kDebugBuildString);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expected.DbgBldStr));
|
||||
ArraySize(expected.DbgBldStr));
|
||||
|
||||
ExpectMiscInfoEqual(&expected, observed);
|
||||
}
|
||||
@@ -744,18 +743,18 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) {
|
||||
expect_misc_info.TimeZone.Bias = 300;
|
||||
c16lcpy(expect_misc_info.TimeZone.StandardName,
|
||||
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;
|
||||
c16lcpy(expect_misc_info.TimeZone.DaylightName,
|
||||
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;
|
||||
c16lcpy(expect_misc_info.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expect_misc_info.BuildString));
|
||||
ArraySize(expect_misc_info.BuildString));
|
||||
c16lcpy(expect_misc_info.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
ARRAYSIZE_UNSAFE(expect_misc_info.DbgBldStr));
|
||||
ArraySize(expect_misc_info.DbgBldStr));
|
||||
|
||||
const timeval kStartTime =
|
||||
{ static_cast<time_t>(expect_misc_info.ProcessCreateTime), 0 };
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "snapshot/test/test_module_snapshot.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -154,9 +155,9 @@ TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
|
||||
sizeof(MinidumpSimpleStringDictionaryEntry) +
|
||||
sizeof(MinidumpAnnotationList) + 2 + // padding
|
||||
sizeof(MinidumpAnnotation) + sizeof(MinidumpUTF8String) +
|
||||
arraysize(kEntry) + 2 + // padding
|
||||
sizeof(MinidumpUTF8String) + arraysize(kKey) +
|
||||
sizeof(MinidumpUTF8String) + arraysize(kValue) +
|
||||
ArraySize(kEntry) + 2 + // padding
|
||||
sizeof(MinidumpUTF8String) + ArraySize(kKey) +
|
||||
sizeof(MinidumpUTF8String) + ArraySize(kValue) +
|
||||
sizeof(MinidumpUTF8String) + annotation.name.size() + 1 +
|
||||
sizeof(MinidumpByteArray) + annotation.value.size());
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "snapshot/test/test_module_snapshot.h"
|
||||
#include "test/gtest_death.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
#include "util/misc/uuid.h"
|
||||
|
||||
@@ -650,10 +651,10 @@ void InitializeTestModuleSnapshotFromMinidumpModule(
|
||||
|
||||
TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
||||
MINIDUMP_MODULE expect_modules[3] = {};
|
||||
const char* module_paths[arraysize(expect_modules)] = {};
|
||||
const char* module_pdbs[arraysize(expect_modules)] = {};
|
||||
UUID uuids[arraysize(expect_modules)] = {};
|
||||
uint32_t ages[arraysize(expect_modules)] = {};
|
||||
const char* module_paths[ArraySize(expect_modules)] = {};
|
||||
const char* module_pdbs[ArraySize(expect_modules)] = {};
|
||||
UUID uuids[ArraySize(expect_modules)] = {};
|
||||
uint32_t ages[ArraySize(expect_modules)] = {};
|
||||
|
||||
expect_modules[0].BaseOfImage = 0x100101000;
|
||||
expect_modules[0].SizeOfImage = 0xf000;
|
||||
@@ -705,7 +706,7 @@ TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
||||
|
||||
std::vector<std::unique_ptr<TestModuleSnapshot>> module_snapshots_owner;
|
||||
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>());
|
||||
TestModuleSnapshot* module_snapshot = module_snapshots_owner.back().get();
|
||||
InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "minidump/test/minidump_rva_list_test_util.h"
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -86,10 +87,10 @@ TEST(MinidumpRVAListWriter, ThreeChildren) {
|
||||
ASSERT_TRUE(list_writer.WriteEverything(&string_file));
|
||||
|
||||
const MinidumpRVAList* list =
|
||||
MinidumpRVAListAtStart(string_file.string(), arraysize(kValues));
|
||||
MinidumpRVAListAtStart(string_file.string(), ArraySize(kValues));
|
||||
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));
|
||||
|
||||
const uint32_t* child = MinidumpWritableAtRVA<uint32_t>(
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "minidump/test/minidump_string_writer_test_util.h"
|
||||
#include "minidump/test/minidump_writable_test_util.h"
|
||||
#include "util/file/string_file.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
@@ -66,14 +67,14 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
||||
{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(
|
||||
"index %" PRIuS ", input %s", index, kTestData[index].input_string));
|
||||
|
||||
// Make sure that the expected output string with its NUL terminator fits in
|
||||
// the space provided.
|
||||
ASSERT_EQ(kTestData[index]
|
||||
.output_string[arraysize(kTestData[index].output_string) - 1],
|
||||
.output_string[ArraySize(kTestData[index].output_string) - 1],
|
||||
0);
|
||||
|
||||
string_file.Reset();
|
||||
@@ -118,7 +119,7 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
|
||||
"\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(
|
||||
"index %" PRIuS ", input %s", index, kTestData[index]));
|
||||
string_file.Reset();
|
||||
@@ -181,7 +182,7 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
|
||||
{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(
|
||||
"index %" PRIuS ", input %s", index, kTestData[index].string));
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "minidump/minidump_string_writer.h"
|
||||
#include "snapshot/system_snapshot.h"
|
||||
#include "util/file/file_writer.h"
|
||||
#include "util/misc/arraysize_unsafe.h"
|
||||
#include "util/misc/arraysize.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
namespace crashpad {
|
||||
@@ -212,7 +212,7 @@ void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx,
|
||||
system_info_.ProcessorArchitecture ==
|
||||
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");
|
||||
|
||||
system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx;
|
||||
@@ -230,7 +230,7 @@ void MinidumpSystemInfoWriter::SetCPUX86VendorString(
|
||||
sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId),
|
||||
"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],
|
||||
&vendor[index * sizeof(*registers)],
|
||||
sizeof(*registers));
|
||||
@@ -270,9 +270,8 @@ void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0,
|
||||
system_info_.ProcessorArchitecture !=
|
||||
kMinidumpCPUArchitectureX86Win64);
|
||||
|
||||
static_assert(
|
||||
ARRAYSIZE_UNSAFE(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2,
|
||||
"ProcessorFeatures must have 2 elements");
|
||||
static_assert(ArraySize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2,
|
||||
"ProcessorFeatures must have 2 elements");
|
||||
|
||||
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0;
|
||||
system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user