Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2019 Nordic Semiconductor ASA
3 : : *
4 : : * SPDX-License-Identifier: Apache-2.0
5 : : */
6 : :
7 : : #include <zephyr/sys/__assert.h>
8 : : #include <zephyr/sys/printk.h>
9 : : #include <zephyr/kernel.h>
10 : : #include <zephyr/llext/symbol.h>
11 : :
12 : : /**
13 : : * @brief Assert Action Handler
14 : : *
15 : : * This routine implements the action to be taken when an assertion fails.
16 : : *
17 : : * System designers may wish to substitute this implementation to take other
18 : : * actions, such as logging program counter, line number, debug information
19 : : * to a persistent repository and/or rebooting the system.
20 : : *
21 : : * @param N/A
22 : : */
23 : : #ifdef CONFIG_ASSERT_NO_FILE_INFO
24 : : __weak void assert_post_action(void)
25 : : #else
26 : 0 : __weak void assert_post_action(const char *file, unsigned int line)
27 : : #endif
28 : : {
29 : : #ifndef CONFIG_ASSERT_NO_FILE_INFO
30 : 0 : ARG_UNUSED(file);
31 : 0 : ARG_UNUSED(line);
32 : : #endif
33 : :
34 : : #ifdef CONFIG_USERSPACE
35 : : /* User threads aren't allowed to induce kernel panics; generate
36 : : * an oops instead.
37 : : */
38 : : if (k_is_user_context()) {
39 : : k_oops();
40 : : }
41 : : #endif
42 : :
43 : 0 : k_panic();
44 : 0 : }
45 : : EXPORT_SYMBOL(assert_post_action);
46 : :
47 : : /**
48 : : * @brief Assert Print Handler
49 : : *
50 : : * This routine implements printing the assertion message.
51 : : *
52 : : * System designers may wish to substitute this implementation to store the
53 : : * assertion, or otherwise change the behavior of the assertion print
54 : : *
55 : : * @param N/A
56 : : */
57 : 0 : __weak void assert_print(const char *fmt, ...)
58 : : {
59 : 0 : va_list ap;
60 : :
61 : 0 : va_start(ap, fmt);
62 : :
63 : 0 : vprintk(fmt, ap);
64 : :
65 : 0 : va_end(ap);
66 : 0 : }
67 : : EXPORT_SYMBOL(assert_print);
|