Crashpad
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
crashpad::MinidumpMemoryWriter Class Referenceabstract

The base class for writers of memory ranges pointed to by MINIDUMP_MEMORY_DESCRIPTOR objects in a minidump file. More...

#include "minidump/minidump_memory_writer.h"

Inheritance diagram for crashpad::MinidumpMemoryWriter:
crashpad::internal::MinidumpWritable crashpad::test::TestMinidumpMemoryWriter crashpad::PointerContainer< crashpad::MinidumpMemoryWriter >

Public Member Functions

const MINIDUMP_MEMORY_DESCRIPTORMinidumpMemoryDescriptor () const
 Returns a MINIDUMP_MEMORY_DESCRIPTOR referencing the data that this object writes. More...
 
void RegisterMemoryDescriptor (MINIDUMP_MEMORY_DESCRIPTOR *memory_descriptor)
 Registers a memory descriptor as one that should point to the object on which this method is called. More...
 
- Public Member Functions inherited from crashpad::internal::MinidumpWritable
virtual bool WriteEverything (FileWriterInterface *file_writer)
 Writes an object and all of its children to a minidump file. More...
 
void RegisterRVA (RVA *rva)
 Registers a file offset pointer as one that should point to the object on which this method is called. More...
 
void RegisterLocationDescriptor (MINIDUMP_LOCATION_DESCRIPTOR *location_descriptor)
 Registers a location descriptor as one that should point to the object on which this method is called. More...
 

Static Public Member Functions

static std::unique_ptr< MinidumpMemoryWriterCreateFromSnapshot (const MemorySnapshot *memory_snapshot)
 Creates a concrete initialized MinidumpMemoryWriter based on memory_snapshot. More...
 

Protected Member Functions

virtual uint64_t MemoryRangeBaseAddress () const =0
 Returns the base address of the memory region in the address space of the process that the snapshot describes. More...
 
virtual size_t MemoryRangeSize () const =0
 Returns the size of the memory region in bytes. More...
 
bool Freeze () override
 Transitions the object from kStateMutable to kStateFrozen. More...
 
size_t SizeOfObject () final
 Returns the amount of space that this object will consume when written to a minidump file, in bytes, not including any leading or trailing padding necessary to maintain proper alignment. More...
 
size_t Alignment () override
 Returns the object’s desired byte-boundary alignment. More...
 
bool WillWriteAtOffsetImpl (FileOffset offset) override
 Called once an object’s writable file offset is determined, as it transitions into kStateWritable. More...
 
Phase WritePhase () final
 Returns the object’s desired write phase. More...
 
- Protected Member Functions inherited from crashpad::internal::MinidumpWritable
State state () const
 The state of the object.
 
virtual std::vector< MinidumpWritable * > Children ()
 Returns the object’s children. More...
 
size_t WillWriteAtOffset (Phase phase, FileOffset *offset, std::vector< MinidumpWritable * > *write_sequence)
 Prepares the object to be written at a known file offset, transitioning it from kStateFrozen to kStateWritable. More...
 
bool WritePaddingAndObject (FileWriterInterface *file_writer)
 Writes the object, transitioning it from kStateWritable to kStateWritten. More...
 
virtual bool WriteObject (FileWriterInterface *file_writer)=0
 Writes the object’s content. More...
 

Additional Inherited Members

- Protected Types inherited from crashpad::internal::MinidumpWritable
enum  State
 Identifies the state of an object. More...
 
enum  Phase
 Identifies the phase during which an object will be written to a minidump file. More...
 
- Static Protected Attributes inherited from crashpad::internal::MinidumpWritable
static const size_t kInvalidSize
 A size value used to signal failure by methods that return size_t. More...
 

Detailed Description

The base class for writers of memory ranges pointed to by MINIDUMP_MEMORY_DESCRIPTOR objects in a minidump file.

This is an abstract base class because users are expected to provide their own implementations that, when possible, obtain the memory contents on-demand in their WriteObject() methods. Memory ranges may be large, and the alternative construction would require the contents of multiple ranges to be held in memory simultaneously while a minidump file is being written.

Member Function Documentation

size_t crashpad::MinidumpMemoryWriter::Alignment ( )
overrideprotectedvirtual

Returns the object’s desired byte-boundary alignment.

Memory regions are aligned to a 16-byte boundary. The actual alignment requirements of any data within the memory region are unknown, and may be more or less strict than this depending on the platform.

