Skip to content

Commit 542b05e

Browse files
committed
If GDBStub library is used, break into gdb on assert and panic
1 parent 5b264af commit 542b05e

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: cores/esp8266/core_esp8266_main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ static void do_global_ctors(void) {
127127
extern "C" void __gdb_init() {}
128128
extern "C" void gdb_init(void) __attribute__ ((weak, alias("__gdb_init")));
129129

130+
extern "C" void __gdb_do_break(){}
131+
extern "C" void gdb_do_break(void) __attribute__ ((weak, alias("__gdb_do_break")));
132+
130133
void init_done() {
131134
system_set_os_print(1);
132135
gdb_init();

Diff for: cores/esp8266/core_esp8266_postmortem.c

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "cont.h"
3030

3131
extern void __real_system_restart_local();
32+
extern void gdb_do_break();
33+
3234
extern cont_t g_cont;
3335

3436
static const char* s_panic_file = 0;
@@ -184,11 +186,14 @@ void __assert_func(const char *file, int line, const char *func, const char *wha
184186
s_panic_file = file;
185187
s_panic_line = line;
186188
s_panic_func = func;
189+
gdb_do_break();
187190
}
188191

189192
void __panic_func(const char* file, int line, const char* func) {
190193
s_panic_file = file;
191194
s_panic_line = line;
192195
s_panic_func = func;
196+
gdb_do_break();
193197
abort();
194198
}
199+

Diff for: libraries/GDBStub/src/internal/gdbstub.c

+5
Original file line numberDiff line numberDiff line change
@@ -787,4 +787,9 @@ void ATTR_GDBINIT gdbstub_init() {
787787
#endif
788788
}
789789

790+
void ATTR_GDBFN gdbstub_do_break_wrapper() {
791+
gdbstub_do_break();
792+
}
793+
794+
extern void gdb_do_break() __attribute__((weak, alias("gdbstub_do_break_wrapper")));
790795
extern void gdb_init() __attribute__((weak, alias("gdbstub_init")));

0 commit comments

Comments
 (0)