mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-28 15:50:26 +08:00
032f1aecc2
Add direct includes for things provided transitively by logging.h (or by other headers including logging.h). This is in preparation for cleaning up unnecessary includes of logging.h in header files (so if something depends on logging.h, it needs include it explicitly), and for when Chromium's logging.h no longer includes check.h, check_op.h, and notreached.h. DEPS is also updated to roll mini_chromium to ae14a14ab4 which includes these new header files. Bug: chromium:1031540 Change-Id: I36f646d0a93854989dc602d0dc7139dd7a7b8621 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2250251 Commit-Queue: Hans Wennborg <hans@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
97 lines
3.2 KiB
C++
97 lines
3.2 KiB
C++
// Copyright 2018 The Crashpad Authors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "snapshot/memory_snapshot.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "base/format_macros.h"
|
|
#include "base/logging.h"
|
|
#include "base/strings/stringprintf.h"
|
|
#include "util/numeric/checked_range.h"
|
|
|
|
namespace crashpad {
|
|
namespace {
|
|
|
|
bool DetermineMergedRangeImpl(bool log,
|
|
const MemorySnapshot* a,
|
|
const MemorySnapshot* b,
|
|
CheckedRange<uint64_t, size_t>* merged) {
|
|
if (a->Size() == 0) {
|
|
LOG_IF(ERROR, log) << base::StringPrintf(
|
|
"invalid empty range at 0x%" PRIx64, a->Address());
|
|
return false;
|
|
}
|
|
|
|
if (b->Size() == 0) {
|
|
LOG_IF(ERROR, log) << base::StringPrintf(
|
|
"invalid empty range at 0x%" PRIx64, b->Address());
|
|
return false;
|
|
}
|
|
|
|
CheckedRange<uint64_t, size_t> range_a(a->Address(), a->Size());
|
|
if (!range_a.IsValid()) {
|
|
LOG_IF(ERROR, log) << base::StringPrintf("invalid range at 0x%" PRIx64
|
|
", size %" PRIuS,
|
|
range_a.base(),
|
|
range_a.size());
|
|
return false;
|
|
}
|
|
|
|
CheckedRange<uint64_t, size_t> range_b(b->Address(), b->Size());
|
|
if (!range_b.IsValid()) {
|
|
LOG_IF(ERROR, log) << base::StringPrintf("invalid range at 0x%" PRIx64
|
|
", size %" PRIuS,
|
|
range_b.base(),
|
|
range_b.size());
|
|
return false;
|
|
}
|
|
|
|
if (!range_a.OverlapsRange(range_b) && range_a.end() != range_b.base() &&
|
|
range_b.end() != range_a.base()) {
|
|
LOG_IF(ERROR, log) << base::StringPrintf(
|
|
"ranges not overlapping or abutting: (0x%" PRIx64 ", size %" PRIuS
|
|
") and (0x%" PRIx64 ", size %" PRIuS ")",
|
|
range_a.base(),
|
|
range_a.size(),
|
|
range_b.base(),
|
|
range_b.size());
|
|
return false;
|
|
}
|
|
|
|
if (merged) {
|
|
uint64_t base = std::min(range_a.base(), range_b.base());
|
|
uint64_t end = std::max(range_a.end(), range_b.end());
|
|
size_t size = static_cast<size_t>(end - base);
|
|
merged->SetRange(base, size);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
bool LoggingDetermineMergedRange(const MemorySnapshot* a,
|
|
const MemorySnapshot* b,
|
|
CheckedRange<uint64_t, size_t>* merged) {
|
|
return DetermineMergedRangeImpl(true, a, b, merged);
|
|
}
|
|
|
|
bool DetermineMergedRange(const MemorySnapshot* a,
|
|
const MemorySnapshot* b,
|
|
CheckedRange<uint64_t, size_t>* merged) {
|
|
return DetermineMergedRangeImpl(false, a, b, merged);
|
|
}
|
|
|
|
} // namespace crashpad
|