summaryrefslogtreecommitdiff
path: root/libcr
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-27 15:27:52 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-29 21:46:26 -0700
commit9eaa70ddf2e5c50503b5e135b52b39ac7ae6f089 (patch)
treee6b29ee637d8f8eab54939fcd932af6bcce6beb1 /libcr
parent5d1c30d11f2f8f1dcf2c1d823a1b0c174dc53495 (diff)
gdb-helpers/libcr.py: Use fewer breakpoints
They're at a premium on the RP2040.
Diffstat (limited to 'libcr')
-rw-r--r--libcr/CMakeLists.txt1
-rw-r--r--libcr/coroutine.c13
2 files changed, 13 insertions, 1 deletions
diff --git a/libcr/CMakeLists.txt b/libcr/CMakeLists.txt
index 7f18e17..130b018 100644
--- a/libcr/CMakeLists.txt
+++ b/libcr/CMakeLists.txt
@@ -20,6 +20,7 @@ set(cfg_matrix
"CONFIG_COROUTINE_PROTECT_STACK;[0;1]"
"CONFIG_COROUTINE_DEBUG;[0;1]"
"CONFIG_COROUTINE_VALGRIND;[0;1]"
+ "CONFIG_COROUTINE_GDB;[0;1]"
)
function(add_libcr_matrix_test n defs)
add_executable("test_matrix${n}" "tests/test_matrix.c")
diff --git a/libcr/coroutine.c b/libcr/coroutine.c
index 18b2b80..a4d41e8 100644
--- a/libcr/coroutine.c
+++ b/libcr/coroutine.c
@@ -42,6 +42,9 @@
#ifndef CONFIG_COROUTINE_VALGRIND
#error config.h must define CONFIG_COROUTINE_VALGRIND (bool)
#endif
+#ifndef CONFIG_COROUTINE_GDB
+ #error config.h must define CONFIG_COROUTINE_GDB (bool)
+#endif
/* Implementation *************************************************************/
@@ -127,6 +130,7 @@
*/
#define ALWAYS_INLINE [[gnu::always_inline]] inline
+#define NEVER_INLINE [[gnu::noinline]]
/* platform support ***********************************************************/
@@ -314,7 +318,14 @@
uintptr_t sp;
#endif
} cr_plat_jmp_buf;
- static inline void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[gnu::unused]]) {
+ #if CONIG_COROUTINE_GDB
+ NEVER_INLINE
+ #endif
+ static void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[gnu::unused]]) {
+ #if CONIG_COROUTINE_GDB
+ /* Prevent the call from being optimized away. */
+ asm ("");
+ #endif
#if CONFIG_COROUTINE_MEASURE_STACK
env->sp = cr_plat_get_sp();
#endif