class ProcessDump

Defined at line 133 of file ../../src/lib/zxdump/include/lib/zxdump/dump.h

This defines the public API methods for dumping (see above).

Public Methods

void ProcessDump ()

Defined at line 135 of file ../../src/lib/zxdump/include/lib/zxdump/dump.h

fit::result<Error> Remarks (std::string_view name, std::string_view string)

Defined at line 177 of file ../../src/lib/zxdump/include/lib/zxdump/dump.h

template <typename Dump>
fit::result<DumpError<Dump>, size_t> DumpHeaders (Dump && dump, size_t limit)

This must be called after CollectProcess.

Accumulate header and note data to be written out, by repeatedly calling

`dump(size_t offset, ByteView data)`. The Dump callback returns some

`fit::result

<error

_type>` type. DumpHeaders returns a result of type

`fit::result

<zxdump

::DumpError

<Dump

>, size_t>` with the result of the

first failing callback, or with the total number of bytes dumped (i.e. the

ending value of `offset`).

This can be used to collect data in place or to stream it out. The

callbacks supply a stream of data where the first chunk has offset 0 and

later chunks always increase the offset. This streams out the ELF file

and program headers, and then the note data that collects all the

process-wide, and (optionally) thread, state. The views point into

storage helds inside the DumpProcess object. They can be used freely

until the object is destroyed or clear()'d.

Defined at line 224 of file ../../src/lib/zxdump/include/lib/zxdump/dump.h

template <typename Dump>
fit::result<DumpError<Dump>, size_t> DumpMemory (Dump && dump, size_t limit)

This must be called after DumpHeaders.

Stream out memory data for the PT_LOAD segments, by repeatedly calling

`dump(size_t offset, ByteView data)` as in DumpHeaders, above. While

DumpHeaders can really only fail if the Dump function returns an error,

DumpMemory's error result might have `.dump_error_ == std::nullopt` when

there was an error for reading memory from the process. On success,

result value is the total byte size of the ET_CORE file, which is now

complete. (This includes the size returned by DumpHeaders plus all the

memory segments written and any padding in between.)

The offset in the first callback is greater than the offset in the last

DumpHeaders callback, and later callbacks always increase the offset.

There may be a gap from the end of previous chunk, which should be filled

with zero (or made sparse in the output file). Unlike DumpHeaders, the

view passed to the `dump` callback here points into a temporary buffer

that will be reused for the next callback. So this `dump` callback must

stream the data out or copy it, not just accumulate the view objects.

Defined at line 249 of file ../../src/lib/zxdump/include/lib/zxdump/dump.h

void ProcessDump (ProcessDump && )

Defined at line 1407 of file ../../src/lib/zxdump/dump.cc

ProcessDump & operator= (ProcessDump && )

Defined at line 1408 of file ../../src/lib/zxdump/dump.cc

void ProcessDump (Process & process)

A single Collector cannot be used for a different process later. It can be

clear()'d to reset all state other than the process handle and the process

being suspended.

Defined at line 1452 of file ../../src/lib/zxdump/dump.cc

void ~ProcessDump ()

Defined at line 1409 of file ../../src/lib/zxdump/dump.cc

Process & process ()

Defined at line 1411 of file ../../src/lib/zxdump/dump.cc

void clear ()

Reset to initial state, except that if the process is already suspended,

it stays that way.

Defined at line 1413 of file ../../src/lib/zxdump/dump.cc

void set_date (time_t date)

If this is called before DumpHeaders, the dump will include a date note.

Defined at line 1442 of file ../../src/lib/zxdump/dump.cc

fit::result<Error> SuspendAndCollectThreads ()

This can be called at most once and must be called first if at all. If

this is not called, then threads may be allowed to run while the dump

takes place, yielding an inconsistent memory image; and CollectProcess

will report only about memory and process-wide state, nothing about

threads. Afterwards the process remains suspended until the ProcessDump

object is destroyed.

Defined at line 1415 of file ../../src/lib/zxdump/dump.cc

fit::result<Error> CollectSystem (const TaskHolder & holder)

Collect system-wide information. This is always optional, but it must

always be called before CollectProcess, if called at all. The system

information is included in the total size returned by CollectProcess.

Defined at line 1425 of file ../../src/lib/zxdump/dump.cc

fit::result<Error> CollectKernel ()

Collect privileged system-wide information from the kernel. This is

always optional, but it must always be called before CollectProcess, if

called at all. The kernel information is included in the total size

returned by CollectProcess. Note this only works if the

zxdump::TaskHolder from which the zxdump::Process being dumped was loaded

has had the info resource inserted (either the real live object or from a

dump).

Defined at line 1423 of file ../../src/lib/zxdump/dump.cc

fit::result<Error> Remarks (std::string_view name, ByteView data)

Add dump remarks. This can be called any number of times, but must be

called before CollectProcess if it's called at all.

Defined at line 1444 of file ../../src/lib/zxdump/dump.cc

fit::result<Error, size_t> CollectProcess (SegmentCallback prune_segment, size_t limit)

This can be called first or after SuspendAndCollectThreads.

This collects information about memory and other process-wide state. The

return value gives the total size of the ET_CORE file to be written.

Collection is cut short without error if the ET_CORE file would already

exceed the size limit without even including the memory. See above for

how the callback is used.

When this is complete, all data has been collected and all ET_CORE layout

has been done and the live data from the process won't be consulted again.

The only state still left to be collected from the process is the contents

of its memory.

Defined at line 1419 of file ../../src/lib/zxdump/dump.cc

fit::result<Error, std::optional<SegmentDisposition::Note>> FindBuildIdNote (const zx_info_maps_t & segment)

This examines the memory to find an ELF image with a build ID note. If

there are no errors reading the memory but no ELF image or no build ID

note is found, then the result is fit::ok(std::nullopt). This is meant

to be used from a `prune_segment` callback in CollectProcess (see above).

Defined at line 1429 of file ../../src/lib/zxdump/dump.cc