mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Use constexpr at function scope
This is essentially based on a search for “^ *const [^*&]*=[^(]*$” Change-Id: Id571119d0b9a64c6f387eccd51cea7c9eb530e13 Reviewed-on: https://chromium-review.googlesource.com/585555 Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
This commit is contained in:
parent
7e6a0145b1
commit
6dac7ecdf5
@ -284,8 +284,8 @@ class HandlerStarter final : public NotifyServer::DefaultInterface {
|
||||
|
||||
if (restart) {
|
||||
// If the handler was ever started before, don’t restart it too quickly.
|
||||
const uint64_t kNanosecondsPerSecond = 1E9;
|
||||
const uint64_t kMinimumStartInterval = 1 * kNanosecondsPerSecond;
|
||||
constexpr uint64_t kNanosecondsPerSecond = 1E9;
|
||||
constexpr uint64_t kMinimumStartInterval = 1 * kNanosecondsPerSecond;
|
||||
|
||||
const uint64_t earliest_next_start_time =
|
||||
handler_restarter->last_start_time_ + kMinimumStartInterval;
|
||||
|
@ -164,7 +164,7 @@ LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* exception_pointers) {
|
||||
SetEvent(g_signal_exception);
|
||||
|
||||
// Time to wait for the handler to create a dump.
|
||||
const DWORD kMillisecondsUntilTerminate = 60 * 1000;
|
||||
constexpr DWORD kMillisecondsUntilTerminate = 60 * 1000;
|
||||
|
||||
// Sleep for a while to allow it to process us. Eventually, we terminate
|
||||
// ourselves in case the crash server is gone, so that we don't leave zombies
|
||||
@ -753,7 +753,7 @@ void CrashpadClient::DumpWithoutCrash(const CONTEXT& context) {
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363082.aspx have
|
||||
// some of the top nibble set, so we make sure to pick a value that doesn't,
|
||||
// so as to be unlikely to conflict.
|
||||
const uint32_t kSimulatedExceptionCode = 0x517a7ed;
|
||||
constexpr uint32_t kSimulatedExceptionCode = 0x517a7ed;
|
||||
EXCEPTION_RECORD record = {};
|
||||
record.ExceptionCode = kSimulatedExceptionCode;
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
@ -829,7 +829,7 @@ bool CrashpadClient::DumpAndCrashTargetProcess(HANDLE process,
|
||||
}
|
||||
}
|
||||
|
||||
const size_t kInjectBufferSize = 4 * 1024;
|
||||
constexpr size_t kInjectBufferSize = 4 * 1024;
|
||||
WinVMAddress inject_memory =
|
||||
FromPointerCast<WinVMAddress>(VirtualAllocEx(process,
|
||||
nullptr,
|
||||
@ -1001,7 +1001,10 @@ bool CrashpadClient::DumpAndCrashTargetProcess(HANDLE process,
|
||||
// letting this cause an exception, even when the target is stuck in the
|
||||
// loader lock.
|
||||
HANDLE injected_thread;
|
||||
const size_t kStackSize = 0x4000; // This is what DebugBreakProcess() uses.
|
||||
|
||||
// This is what DebugBreakProcess() uses.
|
||||
constexpr size_t kStackSize = 0x4000;
|
||||
|
||||
NTSTATUS status = NtCreateThreadEx(&injected_thread,
|
||||
STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL,
|
||||
nullptr,
|
||||
|
@ -121,8 +121,8 @@ TEST(SimpleStringDictionary, Iterator) {
|
||||
char key[SimpleStringDictionary::key_size];
|
||||
char value[SimpleStringDictionary::value_size];
|
||||
|
||||
const int kDictionaryCapacity = SimpleStringDictionary::num_entries;
|
||||
const int kPartitionIndex = kDictionaryCapacity - 5;
|
||||
constexpr int kDictionaryCapacity = SimpleStringDictionary::num_entries;
|
||||
constexpr int kPartitionIndex = kDictionaryCapacity - 5;
|
||||
|
||||
// We assume at least this size in the tests below
|
||||
ASSERT_GE(kDictionaryCapacity, 64);
|
||||
|
@ -268,7 +268,7 @@ void CrashReportUploadThread::ProcessPendingReport(
|
||||
// If the most recent upload attempt occurred within the past hour,
|
||||
// don’t attempt to upload the new report. If it happened longer ago,
|
||||
// attempt to upload the report.
|
||||
const int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour
|
||||
constexpr int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour
|
||||
if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) {
|
||||
database_->SkipReportUpload(
|
||||
report.uuid, Metrics::CrashSkippedReason::kUploadThrottled);
|
||||
@ -280,7 +280,7 @@ void CrashReportUploadThread::ProcessPendingReport(
|
||||
// upload attempt time is bogus, and attempt to upload the report. If
|
||||
// the most recent upload time is in the future but within one day,
|
||||
// accept it and don’t attempt to upload the report.
|
||||
const int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day
|
||||
constexpr int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day
|
||||
if (last_upload_attempt_time - now < kBackwardsClockTolerance) {
|
||||
database_->SkipReportUpload(
|
||||
report.uuid, Metrics::CrashSkippedReason::kUnexpectedTime);
|
||||
|
@ -715,7 +715,7 @@ int HandlerMain(int argc,
|
||||
base::GlobalHistogramAllocator* histogram_allocator = nullptr;
|
||||
if (!options.metrics_dir.empty()) {
|
||||
static constexpr char kMetricsName[] = "CrashpadMetrics";
|
||||
const size_t kMetricsFileSize = 1 << 20;
|
||||
constexpr size_t kMetricsFileSize = 1 << 20;
|
||||
if (base::GlobalHistogramAllocator::CreateWithActiveFileInDir(
|
||||
options.metrics_dir, kMetricsFileSize, 0, kMetricsName)) {
|
||||
histogram_allocator = base::GlobalHistogramAllocator::Get();
|
||||
|
@ -142,7 +142,7 @@ void SomeCrashyFunction() {
|
||||
|
||||
void AllocateExtraMemoryToBeSaved(
|
||||
crashpad::SimpleAddressRangeBag* extra_ranges) {
|
||||
const size_t kNumInts = 2000;
|
||||
constexpr size_t kNumInts = 2000;
|
||||
int* extra_memory = new int[kNumInts];
|
||||
g_extra_memory_pointer = extra_memory;
|
||||
for (int i = 0; i < kNumInts; ++i)
|
||||
@ -154,7 +154,7 @@ void AllocateExtraMemoryToBeSaved(
|
||||
void AllocateExtraUnsavedMemory(crashpad::SimpleAddressRangeBag* extra_ranges) {
|
||||
// Allocate some extra memory, and then Insert() but also Remove() it so we
|
||||
// can confirm it doesn't get saved.
|
||||
const size_t kNumInts = 2000;
|
||||
constexpr size_t kNumInts = 2000;
|
||||
int* extra_memory = new int[kNumInts];
|
||||
g_extra_memory_not_saved = extra_memory;
|
||||
for (int i = 0; i < kNumInts; ++i)
|
||||
@ -211,7 +211,7 @@ int CrashyMain(int argc, wchar_t* argv[]) {
|
||||
FreeLibrary(wmerror);
|
||||
|
||||
// Make sure data pointed to by the stack is captured.
|
||||
const int kDataSize = 512;
|
||||
constexpr int kDataSize = 512;
|
||||
int* pointed_to_data = new int[kDataSize];
|
||||
for (int i = 0; i < kDataSize; ++i)
|
||||
pointed_to_data[i] = i | ((i % 2 == 0) ? 0x80000000 : 0);
|
||||
|
@ -52,7 +52,7 @@ TEST(MinidumpContextWriter, MinidumpContextX86Writer) {
|
||||
SCOPED_TRACE("nonzero");
|
||||
|
||||
string_file.Reset();
|
||||
const uint32_t kSeed = 0x8086;
|
||||
constexpr uint32_t kSeed = 0x8086;
|
||||
|
||||
MinidumpContextX86Writer context_writer;
|
||||
InitializeMinidumpContextX86(context_writer.context(), kSeed);
|
||||
@ -92,7 +92,7 @@ TEST(MinidumpContextWriter, MinidumpContextAMD64Writer) {
|
||||
SCOPED_TRACE("nonzero");
|
||||
|
||||
string_file.Reset();
|
||||
const uint32_t kSeed = 0x808664;
|
||||
constexpr uint32_t kSeed = 0x808664;
|
||||
|
||||
MinidumpContextAMD64Writer context_writer;
|
||||
InitializeMinidumpContextAMD64(context_writer.context(), kSeed);
|
||||
@ -109,7 +109,7 @@ TEST(MinidumpContextWriter, MinidumpContextAMD64Writer) {
|
||||
}
|
||||
|
||||
TEST(MinidumpContextWriter, CreateFromSnapshot_X86) {
|
||||
const uint32_t kSeed = 32;
|
||||
constexpr uint32_t kSeed = 32;
|
||||
|
||||
CPUContextX86 context_snapshot_x86;
|
||||
CPUContext context_snapshot;
|
||||
@ -131,7 +131,7 @@ TEST(MinidumpContextWriter, CreateFromSnapshot_X86) {
|
||||
}
|
||||
|
||||
TEST(MinidumpContextWriter, CreateFromSnapshot_AMD64) {
|
||||
const uint32_t kSeed = 64;
|
||||
constexpr uint32_t kSeed = 64;
|
||||
|
||||
CPUContextX86_64 context_snapshot_x86_64;
|
||||
CPUContext context_snapshot;
|
||||
|
@ -174,7 +174,7 @@ TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) {
|
||||
}
|
||||
|
||||
TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) {
|
||||
const uint32_t kMinidumpModuleListIndex = 3;
|
||||
constexpr uint32_t kMinidumpModuleListIndex = 3;
|
||||
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto crashpad_info_writer =
|
||||
|
@ -64,7 +64,7 @@ void MinidumpExceptionWriter::SetExceptionInformation(
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
|
||||
const size_t parameters = exception_information.size();
|
||||
const size_t kMaxParameters =
|
||||
constexpr size_t kMaxParameters =
|
||||
ARRAYSIZE_UNSAFE(exception_.ExceptionRecord.ExceptionInformation);
|
||||
CHECK_LE(parameters, kMaxParameters);
|
||||
|
||||
|
@ -39,12 +39,12 @@ namespace {
|
||||
// This returns the MINIDUMP_EXCEPTION_STREAM stream in |exception_stream|.
|
||||
void GetExceptionStream(const std::string& file_contents,
|
||||
const MINIDUMP_EXCEPTION_STREAM** exception_stream) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kExceptionStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kExceptionStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kContextOffset =
|
||||
constexpr size_t kContextOffset =
|
||||
kExceptionStreamOffset + sizeof(MINIDUMP_EXCEPTION_STREAM);
|
||||
const size_t kFileSize = kContextOffset + sizeof(MinidumpContextX86);
|
||||
constexpr size_t kFileSize = kContextOffset + sizeof(MinidumpContextX86);
|
||||
ASSERT_EQ(kFileSize, file_contents.size());
|
||||
|
||||
const MINIDUMP_DIRECTORY* directory;
|
||||
@ -96,7 +96,7 @@ TEST(MinidumpExceptionWriter, Minimal) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
|
||||
|
||||
const uint32_t kSeed = 100;
|
||||
constexpr uint32_t kSeed = 100;
|
||||
|
||||
auto context_x86_writer = base::WrapUnique(new MinidumpContextX86Writer());
|
||||
InitializeMinidumpContextX86(context_x86_writer->context(), kSeed);
|
||||
@ -128,15 +128,15 @@ TEST(MinidumpExceptionWriter, Standard) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
|
||||
|
||||
const uint32_t kSeed = 200;
|
||||
const uint32_t kThreadID = 1;
|
||||
const uint32_t kExceptionCode = 2;
|
||||
const uint32_t kExceptionFlags = 3;
|
||||
const uint32_t kExceptionRecord = 4;
|
||||
const uint32_t kExceptionAddress = 5;
|
||||
const uint64_t kExceptionInformation0 = 6;
|
||||
const uint64_t kExceptionInformation1 = 7;
|
||||
const uint64_t kExceptionInformation2 = 7;
|
||||
constexpr uint32_t kSeed = 200;
|
||||
constexpr uint32_t kThreadID = 1;
|
||||
constexpr uint32_t kExceptionCode = 2;
|
||||
constexpr uint32_t kExceptionFlags = 3;
|
||||
constexpr uint32_t kExceptionRecord = 4;
|
||||
constexpr uint32_t kExceptionAddress = 5;
|
||||
constexpr uint64_t kExceptionInformation0 = 6;
|
||||
constexpr uint64_t kExceptionInformation1 = 7;
|
||||
constexpr uint64_t kExceptionInformation2 = 7;
|
||||
|
||||
auto context_x86_writer = base::WrapUnique(new MinidumpContextX86Writer());
|
||||
InitializeMinidumpContextX86(context_x86_writer->context(), kSeed);
|
||||
@ -212,8 +212,8 @@ TEST(MinidumpExceptionWriter, InitializeFromSnapshot) {
|
||||
expect_exception.ExceptionRecord.ExceptionInformation[index] =
|
||||
exception_codes[index];
|
||||
}
|
||||
const uint64_t kThreadID = 0xaaaaaaaaaaaaaaaa;
|
||||
const uint32_t kSeed = 65;
|
||||
constexpr uint64_t kThreadID = 0xaaaaaaaaaaaaaaaa;
|
||||
constexpr uint32_t kSeed = 65;
|
||||
|
||||
TestExceptionSnapshot exception_snapshot;
|
||||
exception_snapshot.SetThreadID(kThreadID);
|
||||
|
@ -92,12 +92,13 @@ class TestStream final : public internal::MinidumpStreamWriter {
|
||||
|
||||
TEST(MinidumpFileWriter, OneStream) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
const time_t kTimestamp = 0x155d2fb8;
|
||||
constexpr time_t kTimestamp = 0x155d2fb8;
|
||||
minidump_file.SetTimestamp(kTimestamp);
|
||||
|
||||
const size_t kStreamSize = 5;
|
||||
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
|
||||
const uint8_t kStreamValue = 0x5a;
|
||||
constexpr size_t kStreamSize = 5;
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr uint8_t kStreamValue = 0x5a;
|
||||
auto stream =
|
||||
base::WrapUnique(new TestStream(kStreamType, kStreamSize, kStreamValue));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
|
||||
@ -105,9 +106,10 @@ TEST(MinidumpFileWriter, OneStream) {
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
@ -131,12 +133,13 @@ TEST(MinidumpFileWriter, OneStream) {
|
||||
|
||||
TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
const time_t kTimestamp = 0x155d2fb8;
|
||||
constexpr time_t kTimestamp = 0x155d2fb8;
|
||||
minidump_file.SetTimestamp(kTimestamp);
|
||||
|
||||
static constexpr uint8_t kStreamData[] = "Hello World!";
|
||||
const size_t kStreamSize = arraysize(kStreamData);
|
||||
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr size_t kStreamSize = arraysize(kStreamData);
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
|
||||
auto data_source = base::WrapUnique(new test::BufferExtensionStreamDataSource(
|
||||
kStreamType, kStreamData, kStreamSize));
|
||||
@ -150,9 +153,10 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
@ -175,10 +179,11 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
||||
|
||||
TEST(MinidumpFileWriter, AddEmptyUserExtensionStream) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
const time_t kTimestamp = 0x155d2fb8;
|
||||
constexpr time_t kTimestamp = 0x155d2fb8;
|
||||
minidump_file.SetTimestamp(kTimestamp);
|
||||
|
||||
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
|
||||
auto data_source = base::WrapUnique(
|
||||
new test::BufferExtensionStreamDataSource(kStreamType, nullptr, 0));
|
||||
@ -187,9 +192,10 @@ TEST(MinidumpFileWriter, AddEmptyUserExtensionStream) {
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kFileSize = kStreamOffset;
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
constexpr size_t kFileSize = kStreamOffset;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
@ -206,12 +212,13 @@ TEST(MinidumpFileWriter, AddEmptyUserExtensionStream) {
|
||||
|
||||
TEST(MinidumpFileWriter, ThreeStreams) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
const time_t kTimestamp = 0x155d2fb8;
|
||||
constexpr time_t kTimestamp = 0x155d2fb8;
|
||||
minidump_file.SetTimestamp(kTimestamp);
|
||||
|
||||
const size_t kStream0Size = 5;
|
||||
const MinidumpStreamType kStream0Type = static_cast<MinidumpStreamType>(0x6d);
|
||||
const uint8_t kStream0Value = 0x5a;
|
||||
constexpr size_t kStream0Size = 5;
|
||||
constexpr MinidumpStreamType kStream0Type =
|
||||
static_cast<MinidumpStreamType>(0x6d);
|
||||
constexpr uint8_t kStream0Value = 0x5a;
|
||||
auto stream0 = base::WrapUnique(
|
||||
new TestStream(kStream0Type, kStream0Size, kStream0Value));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
|
||||
@ -219,16 +226,18 @@ TEST(MinidumpFileWriter, ThreeStreams) {
|
||||
// Make the second stream’s type be a smaller quantity than the first stream’s
|
||||
// to test that the streams show up in the order that they were added, not in
|
||||
// numeric order.
|
||||
const size_t kStream1Size = 3;
|
||||
const MinidumpStreamType kStream1Type = static_cast<MinidumpStreamType>(0x4d);
|
||||
const uint8_t kStream1Value = 0xa5;
|
||||
constexpr size_t kStream1Size = 3;
|
||||
constexpr MinidumpStreamType kStream1Type =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr uint8_t kStream1Value = 0xa5;
|
||||
auto stream1 = base::WrapUnique(
|
||||
new TestStream(kStream1Type, kStream1Size, kStream1Value));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream1)));
|
||||
|
||||
const size_t kStream2Size = 1;
|
||||
const MinidumpStreamType kStream2Type = static_cast<MinidumpStreamType>(0x7e);
|
||||
const uint8_t kStream2Value = 0x36;
|
||||
constexpr size_t kStream2Size = 1;
|
||||
constexpr MinidumpStreamType kStream2Type =
|
||||
static_cast<MinidumpStreamType>(0x7e);
|
||||
constexpr uint8_t kStream2Value = 0x36;
|
||||
auto stream2 = base::WrapUnique(
|
||||
new TestStream(kStream2Type, kStream2Size, kStream2Value));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream2)));
|
||||
@ -236,14 +245,16 @@ TEST(MinidumpFileWriter, ThreeStreams) {
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStream0Offset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStream0Offset =
|
||||
kDirectoryOffset + 3 * sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kStream1Padding = 3;
|
||||
const size_t kStream1Offset = kStream0Offset + kStream0Size + kStream1Padding;
|
||||
const size_t kStream2Padding = 1;
|
||||
const size_t kStream2Offset = kStream1Offset + kStream1Size + kStream2Padding;
|
||||
const size_t kFileSize = kStream2Offset + kStream2Size;
|
||||
constexpr size_t kStream1Padding = 3;
|
||||
constexpr size_t kStream1Offset =
|
||||
kStream0Offset + kStream0Size + kStream1Padding;
|
||||
constexpr size_t kStream2Padding = 1;
|
||||
constexpr size_t kStream2Offset =
|
||||
kStream1Offset + kStream1Size + kStream2Padding;
|
||||
constexpr size_t kFileSize = kStream2Offset + kStream2Size;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
@ -295,17 +306,19 @@ TEST(MinidumpFileWriter, ThreeStreams) {
|
||||
TEST(MinidumpFileWriter, ZeroLengthStream) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
|
||||
const size_t kStreamSize = 0;
|
||||
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr size_t kStreamSize = 0;
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
auto stream = base::WrapUnique(new TestStream(kStreamType, kStreamSize, 0));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
|
||||
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
@ -321,8 +334,8 @@ TEST(MinidumpFileWriter, ZeroLengthStream) {
|
||||
}
|
||||
|
||||
TEST(MinidumpFileWriter, InitializeFromSnapshot_Basic) {
|
||||
const uint32_t kSnapshotTime = 0x4976043c;
|
||||
const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
|
||||
constexpr uint32_t kSnapshotTime = 0x4976043c;
|
||||
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
|
||||
|
||||
TestProcessSnapshot process_snapshot;
|
||||
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
||||
@ -333,9 +346,9 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Basic) {
|
||||
process_snapshot.SetSystem(std::move(system_snapshot));
|
||||
|
||||
auto peb_snapshot = base::WrapUnique(new TestMemorySnapshot());
|
||||
const uint64_t kPebAddress = 0x07f90000;
|
||||
constexpr uint64_t kPebAddress = 0x07f90000;
|
||||
peb_snapshot->SetAddress(kPebAddress);
|
||||
const size_t kPebSize = 0x280;
|
||||
constexpr size_t kPebSize = 0x280;
|
||||
peb_snapshot->SetSize(kPebSize);
|
||||
peb_snapshot->SetValue('p');
|
||||
process_snapshot.AddExtraMemory(std::move(peb_snapshot));
|
||||
@ -383,10 +396,10 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Basic) {
|
||||
TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
|
||||
// In a 32-bit environment, this will give a “timestamp out of range” warning,
|
||||
// but the test should complete without failure.
|
||||
const uint32_t kSnapshotTime = 0xfd469ab8;
|
||||
constexpr uint32_t kSnapshotTime = 0xfd469ab8;
|
||||
MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value.
|
||||
MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion.
|
||||
const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
|
||||
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
|
||||
|
||||
TestProcessSnapshot process_snapshot;
|
||||
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
||||
@ -449,8 +462,8 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
|
||||
}
|
||||
|
||||
TEST(MinidumpFileWriter, InitializeFromSnapshot_CrashpadInfo) {
|
||||
const uint32_t kSnapshotTime = 0x15393bd3;
|
||||
const timeval kSnapshotTimeval = { static_cast<time_t>(kSnapshotTime), 0 };
|
||||
constexpr uint32_t kSnapshotTime = 0x15393bd3;
|
||||
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
|
||||
|
||||
TestProcessSnapshot process_snapshot;
|
||||
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
||||
@ -519,16 +532,17 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_CrashpadInfo) {
|
||||
TEST(MinidumpFileWriter, SameStreamType) {
|
||||
MinidumpFileWriter minidump_file;
|
||||
|
||||
const size_t kStream0Size = 3;
|
||||
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
|
||||
const uint8_t kStream0Value = 0x5a;
|
||||
constexpr size_t kStream0Size = 3;
|
||||
constexpr MinidumpStreamType kStreamType =
|
||||
static_cast<MinidumpStreamType>(0x4d);
|
||||
constexpr uint8_t kStream0Value = 0x5a;
|
||||
auto stream0 = base::WrapUnique(
|
||||
new TestStream(kStreamType, kStream0Size, kStream0Value));
|
||||
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
|
||||
|
||||
// An attempt to add a second stream of the same type should fail.
|
||||
const size_t kStream1Size = 5;
|
||||
const uint8_t kStream1Value = 0xa5;
|
||||
constexpr size_t kStream1Size = 5;
|
||||
constexpr uint8_t kStream1Value = 0xa5;
|
||||
auto stream1 = base::WrapUnique(
|
||||
new TestStream(kStreamType, kStream1Size, kStream1Value));
|
||||
ASSERT_FALSE(minidump_file.AddStream(std::move(stream1)));
|
||||
@ -536,9 +550,10 @@ TEST(MinidumpFileWriter, SameStreamType) {
|
||||
StringFile string_file;
|
||||
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kStream0Offset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kFileSize = kStream0Offset + kStream0Size;
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kStream0Offset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
constexpr size_t kFileSize = kStream0Offset + kStream0Size;
|
||||
|
||||
ASSERT_EQ(string_file.string().size(), kFileSize);
|
||||
|
||||
|
@ -34,8 +34,8 @@ namespace {
|
||||
void GetHandleDataStream(
|
||||
const std::string& file_contents,
|
||||
const MINIDUMP_HANDLE_DATA_STREAM** handle_data_stream) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kHandleDataStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kHandleDataStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
|
||||
const MINIDUMP_DIRECTORY* directory;
|
||||
@ -44,7 +44,7 @@ void GetHandleDataStream(
|
||||
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
||||
ASSERT_TRUE(directory);
|
||||
|
||||
const size_t kDirectoryIndex = 0;
|
||||
constexpr size_t kDirectoryIndex = 0;
|
||||
|
||||
ASSERT_EQ(directory[kDirectoryIndex].StreamType,
|
||||
kMinidumpStreamTypeHandleData);
|
||||
|
@ -33,8 +33,8 @@ namespace {
|
||||
void GetMemoryInfoListStream(
|
||||
const std::string& file_contents,
|
||||
const MINIDUMP_MEMORY_INFO_LIST** memory_info_list) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kMemoryInfoListStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kMemoryInfoListStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
|
||||
const MINIDUMP_DIRECTORY* directory;
|
||||
@ -43,7 +43,7 @@ void GetMemoryInfoListStream(
|
||||
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
||||
ASSERT_TRUE(directory);
|
||||
|
||||
const size_t kDirectoryIndex = 0;
|
||||
constexpr size_t kDirectoryIndex = 0;
|
||||
|
||||
ASSERT_EQ(directory[kDirectoryIndex].StreamType,
|
||||
kMinidumpStreamTypeMemoryInfoList);
|
||||
|
@ -44,7 +44,7 @@ const MinidumpStreamType kBogusStreamType =
|
||||
void GetMemoryListStream(const std::string& file_contents,
|
||||
const MINIDUMP_MEMORY_LIST** memory_list,
|
||||
const uint32_t expected_streams) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kMemoryListStreamOffset =
|
||||
kDirectoryOffset + expected_streams * sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kMemoryDescriptorsOffset =
|
||||
@ -99,9 +99,9 @@ TEST(MinidumpMemoryWriter, OneMemoryRegion) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter());
|
||||
|
||||
const uint64_t kBaseAddress = 0xfedcba9876543210;
|
||||
const uint64_t kSize = 0x1000;
|
||||
const uint8_t kValue = 'm';
|
||||
constexpr uint64_t kBaseAddress = 0xfedcba9876543210;
|
||||
constexpr uint64_t kSize = 0x1000;
|
||||
constexpr uint8_t kValue = 'm';
|
||||
|
||||
auto memory_writer = base::WrapUnique(
|
||||
new TestMinidumpMemoryWriter(kBaseAddress, kSize, kValue));
|
||||
@ -134,12 +134,12 @@ TEST(MinidumpMemoryWriter, TwoMemoryRegions) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter());
|
||||
|
||||
const uint64_t kBaseAddress0 = 0xc0ffee;
|
||||
const uint64_t kSize0 = 0x0100;
|
||||
const uint8_t kValue0 = '6';
|
||||
const uint64_t kBaseAddress1 = 0xfac00fac;
|
||||
const uint64_t kSize1 = 0x0200;
|
||||
const uint8_t kValue1 = '!';
|
||||
constexpr uint64_t kBaseAddress0 = 0xc0ffee;
|
||||
constexpr uint64_t kSize0 = 0x0100;
|
||||
constexpr uint8_t kValue0 = '6';
|
||||
constexpr uint64_t kBaseAddress1 = 0xfac00fac;
|
||||
constexpr uint64_t kSize1 = 0x0200;
|
||||
constexpr uint8_t kValue1 = '!';
|
||||
|
||||
auto memory_writer_0 = base::WrapUnique(
|
||||
new TestMinidumpMemoryWriter(kBaseAddress0, kSize0, kValue0));
|
||||
@ -238,9 +238,9 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
|
||||
// memory writer a child of the memory list writer.
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
|
||||
const uint64_t kBaseAddress0 = 0x1000;
|
||||
const size_t kSize0 = 0x0400;
|
||||
const uint8_t kValue0 = '1';
|
||||
constexpr uint64_t kBaseAddress0 = 0x1000;
|
||||
constexpr size_t kSize0 = 0x0400;
|
||||
constexpr uint8_t kValue0 = '1';
|
||||
auto test_memory_stream =
|
||||
base::WrapUnique(new TestMemoryStream(kBaseAddress0, kSize0, kValue0));
|
||||
|
||||
@ -249,9 +249,9 @@ TEST(MinidumpMemoryWriter, ExtraMemory) {
|
||||
|
||||
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(test_memory_stream)));
|
||||
|
||||
const uint64_t kBaseAddress1 = 0x2000;
|
||||
const size_t kSize1 = 0x0400;
|
||||
const uint8_t kValue1 = 'm';
|
||||
constexpr uint64_t kBaseAddress1 = 0x2000;
|
||||
constexpr size_t kSize1 = 0x0400;
|
||||
constexpr uint8_t kValue1 = 'm';
|
||||
|
||||
auto memory_writer = base::WrapUnique(
|
||||
new TestMinidumpMemoryWriter(kBaseAddress1, kSize1, kValue1));
|
||||
|
@ -42,7 +42,7 @@ namespace {
|
||||
uint32_t TimevalToRoundedSeconds(const timeval& tv) {
|
||||
uint32_t seconds =
|
||||
InRangeCast<uint32_t>(tv.tv_sec, std::numeric_limits<uint32_t>::max());
|
||||
const int kMicrosecondsPerSecond = static_cast<int>(1E6);
|
||||
constexpr int kMicrosecondsPerSecond = static_cast<int>(1E6);
|
||||
if (tv.tv_usec >= kMicrosecondsPerSecond / 2 &&
|
||||
seconds != std::numeric_limits<uint32_t>::max()) {
|
||||
++seconds;
|
||||
@ -163,7 +163,7 @@ void MinidumpMiscInfoWriter::InitializeFromSnapshot(
|
||||
uint64_t current_hz;
|
||||
uint64_t max_hz;
|
||||
system_snapshot->CPUFrequency(¤t_hz, &max_hz);
|
||||
const uint32_t kHzPerMHz = static_cast<const uint32_t>(1E6);
|
||||
constexpr uint32_t kHzPerMHz = static_cast<const uint32_t>(1E6);
|
||||
SetProcessorPowerInfo(
|
||||
InRangeCast<uint32_t>(current_hz / kHzPerMHz,
|
||||
std::numeric_limits<uint32_t>::max()),
|
||||
|
@ -43,11 +43,11 @@ namespace {
|
||||
|
||||
template <typename T>
|
||||
void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kMiscInfoStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kMiscInfoStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kMiscInfoStreamSize = sizeof(T);
|
||||
const size_t kFileSize = kMiscInfoStreamOffset + kMiscInfoStreamSize;
|
||||
constexpr size_t kMiscInfoStreamSize = sizeof(T);
|
||||
constexpr size_t kFileSize = kMiscInfoStreamOffset + kMiscInfoStreamSize;
|
||||
|
||||
ASSERT_EQ(file_contents.size(), kFileSize);
|
||||
|
||||
@ -211,7 +211,7 @@ TEST(MinidumpMiscInfoWriter, ProcessId) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessId = 12345;
|
||||
constexpr uint32_t kProcessId = 12345;
|
||||
|
||||
misc_info_writer->SetProcessID(kProcessId);
|
||||
|
||||
@ -234,9 +234,9 @@ TEST(MinidumpMiscInfoWriter, ProcessTimes) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const time_t kProcessCreateTime = 0x15252f00;
|
||||
const uint32_t kProcessUserTime = 10;
|
||||
const uint32_t kProcessKernelTime = 5;
|
||||
constexpr time_t kProcessCreateTime = 0x15252f00;
|
||||
constexpr uint32_t kProcessUserTime = 10;
|
||||
constexpr uint32_t kProcessKernelTime = 5;
|
||||
|
||||
misc_info_writer->SetProcessTimes(
|
||||
kProcessCreateTime, kProcessUserTime, kProcessKernelTime);
|
||||
@ -262,11 +262,11 @@ TEST(MinidumpMiscInfoWriter, ProcessorPowerInfo) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessorMaxMhz = 2800;
|
||||
const uint32_t kProcessorCurrentMhz = 2300;
|
||||
const uint32_t kProcessorMhzLimit = 3300;
|
||||
const uint32_t kProcessorMaxIdleState = 5;
|
||||
const uint32_t kProcessorCurrentIdleState = 1;
|
||||
constexpr uint32_t kProcessorMaxMhz = 2800;
|
||||
constexpr uint32_t kProcessorCurrentMhz = 2300;
|
||||
constexpr uint32_t kProcessorMhzLimit = 3300;
|
||||
constexpr uint32_t kProcessorMaxIdleState = 5;
|
||||
constexpr uint32_t kProcessorCurrentIdleState = 1;
|
||||
|
||||
misc_info_writer->SetProcessorPowerInfo(kProcessorMaxMhz,
|
||||
kProcessorCurrentMhz,
|
||||
@ -297,7 +297,7 @@ TEST(MinidumpMiscInfoWriter, ProcessIntegrityLevel) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessIntegrityLevel = 0x2000;
|
||||
constexpr uint32_t kProcessIntegrityLevel = 0x2000;
|
||||
|
||||
misc_info_writer->SetProcessIntegrityLevel(kProcessIntegrityLevel);
|
||||
|
||||
@ -320,7 +320,7 @@ TEST(MinidumpMiscInfoWriter, ProcessExecuteFlags) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessExecuteFlags = 0x13579bdf;
|
||||
constexpr uint32_t kProcessExecuteFlags = 0x13579bdf;
|
||||
|
||||
misc_info_writer->SetProcessExecuteFlags(kProcessExecuteFlags);
|
||||
|
||||
@ -343,7 +343,7 @@ TEST(MinidumpMiscInfoWriter, ProtectedProcess) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProtectedProcess = 1;
|
||||
constexpr uint32_t kProtectedProcess = 1;
|
||||
|
||||
misc_info_writer->SetProtectedProcess(kProtectedProcess);
|
||||
|
||||
@ -366,14 +366,14 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kTimeZoneId = 2;
|
||||
const int32_t kBias = 300;
|
||||
constexpr uint32_t kTimeZoneId = 2;
|
||||
constexpr int32_t kBias = 300;
|
||||
static constexpr char kStandardName[] = "EST";
|
||||
const SYSTEMTIME kStandardDate = {0, 11, 1, 0, 2, 0, 0, 0};
|
||||
const int32_t kStandardBias = 0;
|
||||
constexpr SYSTEMTIME kStandardDate = {0, 11, 1, 0, 2, 0, 0, 0};
|
||||
constexpr int32_t kStandardBias = 0;
|
||||
static constexpr char kDaylightName[] = "EDT";
|
||||
const SYSTEMTIME kDaylightDate = {0, 3, 2, 0, 2, 0, 0, 0};
|
||||
const int32_t kDaylightBias = -60;
|
||||
constexpr SYSTEMTIME kDaylightDate = {0, 3, 2, 0, 2, 0, 0, 0};
|
||||
constexpr int32_t kDaylightBias = -60;
|
||||
|
||||
misc_info_writer->SetTimeZone(kTimeZoneId,
|
||||
kBias,
|
||||
@ -423,19 +423,19 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kTimeZoneId = 2;
|
||||
const int32_t kBias = 300;
|
||||
constexpr uint32_t kTimeZoneId = 2;
|
||||
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');
|
||||
const int32_t kStandardBias = 0;
|
||||
constexpr int32_t kStandardBias = 0;
|
||||
std::string daylight_name(ARRAYSIZE_UNSAFE(tmp.TimeZone.DaylightName), 'd');
|
||||
const int32_t kDaylightBias = -60;
|
||||
constexpr int32_t kDaylightBias = -60;
|
||||
|
||||
// Test using kSystemTimeZero, because not all platforms will be able to
|
||||
// provide daylight saving time transition times.
|
||||
const SYSTEMTIME kSystemTimeZero = {};
|
||||
constexpr SYSTEMTIME kSystemTimeZero = {};
|
||||
|
||||
misc_info_writer->SetTimeZone(kTimeZoneId,
|
||||
kBias,
|
||||
@ -551,7 +551,7 @@ TEST(MinidumpMiscInfoWriter, XStateData) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const XSTATE_CONFIG_FEATURE_MSC_INFO kXStateData = {
|
||||
constexpr XSTATE_CONFIG_FEATURE_MSC_INFO kXStateData = {
|
||||
sizeof(XSTATE_CONFIG_FEATURE_MSC_INFO),
|
||||
1024,
|
||||
0x000000000000005f,
|
||||
@ -585,7 +585,7 @@ TEST(MinidumpMiscInfoWriter, ProcessCookie) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessCookie = 0x12345678;
|
||||
constexpr uint32_t kProcessCookie = 0x12345678;
|
||||
|
||||
misc_info_writer->SetProcessCookie(kProcessCookie);
|
||||
|
||||
@ -608,25 +608,25 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto misc_info_writer = base::WrapUnique(new MinidumpMiscInfoWriter());
|
||||
|
||||
const uint32_t kProcessId = 12345;
|
||||
const time_t kProcessCreateTime = 0x15252f00;
|
||||
const uint32_t kProcessUserTime = 10;
|
||||
const uint32_t kProcessKernelTime = 5;
|
||||
const uint32_t kProcessorMaxMhz = 2800;
|
||||
const uint32_t kProcessorCurrentMhz = 2300;
|
||||
const uint32_t kProcessorMhzLimit = 3300;
|
||||
const uint32_t kProcessorMaxIdleState = 5;
|
||||
const uint32_t kProcessorCurrentIdleState = 1;
|
||||
const uint32_t kProcessIntegrityLevel = 0x2000;
|
||||
const uint32_t kProcessExecuteFlags = 0x13579bdf;
|
||||
const uint32_t kProtectedProcess = 1;
|
||||
const uint32_t kTimeZoneId = 2;
|
||||
const int32_t kBias = 300;
|
||||
constexpr uint32_t kProcessId = 12345;
|
||||
constexpr time_t kProcessCreateTime = 0x15252f00;
|
||||
constexpr uint32_t kProcessUserTime = 10;
|
||||
constexpr uint32_t kProcessKernelTime = 5;
|
||||
constexpr uint32_t kProcessorMaxMhz = 2800;
|
||||
constexpr uint32_t kProcessorCurrentMhz = 2300;
|
||||
constexpr uint32_t kProcessorMhzLimit = 3300;
|
||||
constexpr uint32_t kProcessorMaxIdleState = 5;
|
||||
constexpr uint32_t kProcessorCurrentIdleState = 1;
|
||||
constexpr uint32_t kProcessIntegrityLevel = 0x2000;
|
||||
constexpr uint32_t kProcessExecuteFlags = 0x13579bdf;
|
||||
constexpr uint32_t kProtectedProcess = 1;
|
||||
constexpr uint32_t kTimeZoneId = 2;
|
||||
constexpr int32_t kBias = 300;
|
||||
static constexpr char kStandardName[] = "EST";
|
||||
const int32_t kStandardBias = 0;
|
||||
constexpr int32_t kStandardBias = 0;
|
||||
static constexpr char kDaylightName[] = "EDT";
|
||||
const int32_t kDaylightBias = -60;
|
||||
const SYSTEMTIME kSystemTimeZero = {};
|
||||
constexpr int32_t kDaylightBias = -60;
|
||||
constexpr SYSTEMTIME kSystemTimeZero = {};
|
||||
static constexpr char kBuildString[] = "build string";
|
||||
static constexpr char kDebugBuildString[] = "debug build string";
|
||||
|
||||
@ -773,7 +773,7 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) {
|
||||
process_snapshot.SetProcessCPUTimes(kUserCPUTime, kSystemCPUTime);
|
||||
|
||||
auto system_snapshot = base::WrapUnique(new TestSystemSnapshot());
|
||||
const uint64_t kHzPerMHz = static_cast<uint64_t>(1E6);
|
||||
constexpr uint64_t kHzPerMHz = static_cast<uint64_t>(1E6);
|
||||
system_snapshot->SetCPUFrequency(
|
||||
expect_misc_info.ProcessorCurrentMhz * kHzPerMHz,
|
||||
expect_misc_info.ProcessorMaxMhz * kHzPerMHz);
|
||||
|
@ -108,7 +108,7 @@ TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) {
|
||||
}
|
||||
|
||||
TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
|
||||
const uint32_t kMinidumpModuleListIndex = 1;
|
||||
constexpr uint32_t kMinidumpModuleListIndex = 1;
|
||||
static constexpr char kKey[] = "key";
|
||||
static constexpr char kValue[] = "value";
|
||||
static constexpr char kEntry[] = "entry";
|
||||
@ -194,11 +194,11 @@ TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
|
||||
}
|
||||
|
||||
TEST(MinidumpModuleCrashpadInfoWriter, ThreeModules) {
|
||||
const uint32_t kMinidumpModuleListIndex0 = 0;
|
||||
constexpr uint32_t kMinidumpModuleListIndex0 = 0;
|
||||
static constexpr char kKey0[] = "key";
|
||||
static constexpr char kValue0[] = "value";
|
||||
const uint32_t kMinidumpModuleListIndex1 = 2;
|
||||
const uint32_t kMinidumpModuleListIndex2 = 5;
|
||||
constexpr uint32_t kMinidumpModuleListIndex1 = 2;
|
||||
constexpr uint32_t kMinidumpModuleListIndex2 = 5;
|
||||
static constexpr char kKey2A[] = "K";
|
||||
static constexpr char kValue2A[] = "VVV";
|
||||
static constexpr char kKey2B[] = "river";
|
||||
|
@ -42,10 +42,10 @@ namespace {
|
||||
|
||||
void GetModuleListStream(const std::string& file_contents,
|
||||
const MINIDUMP_MODULE_LIST** module_list) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kModuleListStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kModuleListStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kModulesOffset =
|
||||
constexpr size_t kModulesOffset =
|
||||
kModuleListStreamOffset + sizeof(MINIDUMP_MODULE_LIST);
|
||||
|
||||
ASSERT_GE(file_contents.size(), kModulesOffset);
|
||||
@ -311,31 +311,31 @@ TEST(MinidumpModuleWriter, OneModule) {
|
||||
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
||||
|
||||
static constexpr char kModuleName[] = "statically_linked";
|
||||
const uint64_t kModuleBase = 0x10da69000;
|
||||
const uint32_t kModuleSize = 0x1000;
|
||||
const uint32_t kChecksum = 0x76543210;
|
||||
const time_t kTimestamp = 0x386d4380;
|
||||
const uint32_t kFileVersionMS = 0x00010002;
|
||||
const uint32_t kFileVersionLS = 0x00030004;
|
||||
const uint32_t kProductVersionMS = 0x00050006;
|
||||
const uint32_t kProductVersionLS = 0x00070008;
|
||||
const uint32_t kFileFlagsMask = VS_FF_DEBUG | VS_FF_PRERELEASE |
|
||||
VS_FF_PATCHED | VS_FF_PRIVATEBUILD |
|
||||
VS_FF_INFOINFERRED | VS_FF_SPECIALBUILD;
|
||||
const uint32_t kFileFlags = VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD;
|
||||
const uint32_t kFileOS = VOS_DOS;
|
||||
const uint32_t kFileType = VFT_DRV;
|
||||
const uint32_t kFileSubtype = VFT2_DRV_KEYBOARD;
|
||||
constexpr uint64_t kModuleBase = 0x10da69000;
|
||||
constexpr uint32_t kModuleSize = 0x1000;
|
||||
constexpr uint32_t kChecksum = 0x76543210;
|
||||
constexpr time_t kTimestamp = 0x386d4380;
|
||||
constexpr uint32_t kFileVersionMS = 0x00010002;
|
||||
constexpr uint32_t kFileVersionLS = 0x00030004;
|
||||
constexpr uint32_t kProductVersionMS = 0x00050006;
|
||||
constexpr uint32_t kProductVersionLS = 0x00070008;
|
||||
constexpr uint32_t kFileFlagsMask = VS_FF_DEBUG | VS_FF_PRERELEASE |
|
||||
VS_FF_PATCHED | VS_FF_PRIVATEBUILD |
|
||||
VS_FF_INFOINFERRED | VS_FF_SPECIALBUILD;
|
||||
constexpr uint32_t kFileFlags = VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD;
|
||||
constexpr uint32_t kFileOS = VOS_DOS;
|
||||
constexpr uint32_t kFileType = VFT_DRV;
|
||||
constexpr uint32_t kFileSubtype = VFT2_DRV_KEYBOARD;
|
||||
static constexpr char kPDBName[] = "statical.pdb";
|
||||
static constexpr uint8_t kPDBUUIDBytes[16] =
|
||||
{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
0x08, 0x19, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x7f};
|
||||
UUID pdb_uuid;
|
||||
pdb_uuid.InitializeFromBytes(kPDBUUIDBytes);
|
||||
const uint32_t kPDBAge = 1;
|
||||
const uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
||||
constexpr uint32_t kPDBAge = 1;
|
||||
constexpr uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
||||
static constexpr char kDebugName[] = "statical.dbg";
|
||||
const bool kDebugUTF16 = false;
|
||||
constexpr bool kDebugUTF16 = false;
|
||||
|
||||
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
||||
module_writer->SetName(kModuleName);
|
||||
@ -421,11 +421,11 @@ TEST(MinidumpModuleWriter, OneModule_CodeViewUsesPDB20_MiscUsesUTF16) {
|
||||
|
||||
static constexpr char kModuleName[] = "dinosaur";
|
||||
static constexpr char kPDBName[] = "d1n05.pdb";
|
||||
const time_t kPDBTimestamp = 0x386d4380;
|
||||
const uint32_t kPDBAge = 1;
|
||||
const uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
||||
constexpr time_t kPDBTimestamp = 0x386d4380;
|
||||
constexpr uint32_t kPDBAge = 1;
|
||||
constexpr uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
||||
static constexpr char kDebugName[] = "d1n05.dbg";
|
||||
const bool kDebugUTF16 = true;
|
||||
constexpr bool kDebugUTF16 = true;
|
||||
|
||||
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
||||
module_writer->SetName(kModuleName);
|
||||
@ -481,26 +481,26 @@ TEST(MinidumpModuleWriter, ThreeModules) {
|
||||
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
||||
|
||||
static constexpr char kModuleName0[] = "main";
|
||||
const uint64_t kModuleBase0 = 0x100101000;
|
||||
const uint32_t kModuleSize0 = 0xf000;
|
||||
constexpr uint64_t kModuleBase0 = 0x100101000;
|
||||
constexpr uint32_t kModuleSize0 = 0xf000;
|
||||
static constexpr char kPDBName0[] = "main";
|
||||
static constexpr uint8_t kPDBUUIDBytes0[16] =
|
||||
{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11,
|
||||
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
|
||||
UUID pdb_uuid_0;
|
||||
pdb_uuid_0.InitializeFromBytes(kPDBUUIDBytes0);
|
||||
const uint32_t kPDBAge0 = 0;
|
||||
constexpr uint32_t kPDBAge0 = 0;
|
||||
|
||||
static constexpr char kModuleName1[] = "ld.so";
|
||||
const uint64_t kModuleBase1 = 0x200202000;
|
||||
const uint32_t kModuleSize1 = 0x1e000;
|
||||
constexpr uint64_t kModuleBase1 = 0x200202000;
|
||||
constexpr uint32_t kModuleSize1 = 0x1e000;
|
||||
|
||||
static constexpr char kModuleName2[] = "libc.so";
|
||||
const uint64_t kModuleBase2 = 0x300303000;
|
||||
const uint32_t kModuleSize2 = 0x2d000;
|
||||
constexpr uint64_t kModuleBase2 = 0x300303000;
|
||||
constexpr uint32_t kModuleSize2 = 0x2d000;
|
||||
static constexpr char kPDBName2[] = "libc.so";
|
||||
const time_t kPDBTimestamp2 = 0x386d4380;
|
||||
const uint32_t kPDBAge2 = 2;
|
||||
constexpr time_t kPDBTimestamp2 = 0x386d4380;
|
||||
constexpr uint32_t kPDBAge2 = 2;
|
||||
|
||||
auto module_writer_0 = base::WrapUnique(new MinidumpModuleWriter());
|
||||
module_writer_0->SetName(kModuleName0);
|
||||
|
@ -57,7 +57,7 @@ TEST(MinidumpRVAListWriter, Empty) {
|
||||
TEST(MinidumpRVAListWriter, OneChild) {
|
||||
TestMinidumpRVAListWriter list_writer;
|
||||
|
||||
const uint32_t kValue = 0;
|
||||
constexpr uint32_t kValue = 0;
|
||||
list_writer.AddChild(kValue);
|
||||
|
||||
StringFile string_file;
|
||||
|
@ -46,10 +46,10 @@ void GetSystemInfoStream(const std::string& file_contents,
|
||||
const size_t kCSDVersionBytesWithNUL =
|
||||
kCSDVersionBytes + sizeof(tmp.Buffer[0]);
|
||||
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kSystemInfoStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kSystemInfoStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kCSDVersionOffset =
|
||||
constexpr size_t kCSDVersionOffset =
|
||||
kSystemInfoStreamOffset + sizeof(MINIDUMP_SYSTEM_INFO);
|
||||
const size_t kFileSize =
|
||||
kCSDVersionOffset + sizeof(MINIDUMP_STRING) + kCSDVersionBytesWithNUL;
|
||||
@ -120,21 +120,22 @@ TEST(MinidumpSystemInfoWriter, X86_Win) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto system_info_writer = base::WrapUnique(new MinidumpSystemInfoWriter());
|
||||
|
||||
const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86;
|
||||
const uint16_t kCPULevel = 0x0010;
|
||||
const uint16_t kCPURevision = 0x0602;
|
||||
const uint8_t kCPUCount = 1;
|
||||
const MinidumpOS kOS = kMinidumpOSWin32NT;
|
||||
const MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
||||
const uint32_t kOSVersionMajor = 6;
|
||||
const uint32_t kOSVersionMinor = 1;
|
||||
const uint32_t kOSVersionBuild = 7601;
|
||||
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
||||
kMinidumpCPUArchitectureX86;
|
||||
constexpr uint16_t kCPULevel = 0x0010;
|
||||
constexpr uint16_t kCPURevision = 0x0602;
|
||||
constexpr uint8_t kCPUCount = 1;
|
||||
constexpr MinidumpOS kOS = kMinidumpOSWin32NT;
|
||||
constexpr MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
||||
constexpr uint32_t kOSVersionMajor = 6;
|
||||
constexpr uint32_t kOSVersionMinor = 1;
|
||||
constexpr uint32_t kOSVersionBuild = 7601;
|
||||
static constexpr char kCSDVersion[] = "Service Pack 1";
|
||||
const uint16_t kSuiteMask = VER_SUITE_SINGLEUSERTS;
|
||||
constexpr uint16_t kSuiteMask = VER_SUITE_SINGLEUSERTS;
|
||||
static constexpr char kCPUVendor[] = "AuthenticAMD";
|
||||
const uint32_t kCPUVersion = 0x00100f62;
|
||||
const uint32_t kCPUFeatures = 0x078bfbff;
|
||||
const uint32_t kAMDFeatures = 0xefd3fbff;
|
||||
constexpr uint32_t kCPUVersion = 0x00100f62;
|
||||
constexpr uint32_t kCPUFeatures = 0x078bfbff;
|
||||
constexpr uint32_t kAMDFeatures = 0xefd3fbff;
|
||||
|
||||
uint32_t cpu_vendor_registers[3];
|
||||
ASSERT_EQ(strlen(kCPUVendor), sizeof(cpu_vendor_registers));
|
||||
@ -190,16 +191,16 @@ TEST(MinidumpSystemInfoWriter, AMD64_Mac) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto system_info_writer = base::WrapUnique(new MinidumpSystemInfoWriter());
|
||||
|
||||
const MinidumpCPUArchitecture kCPUArchitecture =
|
||||
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
||||
kMinidumpCPUArchitectureAMD64;
|
||||
const uint16_t kCPULevel = 0x0006;
|
||||
const uint16_t kCPURevision = 0x3a09;
|
||||
const uint8_t kCPUCount = 8;
|
||||
const MinidumpOS kOS = kMinidumpOSMacOSX;
|
||||
const MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
||||
const uint32_t kOSVersionMajor = 10;
|
||||
const uint32_t kOSVersionMinor = 9;
|
||||
const uint32_t kOSVersionBuild = 4;
|
||||
constexpr uint16_t kCPULevel = 0x0006;
|
||||
constexpr uint16_t kCPURevision = 0x3a09;
|
||||
constexpr uint8_t kCPUCount = 8;
|
||||
constexpr MinidumpOS kOS = kMinidumpOSMacOSX;
|
||||
constexpr MinidumpOSType kOSType = kMinidumpOSTypeWorkstation;
|
||||
constexpr uint32_t kOSVersionMajor = 10;
|
||||
constexpr uint32_t kOSVersionMinor = 9;
|
||||
constexpr uint32_t kOSVersionBuild = 4;
|
||||
static constexpr char kCSDVersion[] = "13E28";
|
||||
static constexpr uint64_t kCPUFeatures[2] = {0x10427f4c, 0x00000000};
|
||||
|
||||
@ -247,7 +248,8 @@ TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto system_info_writer = base::WrapUnique(new MinidumpSystemInfoWriter());
|
||||
|
||||
const MinidumpCPUArchitecture kCPUArchitecture = kMinidumpCPUArchitectureX86;
|
||||
constexpr MinidumpCPUArchitecture kCPUArchitecture =
|
||||
kMinidumpCPUArchitectureX86;
|
||||
static constexpr uint32_t kCPUVendor[] = {'uneG', 'Ieni', 'letn'};
|
||||
|
||||
system_info_writer->SetCPUArchitecture(kCPUArchitecture);
|
||||
@ -277,9 +279,9 @@ TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
|
||||
TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
|
||||
MINIDUMP_SYSTEM_INFO expect_system_info = {};
|
||||
|
||||
const uint16_t kCPUFamily = 6;
|
||||
const uint8_t kCPUModel = 70;
|
||||
const uint8_t kCPUStepping = 1;
|
||||
constexpr uint16_t kCPUFamily = 6;
|
||||
constexpr uint8_t kCPUModel = 70;
|
||||
constexpr uint8_t kCPUStepping = 1;
|
||||
|
||||
const uint8_t kCPUBasicFamily =
|
||||
static_cast<uint8_t>(std::min(kCPUFamily, static_cast<uint16_t>(15)));
|
||||
@ -291,12 +293,12 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
|
||||
EXPECT_LE(kCPUStepping, 15);
|
||||
EXPECT_TRUE(kCPUBasicFamily == 6 || kCPUBasicFamily == 15 || kCPUModel <= 15);
|
||||
|
||||
const uint8_t kCPUBasicModel = kCPUModel & 0xf;
|
||||
const uint8_t kCPUExtendedModel = kCPUModel >> 4;
|
||||
constexpr uint8_t kCPUBasicModel = kCPUModel & 0xf;
|
||||
constexpr uint8_t kCPUExtendedModel = kCPUModel >> 4;
|
||||
const uint32_t kCPUSignature =
|
||||
(kCPUExtendedFamily << 20) | (kCPUExtendedModel << 16) |
|
||||
(kCPUBasicFamily << 8) | (kCPUBasicModel << 4) | kCPUStepping;
|
||||
const uint64_t kCPUX86Features = 0x7ffafbffbfebfbff;
|
||||
constexpr uint64_t kCPUX86Features = 0x7ffafbffbfebfbff;
|
||||
expect_system_info.ProcessorArchitecture = kMinidumpCPUArchitectureX86;
|
||||
expect_system_info.ProcessorLevel = kCPUFamily;
|
||||
expect_system_info.ProcessorRevision = (kCPUModel << 8) | kCPUStepping;
|
||||
@ -379,9 +381,9 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
|
||||
TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
|
||||
MINIDUMP_SYSTEM_INFO expect_system_info = {};
|
||||
|
||||
const uint8_t kCPUFamily = 6;
|
||||
const uint8_t kCPUModel = 70;
|
||||
const uint8_t kCPUStepping = 1;
|
||||
constexpr uint8_t kCPUFamily = 6;
|
||||
constexpr uint8_t kCPUModel = 70;
|
||||
constexpr uint8_t kCPUStepping = 1;
|
||||
expect_system_info.ProcessorArchitecture = kMinidumpCPUArchitectureAMD64;
|
||||
expect_system_info.ProcessorLevel = kCPUFamily;
|
||||
expect_system_info.ProcessorRevision = (kCPUModel << 8) | kCPUStepping;
|
||||
|
@ -46,7 +46,7 @@ namespace {
|
||||
void GetThreadListStream(const std::string& file_contents,
|
||||
const MINIDUMP_THREAD_LIST** thread_list,
|
||||
const MINIDUMP_MEMORY_LIST** memory_list) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const uint32_t kExpectedStreams = memory_list ? 2 : 1;
|
||||
const size_t kThreadListStreamOffset =
|
||||
kDirectoryOffset + kExpectedStreams * sizeof(MINIDUMP_DIRECTORY);
|
||||
@ -142,12 +142,12 @@ TEST(MinidumpThreadWriter, OneThread_x86_NoStack) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter());
|
||||
|
||||
const uint32_t kThreadID = 0x11111111;
|
||||
const uint32_t kSuspendCount = 1;
|
||||
const uint32_t kPriorityClass = 0x20;
|
||||
const uint32_t kPriority = 10;
|
||||
const uint64_t kTEB = 0x55555555;
|
||||
const uint32_t kSeed = 123;
|
||||
constexpr uint32_t kThreadID = 0x11111111;
|
||||
constexpr uint32_t kSuspendCount = 1;
|
||||
constexpr uint32_t kPriorityClass = 0x20;
|
||||
constexpr uint32_t kPriority = 10;
|
||||
constexpr uint64_t kTEB = 0x55555555;
|
||||
constexpr uint32_t kSeed = 123;
|
||||
|
||||
auto thread_writer = base::WrapUnique(new MinidumpThreadWriter());
|
||||
thread_writer->SetThreadID(kThreadID);
|
||||
@ -201,15 +201,15 @@ TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter());
|
||||
|
||||
const uint32_t kThreadID = 0x22222222;
|
||||
const uint32_t kSuspendCount = 2;
|
||||
const uint32_t kPriorityClass = 0x30;
|
||||
const uint32_t kPriority = 20;
|
||||
const uint64_t kTEB = 0x5555555555555555;
|
||||
const uint64_t kMemoryBase = 0x765432100000;
|
||||
const size_t kMemorySize = 32;
|
||||
const uint8_t kMemoryValue = 99;
|
||||
const uint32_t kSeed = 456;
|
||||
constexpr uint32_t kThreadID = 0x22222222;
|
||||
constexpr uint32_t kSuspendCount = 2;
|
||||
constexpr uint32_t kPriorityClass = 0x30;
|
||||
constexpr uint32_t kPriority = 20;
|
||||
constexpr uint64_t kTEB = 0x5555555555555555;
|
||||
constexpr uint64_t kMemoryBase = 0x765432100000;
|
||||
constexpr size_t kMemorySize = 32;
|
||||
constexpr uint8_t kMemoryValue = 99;
|
||||
constexpr uint32_t kSeed = 456;
|
||||
|
||||
auto thread_writer = base::WrapUnique(new MinidumpThreadWriter());
|
||||
thread_writer->SetThreadID(kThreadID);
|
||||
@ -282,15 +282,15 @@ TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) {
|
||||
auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter());
|
||||
thread_list_writer->SetMemoryListWriter(memory_list_writer.get());
|
||||
|
||||
const uint32_t kThreadID0 = 1111111;
|
||||
const uint32_t kSuspendCount0 = 111111;
|
||||
const uint32_t kPriorityClass0 = 11111;
|
||||
const uint32_t kPriority0 = 1111;
|
||||
const uint64_t kTEB0 = 111;
|
||||
const uint64_t kMemoryBase0 = 0x1110;
|
||||
const size_t kMemorySize0 = 16;
|
||||
const uint8_t kMemoryValue0 = 11;
|
||||
const uint32_t kSeed0 = 1;
|
||||
constexpr uint32_t kThreadID0 = 1111111;
|
||||
constexpr uint32_t kSuspendCount0 = 111111;
|
||||
constexpr uint32_t kPriorityClass0 = 11111;
|
||||
constexpr uint32_t kPriority0 = 1111;
|
||||
constexpr uint64_t kTEB0 = 111;
|
||||
constexpr uint64_t kMemoryBase0 = 0x1110;
|
||||
constexpr size_t kMemorySize0 = 16;
|
||||
constexpr uint8_t kMemoryValue0 = 11;
|
||||
constexpr uint32_t kSeed0 = 1;
|
||||
|
||||
auto thread_writer_0 = base::WrapUnique(new MinidumpThreadWriter());
|
||||
thread_writer_0->SetThreadID(kThreadID0);
|
||||
@ -309,15 +309,15 @@ TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) {
|
||||
|
||||
thread_list_writer->AddThread(std::move(thread_writer_0));
|
||||
|
||||
const uint32_t kThreadID1 = 2222222;
|
||||
const uint32_t kSuspendCount1 = 222222;
|
||||
const uint32_t kPriorityClass1 = 22222;
|
||||
const uint32_t kPriority1 = 2222;
|
||||
const uint64_t kTEB1 = 222;
|
||||
const uint64_t kMemoryBase1 = 0x2220;
|
||||
const size_t kMemorySize1 = 32;
|
||||
const uint8_t kMemoryValue1 = 22;
|
||||
const uint32_t kSeed1 = 2;
|
||||
constexpr uint32_t kThreadID1 = 2222222;
|
||||
constexpr uint32_t kSuspendCount1 = 222222;
|
||||
constexpr uint32_t kPriorityClass1 = 22222;
|
||||
constexpr uint32_t kPriority1 = 2222;
|
||||
constexpr uint64_t kTEB1 = 222;
|
||||
constexpr uint64_t kMemoryBase1 = 0x2220;
|
||||
constexpr size_t kMemorySize1 = 32;
|
||||
constexpr uint8_t kMemoryValue1 = 22;
|
||||
constexpr uint32_t kSeed1 = 2;
|
||||
|
||||
auto thread_writer_1 = base::WrapUnique(new MinidumpThreadWriter());
|
||||
thread_writer_1->SetThreadID(kThreadID1);
|
||||
@ -336,15 +336,15 @@ TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) {
|
||||
|
||||
thread_list_writer->AddThread(std::move(thread_writer_1));
|
||||
|
||||
const uint32_t kThreadID2 = 3333333;
|
||||
const uint32_t kSuspendCount2 = 333333;
|
||||
const uint32_t kPriorityClass2 = 33333;
|
||||
const uint32_t kPriority2 = 3333;
|
||||
const uint64_t kTEB2 = 333;
|
||||
const uint64_t kMemoryBase2 = 0x3330;
|
||||
const size_t kMemorySize2 = 48;
|
||||
const uint8_t kMemoryValue2 = 33;
|
||||
const uint32_t kSeed2 = 3;
|
||||
constexpr uint32_t kThreadID2 = 3333333;
|
||||
constexpr uint32_t kSuspendCount2 = 333333;
|
||||
constexpr uint32_t kPriorityClass2 = 33333;
|
||||
constexpr uint32_t kPriority2 = 3333;
|
||||
constexpr uint64_t kTEB2 = 333;
|
||||
constexpr uint64_t kMemoryBase2 = 0x3330;
|
||||
constexpr size_t kMemorySize2 = 48;
|
||||
constexpr uint8_t kMemoryValue2 = 33;
|
||||
constexpr uint32_t kSeed2 = 3;
|
||||
|
||||
auto thread_writer_2 = base::WrapUnique(new MinidumpThreadWriter());
|
||||
thread_writer_2->SetThreadID(kThreadID2);
|
||||
@ -533,7 +533,7 @@ void RunInitializeFromSnapshotTest(bool thread_id_collision) {
|
||||
uint32_t context_seeds[arraysize(expect_threads)] = {};
|
||||
MINIDUMP_MEMORY_DESCRIPTOR tebs[arraysize(expect_threads)] = {};
|
||||
|
||||
const size_t kTebSize = 1024;
|
||||
constexpr size_t kTebSize = 1024;
|
||||
|
||||
expect_threads[0].ThreadId = 1;
|
||||
expect_threads[0].SuspendCount = 2;
|
||||
|
@ -46,10 +46,10 @@ void ExpectUnloadedModule(const MINIDUMP_UNLOADED_MODULE* expected,
|
||||
void GetUnloadedModuleListStream(
|
||||
const std::string& file_contents,
|
||||
const MINIDUMP_UNLOADED_MODULE_LIST** unloaded_module_list) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kUnloadedModuleListStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kUnloadedModuleListStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
const size_t kUnloadedModulesOffset =
|
||||
constexpr size_t kUnloadedModulesOffset =
|
||||
kUnloadedModuleListStreamOffset + sizeof(MINIDUMP_UNLOADED_MODULE_LIST);
|
||||
|
||||
ASSERT_GE(file_contents.size(), kUnloadedModulesOffset);
|
||||
@ -114,10 +114,10 @@ TEST(MinidumpUnloadedModuleWriter, OneModule) {
|
||||
base::WrapUnique(new MinidumpUnloadedModuleListWriter());
|
||||
|
||||
static constexpr char kModuleName[] = "statically_linked";
|
||||
const uint64_t kModuleBase = 0x10da69000;
|
||||
const uint32_t kModuleSize = 0x1000;
|
||||
const uint32_t kChecksum = 0x76543210;
|
||||
const time_t kTimestamp = 0x386d4380;
|
||||
constexpr uint64_t kModuleBase = 0x10da69000;
|
||||
constexpr uint32_t kModuleSize = 0x1000;
|
||||
constexpr uint32_t kChecksum = 0x76543210;
|
||||
constexpr time_t kTimestamp = 0x386d4380;
|
||||
|
||||
auto unloaded_module_writer =
|
||||
base::WrapUnique(new MinidumpUnloadedModuleWriter());
|
||||
|
@ -35,8 +35,8 @@ void GetUserStream(const std::string& file_contents,
|
||||
MINIDUMP_LOCATION_DESCRIPTOR* user_stream_location,
|
||||
uint32_t stream_type,
|
||||
size_t stream_size) {
|
||||
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
const size_t kUserStreamOffset =
|
||||
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
||||
constexpr size_t kUserStreamOffset =
|
||||
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
||||
|
||||
const MINIDUMP_DIRECTORY* directory;
|
||||
@ -45,7 +45,7 @@ void GetUserStream(const std::string& file_contents,
|
||||
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
||||
ASSERT_TRUE(directory);
|
||||
|
||||
const size_t kDirectoryIndex = 0;
|
||||
constexpr size_t kDirectoryIndex = 0;
|
||||
|
||||
ASSERT_EQ(directory[kDirectoryIndex].StreamType, stream_type);
|
||||
EXPECT_EQ(directory[kDirectoryIndex].Location.Rva, kUserStreamOffset);
|
||||
@ -100,7 +100,7 @@ TEST(MinidumpUserStreamWriter, InitializeFromSnapshotOneStream) {
|
||||
|
||||
TestMemorySnapshot* test_data = new TestMemorySnapshot();
|
||||
test_data->SetAddress(97865);
|
||||
const size_t kStreamSize = 128;
|
||||
constexpr size_t kStreamSize = 128;
|
||||
test_data->SetSize(kStreamSize);
|
||||
test_data->SetValue('c');
|
||||
auto stream =
|
||||
@ -125,7 +125,7 @@ TEST(MinidumpUserStreamWriter, InitializeFromSnapshotOneStream) {
|
||||
TEST(MinidumpUserStreamWriter, InitializeFromBufferOneStream) {
|
||||
MinidumpFileWriter minidump_file_writer;
|
||||
|
||||
const size_t kStreamSize = 128;
|
||||
constexpr size_t kStreamSize = 128;
|
||||
std::vector<uint8_t> data(kStreamSize, 'c');
|
||||
auto data_source = base::WrapUnique(new test::BufferExtensionStreamDataSource(
|
||||
kTestStreamId, &data[0], data.size()));
|
||||
|
@ -37,7 +37,7 @@ void ExpectMinidumpMemoryDescriptor(
|
||||
EXPECT_EQ(observed->StartOfMemoryRange, expected->StartOfMemoryRange);
|
||||
EXPECT_EQ(observed->Memory.DataSize, expected->Memory.DataSize);
|
||||
if (expected->Memory.Rva != 0) {
|
||||
const uint32_t kMemoryAlignment = 16;
|
||||
constexpr uint32_t kMemoryAlignment = 16;
|
||||
EXPECT_EQ(observed->Memory.Rva,
|
||||
(expected->Memory.Rva + kMemoryAlignment - 1) &
|
||||
~(kMemoryAlignment - 1));
|
||||
|
@ -28,7 +28,7 @@ namespace {
|
||||
|
||||
void MaybeCaptureMemoryAround(CaptureMemory::Delegate* delegate,
|
||||
uint64_t address) {
|
||||
const uint64_t non_address_offset = 0x10000;
|
||||
constexpr uint64_t non_address_offset = 0x10000;
|
||||
if (address < non_address_offset)
|
||||
return;
|
||||
|
||||
@ -38,9 +38,9 @@ void MaybeCaptureMemoryAround(CaptureMemory::Delegate* delegate,
|
||||
if (address > max_address - non_address_offset)
|
||||
return;
|
||||
|
||||
const uint64_t kRegisterByteOffset = 128;
|
||||
constexpr uint64_t kRegisterByteOffset = 128;
|
||||
const uint64_t target = address - kRegisterByteOffset;
|
||||
const uint64_t size = 512;
|
||||
constexpr uint64_t size = 512;
|
||||
static_assert(kRegisterByteOffset <= size / 2,
|
||||
"negative offset too large");
|
||||
auto ranges =
|
||||
|
@ -133,7 +133,7 @@ void ProcessReader::Thread::InitializeStack(ProcessReader* reader) {
|
||||
#if defined(ARCH_CPU_X86_FAMILY)
|
||||
// Adjust start address to include the red zone
|
||||
if (reader->Is64Bit()) {
|
||||
const LinuxVMSize kRedZoneSize = 128;
|
||||
constexpr LinuxVMSize kRedZoneSize = 128;
|
||||
LinuxVMAddress red_zone_base =
|
||||
stack_region_start - std::min(kRedZoneSize, stack_region_start);
|
||||
|
||||
|
@ -91,7 +91,7 @@ void MachOImageAnnotationsReader::ReadCrashReporterClientAnnotations(
|
||||
|
||||
// This number was totally made up out of nowhere, but it seems prudent to
|
||||
// enforce some limit.
|
||||
const size_t kMaxMessageSize = 1024;
|
||||
constexpr size_t kMaxMessageSize = 1024;
|
||||
if (crash_info.message) {
|
||||
std::string message;
|
||||
if (process_reader_->Memory()->ReadCStringSizeLimited(
|
||||
|
@ -611,7 +611,7 @@ mach_vm_address_t ProcessReader::CalculateStackRegion(
|
||||
// Regardless of whether the ABI requires a red zone, capture up to
|
||||
// kExtraCaptureSize additional bytes of stack, but only if present in the
|
||||
// region that was already found.
|
||||
const mach_vm_size_t kExtraCaptureSize = 128;
|
||||
constexpr mach_vm_size_t kExtraCaptureSize = 128;
|
||||
start_address = std::max(start_address >= kExtraCaptureSize
|
||||
? start_address - kExtraCaptureSize
|
||||
: start_address,
|
||||
@ -620,7 +620,7 @@ mach_vm_address_t ProcessReader::CalculateStackRegion(
|
||||
// Align start_address to a 16-byte boundary, which can help readers by
|
||||
// ensuring that data is aligned properly. This could page-align instead,
|
||||
// but that might be wasteful.
|
||||
const mach_vm_size_t kDesiredAlignment = 16;
|
||||
constexpr mach_vm_size_t kDesiredAlignment = 16;
|
||||
start_address &= ~(kDesiredAlignment - 1);
|
||||
DCHECK_GE(start_address, region_base);
|
||||
}
|
||||
@ -685,7 +685,7 @@ void ProcessReader::LocateRedZone(mach_vm_address_t* const start_address,
|
||||
// x86_64 has a red zone. See AMD64 ABI 0.99.6,
|
||||
// http://www.x86-64.org/documentation/abi.pdf, section 3.2.2, “The Stack
|
||||
// Frame”.
|
||||
const mach_vm_size_t kRedZoneSize = 128;
|
||||
constexpr mach_vm_size_t kRedZoneSize = 128;
|
||||
mach_vm_address_t red_zone_base =
|
||||
*start_address >= kRedZoneSize ? *start_address - kRedZoneSize : 0;
|
||||
bool red_zone_ok = false;
|
||||
|
@ -384,7 +384,7 @@ TEST(ProcessReader, SelfSeveralThreads) {
|
||||
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
|
||||
|
||||
TestThreadPool thread_pool;
|
||||
const size_t kChildThreads = 16;
|
||||
constexpr size_t kChildThreads = 16;
|
||||
ASSERT_NO_FATAL_FAILURE(thread_pool.StartThreads(kChildThreads));
|
||||
|
||||
// Build a map of all expected threads, keyed by each thread’s ID. The values
|
||||
@ -523,13 +523,13 @@ class ProcessReaderThreadedChild final : public MachMultiprocess {
|
||||
|
||||
TEST(ProcessReader, ChildOneThread) {
|
||||
// The main thread plus zero child threads equals one thread.
|
||||
const size_t kChildThreads = 0;
|
||||
constexpr size_t kChildThreads = 0;
|
||||
ProcessReaderThreadedChild process_reader_threaded_child(kChildThreads);
|
||||
process_reader_threaded_child.Run();
|
||||
}
|
||||
|
||||
TEST(ProcessReader, ChildSeveralThreads) {
|
||||
const size_t kChildThreads = 64;
|
||||
constexpr size_t kChildThreads = 64;
|
||||
ProcessReaderThreadedChild process_reader_threaded_child(kChildThreads);
|
||||
process_reader_threaded_child.Run();
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class CrashingDelegate : public ExceptionHandlerServer::Delegate {
|
||||
// Verify the exception happened at the expected location with a bit of
|
||||
// slop space to allow for reading the current PC before the exception
|
||||
// happens. See TestCrashingChild().
|
||||
const uint64_t kAllowedOffset = 64;
|
||||
constexpr uint64_t kAllowedOffset = 64;
|
||||
EXPECT_GT(snapshot.Exception()->ExceptionAddress(), break_near_);
|
||||
EXPECT_LT(snapshot.Exception()->ExceptionAddress(),
|
||||
break_near_ + kAllowedOffset);
|
||||
@ -205,7 +205,7 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate {
|
||||
|
||||
// Verify the dump was captured at the expected location with some slop
|
||||
// space.
|
||||
const uint64_t kAllowedOffset = 64;
|
||||
constexpr uint64_t kAllowedOffset = 64;
|
||||
EXPECT_GT(snapshot.Exception()->Context()->InstructionPointer(),
|
||||
dump_near_);
|
||||
EXPECT_LT(snapshot.Exception()->Context()->InstructionPointer(),
|
||||
|
@ -554,7 +554,7 @@ void ProcessSnapshotWin::ReadLock(
|
||||
AddMemorySnapshot(
|
||||
start, sizeof(process_types::RTL_CRITICAL_SECTION<Traits>), into);
|
||||
|
||||
const decltype(critical_section.DebugInfo) kInvalid =
|
||||
constexpr decltype(critical_section.DebugInfo) kInvalid =
|
||||
static_cast<decltype(critical_section.DebugInfo)>(-1);
|
||||
if (critical_section.DebugInfo == kInvalid)
|
||||
return;
|
||||
|
@ -192,7 +192,7 @@ void SystemSnapshotWin::CPUFrequency(uint64_t* current_hz,
|
||||
*max_hz = 0;
|
||||
return;
|
||||
}
|
||||
const uint64_t kMhzToHz = static_cast<uint64_t>(1E6);
|
||||
constexpr uint64_t kMhzToHz = static_cast<uint64_t>(1E6);
|
||||
*current_hz = std::max_element(info.begin(),
|
||||
info.end(),
|
||||
[](const PROCESSOR_POWER_INFORMATION& a,
|
||||
|
@ -398,7 +398,7 @@ void TestOpenFileForWrite(FileHandle (*opener)(const base::FilePath&,
|
||||
EXPECT_TRUE(FileExists(file_path_1));
|
||||
EXPECT_EQ(FileSize(file_path_1), 0);
|
||||
|
||||
const char data = '%';
|
||||
constexpr char data = '%';
|
||||
EXPECT_TRUE(LoggingWriteFile(file_handle.get(), &data, sizeof(data)));
|
||||
|
||||
// Close file_handle to ensure that the write is flushed to disk.
|
||||
|
@ -109,9 +109,9 @@ ParseResult ParseMapsLine(DelimitedFileReader* maps_file_reader,
|
||||
|
||||
// TODO(jperaza): set bitness properly
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
const bool is_64_bit = true;
|
||||
constexpr bool is_64_bit = true;
|
||||
#else
|
||||
const bool is_64_bit = false;
|
||||
constexpr bool is_64_bit = false;
|
||||
#endif
|
||||
|
||||
MemoryMap::Mapping mapping;
|
||||
|
@ -39,9 +39,9 @@ class SameBitnessTest : public Multiprocess {
|
||||
ASSERT_TRUE(thread_info.Initialize(ChildPID()));
|
||||
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
const bool am_64_bit = true;
|
||||
constexpr bool am_64_bit = true;
|
||||
#else
|
||||
const bool am_64_bit = false;
|
||||
constexpr bool am_64_bit = false;
|
||||
#endif // ARCH_CPU_64_BITS
|
||||
|
||||
EXPECT_EQ(thread_info.Is64Bit(), am_64_bit);
|
||||
|
@ -175,7 +175,7 @@ mach_port_t ChildPortHandshakeServer::RunServer(
|
||||
// be delivered out of order and the check-in message will still be
|
||||
// processed.
|
||||
struct kevent event;
|
||||
const timespec nonblocking_timeout = {};
|
||||
constexpr timespec nonblocking_timeout = {};
|
||||
const timespec* timeout = blocking ? nullptr : &nonblocking_timeout;
|
||||
rv = HANDLE_EINTR(kevent(kq.get(), nullptr, 0, &event, 1, timeout));
|
||||
PCHECK(rv != -1) << "kevent";
|
||||
@ -341,7 +341,7 @@ ChildPortHandshake::ChildPortHandshake()
|
||||
|
||||
// SIGPIPE is undesirable when writing to this pipe. Allow broken-pipe writes
|
||||
// to fail with EPIPE instead.
|
||||
const int value = 1;
|
||||
constexpr int value = 1;
|
||||
PCHECK(setsockopt(server_write_fd_.get(),
|
||||
SOL_SOCKET,
|
||||
SO_NOSIGPIPE,
|
||||
|
@ -135,10 +135,10 @@ TEST(CompositeMachMessageServer, HandlerDoesNotHandle) {
|
||||
}
|
||||
|
||||
TEST(CompositeMachMessageServer, OneHandler) {
|
||||
const mach_msg_id_t kRequestID = 100;
|
||||
const mach_msg_size_t kRequestSize = 256;
|
||||
const mach_msg_size_t kReplySize = 128;
|
||||
const kern_return_t kReturnCode = KERN_SUCCESS;
|
||||
constexpr mach_msg_id_t kRequestID = 100;
|
||||
constexpr mach_msg_size_t kRequestSize = 256;
|
||||
constexpr mach_msg_size_t kReplySize = 128;
|
||||
constexpr kern_return_t kReturnCode = KERN_SUCCESS;
|
||||
|
||||
TestMachMessageHandler handler;
|
||||
handler.AddRequestID(kRequestID);
|
||||
@ -183,15 +183,15 @@ TEST(CompositeMachMessageServer, OneHandler) {
|
||||
|
||||
TEST(CompositeMachMessageServer, ThreeHandlers) {
|
||||
static constexpr mach_msg_id_t kRequestIDs0[] = {5};
|
||||
const kern_return_t kReturnCode0 = KERN_SUCCESS;
|
||||
constexpr kern_return_t kReturnCode0 = KERN_SUCCESS;
|
||||
|
||||
static constexpr mach_msg_id_t kRequestIDs1[] = {4, 7};
|
||||
const kern_return_t kReturnCode1 = KERN_PROTECTION_FAILURE;
|
||||
constexpr kern_return_t kReturnCode1 = KERN_PROTECTION_FAILURE;
|
||||
|
||||
static constexpr mach_msg_id_t kRequestIDs2[] = {10, 0, 20};
|
||||
const mach_msg_size_t kRequestSize2 = 6144;
|
||||
const mach_msg_size_t kReplySize2 = 16384;
|
||||
const kern_return_t kReturnCode2 = KERN_NOT_RECEIVER;
|
||||
constexpr mach_msg_size_t kRequestSize2 = 6144;
|
||||
constexpr mach_msg_size_t kReplySize2 = 16384;
|
||||
constexpr kern_return_t kReturnCode2 = KERN_NOT_RECEIVER;
|
||||
|
||||
TestMachMessageHandler handlers[3];
|
||||
std::set<mach_msg_id_t> expect_request_ids;
|
||||
@ -289,7 +289,7 @@ TEST(CompositeMachMessageServer, ThreeHandlers) {
|
||||
// CompositeMachMessageServer can’t deal with two handlers that want to handle
|
||||
// the same request ID.
|
||||
TEST(CompositeMachMessageServerDeathTest, DuplicateRequestID) {
|
||||
const mach_msg_id_t kRequestID = 400;
|
||||
constexpr mach_msg_id_t kRequestID = 400;
|
||||
|
||||
TestMachMessageHandler handlers[2];
|
||||
handlers[0].AddRequestID(kRequestID);
|
||||
|
@ -328,7 +328,7 @@ class ExcServer : public MachMessageServer::Interface {
|
||||
bool* destroy_complex_request) override;
|
||||
|
||||
std::set<mach_msg_id_t> MachMessageServerRequestIDs() override {
|
||||
const mach_msg_id_t request_ids[] = {
|
||||
constexpr mach_msg_id_t request_ids[] = {
|
||||
Traits::kMachMessageIDExceptionRaise,
|
||||
Traits::kMachMessageIDExceptionRaiseState,
|
||||
Traits::kMachMessageIDExceptionRaiseStateIdentity,
|
||||
|
@ -601,7 +601,7 @@ TEST(ExcServerVariants, MockExceptionRaise) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior = EXCEPTION_DEFAULT;
|
||||
constexpr exception_behavior_t kExceptionBehavior = EXCEPTION_DEFAULT;
|
||||
|
||||
EXPECT_CALL(server,
|
||||
MockCatchMachException(kExceptionBehavior,
|
||||
@ -646,7 +646,7 @@ TEST(ExcServerVariants, MockExceptionRaiseState) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE;
|
||||
constexpr exception_behavior_t kExceptionBehavior = EXCEPTION_STATE;
|
||||
|
||||
EXPECT_CALL(
|
||||
server,
|
||||
@ -695,7 +695,7 @@ TEST(ExcServerVariants, MockExceptionRaiseStateIdentity) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE_IDENTITY;
|
||||
constexpr exception_behavior_t kExceptionBehavior = EXCEPTION_STATE_IDENTITY;
|
||||
|
||||
EXPECT_CALL(
|
||||
server,
|
||||
@ -741,7 +741,7 @@ TEST(ExcServerVariants, MockMachExceptionRaise) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior =
|
||||
constexpr exception_behavior_t kExceptionBehavior =
|
||||
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES;
|
||||
|
||||
EXPECT_CALL(
|
||||
@ -788,7 +788,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseState) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior =
|
||||
constexpr exception_behavior_t kExceptionBehavior =
|
||||
EXCEPTION_STATE | MACH_EXCEPTION_CODES;
|
||||
|
||||
EXPECT_CALL(
|
||||
@ -838,7 +838,7 @@ TEST(ExcServerVariants, MockMachExceptionRaiseStateIdentity) {
|
||||
EXPECT_LE(sizeof(reply),
|
||||
universal_mach_exc_server.MachMessageServerReplySize());
|
||||
|
||||
const exception_behavior_t kExceptionBehavior =
|
||||
constexpr exception_behavior_t kExceptionBehavior =
|
||||
EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES;
|
||||
|
||||
EXPECT_CALL(
|
||||
@ -1269,7 +1269,7 @@ TEST(ExcServerVariants, ExcServerCopyState) {
|
||||
static constexpr natural_t old_state[] = {1, 2, 3, 4, 5};
|
||||
natural_t new_state[10] = {};
|
||||
|
||||
const 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);
|
||||
|
||||
// EXCEPTION_DEFAULT (with or without MACH_EXCEPTION_CODES) is not
|
||||
|
@ -99,7 +99,7 @@ bool ExceptionPorts::GetExceptionPorts(exception_mask_t mask,
|
||||
// later operating system versions have defined more exception types. The
|
||||
// generated task_get_exception_ports() in taskUser.c expects there to be room
|
||||
// for 32.
|
||||
const int kMaxPorts = 32;
|
||||
constexpr int kMaxPorts = 32;
|
||||
|
||||
// task_get_exception_ports() doesn’t actually use the initial value of
|
||||
// handler_count, but 10.9.4
|
||||
|
@ -58,7 +58,7 @@ namespace {
|
||||
void TestGetExceptionPorts(const ExceptionPorts& exception_ports,
|
||||
mach_port_t expect_port,
|
||||
exception_behavior_t expect_behavior) {
|
||||
const exception_mask_t kExceptionMask = EXC_MASK_CRASH;
|
||||
constexpr exception_mask_t kExceptionMask = EXC_MASK_CRASH;
|
||||
|
||||
thread_state_flavor_t expect_flavor = (expect_behavior == EXCEPTION_DEFAULT)
|
||||
? THREAD_STATE_NONE
|
||||
@ -440,7 +440,7 @@ class TestExceptionPorts : public MachMultiprocess,
|
||||
if (who_crashes_ != kNobodyCrashes) {
|
||||
UniversalMachExcServer universal_mach_exc_server(this);
|
||||
|
||||
const mach_msg_timeout_t kTimeoutMs = 50;
|
||||
constexpr mach_msg_timeout_t kTimeoutMs = 50;
|
||||
kern_return_t kr =
|
||||
MachMessageServer::Run(&universal_mach_exc_server,
|
||||
local_port,
|
||||
|
@ -103,7 +103,7 @@ exception_mask_t ExcMaskAll() {
|
||||
|
||||
// See 10.6.8 xnu-1504.15.3/osfmk/mach/exception_types.h. 10.7 uses the same
|
||||
// definition as 10.6. See 10.7.5 xnu-1699.32.7/osfmk/mach/exception_types.h
|
||||
const exception_mask_t kExcMaskAll_10_6 =
|
||||
constexpr exception_mask_t kExcMaskAll_10_6 =
|
||||
EXC_MASK_BAD_ACCESS |
|
||||
EXC_MASK_BAD_INSTRUCTION |
|
||||
EXC_MASK_ARITHMETIC |
|
||||
@ -122,7 +122,7 @@ exception_mask_t ExcMaskAll() {
|
||||
|
||||
// 10.8 added EXC_MASK_RESOURCE. See 10.8.5
|
||||
// xnu-2050.48.11/osfmk/mach/exception_types.h.
|
||||
const exception_mask_t kExcMaskAll_10_8 =
|
||||
constexpr exception_mask_t kExcMaskAll_10_8 =
|
||||
kExcMaskAll_10_6 | EXC_MASK_RESOURCE;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
|
||||
if (mac_os_x_minor_version < 9) {
|
||||
@ -132,7 +132,8 @@ exception_mask_t ExcMaskAll() {
|
||||
|
||||
// 10.9 added EXC_MASK_GUARD. See 10.9.4
|
||||
// xnu-2422.110.17/osfmk/mach/exception_types.h.
|
||||
const exception_mask_t kExcMaskAll_10_9 = kExcMaskAll_10_8 | EXC_MASK_GUARD;
|
||||
constexpr exception_mask_t kExcMaskAll_10_9 =
|
||||
kExcMaskAll_10_8 | EXC_MASK_GUARD;
|
||||
return kExcMaskAll_10_9;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,8 @@ bool TimerRunning(uint64_t deadline,
|
||||
uint64_t remaining = deadline - now;
|
||||
|
||||
// Round to the nearest millisecond, taking care not to overflow.
|
||||
const int kHalfMillisecondInNanoseconds = kNanosecondsPerMillisecond / 2;
|
||||
constexpr int kHalfMillisecondInNanoseconds =
|
||||
kNanosecondsPerMillisecond / 2;
|
||||
if (remaining <=
|
||||
std::numeric_limits<uint64_t>::max() - kHalfMillisecondInNanoseconds) {
|
||||
*remaining_ms = (remaining + kHalfMillisecondInNanoseconds) /
|
||||
|
@ -589,16 +589,16 @@ class TestMachMessageServer : public MachMessageServer::Interface,
|
||||
static uint32_t requests_;
|
||||
static uint32_t replies_;
|
||||
|
||||
static const mach_msg_id_t kRequestMessageID = 16237;
|
||||
static const mach_msg_id_t kReplyMessageID = kRequestMessageID + 100;
|
||||
static constexpr mach_msg_id_t kRequestMessageID = 16237;
|
||||
static constexpr mach_msg_id_t kReplyMessageID = kRequestMessageID + 100;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TestMachMessageServer);
|
||||
};
|
||||
|
||||
uint32_t TestMachMessageServer::requests_;
|
||||
uint32_t TestMachMessageServer::replies_;
|
||||
const mach_msg_id_t TestMachMessageServer::kRequestMessageID;
|
||||
const mach_msg_id_t TestMachMessageServer::kReplyMessageID;
|
||||
constexpr mach_msg_id_t TestMachMessageServer::kRequestMessageID;
|
||||
constexpr mach_msg_id_t TestMachMessageServer::kReplyMessageID;
|
||||
|
||||
TEST(MachMessageServer, Basic) {
|
||||
// The client sends one message to the server, which will wait indefinitely in
|
||||
@ -688,7 +688,7 @@ TEST(MachMessageServer, PersistentNonblockingFourMessages) {
|
||||
// child is allowed to begin sending messages, so
|
||||
// child_wait_for_parent_pipe_early is used to make the child wait until the
|
||||
// parent is ready.
|
||||
const size_t kTransactionCount = 4;
|
||||
constexpr size_t kTransactionCount = 4;
|
||||
static_assert(kTransactionCount <= MACH_PORT_QLIMIT_DEFAULT,
|
||||
"must not exceed queue limit");
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace {
|
||||
|
||||
TEST(TaskMemory, ReadSelf) {
|
||||
vm_address_t address = 0;
|
||||
const vm_size_t kSize = 4 * PAGE_SIZE;
|
||||
constexpr vm_size_t kSize = 4 * PAGE_SIZE;
|
||||
kern_return_t kr =
|
||||
vm_allocate(mach_task_self(), &address, kSize, VM_FLAGS_ANYWHERE);
|
||||
ASSERT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "vm_allocate");
|
||||
@ -102,7 +102,7 @@ TEST(TaskMemory, ReadSelf) {
|
||||
|
||||
TEST(TaskMemory, ReadSelfUnmapped) {
|
||||
vm_address_t address = 0;
|
||||
const vm_size_t kSize = 2 * PAGE_SIZE;
|
||||
constexpr vm_size_t kSize = 2 * PAGE_SIZE;
|
||||
kern_return_t kr =
|
||||
vm_allocate(mach_task_self(), &address, kSize, VM_FLAGS_ANYWHERE);
|
||||
ASSERT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "vm_allocate");
|
||||
@ -221,7 +221,7 @@ TEST(TaskMemory, ReadCStringSelf) {
|
||||
EXPECT_EQ(result, string_short);
|
||||
|
||||
std::string string_long;
|
||||
const size_t kStringLongSize = 4 * PAGE_SIZE;
|
||||
constexpr size_t kStringLongSize = 4 * PAGE_SIZE;
|
||||
for (size_t index = 0; index < kStringLongSize; ++index) {
|
||||
// Don’t include any NUL bytes, because ReadCString stops when it encounters
|
||||
// a NUL.
|
||||
@ -236,7 +236,7 @@ TEST(TaskMemory, ReadCStringSelf) {
|
||||
|
||||
TEST(TaskMemory, ReadCStringSelfUnmapped) {
|
||||
vm_address_t address = 0;
|
||||
const vm_size_t kSize = 2 * PAGE_SIZE;
|
||||
constexpr vm_size_t kSize = 2 * PAGE_SIZE;
|
||||
kern_return_t kr =
|
||||
vm_allocate(mach_task_self(), &address, kSize, VM_FLAGS_ANYWHERE);
|
||||
ASSERT_EQ(kr, KERN_SUCCESS) << MachErrorMessage(kr, "vm_allocate");
|
||||
@ -418,7 +418,7 @@ TEST(TaskMemory, ReadCStringSizeLimited_StringLong) {
|
||||
std::string result;
|
||||
|
||||
std::string string_long;
|
||||
const size_t kStringLongSize = 4 * PAGE_SIZE;
|
||||
constexpr size_t kStringLongSize = 4 * PAGE_SIZE;
|
||||
for (size_t index = 0; index < kStringLongSize; ++index) {
|
||||
// Don’t include any NUL bytes, because ReadCString stops when it encounters
|
||||
// a NUL.
|
||||
@ -498,7 +498,7 @@ TEST(TaskMemory, MappedMemoryDeallocates) {
|
||||
// This is the same but with a big buffer that’s definitely larger than a
|
||||
// single page. This makes sure that the whole mapped region winds up being
|
||||
// deallocated.
|
||||
const size_t kBigSize = 4 * PAGE_SIZE;
|
||||
constexpr size_t kBigSize = 4 * PAGE_SIZE;
|
||||
std::unique_ptr<char[]> big_buffer(new char[kBigSize]);
|
||||
test_address = FromPointerCast<mach_vm_address_t>(&big_buffer[0]);
|
||||
ASSERT_TRUE((mapped = memory.ReadMapped(test_address, kBigSize)));
|
||||
|
@ -40,7 +40,7 @@ uint64_t ClockMonotonicNanoseconds() {
|
||||
int64_t frequency = QpcFrequency();
|
||||
int64_t whole_seconds = time.QuadPart / frequency;
|
||||
int64_t leftover_ticks = time.QuadPart % frequency;
|
||||
const int64_t kNanosecondsPerSecond = static_cast<const int64_t>(1E9);
|
||||
constexpr int64_t kNanosecondsPerSecond = static_cast<const int64_t>(1E9);
|
||||
return (whole_seconds * kNanosecondsPerSecond) +
|
||||
((leftover_ticks * kNanosecondsPerSecond) / frequency);
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ FileOperationResult GzipHTTPBodyStream::GetBytesBuffer(uint8_t* buffer,
|
||||
// are the values that deflateInit() would use, but they’re not exported
|
||||
// from zlib. deflateInit2() is used instead of deflateInit() to get the
|
||||
// gzip wrapper.
|
||||
const int kZlibMaxWindowBits = 15;
|
||||
const int kZlibDefaultMemoryLevel = 8;
|
||||
constexpr int kZlibMaxWindowBits = 15;
|
||||
constexpr int kZlibDefaultMemoryLevel = 8;
|
||||
|
||||
int zr = deflateInit2(z_stream_.get(),
|
||||
Z_DEFAULT_COMPRESSION,
|
||||
|
@ -83,7 +83,7 @@ void TestGzipDeflateInflate(const std::string& string) {
|
||||
|
||||
// The minimum size of a gzip wrapper per RFC 1952: a 10-byte header and an
|
||||
// 8-byte trailer.
|
||||
const size_t kGzipHeaderSize = 18;
|
||||
constexpr size_t kGzipHeaderSize = 18;
|
||||
|
||||
// Per http://www.zlib.net/zlib_tech.html, in the worst case, zlib will store
|
||||
// uncompressed data as-is, at an overhead of 5 bytes per 16384-byte block.
|
||||
|
@ -257,7 +257,7 @@ bool HTTPTransportLibcurl::ExecuteSynchronously(std::string* response_body) {
|
||||
|
||||
TRY_CURL_EASY_SETOPT(curl.get(), CURLOPT_URL, url().c_str());
|
||||
|
||||
const int kMillisecondsPerSecond = 1E3;
|
||||
constexpr int kMillisecondsPerSecond = 1E3;
|
||||
TRY_CURL_EASY_SETOPT(curl.get(),
|
||||
CURLOPT_TIMEOUT_MS,
|
||||
static_cast<long>(timeout() * kMillisecondsPerSecond));
|
||||
|
@ -118,23 +118,23 @@ class HTTPBodyStreamCFReadStream {
|
||||
// Creates a new NSInputStream, which the caller owns.
|
||||
NSInputStream* CreateInputStream() {
|
||||
CFStreamClientContext context = {
|
||||
.version = 0,
|
||||
.info = this,
|
||||
.retain = nullptr,
|
||||
.release = nullptr,
|
||||
.copyDescription = nullptr
|
||||
.version = 0,
|
||||
.info = this,
|
||||
.retain = nullptr,
|
||||
.release = nullptr,
|
||||
.copyDescription = nullptr
|
||||
};
|
||||
const CFReadStreamCallBacksV0 callbacks = {
|
||||
.version = 0,
|
||||
.open = &Open,
|
||||
.openCompleted = &OpenCompleted,
|
||||
.read = &Read,
|
||||
.getBuffer = &GetBuffer,
|
||||
.canRead = &CanRead,
|
||||
.close = &Close,
|
||||
.copyProperty = &CopyProperty,
|
||||
.schedule = &Schedule,
|
||||
.unschedule = &Unschedule
|
||||
constexpr CFReadStreamCallBacksV0 callbacks = {
|
||||
.version = 0,
|
||||
.open = &Open,
|
||||
.openCompleted = &OpenCompleted,
|
||||
.read = &Read,
|
||||
.getBuffer = &GetBuffer,
|
||||
.canRead = &CanRead,
|
||||
.close = &Close,
|
||||
.copyProperty = &CopyProperty,
|
||||
.schedule = &Schedule,
|
||||
.unschedule = &Unschedule
|
||||
};
|
||||
CFReadStreamRef read_stream = CFReadStreamCreate(nullptr,
|
||||
reinterpret_cast<const CFReadStreamCallBacks*>(&callbacks), &context);
|
||||
|
@ -227,9 +227,9 @@ bool ProcessInfo::Is64Bit(bool* is_64_bit) const {
|
||||
is_64_bit_initialized_.set_invalid();
|
||||
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
const bool am_64_bit = true;
|
||||
constexpr bool am_64_bit = true;
|
||||
#else
|
||||
const bool am_64_bit = false;
|
||||
constexpr bool am_64_bit = false;
|
||||
#endif
|
||||
|
||||
if (pid_ == getpid()) {
|
||||
|
@ -238,7 +238,7 @@ void Signals::RestoreHandlerAndReraiseSignalOnReturn(
|
||||
// Failures in this function should _exit(kFailureExitCode). This is a quick
|
||||
// and quiet failure. This function runs in signal handler context, and it’s
|
||||
// difficult to safely be loud from a signal handler.
|
||||
const int kFailureExitCode = 191;
|
||||
constexpr int kFailureExitCode = 191;
|
||||
|
||||
struct sigaction default_action;
|
||||
sigemptyset(&default_action.sa_mask);
|
||||
|
@ -122,9 +122,9 @@ TEST(SymbolicConstantsPOSIX, SignalToString) {
|
||||
|
||||
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
// NSIG is 64 to account for real-time signals.
|
||||
const int kSignalCount = 32;
|
||||
constexpr int kSignalCount = 32;
|
||||
#else
|
||||
const int kSignalCount = NSIG;
|
||||
constexpr int kSignalCount = NSIG;
|
||||
#endif
|
||||
|
||||
for (int signal = 0; signal < kSignalCount + 8; ++signal) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
@ -120,10 +121,9 @@ TEST(Semaphore, TenThreaded) {
|
||||
// resources (10), and the threads each try to obtain the resource a different
|
||||
// number of times.
|
||||
Semaphore semaphore(5);
|
||||
const size_t kThreads = 10;
|
||||
ThreadMainInfo info[kThreads];
|
||||
ThreadMainInfo info[10];
|
||||
size_t iterations = 0;
|
||||
for (size_t index = 0; index < kThreads; ++index) {
|
||||
for (size_t index = 0; index < arraysize(info); ++index) {
|
||||
info[index].semaphore = &semaphore;
|
||||
info[index].iterations = index;
|
||||
iterations += info[index].iterations;
|
||||
@ -135,7 +135,7 @@ TEST(Semaphore, TenThreaded) {
|
||||
semaphore.Signal();
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < kThreads; ++index) {
|
||||
for (size_t index = 0; index < arraysize(info); ++index) {
|
||||
JoinThread(&info[index]);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ std::string MessageString(const std::string& log_message) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const char kStartChar = '[';
|
||||
constexpr char kStartChar = '[';
|
||||
if (log_message[0] != kStartChar) {
|
||||
EXPECT_EQ(log_message[0], kStartChar);
|
||||
return std::string();
|
||||
@ -63,7 +63,7 @@ std::string MessageString(const std::string& log_message) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
const char kEndChar = '\n';
|
||||
constexpr char kEndChar = '\n';
|
||||
if (message_string[message_string.size() - 1] != kEndChar) {
|
||||
EXPECT_NE(message_string[message_string.size() - 1], kEndChar);
|
||||
return std::string();
|
||||
|
@ -34,13 +34,13 @@ namespace {
|
||||
// gtest assertions.
|
||||
void SanityCheckContext(const CONTEXT& context) {
|
||||
#if defined(ARCH_CPU_X86)
|
||||
const uint32_t must_have = CONTEXT_i386 |
|
||||
CONTEXT_CONTROL |
|
||||
CONTEXT_INTEGER |
|
||||
CONTEXT_SEGMENTS |
|
||||
CONTEXT_FLOATING_POINT;
|
||||
constexpr uint32_t must_have = CONTEXT_i386 |
|
||||
CONTEXT_CONTROL |
|
||||
CONTEXT_INTEGER |
|
||||
CONTEXT_SEGMENTS |
|
||||
CONTEXT_FLOATING_POINT;
|
||||
ASSERT_EQ(context.ContextFlags & must_have, must_have);
|
||||
const uint32_t may_have = CONTEXT_EXTENDED_REGISTERS;
|
||||
constexpr uint32_t may_have = CONTEXT_EXTENDED_REGISTERS;
|
||||
ASSERT_EQ(context.ContextFlags & ~(must_have | may_have), 0);
|
||||
#elif defined(ARCH_CPU_X86_64)
|
||||
ASSERT_EQ(context.ContextFlags,
|
||||
|
@ -329,7 +329,7 @@ bool ReadProcessData(HANDLE process,
|
||||
bool ReadMemoryInfo(HANDLE process, bool is_64_bit, ProcessInfo* process_info) {
|
||||
DCHECK(process_info->memory_info_.empty());
|
||||
|
||||
const WinVMAddress min_address = 0;
|
||||
constexpr WinVMAddress min_address = 0;
|
||||
// We can't use GetSystemInfo() to get the address space range for another
|
||||
// process. VirtualQueryEx() will fail with ERROR_INVALID_PARAMETER if the
|
||||
// address is above the highest memory address accessible to the process, so
|
||||
|
@ -601,7 +601,7 @@ TEST(ProcessInfo, Handles) {
|
||||
|
||||
// OBJ_INHERIT from ntdef.h, but including that conflicts with other
|
||||
// headers.
|
||||
const int kObjInherit = 0x2;
|
||||
constexpr int kObjInherit = 0x2;
|
||||
EXPECT_EQ(handle.attributes, kObjInherit);
|
||||
}
|
||||
if (handle.handle == HandleToInt(scoped_key.get())) {
|
||||
@ -633,7 +633,7 @@ TEST(ProcessInfo, Handles) {
|
||||
}
|
||||
|
||||
TEST(ProcessInfo, OutOfRangeCheck) {
|
||||
const size_t kAllocationSize = 12345;
|
||||
constexpr size_t kAllocationSize = 12345;
|
||||
std::unique_ptr<char[]> safe_memory(new char[kAllocationSize]);
|
||||
|
||||
ProcessInfo info;
|
||||
|
@ -46,7 +46,7 @@ timeval FiletimeToTimevalEpoch(const FILETIME& filetime) {
|
||||
// 1601 to 1970 is 369 years + 89 leap days = 134774 days * 86400 seconds per
|
||||
// day. It's not entirely clear, but it appears that these are solar seconds,
|
||||
// not SI seconds, so there are no leap seconds to be considered.
|
||||
const uint64_t kNumSecondsFrom1601To1970 = (369 * 365 + 89) * 86400ULL;
|
||||
constexpr uint64_t kNumSecondsFrom1601To1970 = (369 * 365 + 89) * 86400ULL;
|
||||
DCHECK_GE(microseconds, kNumSecondsFrom1601To1970 * kMicrosecondsPerSecond);
|
||||
microseconds -= kNumSecondsFrom1601To1970 * kMicrosecondsPerSecond;
|
||||
return MicrosecondsToTimeval(microseconds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user