diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-08 18:08:27 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-09 12:24:43 -0700 |
commit | 150a10e8841f012645b77d1a6eb10d25dbf89b56 (patch) | |
tree | d0066f5651c3adf821ae44c4fd30ad1f221dfa73 | |
parent | 1c305010f427ac40fbecb80175d4323020a2ea66 (diff) |
GDB fixes
-rw-r--r-- | gdb-helpers/libcr.py | 11 | ||||
-rw-r--r-- | libcr/coroutine.c | 6 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gdb-helpers/libcr.py b/gdb-helpers/libcr.py index c07b679..3ffafce 100644 --- a/gdb-helpers/libcr.py +++ b/gdb-helpers/libcr.py @@ -26,6 +26,14 @@ def gdb_unregister_unwinder( gdb.invalidate_cached_frames() +def gdb_is_on_os() -> bool: + try: + gdb.execute("info proc", to_string=True) + return True + except gdb.error: + return False + + class gdb_JmpBuf: """Our own in-Python GDB-specific implementation of `jmp_buf`""" @@ -105,7 +113,8 @@ class CrGlobals: self._breakpoint.enabled = True gdb.execute(f"call (void)cr_gdb_readjmp({env_ptr_expr})") self._breakpoint.enabled = False - gdb.execute("queue-signal SIGWINCH") + if gdb_is_on_os(): + gdb.execute("queue-signal SIGWINCH") return self._breakpoint.env def _on_cont(self, event: gdb.Event) -> None: diff --git a/libcr/coroutine.c b/libcr/coroutine.c index a947ae9..7392b6c 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -635,6 +635,12 @@ void coroutine_main(void) { assert(saved); assert(!cr_is_in_intrhandler()); coroutine_running = 0; +#if CONFIG_COROUTINE_GDB + /* Some pointless call to prevent cr_gdb_readjmp() from + * getting pruned out of the firmware image. */ + if (coroutine_table[0].state != CR_NONE) + cr_gdb_readjmp(&coroutine_table[0].env); +#endif while (coroutine_cnt) { cid_t next; while ( !((next = coroutine_ringbuf_pop())) ) { |