xref: /aosp_15_r20/external/pigweed/pw_snapshot/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_snapshot:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker===========
4*61c4878aSAndroid Build Coastguard Workerpw_snapshot
5*61c4878aSAndroid Build Coastguard Worker===========
6*61c4878aSAndroid Build Coastguard Worker
7*61c4878aSAndroid Build Coastguard Worker.. warning::
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Worker  This module is unstable and under active development. The snapshot proto
10*61c4878aSAndroid Build Coastguard Worker  format may see breaking changes as it stabilizes.
11*61c4878aSAndroid Build Coastguard Worker
12*61c4878aSAndroid Build Coastguard Worker``pw_snapshot`` provides a storage format and associated tooling for capturing a
13*61c4878aSAndroid Build Coastguard Workerdevice's system state at a given point in time for analysis at a later time.
14*61c4878aSAndroid Build Coastguard WorkerThis is particularly useful for capturing information at crash time to provide
15*61c4878aSAndroid Build Coastguard Workercontext to the cause of the crash. Outside of crash reporting, snapshots can be
16*61c4878aSAndroid Build Coastguard Workerused to debug anomalies that don't result in crashes by treating snapshotting as
17*61c4878aSAndroid Build Coastguard Workera heavyweight alternative to tracing, logging-based dump commands, or other
18*61c4878aSAndroid Build Coastguard Workeron-demand system state capturing.
19*61c4878aSAndroid Build Coastguard Worker
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Worker.. toctree::
22*61c4878aSAndroid Build Coastguard Worker  :maxdepth: 1
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Worker  setup
25*61c4878aSAndroid Build Coastguard Worker  module_usage
26*61c4878aSAndroid Build Coastguard Worker  proto_format
27*61c4878aSAndroid Build Coastguard Worker  design_discussion
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Worker------------------
30*61c4878aSAndroid Build Coastguard WorkerLife of a Snapshot
31*61c4878aSAndroid Build Coastguard Worker------------------
32*61c4878aSAndroid Build Coastguard WorkerA "snapshot" is just a `proto message
33*61c4878aSAndroid Build Coastguard Worker<https://cs.pigweed.dev/pigweed/+/HEAD:pw_snapshot/pw_snapshot_protos/snapshot.proto>`_
34*61c4878aSAndroid Build Coastguard Workerwith many optional fields that describe a device's state at the time the
35*61c4878aSAndroid Build Coastguard Workersnapshot was captured. The serialized proto can then be stored and transfered
36*61c4878aSAndroid Build Coastguard Workerlike a file so it can be analyzed at a later time.
37*61c4878aSAndroid Build Coastguard Worker
38*61c4878aSAndroid Build Coastguard Worker#. **Snapshot capture triggered** - The device encounters a condition that
39*61c4878aSAndroid Build Coastguard Worker   indicates a snapshot should be captured. This could be through a crash
40*61c4878aSAndroid Build Coastguard Worker   handler, or through other developer-specified entry points.
41*61c4878aSAndroid Build Coastguard Worker#. **Device "pauses"** - In order to capture system state, the device must
42*61c4878aSAndroid Build Coastguard Worker   temporarily disable the thread scheduler and regular servicing of interrupts
43*61c4878aSAndroid Build Coastguard Worker   to prevent the system state from churning while it is captured.
44*61c4878aSAndroid Build Coastguard Worker#. **Snapshot captured** - The device collects information throughout the
45*61c4878aSAndroid Build Coastguard Worker   system through a project-provided snapshot collection logic flow. This data
46*61c4878aSAndroid Build Coastguard Worker   is stored as a serialized Snapshot proto message for later retrieval.
47*61c4878aSAndroid Build Coastguard Worker#. **Device resumes** - After a snapshot is stored, the device resumes normal
48*61c4878aSAndroid Build Coastguard Worker   execution. In a crash handler, the device will usually reboot instead of
49*61c4878aSAndroid Build Coastguard Worker   returning to normal execution.
50*61c4878aSAndroid Build Coastguard Worker#. **Snapshot retrieved from device** - During normal device operation, stored
51*61c4878aSAndroid Build Coastguard Worker   snapshots are retrieved from a device by a client that is interested in
52*61c4878aSAndroid Build Coastguard Worker   analyzing the snapshot, or forwarding it elsewhere to be analyzed.
53*61c4878aSAndroid Build Coastguard Worker#. **Snapshot analyzed** - Finally, analysis tooling is run on the captured
54*61c4878aSAndroid Build Coastguard Worker   snapshot proto to produce human readable dumps (akin to a crash report).
55*61c4878aSAndroid Build Coastguard Worker   Alternatively, the data can be ingested by a server to act as a cloud crash
56*61c4878aSAndroid Build Coastguard Worker   reporting endpoint. The structured form of a snapshot enables common
57*61c4878aSAndroid Build Coastguard Worker   cloud-based crash reporting needs like version filtering, crash signatures,
58*61c4878aSAndroid Build Coastguard Worker   de-duplication, and binary-matched symbolization.
59*61c4878aSAndroid Build Coastguard Worker
60*61c4878aSAndroid Build Coastguard WorkerWhile Pigweed provides libraries for each part of a snapshot's lifecycle, the
61*61c4878aSAndroid Build Coastguard Workerglue that puts all these pieces together is project specific. Please see the
62*61c4878aSAndroid Build Coastguard Workersection on :ref:`Setting up a Snapshot Pipeline<module-pw_snapshot-setup>` for
63*61c4878aSAndroid Build Coastguard Workermore information on how to bring up snapshot support for your project.
64