esp-idf: backtrace for abort / panic not available in coredump (IDFGH-4276)
Environment
- Development Kit: ESP32-Wrover-Kit or ESP32-DevKitC
- Kit version (for WroverKit/PicoKit/DevKitC): v4
- Module or chip used: ESP32-WROVER-B or ESP32-WROVER-B
- IDF version (run
git describe --tagsto find it): v4.1 - Build System: CMake
- Compiler version (run
xtensa-esp32-elf-gcc --versionto find it): (crosstool-NG esp-2020r2) 8.2.0 - Operating System: Windows
- (Windows only) environment type: ESP Command Prompt
- Using an IDE?: Yes Eclipse ESP-IDF Plugin
- Power Supply: USB
Problem Description
the CoreDump component is intended to locate problems in the sources, but it cannot provide a backtrace in case of panic / assert / abort
Expected Behavior
Complete backtrace is available
Actual Behavior
Just 2 frames are available
#0 0x4008429c in invoke_abort () at D:/esp-idf/esp-idf-v4.1/components/esp32/panic.c:159
#1 0x40084698 in abort () at D:/esp-idf/esp-idf-v4.1/components/esp32/panic.c:174
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Steps to reproduce
- take an example (like examples / get-started / hello_world)
- put an
assert(0);somewhere, for example in the loop, line 45 of hello_world_main.c, see below too - configure coredump to flash in sdkconfig (or use attached config file)
- run the code
- read the dump via
\esp-idf-v4.1\components\espcoredump\espcoredump.py -p COM15 info_corefile D:\eclipse_cpp\workspace\hello_world\build\hello-world.elf
Code to reproduce this issue
/* Hello World Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#ifdef CONFIG_IDF_TARGET_ESP32
#define CHIP_NAME "ESP32"
#endif
#ifdef CONFIG_IDF_TARGET_ESP32S2BETA
#define CHIP_NAME "ESP32-S2 Beta"
#endif
void app_main(void)
{
printf("Hello world!\n");
/* Print chip information */
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
printf("This is %s chip with %d CPU cores, WiFi%s%s, ",
CHIP_NAME,
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
printf("silicon revision %d, ", chip_info.revision);
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
for (int i = 10; i >= 0; i--) {
printf("Restarting in %d seconds...\n", i);
vTaskDelay(1000 / portTICK_PERIOD_MS);
assert(0);
}
printf("Restarting now.\n");
fflush(stdout);
esp_restart();
}
Other items if possible
- sdkconfig file (remove the txt extension) sdkconfig.txt
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 26 (7 by maintainers)
Commits related to this issue
- Add patch for truncated backtraces Pull in the patch from here: > https://github.com/espressif/esp-idf/issues/6124#issuecomment-949843140 Which was applied to the espressif binutils-gdb fork here: ... — committed to memfault/conda-recipes by noahp 3 years ago
- Add patch for truncated backtraces Pull in the patch from here: > https://github.com/espressif/esp-idf/issues/6124#issuecomment-949843140 Which was applied to the espressif binutils-gdb fork here: ... — committed to memfault/conda-recipes by noahp 3 years ago
- Add patch for truncated backtraces Pull in the patch from here: > https://github.com/espressif/esp-idf/issues/6124#issuecomment-949843140 Which was applied to the espressif binutils-gdb fork here: ... — committed to memfault/conda-recipes by noahp 3 years ago
- Add patch for truncated backtraces Pull in the patch from here: > https://github.com/espressif/esp-idf/issues/6124#issuecomment-949843140 Which was applied to the espressif binutils-gdb fork here: ... — committed to memfault/conda-recipes by noahp 3 years ago
- Update toolchains to esp-2021r2 Updated GDB to 9.2 version for xtensa chips Fixed coredump work for xtensa chips Fixed backtrace for xtensa chips Fixed multilib for riscv32 chips ... — committed to espressif/esp-idf by antmak 3 years ago
- Update toolchains to esp-2021r2 Updated GDB to 9.2 version for xtensa chips Fixed coredump work for xtensa chips Fixed backtrace for xtensa chips Fixed multilib for riscv32 chips ... — committed to espressif/esp-idf by antmak 3 years ago
- tools: update gdb version to '11.2_20220823' Closes https://github.com/espressif/esp-idf/issues/6124 — committed to espressif/esp-idf by Lapshin 2 years ago
- tools: Update GCC toolchain to esp-2021r2-patch4 version. Includes GCC 8.4.0, Newlib 3.3.0 Closes https://github.com/espressif/esp-idf/issues/7857 Closes https://github.com/espressif/esp-idf/issues/6... — committed to espressif/esp-idf by antmak 2 years ago
@KaeLL, it’s already avaliabe in 5.0 branch (06cdc0ee4f6a254f4c682e4652e345506d194e3e)
Also, it will be patched for v4.4 soon
How to get backtrace from
esp_core_dump_summary_t?flashand it is working fine. Now, i get thecoredump_summaryusing this functions.@igrr
Hi @ztefanjo, i’m sorry I have missed your previous comment, I was on leave. Here is the patch you can apply to release/v4.4 to prevent the issue for noreturn functions. 0001-system-add-workaround-for-interrupted-backtraces-on-.patch.txt
We had this change in review a while ago, but it wasn’t accepted because the issue may still occur for “noreturn” functions in application code. Given that we had to revert the fix in GDB, I’ll put this patch for review once again.
@KaeLL for your question, you can trigger some exception (like
*((int*)1) = 0;) or use the__builtin_trap();compiler built-in.