Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PICO_PANIC_NO_STRINGS_ON_TARGET config #1771

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/rp2_common/pico_platform/include/pico/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,11 @@ void __attribute__((noreturn)) panic_unsupported(void);
* @param fmt format string (printf-like)
* @param ... printf-like arguments
*/
#ifdef PICO_PANIC_NO_STRINGS_ON_TARGET
#define panic(fmt, ...) do{__breakpoint();while(1){};}while(0)
#else
void __attribute__((noreturn)) panic(const char *fmt, ...);
#endif

#ifdef NDEBUG
#define panic_compact(...) panic(__VA_ARGS__)
Expand Down
2 changes: 2 additions & 0 deletions src/rp2_common/pico_runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ void __attribute__((noreturn)) panic_unsupported(void) {
panic("not supported");
}

#ifndef PICO_PANIC_NO_STRINGS_ON_TARGET
// 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
// note the default is not "panic" it is undefined
#ifdef PICO_PANIC_FUNCTION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider defining PICO_PANIC_FUNCTION?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I doxygen it here or it is more platform.h place?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've misunderstood see #1770 (comment) for benchmarks

Expand Down Expand Up @@ -325,6 +326,7 @@ void __attribute__((noreturn)) __printflike(1, 0) panic(const char *fmt, ...) {
_exit(1);
}
#endif
#endif

void hard_assertion_failure(void) {
panic("Hard assert");
Expand Down