xref: /aosp_15_r20/external/pigweed/pw_assert/backends.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_assert-backends:
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker==================
4*61c4878aSAndroid Build Coastguard Workerpw_assert backends
5*61c4878aSAndroid Build Coastguard Worker==================
6*61c4878aSAndroid Build Coastguard Worker.. pigweed-module-subpage::
7*61c4878aSAndroid Build Coastguard Worker   :name: pw_assert
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Worker.. TODO: b/323607687 - Add backend guidance here
10*61c4878aSAndroid Build Coastguard Worker
11*61c4878aSAndroid Build Coastguard WorkerThe following backends are already implemented and available for use in your
12*61c4878aSAndroid Build Coastguard Workerprojects:
13*61c4878aSAndroid Build Coastguard Worker
14*61c4878aSAndroid Build Coastguard Worker- ``pw_assert:print_and_abort_backend`` - **Stable** - Uses the ``printf`` and
15*61c4878aSAndroid Build Coastguard Worker  ``abort`` standard library functions to implement the assert facade. Prints
16*61c4878aSAndroid Build Coastguard Worker  the assert expression, evaluated arguments if any, file/line, function name,
17*61c4878aSAndroid Build Coastguard Worker  and user message, then aborts. Only suitable for targets that support these
18*61c4878aSAndroid Build Coastguard Worker  standard library functions.
19*61c4878aSAndroid Build Coastguard Worker- :ref:`module-pw_assert_basic` - **Stable** - The assert basic module is a
20*61c4878aSAndroid Build Coastguard Worker  simple assert handler that displays the failed assert line and the values of
21*61c4878aSAndroid Build Coastguard Worker  captured arguments. Output is directed to ``pw_sys_io``. This module is a
22*61c4878aSAndroid Build Coastguard Worker  great ready-to-roll module when bringing up a system, but is likely not the
23*61c4878aSAndroid Build Coastguard Worker  best choice for production.
24*61c4878aSAndroid Build Coastguard Worker- :ref:`module-pw_assert_log` - **Stable** - This assert backend redirects to
25*61c4878aSAndroid Build Coastguard Worker  logging, but with a logging flag set that indicates an assert failure. This
26*61c4878aSAndroid Build Coastguard Worker  is our advised approach to get **tokenized asserts**--by using tokenized
27*61c4878aSAndroid Build Coastguard Worker  logging, then using the ``pw_assert_log`` backend.
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard WorkerNote: If one desires a null assert module (where asserts are removed), use
30*61c4878aSAndroid Build Coastguard Worker``pw_assert_log`` in combination with ``pw_log_null``. This will direct asserts
31*61c4878aSAndroid Build Coastguard Workerto logs, then the logs are removed due to the null backend.
32*61c4878aSAndroid Build Coastguard Worker
33*61c4878aSAndroid Build Coastguard Worker.. toctree::
34*61c4878aSAndroid Build Coastguard Worker   :maxdepth: 1
35*61c4878aSAndroid Build Coastguard Worker
36*61c4878aSAndroid Build Coastguard Worker   Basic <../pw_assert_basic/docs>
37*61c4878aSAndroid Build Coastguard Worker   Pigweed logging <../pw_assert_log/docs>
38*61c4878aSAndroid Build Coastguard Worker   Fuchsia <../pw_assert_fuchsia/docs>
39*61c4878aSAndroid Build Coastguard Worker   Tokenized <../pw_assert_tokenized/docs>
40*61c4878aSAndroid Build Coastguard Worker   Trap <../pw_assert_trap/docs>
41*61c4878aSAndroid Build Coastguard Worker   Zephyr <../pw_assert_zephyr/docs>
42