Returns
16.
Note
Valid in kStateFrozen or any subsequent state.

Reimplemented from crashpad::internal::MinidumpWritable.

std::unique_ptr< MinidumpMemoryWriter > crashpad::MinidumpMemoryWriter::CreateFromSnapshot ( const MemorySnapshot memory_snapshot)
static

Creates a concrete initialized MinidumpMemoryWriter based on memory_snapshot.

Parameters
[in]memory_snapshotThe memory snapshot to use as source data.
Returns
An object of a MinidumpMemoryWriter subclass initialized using the source data in memory_snapshot.
bool crashpad::MinidumpMemoryWriter::Freeze ( )
overrideprotectedvirtual

Transitions the object from kStateMutable to kStateFrozen.

The default implementation marks the object as frozen and recursively calls Freeze() on all of its children. Subclasses may override this method to perform processing that should only be done once callers have finished populating an object with data. Typically, a subclass implementation would call RegisterRVA() or RegisterLocationDescriptor() on other objects as appropriate, because at the time Freeze() runs, the in-memory locations of RVAs and location descriptors are known and will not change for the remaining duration of an object’s lifetime.

Returns
true on success. false on failure, with an appropriate message logged.

Reimplemented from crashpad::internal::MinidumpWritable.

virtual uint64_t crashpad::MinidumpMemoryWriter::MemoryRangeBaseAddress ( ) const
protectedpure virtual

Returns the base address of the memory region in the address space of the process that the snapshot describes.

Note
This method will only be called in kStateFrozen.

Implemented in crashpad::test::TestMinidumpMemoryWriter.

virtual size_t crashpad::MinidumpMemoryWriter::MemoryRangeSize ( ) const
protectedpure virtual

Returns the size of the memory region in bytes.

Note
This method will only be called in kStateFrozen or a subsequent state.

Implemented in crashpad::test::TestMinidumpMemoryWriter.

const MINIDUMP_MEMORY_DESCRIPTOR * crashpad::MinidumpMemoryWriter::MinidumpMemoryDescriptor ( ) const

Returns a MINIDUMP_MEMORY_DESCRIPTOR referencing the data that this object writes.

This method is expected to be called by a MinidumpMemoryListWriter in order to obtain a MINIDUMP_MEMORY_DESCRIPTOR to include in its list.

Note
Valid in kStateWritable.
void crashpad::MinidumpMemoryWriter::RegisterMemoryDescriptor ( MINIDUMP_MEMORY_DESCRIPTOR memory_descriptor)

Registers a memory descriptor as one that should point to the object on which this method is called.

This method is expected to be called by objects of other classes, when those other classes have their own memory descriptors that need to point to memory ranges within a minidump file. MinidumpThreadWriter is one such class. This method is public for this reason, otherwise it would suffice to be private.

Note
Valid in kStateFrozen or any preceding state.
size_t crashpad::MinidumpMemoryWriter::SizeOfObject ( )
finalprotectedvirtual

Returns the amount of space that this object will consume when written to a minidump file, in bytes, not including any leading or trailing padding necessary to maintain proper alignment.

Note
Valid in kStateFrozen or any subsequent state.

Implements crashpad::internal::MinidumpWritable.

bool crashpad::MinidumpMemoryWriter::WillWriteAtOffsetImpl ( FileOffset  offset)
overrideprotectedvirtual

Called once an object’s writable file offset is determined, as it transitions into kStateWritable.

Subclasses can override this method if they need to provide additional processing once their writable file offset is known. Typically, this will be done by subclasses that handle certain RVAs themselves instead of using the RegisterRVA() interface.

Parameters
[in]offsetThe file offset at which the object will be written. The value passed to this method will already have been adjusted to meet alignment requirements.
Returns
true on success. false on error, indicating that the minidump file should not be written.
Note
Valid in kStateFrozen. The object will transition to kStateWritable after this method returns.

Reimplemented from crashpad::internal::MinidumpWritable.

Reimplemented in crashpad::test::TestMinidumpMemoryWriter.

internal::MinidumpWritable::Phase crashpad::MinidumpMemoryWriter::WritePhase ( )
finalprotectedvirtual

Returns the object’s desired write phase.

Memory regions are written at the end of minidump files, because it is expected that unlike most other data in a minidump file, the contents of memory regions will be accessed sparsely.

Returns
kPhaseLate.
Note
Valid in any state.

Reimplemented from crashpad::internal::MinidumpWritable.


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