From 8c7d1b780e68767d807b57a8378bc29b2df52cbe Mon Sep 17 00:00:00 2001 From: david gauchard Date: Thu, 18 May 2017 00:22:47 +0200 Subject: [PATCH] automate crash for GDBStub --- cores/esp8266/core_esp8266_postmortem.c | 3 +++ libraries/GDBStub/src/GDBStub.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cores/esp8266/core_esp8266_postmortem.c b/cores/esp8266/core_esp8266_postmortem.c index a00bd4dd0..5066b50cb 100644 --- a/cores/esp8266/core_esp8266_postmortem.c +++ b/cores/esp8266/core_esp8266_postmortem.c @@ -45,6 +45,8 @@ static void uart1_write_char_d(char c); static void print_stack(uint32_t start, uint32_t end); //static void print_pcs(uint32_t start, uint32_t end); +bool __attribute((weak)) crash_for_gdb = 0; + extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) { (void) rst_info; (void) stack; @@ -54,6 +56,7 @@ extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback"))); void __wrap_system_restart_local() { + if (crash_for_gdb) *((int*)0) = 0; register uint32_t sp asm("a1"); struct rst_info rst_info = {0}; diff --git a/libraries/GDBStub/src/GDBStub.h b/libraries/GDBStub/src/GDBStub.h index c9145016d..4efec8c76 100644 --- a/libraries/GDBStub/src/GDBStub.h +++ b/libraries/GDBStub/src/GDBStub.h @@ -3,4 +3,6 @@ // this header is intentionally left blank +bool crash_for_gdb = 1; + #endif //GDBSTUB_H