mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
change(coredump): include coredump own stack into coredump file
This commit is contained in:
parent
7da66fb098
commit
1456fec98c
@ -136,12 +136,6 @@ esp_err_t esp_core_dump_write_data(core_dump_write_data_t *wr_data, void *data,
|
||||
*/
|
||||
esp_err_t esp_core_dump_write_end(core_dump_write_data_t *wr_data);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the stack information which will be used from the coredump module itself.
|
||||
* It will show the whole stack boundaries in case the stack is shared with the crashed task.
|
||||
*/
|
||||
void esp_core_dump_get_own_stack_info(uint32_t *addr, uint32_t *size);
|
||||
|
||||
/**
|
||||
* @brief Stores the core dump in either binary or ELF format.
|
||||
*/
|
||||
|
@ -312,26 +312,6 @@ int esp_core_dump_get_user_ram_info(coredump_region_t region, uint32_t *start)
|
||||
return total_sz;
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_COREDUMP_CAPTURE_DRAM
|
||||
void esp_core_dump_get_own_stack_info(uint32_t *addr, uint32_t *size)
|
||||
{
|
||||
#if CONFIG_ESP_COREDUMP_STACK_SIZE > 0
|
||||
/* Custom stack reserved for the coredump */
|
||||
*addr = (uint32_t)s_coredump_stack;
|
||||
*size = sizeof(s_coredump_stack);
|
||||
#else
|
||||
/* Shared stack with the crashed task */
|
||||
core_dump_task_handle_t handle = esp_core_dump_get_current_task_handle();
|
||||
TaskSnapshot_t rtos_snapshot = { 0 };
|
||||
vTaskGetSnapshot(handle, &rtos_snapshot);
|
||||
StaticTask_t *current = (StaticTask_t *)handle;
|
||||
*addr = (uint32_t)current->pxDummy6; //pxStack
|
||||
*size = (uint32_t)rtos_snapshot.pxTopOfStack - (uint32_t)current->pxDummy6; /* free */
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP_COREDUMP_CAPTURE_DRAM */
|
||||
|
||||
inline bool esp_core_dump_tcb_addr_is_sane(uint32_t addr)
|
||||
{
|
||||
return esp_core_dump_mem_seg_is_sane(addr, esp_core_dump_get_tcb_len());
|
||||
|
@ -81,11 +81,6 @@ typedef struct _core_dump_elf_t {
|
||||
uint16_t segs_count;
|
||||
core_dump_write_data_t write_data;
|
||||
uint32_t note_data_size; /* can be used where static storage needed */
|
||||
#if CONFIG_ESP_COREDUMP_CAPTURE_DRAM
|
||||
/* To avoid checksum failure, coredump stack region will be excluded while storing the sections. */
|
||||
uint32_t coredump_stack_start;
|
||||
uint32_t coredump_stack_size;
|
||||
#endif
|
||||
} core_dump_elf_t;
|
||||
|
||||
typedef struct {
|
||||
@ -524,61 +519,6 @@ static int elf_write_tasks_data(core_dump_elf_t *self)
|
||||
|
||||
#if CONFIG_ESP_COREDUMP_CAPTURE_DRAM
|
||||
|
||||
/* Coredump stack will also be used by the checksum functions while saving sections.
|
||||
* There is a potential for inconsistency when writing coredump stack to the flash and calculating checksum simultaneously.
|
||||
* This is because, coredump stack will be modified during the process, leading to incorrect checksum calculations.
|
||||
* To mitigate this issue, it's important to ensure that the coredump stack excluded from checksum calculation by
|
||||
* filter out from the written regions.
|
||||
* Typically, the coredump stack can be located in two different sections.
|
||||
* 1. In the bss section;
|
||||
* 1.a if `CONFIG_ESP_COREDUMP_STACK_SIZE` set to a nonzero value
|
||||
* 1.b if the crashed task is created with a static task buffer using the xTaskCreateStatic() api
|
||||
* 2. In the heap section, if custom stack is not defined and the crashed task buffer is allocated in the heap
|
||||
* with the xTaskCreate() api
|
||||
*
|
||||
* esp_core_dump_store_section() will check if the coredump stack is located inside the section.
|
||||
* If it is, this part will be skipped.
|
||||
* |+++++++++| xxxxxxxxxxxxxx |++++++++|
|
||||
* |+++++++++| coredump stack |++++++++|
|
||||
*/
|
||||
static int esp_core_dump_store_section(core_dump_elf_t *self, uint32_t start, uint32_t data_len)
|
||||
{
|
||||
uint32_t end = start + data_len;
|
||||
int total_sz = 0;
|
||||
int ret;
|
||||
|
||||
if (self->coredump_stack_start > start && self->coredump_stack_start < end) {
|
||||
/* write until the coredump stack. */
|
||||
data_len = self->coredump_stack_start - start;
|
||||
ret = elf_add_segment(self, PT_LOAD,
|
||||
start,
|
||||
(void*)start,
|
||||
data_len);
|
||||
|
||||
if (ret <= 0) {
|
||||
return ret;
|
||||
}
|
||||
total_sz += ret;
|
||||
|
||||
/* Skip coredump stack and set offset for the rest of the section */
|
||||
start = self->coredump_stack_start + self->coredump_stack_size;
|
||||
data_len = end - start;
|
||||
}
|
||||
|
||||
if (data_len > 0) {
|
||||
ret = elf_add_segment(self, PT_LOAD,
|
||||
(uint32_t)start,
|
||||
(void*)start,
|
||||
(uint32_t)data_len);
|
||||
if (ret <= 0) {
|
||||
return ret;
|
||||
}
|
||||
total_sz += ret;
|
||||
}
|
||||
|
||||
return total_sz;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
core_dump_elf_t *self;
|
||||
int *total_sz;
|
||||
@ -611,11 +551,6 @@ bool esp_core_dump_write_heap_blocks(walker_heap_into_t heap_info, walker_block_
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self->coredump_stack_start == (uint32_t)block_info.ptr) {
|
||||
/* skip writing coredump stack block */
|
||||
return true;
|
||||
}
|
||||
|
||||
*ret = elf_add_segment(self, PT_LOAD,
|
||||
(uint32_t)block_info.ptr,
|
||||
(void*)block_info.ptr,
|
||||
@ -629,7 +564,7 @@ bool esp_core_dump_write_heap_blocks(walker_heap_into_t heap_info, walker_block_
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
static int esp_core_dump_store_section(core_dump_elf_t *self, uint32_t start, uint32_t data_len)
|
||||
{
|
||||
@ -639,8 +574,6 @@ static int esp_core_dump_store_section(core_dump_elf_t *self, uint32_t start, ui
|
||||
data_len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int elf_write_core_dump_user_data(core_dump_elf_t *self)
|
||||
{
|
||||
int total_sz = 0;
|
||||
@ -825,12 +758,6 @@ static esp_err_t esp_core_dump_write_elf(void)
|
||||
int tot_len = sizeof(dump_hdr);
|
||||
int write_len = sizeof(dump_hdr);
|
||||
|
||||
#if CONFIG_ESP_COREDUMP_CAPTURE_DRAM
|
||||
esp_core_dump_get_own_stack_info(&self.coredump_stack_start, &self.coredump_stack_size);
|
||||
ESP_COREDUMP_LOG_PROCESS("Core dump stack start=%p size = %d",
|
||||
(void *)self.coredump_stack_start, self.coredump_stack_size);
|
||||
#endif
|
||||
|
||||
esp_err_t err = esp_core_dump_write_init();
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Elf write init failed!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user