Crashpad
|
The root-level object in a minidump file. More...
#include "minidump/minidump_file_writer.h"
Public Member Functions | |
void | InitializeFromSnapshot (const ProcessSnapshot *process_snapshot) |
Initializes the MinidumpFileWriter and populates it with appropriate child streams based on process_snapshot. More... | |
void | SetTimestamp (time_t timestamp) |
Sets MINIDUMP_HEADER::Timestamp. More... | |
bool | AddStream (std::unique_ptr< internal::MinidumpStreamWriter > stream) |
Adds a stream to the minidump file and arranges for a MINIDUMP_DIRECTORY entry to point to it. More... | |
bool | AddUserExtensionStream (std::unique_ptr< MinidumpUserExtensionStreamDataSource > user_extension_stream_data) |
Adds a user extension stream to the minidump file and arranges for a MINIDUMP_DIRECTORY entry to point to it. More... | |
bool | WriteEverything (FileWriterInterface *file_writer) override |
Writes an object and all of its children to a minidump file. More... | |
bool | WriteMinidump (FileWriterInterface *file_writer, bool allow_seek) |
Writes this object to a minidump file. More... | |
Public Member Functions inherited from crashpad::internal::MinidumpWritable | |
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... | |
Protected Member Functions | |
bool | Freeze () override |
Transitions the object from kStateMutable to kStateFrozen. More... | |
size_t | SizeOfObject () override |
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... | |
std::vector< MinidumpWritable * > | Children () override |
Returns the object’s children. More... | |
bool | WillWriteAtOffsetImpl (FileOffset offset) override |
Called once an object’s writable file offset is determined, as it transitions into kStateWritable. More... | |
bool | WriteObject (FileWriterInterface *file_writer) override |
Writes the object’s content. More... | |
Protected Member Functions inherited from crashpad::internal::MinidumpWritable | |
State | state () const |
The state of the object. | |
virtual size_t | Alignment () |
Returns the object’s desired byte-boundary alignment. More... | |
virtual Phase | WritePhase () |
Returns the object’s desired write phase. 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... | |
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 constexpr size_t | kInvalidSize = std::numeric_limits<size_t>::max() |
A size value used to signal failure by methods that return size_t . | |
The root-level object in a minidump file.
This object writes a MINIDUMP_HEADER and list of MINIDUMP_DIRECTORY entries to a minidump file.
bool crashpad::MinidumpFileWriter::AddStream | ( | std::unique_ptr< internal::MinidumpStreamWriter > | stream | ) |
Adds a stream to the minidump file and arranges for a MINIDUMP_DIRECTORY entry to point to it.
This object takes ownership of stream and becomes its parent in the overall tree of internal::MinidumpWritable objects.
At most one object of each stream type (as obtained from internal::MinidumpStreamWriter::StreamType()) may be added to a MinidumpFileWriter object. If an attempt is made to add a stream whose type matches an existing stream’s type, this method discards the new stream.
true
on success. false
on failure, as occurs when an attempt is made to add a stream whose type matches an existing stream’s type, with a message logged. bool crashpad::MinidumpFileWriter::AddUserExtensionStream | ( | std::unique_ptr< MinidumpUserExtensionStreamDataSource > | user_extension_stream_data | ) |
Adds a user extension stream to the minidump file and arranges for a MINIDUMP_DIRECTORY entry to point to it.
This object takes ownership of user_extension_stream_data.
At most one object of each stream type (as obtained from internal::MinidumpStreamWriter::StreamType()) may be added to a MinidumpFileWriter object. If an attempt is made to add a stream whose type matches an existing stream’s type, this method discards the new stream.
[in] | user_extension_stream_data | The stream data to add to the minidump file. Note that the buffer this object points to must be valid through WriteEverything(). |
true
on success. false
on failure, as occurs when an attempt is made to add a stream whose type matches an existing stream’s type, with a message logged.
|
overrideprotectedvirtual |
Returns the object’s children.
Reimplemented from crashpad::internal::MinidumpWritable.
|
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.
true
on success. false
on failure, with an appropriate message logged. Reimplemented from crashpad::internal::MinidumpWritable.
void crashpad::MinidumpFileWriter::InitializeFromSnapshot | ( | const ProcessSnapshot * | process_snapshot | ) |
Initializes the MinidumpFileWriter and populates it with appropriate child streams based on process_snapshot.
This method will add additional streams to the minidump file as children of the MinidumpFileWriter object and as pointees of the top-level MINIDUMP_DIRECTORY. To do so, it will obtain other snapshot information from process_snapshot, such as a SystemSnapshot, lists of ThreadSnapshot and ModuleSnapshot objects, and, if available, an ExceptionSnapshot.
The streams are added in the order that they are expected to be most useful to minidump readers, to improve data locality and minimize seeking. The streams are added in this order:
[in] | process_snapshot | The process snapshot to use as source data. |
void crashpad::MinidumpFileWriter::SetTimestamp | ( | time_t | timestamp | ) |
Sets MINIDUMP_HEADER::Timestamp.
|
overrideprotectedvirtual |
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.
Implements crashpad::internal::MinidumpWritable.
|
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.
[in] | offset | The file offset at which the object will be written. The value passed to this method will already have been adjusted to meet alignment requirements. |
true
on success. false
on error, indicating that the minidump file should not be written.Reimplemented from crashpad::internal::MinidumpWritable.
|
overridevirtual |
Writes an object and all of its children to a minidump file.
Use this on the root object of a tree of MinidumpWritable objects, typically on a MinidumpFileWriter object.
[in] | file_writer | The file writer to receive the minidump file’s content. |
true
on success. false
on failure, with an appropriate message logged.This method does not initially write the final value for MINIDUMP_HEADER::Signature. After all child objects have been written, it rewinds to the beginning of the file and writes the correct value for this field. This prevents incompletely-written minidump files from being mistaken for valid ones.
Reimplemented from crashpad::internal::MinidumpWritable.
bool crashpad::MinidumpFileWriter::WriteMinidump | ( | FileWriterInterface * | file_writer, |
bool | allow_seek | ||
) |
Writes this object to a minidump file.
Same as WriteEverything, but give the option to disable the seek. It is typically used to write to stream backed FileWriterInterface which doesn't support seek.
[in] | file_writer | The file writer to receive the minidump file’s content. |
[in] | allow_seek | Whether seek is allowed. |
true
on success. false
on failure, with an appropriate message logged.
|
overrideprotectedvirtual |
Writes the object’s content.
[in] | file_writer | The file writer to receive the object’s content. |
true
on success. false
on error, indicating that the content could not be written to the minidump file.Implements crashpad::internal::MinidumpWritable.