2022-09-06 19:14:07 -04:00
|
|
|
// Copyright 2016 The Crashpad Authors
|
2016-01-14 12:50:22 -08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#ifndef CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_
|
|
|
|
#define CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "snapshot/cpu_context.h"
|
|
|
|
#include "util/numeric/checked_range.h"
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
|
|
|
class MemorySnapshot;
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class CaptureMemory {
|
|
|
|
public:
|
|
|
|
//! \brief An interface to a platform-specific process reader.
|
|
|
|
class Delegate {
|
|
|
|
public:
|
|
|
|
virtual ~Delegate() {}
|
|
|
|
|
|
|
|
//! \return `true` if the target process is a 64-bit process.
|
|
|
|
virtual bool Is64Bit() const = 0;
|
|
|
|
|
|
|
|
//! \brief Attempts to read \a num_bytes bytes from the target process
|
|
|
|
//! starting at address \a at into \a into.
|
|
|
|
//!
|
|
|
|
//! \return `true` if the entire region could be read, or `false` with an
|
|
|
|
//! error logged.
|
|
|
|
virtual bool ReadMemory(uint64_t at,
|
|
|
|
uint64_t num_bytes,
|
|
|
|
void* into) const = 0;
|
|
|
|
|
|
|
|
//! \brief Given a range to be read from the target process, returns a
|
|
|
|
//! vector
|
|
|
|
//! of ranges, representing the readable portions of the original range.
|
|
|
|
//!
|
|
|
|
//! \param[in] range The range being identified.
|
|
|
|
//!
|
|
|
|
//! \return A vector of ranges corresponding to the portion of \a range that
|
|
|
|
//! is readable.
|
|
|
|
virtual std::vector<CheckedRange<uint64_t>> GetReadableRanges(
|
|
|
|
const CheckedRange<uint64_t, uint64_t>& range) const = 0;
|
|
|
|
|
|
|
|
//! \brief Adds the given range representing a memory snapshot in the target
|
|
|
|
//! process to the result.
|
|
|
|
virtual void AddNewMemorySnapshot(
|
|
|
|
const CheckedRange<uint64_t, uint64_t>& range) = 0;
|
|
|
|
};
|
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
CaptureMemory() = delete;
|
|
|
|
CaptureMemory(const CaptureMemory&) = delete;
|
|
|
|
CaptureMemory& operator=(const CaptureMemory&) = delete;
|
|
|
|
|
2016-01-14 12:50:22 -08:00
|
|
|
//! \brief For all registers that appear to be pointer-like in \a context,
|
|
|
|
//! captures a small amount of memory near their pointed to location.
|
|
|
|
//!
|
|
|
|
//! "Pointer-like" in this context means not too close to zero (signed or
|
|
|
|
//! unsigned) so that there's a reasonable chance that the value is a pointer.
|
|
|
|
//!
|
|
|
|
//! \param[in] context The context to inspect.
|
doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.
The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.
Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).
A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.
Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.
Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 14:23:09 -05:00
|
|
|
//! \param[in] delegate A Delegate that handles reading from the target
|
|
|
|
//! process and adding new ranges.
|
2016-01-14 12:50:22 -08:00
|
|
|
static void PointedToByContext(const CPUContext& context, Delegate* delegate);
|
|
|
|
|
|
|
|
//! \brief For all pointer-like values in a memory range of the target
|
|
|
|
//! process,
|
|
|
|
//! captures a small amount of memory near the pointed to location.
|
|
|
|
//!
|
|
|
|
//! \param[in] memory An existing MemorySnapshot of the range to search. The
|
|
|
|
//! base address and size must be pointer-aligned and an integral number
|
|
|
|
//! of
|
|
|
|
//! pointers long.
|
doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.
The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.
Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).
A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.
Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.
Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 14:23:09 -05:00
|
|
|
//! \param[in] delegate A Delegate that handles reading from the target
|
|
|
|
//! process and adding new ranges.
|
2016-01-14 12:50:22 -08:00
|
|
|
static void PointedToByMemoryRange(const MemorySnapshot& memory,
|
|
|
|
Delegate* delegate);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
#endif // CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_
|