Crashpad
Classes | Public Member Functions | List of all members
crashpad::MemoryMap Class Reference

Accesses information about mapped memory in another process. More...

#include "util/linux/memory_map.h"

Classes

class  Iterator
 An abstract base class for iterating over ordered sets of mappings in a MemoryMap. More...
 
struct  Mapping
 Information about a mapped region of memory. More...
 

Public Member Functions

bool Initialize (PtraceConnection *connection)
 Initializes this object with information about the mapped memory regions in the process connected via connection. More...
 
const MappingFindMapping (LinuxVMAddress address) const
 
const MappingFindMappingWithName (const std::string &name) const
 
std::unique_ptr< IteratorFindFilePossibleMmapStarts (const Mapping &mapping) const
 Find possible initial mappings of files mapped over several segments. More...
 
std::unique_ptr< IteratorReverseIteratorFrom (const Mapping &mapping) const
 

Detailed Description

Accesses information about mapped memory in another process.

The target process must be stopped to guarantee correct mappings. If the target process is not stopped, mappings may be invalid after the return from Initialize(), and even mappings existing at the time Initialize() was called may not be found.

Member Function Documentation

◆ FindFilePossibleMmapStarts()

std::unique_ptr< MemoryMap::Iterator > crashpad::MemoryMap::FindFilePossibleMmapStarts ( const Mapping mapping) const

Find possible initial mappings of files mapped over several segments.

Executables and libaries are typically loaded into several mappings with varying permissions for different segments. Portions of an ELF file may be mapped multiple times as part of loading the file, for example, when initializing GNU_RELRO segments.

This method searches for mappings at or below mapping in memory that are mapped from the same file as mapping from offset 0.

On Android, ELF modules may be loaded from within a zipfile, so this method may return mappings whose offset is not 0.

This method is intended to help identify the possible base address for loaded modules, but it is the caller's responsibility to determine which returned mapping is correct.

If mapping does not refer to a valid mapping, an empty vector will be returned and a message will be logged. If mapping is found but does not map a file, mapping is returned in possible_starts.

Parameters
[in]mappingA Mapping whose series to find the start of.
Returns
a reverse iterator over the possible mapping starts, starting from the mapping with highest base address.

◆ FindMapping()

const MemoryMap::Mapping * crashpad::MemoryMap::FindMapping ( LinuxVMAddress  address) const
Returns
The Mapping containing address or nullptr if no match is found. The caller does not take ownership of this object. It is scoped to the lifetime of the MemoryMap object that it was obtained from.

◆ FindMappingWithName()

const MemoryMap::Mapping * crashpad::MemoryMap::FindMappingWithName ( const std::string &  name) const
Returns
The Mapping with the lowest base address whose name is name or nullptr if no match is found. The caller does not take ownership of this object. It is scoped to the lifetime of the MemoryMap object that it was obtained from.

◆ Initialize()

bool crashpad::MemoryMap::Initialize ( PtraceConnection connection)

Initializes this object with information about the mapped memory regions in the process connected via connection.

This method must be called successfully prior to calling any other method in this class. This method may only be called once.

Parameters
[in]connectionA connection to the process create a map for.
Returns
true on success, false on failure with a message logged.

◆ ReverseIteratorFrom()

std::unique_ptr< MemoryMap::Iterator > crashpad::MemoryMap::ReverseIteratorFrom ( const Mapping mapping) const
Returns
A reverse iterator over all mappings in the MemoryMap from mapping to the start of the MemoryMap.

The documentation for this class was generated from the following files: