mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(espcoredump): format coredump component with astyle
This commit is contained in:
parent
10f14d5cca
commit
f4acf0b378
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,6 @@ bool esp_core_dump_get_task_snapshot(core_dump_task_handle_t handle,
|
|||||||
*/
|
*/
|
||||||
void esp_core_dump_reset_tasks_snapshots_iter(void);
|
void esp_core_dump_reset_tasks_snapshots_iter(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the TCB passed as a parameter is sane.
|
* @brief Check if the TCB passed as a parameter is sane.
|
||||||
*
|
*
|
||||||
@ -67,7 +66,6 @@ bool esp_core_dump_tcb_addr_is_sane(uint32_t addr);
|
|||||||
*/
|
*/
|
||||||
uint32_t esp_core_dump_get_user_ram_segments(void);
|
uint32_t esp_core_dump_get_user_ram_segments(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get start address and size of a memory region.
|
* @brief Get start address and size of a memory region.
|
||||||
*
|
*
|
||||||
@ -79,7 +77,6 @@ uint32_t esp_core_dump_get_user_ram_segments(void);
|
|||||||
*/
|
*/
|
||||||
int esp_core_dump_get_user_ram_info(coredump_region_t region, uint32_t *start);
|
int esp_core_dump_get_user_ram_info(coredump_region_t region, uint32_t *start);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the current task is in an ISR.
|
* @brief Check if the current task is in an ISR.
|
||||||
*
|
*
|
||||||
@ -87,7 +84,6 @@ int esp_core_dump_get_user_ram_info(coredump_region_t region, uint32_t *start);
|
|||||||
*/
|
*/
|
||||||
bool esp_core_dump_in_isr_context(void);
|
bool esp_core_dump_in_isr_context(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the size all the memory regions (DRAM, RTC, RTC_FAST, IRAM)
|
* @brief Get the size all the memory regions (DRAM, RTC, RTC_FAST, IRAM)
|
||||||
*
|
*
|
||||||
@ -95,7 +91,6 @@ bool esp_core_dump_in_isr_context(void);
|
|||||||
*/
|
*/
|
||||||
uint32_t esp_core_dump_get_user_ram_size(void);
|
uint32_t esp_core_dump_get_user_ram_size(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get TCB length, in bytes.
|
* @brief Get TCB length, in bytes.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -60,7 +60,6 @@ void esp_core_dump_reset_fake_stacks(void);
|
|||||||
*/
|
*/
|
||||||
uint32_t esp_core_dump_get_isr_stack_end(void);
|
uint32_t esp_core_dump_get_isr_stack_end(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the top of the ISR stack.
|
* @brief Get the top of the ISR stack.
|
||||||
*
|
*
|
||||||
@ -68,7 +67,6 @@ uint32_t esp_core_dump_get_isr_stack_end(void);
|
|||||||
*/
|
*/
|
||||||
uint8_t* esp_core_dump_get_isr_stack_top(void);
|
uint8_t* esp_core_dump_get_isr_stack_top(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check the stack defined by address given.
|
* @brief Check the stack defined by address given.
|
||||||
*
|
*
|
||||||
@ -78,7 +76,6 @@ uint8_t* esp_core_dump_get_isr_stack_top(void);
|
|||||||
*/
|
*/
|
||||||
bool esp_core_dump_check_stack(core_dump_task_header_t *task);
|
bool esp_core_dump_check_stack(core_dump_task_header_t *task);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the memory segment is sane.
|
* @brief Check if the memory segment is sane.
|
||||||
*
|
*
|
||||||
@ -89,7 +86,6 @@ bool esp_core_dump_check_stack(core_dump_task_header_t *task);
|
|||||||
*/
|
*/
|
||||||
bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz);
|
bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the stack of a task.
|
* @brief Get the stack of a task.
|
||||||
*
|
*
|
||||||
@ -104,7 +100,6 @@ bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz);
|
|||||||
uint32_t esp_core_dump_get_stack(core_dump_task_header_t* task_snapshot,
|
uint32_t esp_core_dump_get_stack(core_dump_task_header_t* task_snapshot,
|
||||||
uint32_t* stk_vaddr, uint32_t* stk_paddr);
|
uint32_t* stk_vaddr, uint32_t* stk_paddr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check the task passed as a parameter.
|
* @brief Check the task passed as a parameter.
|
||||||
*
|
*
|
||||||
@ -120,7 +115,6 @@ uint32_t esp_core_dump_get_stack(core_dump_task_header_t* task_snapshot,
|
|||||||
*/
|
*/
|
||||||
bool esp_core_dump_check_task(core_dump_task_header_t *task);
|
bool esp_core_dump_check_task(core_dump_task_header_t *task);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a dump of the task's registers.
|
* @brief Get a dump of the task's registers.
|
||||||
*
|
*
|
||||||
|
@ -96,8 +96,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define COREDUMP_VERSION_CHIP CONFIG_IDF_FIRMWARE_CHIP_ID
|
#define COREDUMP_VERSION_CHIP CONFIG_IDF_FIRMWARE_CHIP_ID
|
||||||
|
|
||||||
typedef struct _core_dump_write_data_t
|
typedef struct _core_dump_write_data_t {
|
||||||
{
|
|
||||||
uint32_t off; /*!< Current offset of data being written */
|
uint32_t off; /*!< Current offset of data being written */
|
||||||
uint8_t cached_data[COREDUMP_CACHE_SIZE]; /*!< Cache used to write to flash */
|
uint8_t cached_data[COREDUMP_CACHE_SIZE]; /*!< Cache used to write to flash */
|
||||||
uint8_t cached_bytes; /*!< Number of bytes filled in the cached */
|
uint8_t cached_bytes; /*!< Number of bytes filled in the cached */
|
||||||
@ -116,7 +115,6 @@ typedef esp_err_t (*esp_core_dump_flash_write_data_t)(core_dump_write_data_t* pr
|
|||||||
void * data,
|
void * data,
|
||||||
uint32_t data_len);
|
uint32_t data_len);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Core dump emitter control structure.
|
* @brief Core dump emitter control structure.
|
||||||
* This structure contains the functions that are called in order to write
|
* This structure contains the functions that are called in order to write
|
||||||
@ -127,8 +125,7 @@ typedef esp_err_t (*esp_core_dump_flash_write_data_t)(core_dump_write_data_t* pr
|
|||||||
* - write (called once or more)
|
* - write (called once or more)
|
||||||
* - end
|
* - end
|
||||||
*/
|
*/
|
||||||
typedef struct _core_dump_write_config_t
|
typedef struct _core_dump_write_config_t {
|
||||||
{
|
|
||||||
esp_core_dump_write_prepare_t prepare; /*!< Function called for sanity checks */
|
esp_core_dump_write_prepare_t prepare; /*!< Function called for sanity checks */
|
||||||
esp_core_dump_write_start_t start; /*!< Function called at the beginning of data writing */
|
esp_core_dump_write_start_t start; /*!< Function called at the beginning of data writing */
|
||||||
esp_core_dump_flash_write_data_t write; /*!< Function called to write data chunk */
|
esp_core_dump_flash_write_data_t write; /*!< Function called to write data chunk */
|
||||||
@ -139,8 +136,7 @@ typedef struct _core_dump_write_config_t
|
|||||||
/**
|
/**
|
||||||
* @brief Core dump data header
|
* @brief Core dump data header
|
||||||
* This header predecesses the actual core dump data (ELF or binary). */
|
* This header predecesses the actual core dump data (ELF or binary). */
|
||||||
typedef struct _core_dump_header_t
|
typedef struct _core_dump_header_t {
|
||||||
{
|
|
||||||
uint32_t data_len; /*!< Data length */
|
uint32_t data_len; /*!< Data length */
|
||||||
uint32_t version; /*!< Core dump version */
|
uint32_t version; /*!< Core dump version */
|
||||||
uint32_t tasks_num; /*!< Number of tasks */
|
uint32_t tasks_num; /*!< Number of tasks */
|
||||||
@ -158,8 +154,7 @@ typedef void* core_dump_task_handle_t;
|
|||||||
/**
|
/**
|
||||||
* @brief Header for the tasks
|
* @brief Header for the tasks
|
||||||
*/
|
*/
|
||||||
typedef struct _core_dump_task_header_t
|
typedef struct _core_dump_task_header_t {
|
||||||
{
|
|
||||||
core_dump_task_handle_t tcb_addr; /*!< TCB address */
|
core_dump_task_handle_t tcb_addr; /*!< TCB address */
|
||||||
uint32_t stack_start; /*!< Start of the stack address */
|
uint32_t stack_start; /*!< Start of the stack address */
|
||||||
uint32_t stack_end; /*!< End of the stack address */
|
uint32_t stack_end; /*!< End of the stack address */
|
||||||
@ -168,8 +163,7 @@ typedef struct _core_dump_task_header_t
|
|||||||
/**
|
/**
|
||||||
* @brief Core dump memory segment header
|
* @brief Core dump memory segment header
|
||||||
*/
|
*/
|
||||||
typedef struct _core_dump_mem_seg_header_t
|
typedef struct _core_dump_mem_seg_header_t {
|
||||||
{
|
|
||||||
uint32_t start; /*!< Memory region start address */
|
uint32_t start; /*!< Memory region start address */
|
||||||
uint32_t size; /*!< Memory region size */
|
uint32_t size; /*!< Memory region size */
|
||||||
} core_dump_mem_seg_header_t;
|
} core_dump_mem_seg_header_t;
|
||||||
@ -179,7 +173,6 @@ typedef struct _core_dump_mem_seg_header_t
|
|||||||
*/
|
*/
|
||||||
void esp_core_dump_flash_init(void);
|
void esp_core_dump_flash_init(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Common core dump write function
|
* @brief Common core dump write function
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -42,7 +42,6 @@ FORCE_INLINE_ATTR void esp_core_dump_replace_sp(void* new_sp, core_dump_stack_co
|
|||||||
: "r"(new_sp));
|
: "r"(new_sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Restore the stack pointer that was returned when calling `esp_core_dump_replace_sp()` function.
|
* @brief Restore the stack pointer that was returned when calling `esp_core_dump_replace_sp()` function.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -63,7 +63,6 @@ FORCE_INLINE_ATTR void esp_core_dump_replace_sp(void* new_sp, core_dump_stack_co
|
|||||||
SET_STACK(new_sp);
|
SET_STACK(new_sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Restore the stack pointer that was returned when calling `esp_core_dump_replace_sp()` function.
|
* @brief Restore the stack pointer that was returned when calling `esp_core_dump_replace_sp()` function.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
const static char TAG[] __attribute__((unused)) = "esp_core_dump_binary";
|
const static char TAG[] __attribute__((unused)) = "esp_core_dump_binary";
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t esp_core_dump_save_task(core_dump_write_config_t *write_cfg,
|
static esp_err_t esp_core_dump_save_task(core_dump_write_config_t *write_cfg,
|
||||||
core_dump_task_header_t *task)
|
core_dump_task_header_t *task)
|
||||||
{
|
{
|
||||||
@ -205,8 +204,9 @@ esp_err_t esp_core_dump_write_binary(core_dump_write_config_t *write_cfg)
|
|||||||
// Write all other tasks in the snapshot
|
// Write all other tasks in the snapshot
|
||||||
esp_core_dump_task_iterator_init(&task_iter);
|
esp_core_dump_task_iterator_init(&task_iter);
|
||||||
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
||||||
if (!esp_core_dump_get_task_snapshot(task_iter.pxTaskHandle, &task_hdr, NULL))
|
if (!esp_core_dump_get_task_snapshot(task_iter.pxTaskHandle, &task_hdr, NULL)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
// Skip first crashed task
|
// Skip first crashed task
|
||||||
if (task_iter.pxTaskHandle == cur_task) {
|
if (task_iter.pxTaskHandle == cur_task) {
|
||||||
continue;
|
continue;
|
||||||
@ -226,8 +226,9 @@ esp_err_t esp_core_dump_write_binary(core_dump_write_config_t *write_cfg)
|
|||||||
esp_core_dump_reset_tasks_snapshots_iter();
|
esp_core_dump_reset_tasks_snapshots_iter();
|
||||||
esp_core_dump_task_iterator_init(&task_iter);
|
esp_core_dump_task_iterator_init(&task_iter);
|
||||||
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
||||||
if (!esp_core_dump_get_task_snapshot(task_iter.pxTaskHandle, &task_hdr, &mem_seg))
|
if (!esp_core_dump_get_task_snapshot(task_iter.pxTaskHandle, &task_hdr, &mem_seg)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (mem_seg.size > 0) {
|
if (mem_seg.size > 0) {
|
||||||
ESP_COREDUMP_LOG_PROCESS("Save interrupted task stack %lu bytes @ %x",
|
ESP_COREDUMP_LOG_PROCESS("Save interrupted task stack %lu bytes @ %x",
|
||||||
mem_seg.size, mem_seg.start);
|
mem_seg.size, mem_seg.start);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -52,7 +52,6 @@ extern int _coredump_rtc_fast_end;
|
|||||||
#define ESP_COREDUMP_STACK_SIZE CONFIG_ESP_COREDUMP_STACK_SIZE
|
#define ESP_COREDUMP_STACK_SIZE CONFIG_ESP_COREDUMP_STACK_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define COREDUMP_STACK_FILL_BYTE (0xa5U)
|
#define COREDUMP_STACK_FILL_BYTE (0xa5U)
|
||||||
|
|
||||||
static uint8_t s_coredump_stack[ESP_COREDUMP_STACK_SIZE];
|
static uint8_t s_coredump_stack[ESP_COREDUMP_STACK_SIZE];
|
||||||
@ -91,8 +90,7 @@ FORCE_INLINE_ATTR uint32_t esp_core_dump_free_stack_space(const uint8_t *pucStac
|
|||||||
{
|
{
|
||||||
uint32_t ulCount = 0U;
|
uint32_t ulCount = 0U;
|
||||||
while (ulCount < ESP_COREDUMP_STACK_SIZE &&
|
while (ulCount < ESP_COREDUMP_STACK_SIZE &&
|
||||||
*pucStackByte == (uint8_t)COREDUMP_STACK_FILL_BYTE )
|
*pucStackByte == (uint8_t)COREDUMP_STACK_FILL_BYTE) {
|
||||||
{
|
|
||||||
pucStackByte -= portSTACK_GROWTH;
|
pucStackByte -= portSTACK_GROWTH;
|
||||||
ulCount++;
|
ulCount++;
|
||||||
}
|
}
|
||||||
@ -137,7 +135,6 @@ FORCE_INLINE_ATTR void esp_core_dump_setup_stack(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FORCE_INLINE_ATTR void esp_core_dump_report_stack_usage(void)
|
FORCE_INLINE_ATTR void esp_core_dump_report_stack_usage(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -44,23 +44,20 @@
|
|||||||
return (ret_val); \
|
return (ret_val); \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
ELF_STAGE_CALC_SPACE = 0,
|
ELF_STAGE_CALC_SPACE = 0,
|
||||||
ELF_STAGE_PLACE_HEADERS = 1,
|
ELF_STAGE_PLACE_HEADERS = 1,
|
||||||
ELF_STAGE_PLACE_DATA = 2
|
ELF_STAGE_PLACE_DATA = 2
|
||||||
} core_dump_elf_stages_t;
|
} core_dump_elf_stages_t;
|
||||||
|
|
||||||
typedef enum _elf_err_t
|
typedef enum _elf_err_t {
|
||||||
{
|
|
||||||
ELF_PROC_ERR_SKIP_HEADER = 0,
|
ELF_PROC_ERR_SKIP_HEADER = 0,
|
||||||
ELF_PROC_ERR_STACK_CORRUPTED = -1,
|
ELF_PROC_ERR_STACK_CORRUPTED = -1,
|
||||||
ELF_PROC_ERR_WRITE_FAIL = -2,
|
ELF_PROC_ERR_WRITE_FAIL = -2,
|
||||||
ELF_PROC_ERR_OTHER = -3
|
ELF_PROC_ERR_OTHER = -3
|
||||||
} core_dump_elf_proc_err_t;
|
} core_dump_elf_proc_err_t;
|
||||||
|
|
||||||
typedef struct _core_dump_task_info_t
|
typedef struct _core_dump_task_info_t {
|
||||||
{
|
|
||||||
elf_phdr* phdr;
|
elf_phdr* phdr;
|
||||||
void* frame;
|
void* frame;
|
||||||
core_dump_task_header_t* task_hdr;
|
core_dump_task_header_t* task_hdr;
|
||||||
@ -69,8 +66,7 @@ typedef struct _core_dump_task_info_t
|
|||||||
int* size_ptr;
|
int* size_ptr;
|
||||||
} core_dump_task_data_t;
|
} core_dump_task_data_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t version; // coredump version
|
uint32_t version; // coredump version
|
||||||
uint8_t app_elf_sha256[ELF_APP_SHA256_SIZE]; // sha256 of elf file
|
uint8_t app_elf_sha256[ELF_APP_SHA256_SIZE]; // sha256 of elf file
|
||||||
} core_dump_elf_version_info_t;
|
} core_dump_elf_version_info_t;
|
||||||
@ -78,8 +74,7 @@ typedef struct
|
|||||||
const static char TAG[] __attribute__((unused)) = "esp_core_dump_elf";
|
const static char TAG[] __attribute__((unused)) = "esp_core_dump_elf";
|
||||||
|
|
||||||
// Main ELF handle type
|
// Main ELF handle type
|
||||||
typedef struct _core_dump_elf_t
|
typedef struct _core_dump_elf_t {
|
||||||
{
|
|
||||||
core_dump_elf_version_info_t elf_version_info;
|
core_dump_elf_version_info_t elf_version_info;
|
||||||
uint16_t elf_stage;
|
uint16_t elf_stage;
|
||||||
uint32_t elf_next_data_offset;
|
uint32_t elf_next_data_offset;
|
||||||
@ -417,8 +412,9 @@ static int elf_process_tasks_regs(core_dump_elf_t *self)
|
|||||||
esp_core_dump_task_iterator_init(&task_iter);
|
esp_core_dump_task_iterator_init(&task_iter);
|
||||||
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
while (esp_core_dump_task_iterator_next(&task_iter) != -1) {
|
||||||
task = task_iter.pxTaskHandle;
|
task = task_iter.pxTaskHandle;
|
||||||
if (!task || task == esp_core_dump_get_current_task_handle()) // skip current task (already processed)
|
if (!task || task == esp_core_dump_get_current_task_handle()) { // skip current task (already processed)
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (esp_core_dump_get_task_snapshot(task, &task_hdr, NULL)) {
|
if (esp_core_dump_get_task_snapshot(task, &task_hdr, NULL)) {
|
||||||
ret = elf_add_regs(self, &task_hdr);
|
ret = elf_add_regs(self, &task_hdr);
|
||||||
if (self->elf_stage == ELF_STAGE_PLACE_HEADERS) {
|
if (self->elf_stage == ELF_STAGE_PLACE_HEADERS) {
|
||||||
@ -619,7 +615,9 @@ static int elf_write_core_dump_info(core_dump_elf_t *self)
|
|||||||
extern bool g_twdt_isr;
|
extern bool g_twdt_isr;
|
||||||
if (g_twdt_isr) {
|
if (g_twdt_isr) {
|
||||||
ret = elf_add_wdt_panic_details(self);
|
ret = elf_add_wdt_panic_details(self);
|
||||||
if (ret <= 0) { return ret; }
|
if (ret <= 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
data_len += ret;
|
data_len += ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -686,7 +684,9 @@ esp_err_t esp_core_dump_write_elf(core_dump_write_config_t *write_cfg)
|
|||||||
self.elf_stage = ELF_STAGE_CALC_SPACE;
|
self.elf_stage = ELF_STAGE_CALC_SPACE;
|
||||||
ESP_COREDUMP_LOG_PROCESS("================= Calc data size ===============");
|
ESP_COREDUMP_LOG_PROCESS("================= Calc data size ===============");
|
||||||
int ret = esp_core_dump_do_write_elf_pass(&self);
|
int ret = esp_core_dump_do_write_elf_pass(&self);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
tot_len += ret;
|
tot_len += ret;
|
||||||
ESP_COREDUMP_LOG_PROCESS("Core dump tot_len=%lu", tot_len);
|
ESP_COREDUMP_LOG_PROCESS("Core dump tot_len=%lu", tot_len);
|
||||||
ESP_COREDUMP_LOG_PROCESS("============== Data size = %d bytes ============", tot_len);
|
ESP_COREDUMP_LOG_PROCESS("============== Data size = %d bytes ============", tot_len);
|
||||||
@ -728,7 +728,9 @@ esp_err_t esp_core_dump_write_elf(core_dump_write_config_t *write_cfg)
|
|||||||
// set initial offset to elf segments data area
|
// set initial offset to elf segments data area
|
||||||
self.elf_next_data_offset = sizeof(elfhdr) + ELF_SEG_HEADERS_COUNT(&self) * sizeof(elf_phdr);
|
self.elf_next_data_offset = sizeof(elfhdr) + ELF_SEG_HEADERS_COUNT(&self) * sizeof(elf_phdr);
|
||||||
ret = esp_core_dump_do_write_elf_pass(&self);
|
ret = esp_core_dump_do_write_elf_pass(&self);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
write_len += ret;
|
write_len += ret;
|
||||||
ESP_COREDUMP_LOG_PROCESS("============== Headers size = %d bytes ============", write_len);
|
ESP_COREDUMP_LOG_PROCESS("============== Headers size = %d bytes ============", write_len);
|
||||||
|
|
||||||
@ -736,7 +738,9 @@ esp_err_t esp_core_dump_write_elf(core_dump_write_config_t *write_cfg)
|
|||||||
// set initial offset to elf segments data area, this is not necessary in this stage, just for pretty debug output
|
// set initial offset to elf segments data area, this is not necessary in this stage, just for pretty debug output
|
||||||
self.elf_next_data_offset = sizeof(elfhdr) + ELF_SEG_HEADERS_COUNT(&self) * sizeof(elf_phdr);
|
self.elf_next_data_offset = sizeof(elfhdr) + ELF_SEG_HEADERS_COUNT(&self) * sizeof(elf_phdr);
|
||||||
ret = esp_core_dump_do_write_elf_pass(&self);
|
ret = esp_core_dump_do_write_elf_pass(&self);
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
write_len += ret;
|
write_len += ret;
|
||||||
ESP_COREDUMP_LOG_PROCESS("=========== Data written size = %d bytes ==========", write_len);
|
ESP_COREDUMP_LOG_PROCESS("=========== Data written size = %d bytes ==========", write_len);
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_flash";
|
|||||||
|
|
||||||
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
|
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH
|
||||||
|
|
||||||
typedef struct _core_dump_partition_t
|
typedef struct _core_dump_partition_t {
|
||||||
{
|
|
||||||
/* Core dump partition start. */
|
/* Core dump partition start. */
|
||||||
uint32_t start;
|
uint32_t start;
|
||||||
/* Core dump partition size. */
|
/* Core dump partition size. */
|
||||||
@ -35,8 +34,7 @@ typedef struct _core_dump_partition_t
|
|||||||
|
|
||||||
typedef uint32_t core_dump_crc_t;
|
typedef uint32_t core_dump_crc_t;
|
||||||
|
|
||||||
typedef struct _core_dump_flash_config_t
|
typedef struct _core_dump_flash_config_t {
|
||||||
{
|
|
||||||
/* Core dump partition config. */
|
/* Core dump partition config. */
|
||||||
core_dump_partition_t partition;
|
core_dump_partition_t partition;
|
||||||
/* CRC of core dump partition config. */
|
/* CRC of core dump partition config. */
|
||||||
@ -119,10 +117,11 @@ static esp_err_t esp_core_dump_flash_write_data(core_dump_write_data_t* priv, ui
|
|||||||
/* Some bytes are in the cache, let's continue filling the cache
|
/* Some bytes are in the cache, let's continue filling the cache
|
||||||
* with the data received as parameter. Let's calculate the maximum
|
* with the data received as parameter. Let's calculate the maximum
|
||||||
* amount of bytes we can still fill the cache with. */
|
* amount of bytes we can still fill the cache with. */
|
||||||
if ((COREDUMP_CACHE_SIZE - wr_data->cached_bytes) > data_size)
|
if ((COREDUMP_CACHE_SIZE - wr_data->cached_bytes) > data_size) {
|
||||||
wr_sz = data_size;
|
wr_sz = data_size;
|
||||||
else
|
} else {
|
||||||
wr_sz = COREDUMP_CACHE_SIZE - wr_data->cached_bytes;
|
wr_sz = COREDUMP_CACHE_SIZE - wr_data->cached_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
/* Append wr_sz bytes from data parameter to the cache. */
|
/* Append wr_sz bytes from data parameter to the cache. */
|
||||||
memcpy(&wr_data->cached_data[wr_data->cached_bytes], data, wr_sz);
|
memcpy(&wr_data->cached_data[wr_data->cached_bytes], data, wr_sz);
|
||||||
|
@ -21,7 +21,8 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_uart";
|
|||||||
* explicitly the header for each board. */
|
* explicitly the header for each board. */
|
||||||
int esp_clk_cpu_freq(void);
|
int esp_clk_cpu_freq(void);
|
||||||
|
|
||||||
static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8_t *dst) {
|
static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8_t *dst)
|
||||||
|
{
|
||||||
const static char b64[] =
|
const static char b64[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
int i, j, a, b, c;
|
int i, j, a, b, c;
|
||||||
@ -97,7 +98,9 @@ static esp_err_t esp_core_dump_uart_write_data(core_dump_write_data_t *priv, voi
|
|||||||
|
|
||||||
while (addr < end) {
|
while (addr < end) {
|
||||||
size_t len = end - addr;
|
size_t len = end - addr;
|
||||||
if (len > 48) len = 48;
|
if (len > 48) {
|
||||||
|
len = 48;
|
||||||
|
}
|
||||||
/* Copy to stack to avoid alignment restrictions. */
|
/* Copy to stack to avoid alignment restrictions. */
|
||||||
char *tmp = buf + (sizeof(buf) - len);
|
char *tmp = buf + (sizeof(buf) - len);
|
||||||
memcpy(tmp, addr, len);
|
memcpy(tmp, addr, len);
|
||||||
@ -113,7 +116,8 @@ static esp_err_t esp_core_dump_uart_write_data(core_dump_write_data_t *priv, voi
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int esp_core_dump_uart_get_char(void) {
|
static int esp_core_dump_uart_get_char(void)
|
||||||
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
uint32_t reg = (READ_PERI_REG(UART_STATUS_REG(0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT;
|
uint32_t reg = (READ_PERI_REG(UART_STATUS_REG(0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT;
|
||||||
if (reg) {
|
if (reg) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -144,7 +144,6 @@ typedef struct {
|
|||||||
uint32_t isr_context;
|
uint32_t isr_context;
|
||||||
} riscv_extra_info_t;
|
} riscv_extra_info_t;
|
||||||
|
|
||||||
|
|
||||||
/* Allocate the fake stack that will be used by broken tasks. */
|
/* Allocate the fake stack that will be used by broken tasks. */
|
||||||
static RvExcFrame s_fake_stack_frame = {
|
static RvExcFrame s_fake_stack_frame = {
|
||||||
.mepc = COREDUMP_FAKE_STACK_START,
|
.mepc = COREDUMP_FAKE_STACK_START,
|
||||||
@ -355,7 +354,8 @@ uint32_t esp_core_dump_get_task_regs_dump(core_dump_task_header_t *task, void **
|
|||||||
/**
|
/**
|
||||||
* Save the crashed task handle in the extra info structure.
|
* Save the crashed task handle in the extra info structure.
|
||||||
*/
|
*/
|
||||||
void esp_core_dump_port_set_crashed_tcb(uint32_t handle) {
|
void esp_core_dump_port_set_crashed_tcb(uint32_t handle)
|
||||||
|
{
|
||||||
s_extra_info.crashed_task_tcb = handle;
|
s_extra_info.crashed_task_tcb = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -44,8 +44,7 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_port";
|
|||||||
|
|
||||||
// Enumeration of registers of exception stack frame
|
// Enumeration of registers of exception stack frame
|
||||||
// and solicited stack frame
|
// and solicited stack frame
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
// XT_SOL_EXIT = 0,
|
// XT_SOL_EXIT = 0,
|
||||||
XT_SOL_PC = 1,
|
XT_SOL_PC = 1,
|
||||||
XT_SOL_PS = 2,
|
XT_SOL_PS = 2,
|
||||||
@ -69,8 +68,7 @@ typedef enum
|
|||||||
|
|
||||||
// Xtensa ELF core file register set representation ('.reg' section).
|
// Xtensa ELF core file register set representation ('.reg' section).
|
||||||
// Copied from target-side ELF header <xtensa/elf.h>.
|
// Copied from target-side ELF header <xtensa/elf.h>.
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t pc;
|
uint32_t pc;
|
||||||
uint32_t ps;
|
uint32_t ps;
|
||||||
uint32_t lbeg;
|
uint32_t lbeg;
|
||||||
@ -83,14 +81,12 @@ typedef struct
|
|||||||
uint32_t ar[XCHAL_NUM_AREGS];
|
uint32_t ar[XCHAL_NUM_AREGS];
|
||||||
} __attribute__((packed)) xtensa_gregset_t;
|
} __attribute__((packed)) xtensa_gregset_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t reg_index;
|
uint32_t reg_index;
|
||||||
uint32_t reg_val;
|
uint32_t reg_val;
|
||||||
} __attribute__((packed)) core_dump_reg_pair_t;
|
} __attribute__((packed)) core_dump_reg_pair_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t crashed_task_tcb;
|
uint32_t crashed_task_tcb;
|
||||||
core_dump_reg_pair_t exccause;
|
core_dump_reg_pair_t exccause;
|
||||||
core_dump_reg_pair_t excvaddr;
|
core_dump_reg_pair_t excvaddr;
|
||||||
@ -99,8 +95,7 @@ typedef struct
|
|||||||
} __attribute__((packed)) xtensa_extra_info_t;
|
} __attribute__((packed)) xtensa_extra_info_t;
|
||||||
|
|
||||||
// Xtensa Program Status for GDB
|
// Xtensa Program Status for GDB
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint32_t si_signo;
|
uint32_t si_signo;
|
||||||
uint32_t si_code;
|
uint32_t si_code;
|
||||||
uint32_t si_errno;
|
uint32_t si_errno;
|
||||||
@ -118,8 +113,7 @@ typedef struct
|
|||||||
uint64_t pr_cstime;
|
uint64_t pr_cstime;
|
||||||
} __attribute__((packed)) xtensa_pr_status_t;
|
} __attribute__((packed)) xtensa_pr_status_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
xtensa_pr_status_t pr_status;
|
xtensa_pr_status_t pr_status;
|
||||||
xtensa_gregset_t regs;
|
xtensa_gregset_t regs;
|
||||||
// Todo: acc to xtensa_gregset_t number of regs must be 128,
|
// Todo: acc to xtensa_gregset_t number of regs must be 128,
|
||||||
@ -155,7 +149,6 @@ static void *esp_core_dump_get_fake_stack(uint32_t *stk_len)
|
|||||||
return (uint8_t*)COREDUMP_FAKE_STACK_START + sizeof(s_fake_stack_frame) * s_fake_stacks_num++;
|
return (uint8_t*)COREDUMP_FAKE_STACK_START + sizeof(s_fake_stack_frame) * s_fake_stacks_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static core_dump_reg_pair_t *esp_core_dump_get_epc_regs(core_dump_reg_pair_t* src)
|
static core_dump_reg_pair_t *esp_core_dump_get_epc_regs(core_dump_reg_pair_t* src)
|
||||||
{
|
{
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
@ -210,8 +203,7 @@ static esp_err_t esp_core_dump_get_regs_from_stack(void* stack_addr,
|
|||||||
uint32_t rc = exc_frame->exit;
|
uint32_t rc = exc_frame->exit;
|
||||||
|
|
||||||
// is this current crashed task?
|
// is this current crashed task?
|
||||||
if (rc == COREDUMP_CURR_TASK_MARKER)
|
if (rc == COREDUMP_CURR_TASK_MARKER) {
|
||||||
{
|
|
||||||
s_extra_info.exccause.reg_val = exc_frame->exccause;
|
s_extra_info.exccause.reg_val = exc_frame->exccause;
|
||||||
s_extra_info.exccause.reg_index = EXCCAUSE;
|
s_extra_info.exccause.reg_index = EXCCAUSE;
|
||||||
s_extra_info.excvaddr.reg_val = exc_frame->excvaddr;
|
s_extra_info.excvaddr.reg_val = exc_frame->excvaddr;
|
||||||
@ -304,7 +296,6 @@ uint32_t esp_core_dump_get_isr_stack_end(void)
|
|||||||
return (uint32_t)(isr_top_stack + (xPortGetCoreID() + 1) * configISR_STACK_SIZE);
|
return (uint32_t)(isr_top_stack + (xPortGetCoreID() + 1) * configISR_STACK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp)
|
static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp)
|
||||||
{
|
{
|
||||||
return esp_ptr_in_dram((void *)sp)
|
return esp_ptr_in_dram((void *)sp)
|
||||||
@ -317,7 +308,6 @@ static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool esp_core_dump_check_stack(core_dump_task_header_t *task)
|
bool esp_core_dump_check_stack(core_dump_task_header_t *task)
|
||||||
{
|
{
|
||||||
// Check task's stack
|
// Check task's stack
|
||||||
@ -431,7 +421,6 @@ bool esp_core_dump_check_task(core_dump_task_header_t *task)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a dump of the task's registers.
|
* Get a dump of the task's registers.
|
||||||
* Check core dump port interface for more information about this function.
|
* Check core dump port interface for more information about this function.
|
||||||
@ -464,8 +453,8 @@ uint32_t esp_core_dump_get_task_regs_dump(core_dump_task_header_t *task, void **
|
|||||||
return sizeof(s_reg_dump);
|
return sizeof(s_reg_dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void esp_core_dump_port_set_crashed_tcb(uint32_t handle)
|
||||||
void esp_core_dump_port_set_crashed_tcb(uint32_t handle) {
|
{
|
||||||
s_extra_info.crashed_task_tcb = handle;
|
s_extra_info.crashed_task_tcb = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,6 @@ extern "C" {
|
|||||||
|
|
||||||
// ---------------------------------------------------- HID Mouse ------------------------------------------------------
|
// ---------------------------------------------------- HID Mouse ------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Note: The mock HID mouse tests require that USB low speed mouse be connected. The mouse should...
|
Note: The mock HID mouse tests require that USB low speed mouse be connected. The mouse should...
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ components_not_formatted_temporary:
|
|||||||
- "/components/esp_rom/"
|
- "/components/esp_rom/"
|
||||||
- "/components/esp_wifi/"
|
- "/components/esp_wifi/"
|
||||||
- "/components/esp-tls/"
|
- "/components/esp-tls/"
|
||||||
- "/components/espcoredump/"
|
|
||||||
- "/components/esptool_py/"
|
- "/components/esptool_py/"
|
||||||
- "/components/fatfs/"
|
- "/components/fatfs/"
|
||||||
- "/components/hal/"
|
- "/components/hal/"
|
||||||
@ -165,6 +164,8 @@ components_not_formatted_permanent:
|
|||||||
# Example resource files (generated)
|
# Example resource files (generated)
|
||||||
- "/examples/peripherals/lcd/i80_controller/main/images/"
|
- "/examples/peripherals/lcd/i80_controller/main/images/"
|
||||||
- "/examples/peripherals/dac/dac_continuous/dac_audio/main/audio_example_file.h"
|
- "/examples/peripherals/dac/dac_continuous/dac_audio/main/audio_example_file.h"
|
||||||
|
# Coredump (generated)
|
||||||
|
- /components/espcoredump/include_core_dump/elf.h
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
# Docs directory contains some .inc files, which are not C include files
|
# Docs directory contains some .inc files, which are not C include files
|
||||||
|
Loading…
Reference in New Issue
Block a user