crashpad/snapshot/win/capture_memory_delegate_win.cc
Scott Graham 0d4438b2a5 win: Don't add zero-sized memory ranges to dump
One possible cause for this would be a register "pointing" to the edge of an
inaccessible range. Having these zero-sized ranges doesn't break the minidump,
but it causes a warning when opening in windbg.

Also drop user-supplied zero-length memory ranges for the same reason.

BUG=crashpad:104

Change-Id: I2c5acc54f04fb617806cecd87ac4ad5db93f3db8
Reviewed-on: https://chromium-review.googlesource.com/339210
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-04-19 19:41:36 +00:00

59 lines
2.1 KiB
C++

// Copyright 2016 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "snapshot/win/capture_memory_delegate_win.h"
#include "snapshot/win/memory_snapshot_win.h"
namespace crashpad {
namespace internal {
CaptureMemoryDelegateWin::CaptureMemoryDelegateWin(
ProcessReaderWin* process_reader,
const ProcessReaderWin::Thread& thread,
PointerVector<MemorySnapshotWin>* snapshots)
: stack_(thread.stack_region_address, thread.stack_region_size),
process_reader_(process_reader),
snapshots_(snapshots) {}
bool CaptureMemoryDelegateWin::Is64Bit() const {
return process_reader_->Is64Bit();
}
bool CaptureMemoryDelegateWin::ReadMemory(uint64_t at,
uint64_t num_bytes,
void* into) const {
return process_reader_->ReadMemory(at, num_bytes, into);
}
std::vector<CheckedRange<uint64_t>> CaptureMemoryDelegateWin::GetReadableRanges(
const CheckedRange<uint64_t, uint64_t>& range) const {
return process_reader_->GetProcessInfo().GetReadableRanges(range);
}
void CaptureMemoryDelegateWin::AddNewMemorySnapshot(
const CheckedRange<uint64_t, uint64_t>& range) {
// Don't bother storing this memory if it points back into the stack.
if (stack_.ContainsRange(range))
return;
if (range.size() == 0)
return;
internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin();
snapshot->Initialize(process_reader_, range.base(), range.size());
snapshots_->push_back(snapshot);
}
} // namespace internal
} // namespace crashpad