Save the state of the system when it crashes, for analysis after the reset.
More...
Save the state of the system when it crashes, for analysis after the reset.
A dump holds the memory regions defined with PBL_COREDUMP_REGION_DEFINE and the registers of every thread. It is written to every backend, see Backends, and read back after the reset through the pbl_coredump_stored_* functions.
◆ pbl_coredump_metadata
| struct pbl_coredump_metadata |
Identification of the system that wrote a dump.
| Data Fields |
|
char |
build_id[64] |
Firmware build ID. |
|
char |
serial_number[16] |
Device serial number. |
◆ pbl_coredump_stored
| struct pbl_coredump_stored |
Dump stored by a backend.
| Data Fields |
|
const struct pbl_coredump_backend * |
backend |
Backend storing the dump. |
|
uint32_t |
id |
Identifier of the dump in the backend. |
◆ PBL_COREDUMP__REGION_SECTION
◆ PBL_COREDUMP_LATE_REGION_DEFINE
| #define PBL_COREDUMP_LATE_REGION_DEFINE |
( |
|
_name, |
|
|
|
_start, |
|
|
|
_size, |
|
|
|
_prepare |
|
) |
| |
Value:
_name) = {.
start = (_start), .
size = (_size), .prepare = (_prepare), .
late =
true}
#define PBL_COREDUMP__REGION_SECTION(_name)
Definition coredump.h:41
#define PBL_USED
Keep the symbol even if it appears unreferenced.
Definition compiler.h:90
Memory region to dump.
Definition coredump.h:27
const void * start
Start address.
Definition coredump.h:29
size_t size
Size in bytes.
Definition coredump.h:31
bool late
Dump after the threads, because reading the region could hang or fault.
Definition coredump.h:35
Define a memory region that is dumped after the threads.
For memory whose read could hang or fault, so the rest of the dump is saved first.
- Parameters
-
| _name | Region name, also its identifier. |
| _start | Start address, a constant expression. |
| _size | Size in bytes, a constant expression. |
| _prepare | Function that makes the region readable, or NULL. |
◆ PBL_COREDUMP_REGION_DEFINE
| #define PBL_COREDUMP_REGION_DEFINE |
( |
|
_name, |
|
|
|
_start, |
|
|
|
_size |
|
) |
| |
Value:
Define a memory region to dump.
- Parameters
-
| _name | Region name, also its identifier. |
| _start | Start address, a constant expression. |
| _size | Size in bytes, a constant expression. |
◆ pbl_coredump_platform_prepare()
Prepare the system for a dump, implemented by the platform.
Runs without OS services, once the backends are initialized and before they touch what they store. Drivers that a backend uses, like flash, already work.
- Parameters
-
| [out] | metadata | Identification to store in the dump. |
◆ pbl_coredump_stored_find()
Find the most recent stored dump of the first backend that has one.
- Parameters
-
| unread_only | Only consider dumps that have not been marked as read. |
| [out] | stored | The dump. |
- Returns
- 0 on success, or -ENOENT if there is none.
◆ pbl_coredump_stored_mark_read()
Mark a stored dump as read, so it can be replaced.
- Parameters
-
- Returns
- 0 on success, or a negative errno.
◆ pbl_coredump_stored_read()
| int pbl_coredump_stored_read |
( |
const struct pbl_coredump_stored * |
stored, |
|
|
uint32_t |
offset, |
|
|
void * |
buf, |
|
|
size_t |
len |
|
) |
| |
Read a stored dump.
- Parameters
-
| stored | The dump. |
| offset | Offset in the dump. |
| [out] | buf | Destination. |
| len | Number of bytes to read. |
- Returns
- 0 on success, or a negative errno.
◆ pbl_coredump_stored_size()
Get the size of a stored dump.
- Parameters
-
| stored | The dump. |
| [out] | size | Size in bytes. |
- Returns
- 0 on success, or a negative errno, -EBADMSG if the dump is corrupted.
◆ pbl_coredump_trigger()
| void pbl_coredump_trigger |
( |
bool |
forced | ) |
|
Write a core dump and reset.
Can be called from any context. Does not return, unless entering the dump failed.
- Parameters
-
| forced | Replace a stored dump that has not been read yet, however recent. |