Loading...
Searching...
No Matches
panic.h
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_PLATFORM_PANIC_H
8#define _PICO_PLATFORM_PANIC_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14// PICO_CONFIG: PICO_PANIC_FUNCTION, Name of a function to use in place of the stock panic function or empty string to simply breakpoint on panic, group=pico_runtime
15
16// PICO_CONFIG: PICO_PANIC_FUNCTION_WITH_CALL_STACK, Ensure the call stack is available when using a custom panic function via PICO_PANIC_FUNCTION. When set to 1 it conflicts with PICO_PANIC_FUNCTION_WITH_ALL_VAARGS as a stack frame must be pushed onto the stack corrupting later vaargs. Note this defaults to 1 as most custom panic functions don't actually use the arguments and the call stack seems more useful in general, default=1, group=pico_runtime
17#ifndef PICO_PANIC_FUNCTION_WITH_CALL_STACK
18#define PICO_PANIC_FUNCTION_WITH_CALL_STACK 1
19#endif
20
21// PICO_CONFIG: PICO_PANIC_FUNCTION_WITH_ALL_VAARGS, Ensures that all vaargs are faithfully passed to the custom panic function via PICO_PANIC_FUNCTION. When set to 1 it conflicts with PICO_PANIC_FUNCTION_WITH_CALL_STACK because both the later vaargs and the stack frame would be expected at the top of the stack. Note this defaults to 0 as most custom panic functions don't actually use the arguments and the call stack seems more useful in general, default=0, group=pico_runtime
22#ifndef PICO_PANIC_FUNCTION_WITH_ALL_VAARGS
23#define PICO_PANIC_FUNCTION_WITH_ALL_VAARGS 0
24#endif
25
26// PICO_CONFIG: PICO_PANIC_FUNCTION_DOES_NOT_RETURN, Indicate that the user supplied PICO_PANIC_FUNCTION does not return so the caller does not need to inject a breakpoint. When this is 1 the full call stack is available and all vaargs are correctly passed to the user function, default=0, group=pico_runtime
27#ifndef PICO_PANIC_FUNCTION_DOES_NOT_RETURN
28#define PICO_PANIC_FUNCTION_DOES_NOT_RETURN 0
29#endif
30
31#ifndef __ASSEMBLER__
36void __attribute__((noreturn)) panic_unsupported(void);
37
47void __attribute__((noreturn)) panic(const char *fmt, ...);
48
49#ifdef NDEBUG
50#define panic_compact(...) panic(__VA_ARGS__)
51#else
52#define panic_compact(...) panic("")
53#endif
54#endif
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif
void panic_unsupported(void)
Panics with the message "Unsupported".
Definition panic.c:20
void panic(const char *fmt,...)
Displays a panic message and halts execution.
Definition panic.c:31