Skip to content

Commit

Permalink
If GDBStub library is used, break into gdb on assert and panic
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed May 10, 2016
1 parent 5b264af commit 542b05e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ static void do_global_ctors(void) {
extern "C" void __gdb_init() {}
extern "C" void gdb_init(void) __attribute__ ((weak, alias("__gdb_init")));

extern "C" void __gdb_do_break(){}
extern "C" void gdb_do_break(void) __attribute__ ((weak, alias("__gdb_do_break")));

void init_done() {
system_set_os_print(1);
gdb_init();
Expand Down
5 changes: 5 additions & 0 deletions cores/esp8266/core_esp8266_postmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "cont.h"

extern void __real_system_restart_local();
extern void gdb_do_break();

extern cont_t g_cont;

static const char* s_panic_file = 0;
Expand Down Expand Up @@ -184,11 +186,14 @@ void __assert_func(const char *file, int line, const char *func, const char *wha
s_panic_file = file;
s_panic_line = line;
s_panic_func = func;
gdb_do_break();
}

void __panic_func(const char* file, int line, const char* func) {
s_panic_file = file;
s_panic_line = line;
s_panic_func = func;
gdb_do_break();
abort();
}

5 changes: 5 additions & 0 deletions libraries/GDBStub/src/internal/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,4 +787,9 @@ void ATTR_GDBINIT gdbstub_init() {
#endif
}

void ATTR_GDBFN gdbstub_do_break_wrapper() {
gdbstub_do_break();
}

extern void gdb_do_break() __attribute__((weak, alias("gdbstub_do_break_wrapper")));
extern void gdb_init() __attribute__((weak, alias("gdbstub_init")));

0 comments on commit 542b05e

Please sign in to comment.