Fix problem with panic handler with gdbstubs.

This commit is contained in:
Dmitry
2021-04-16 13:59:37 +03:00
parent a16ae6c737
commit f8197c2446
5 changed files with 38 additions and 61 deletions

View File

@@ -19,6 +19,7 @@ extern "C" {
#endif #endif
void esp_gdbstub_init(void); void esp_gdbstub_init(void);
void esp_gdbstub_panic_handler(void *frame);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -18,6 +18,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include "gdbstub_target_config.h"
#include "esp_gdbstub_arch.h" #include "esp_gdbstub_arch.h"
#include "sdkconfig.h" #include "sdkconfig.h"

View File

@@ -45,8 +45,9 @@ static esp_gdbstub_gdb_regfile_t *gdb_local_regfile = &s_scratch.regfile;
/** /**
* @breef panic handler * @breef panic handler
*/ */
void esp_gdbstub_panic_handler(esp_gdbstub_frame_t *frame) void esp_gdbstub_panic_handler(void *in_frame)
{ {
esp_gdbstub_frame_t* frame = (esp_gdbstub_frame_t*)in_frame;
#ifndef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS #ifndef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
esp_gdbstub_frame_to_regfile(frame, &s_scratch.regfile); esp_gdbstub_frame_to_regfile(frame, &s_scratch.regfile);
#else #else

View File

@@ -15,7 +15,6 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "freertos/xtensa_context.h" #include "freertos/xtensa_context.h"
#include "gdbstub_target_config.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -30,7 +30,6 @@
#include "esp_private/panic_internal.h" #include "esp_private/panic_internal.h"
#include "port/panic_funcs.h" #include "port/panic_funcs.h"
#include "esp_rom_sys.h"
#include "sdkconfig.h" #include "sdkconfig.h"
@@ -59,10 +58,6 @@
#include "esp_gdbstub.h" #include "esp_gdbstub.h"
#endif #endif
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
#include "hal/usb_serial_jtag_ll.h"
#endif
bool g_panic_abort = false; bool g_panic_abort = false;
static char *s_panic_abort_details = NULL; static char *s_panic_abort_details = NULL;
@@ -92,27 +87,6 @@ void panic_print_char(const char c)
} }
#endif // CONFIG_ESP_CONSOLE_USB_CDC #endif // CONFIG_ESP_CONSOLE_USB_CDC
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
//Timeout; if there's no host listening, the txfifo won't ever
//be writable after the first packet.
#define USBSERIAL_TIMEOUT_MAX_US 50000
static int s_usbserial_timeout = 0;
void panic_print_char(const char c)
{
while (!usb_serial_jtag_ll_txfifo_writable() && s_usbserial_timeout < (USBSERIAL_TIMEOUT_MAX_US / 100)) {
esp_rom_delay_us(100);
s_usbserial_timeout++;
}
if (usb_serial_jtag_ll_txfifo_writable()) {
usb_serial_jtag_ll_write_txfifo((const uint8_t *)&c, 1);
s_usbserial_timeout = 0;
}
}
#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
#if CONFIG_ESP_CONSOLE_NONE #if CONFIG_ESP_CONSOLE_NONE
void panic_print_char(const char c) void panic_print_char(const char c)
{ {
@@ -322,7 +296,7 @@ void esp_panic_handler(panic_info_t *info)
wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_disable(&rtc_wdt_ctx);
wdt_hal_write_protect_enable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx);
panic_print_str("Entering gdb stub now.\r\n"); panic_print_str("Entering gdb stub now.\r\n");
esp_gdbstub_panic_handler((esp_gdbstub_frame_t *)info->frame); esp_gdbstub_panic_handler(info->frame);
#else #else
#if CONFIG_ESP_COREDUMP_ENABLE #if CONFIG_ESP_COREDUMP_ENABLE
static bool s_dumping_core; static bool s_dumping_core;
@@ -347,7 +321,8 @@ void esp_panic_handler(panic_info_t *info)
#if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT #if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) { if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) {
switch (info->exception) { switch (info->exception)
{
case PANIC_EXCEPTION_IWDT: case PANIC_EXCEPTION_IWDT:
esp_reset_reason_set_hint(ESP_RST_INT_WDT); esp_reset_reason_set_hint(ESP_RST_INT_WDT);
break; break;
@@ -373,7 +348,7 @@ void esp_panic_handler(panic_info_t *info)
} }
void __attribute__((noreturn,no_sanitize_undefined)) panic_abort(const char *details) void __attribute__((noreturn)) panic_abort(const char *details)
{ {
g_panic_abort = true; g_panic_abort = true;
s_panic_abort_details = (char*) details; s_panic_abort_details = (char*) details;