Skip to content

Commit 75ec37c

Browse files
committed
add extra test and fix PICO_CONFIGs
1 parent 771ac20 commit 75ec37c

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/rp2_common/pico_platform_panic/include/pico/platform/panic.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ extern "C" {
1313

1414
// 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
1515

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=1 as a stack fram is 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=1group=pico_runtime
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=1 as a stack fram is 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
1717
#ifndef PICO_PANIC_FUNCTION_WITH_CALL_STACK
1818
#define PICO_PANIC_FUNCTION_WITH_CALL_STACK 1
1919
#endif
2020

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=1 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=1group=pico_runtime
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=1 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
2222
#ifndef PICO_PANIC_FUNCTION_WITH_ALL_VAARGS
2323
#define PICO_PANIC_FUNCTION_WITH_ALL_VAARGS 0
2424
#endif
2525

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 both full call stacks are available and all vaargs are correctly passed to the user function, default=-0 group=pico_runtime
27+
#ifndef PICO_PANIC_FUNCTION_WITH_ALL_VAARGS
28+
#define PICO_PANIC_FUNCTION_WITH_ALL_VAARGS 0
29+
#endif
2630

2731
#ifndef __ASSEMBLER__
2832
/*! \brief Panics with the message "Unsupported"

test/panic_function_test/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ add_executable(panic_function_test_user_all_vaargs ${CMAKE_CURRENT_LIST_DIR}/pan
1616
target_compile_definitions(panic_function_test_user_all_vaargs PRIVATE PICO_PANIC_FUNCTION=handle_panic PICO_PANIC_FUNCTION_WITH_ALL_VAARGS=1 PICO_PANIC_FUNCTION_WITH_CALL_STACK=0)
1717
target_link_libraries(panic_function_test_user_all_vaargs PRIVATE pico_stdlib)
1818
pico_add_extra_outputs(panic_function_test_user_all_vaargs)
19+
20+
add_executable(panic_function_test_user_not_returning ${CMAKE_CURRENT_LIST_DIR}/panic_function_test.c)
21+
target_compile_definitions(panic_function_test_user_not_returning PRIVATE PICO_PANIC_FUNCTION=handle_panic
22+
PICO_PANIC_FUNCTION_DOES_NOT_RETURN=1
23+
PICO_PANIC_FUNCTION_WITH_ALL_VAARGS=1 PICO_PANIC_FUNCTION_WITH_CALL_STACK=1 #these usually conflicting options are now fine
24+
)
25+
target_link_libraries(panic_function_test_user_not_returning PRIVATE pico_stdlib)
26+
pico_add_extra_outputs(panic_function_test_user_not_returning)

test/panic_function_test/panic_function_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ void __printflike(1, 0) handle_panic(const char *magic1, ...)
5858
#endif
5959
va_end(args);
6060
puts("PASSED");
61+
#if PICO_PANIC_FUNCTION_DOES_NOT_RETURN
62+
__breakpoint();
63+
#endif
6164
}
6265

6366
void main() {

0 commit comments

Comments
 (0)