mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/eh_frame_backtrace' into 'master'
fix(system): fixed eh-frame backtrace issue from WDT See merge request espressif/esp-idf!33112
This commit is contained in:
commit
7cf872e610
@ -55,7 +55,7 @@ esp_err_t IRAM_ATTR esp_backtrace_print(int depth)
|
||||
|
||||
#if CONFIG_ESP_SYSTEM_USE_EH_FRAME
|
||||
esp_rom_printf("esp_backtrace_print: Print CPU %d (current core) backtrace\n", current_core);
|
||||
esp_eh_frame_print_backtrace(&frame);
|
||||
esp_eh_frame_print_backtrace(frame);
|
||||
#else // CONFIG_ESP_SYSTEM_USE_EH_FRAME
|
||||
esp_rom_printf("esp_backtrace_print: Print CPU %d (current core) registers\n", current_core);
|
||||
panic_prepare_frame_from_ctx(&backtrace_frame);
|
||||
|
@ -25,9 +25,8 @@ tools/test_apps/system/cxx_no_except:
|
||||
|
||||
tools/test_apps/system/eh_frame:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32c2", "esp32c3"]
|
||||
temporary: true
|
||||
reason: the other targets are not tested yet
|
||||
- if: IDF_TARGET not in ["esp32", "esp32s2", "esp32s3", "linux"]
|
||||
reason: Only relevant for riscv targets
|
||||
|
||||
tools/test_apps/system/esp_intr_dump:
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32-C2 | ESP32-C3 |
|
||||
| ----------------- | -------- | -------- |
|
||||
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 |
|
||||
| ----------------- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
|
||||
|
||||
# Building and running
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "eh_frame_main.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES esp_system)
|
||||
REQUIRES esp_system unity esp_timer)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@ -7,7 +7,9 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "unity.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_debug_helpers.h"
|
||||
/**
|
||||
* @brief Symbols defined by the linker.
|
||||
* Retrieve the addresses of both .eh_frame_hdr and .eh_frame sections.
|
||||
@ -26,6 +28,24 @@ extern char __eh_frame_end;
|
||||
#define EH_FRAME_END_ADDR ((void*) (&__eh_frame_end))
|
||||
|
||||
|
||||
void __attribute((noinline)) trigger_wdt(void)
|
||||
{
|
||||
const int wait_until_time = esp_timer_get_time() + (1000*1000 * (CONFIG_ESP_TASK_WDT_TIMEOUT_S + 1));
|
||||
while(esp_timer_get_time() < wait_until_time) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test task wdt can print backtrace with eh-frame", "eh-frame")
|
||||
{
|
||||
trigger_wdt();
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Test panic can print backtrace with eh-frame", "eh-frame")
|
||||
{
|
||||
asm("unimp");
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/* As soon as this test compiles, it can be considered passed. The linker should
|
||||
@ -37,4 +57,6 @@ void app_main(void)
|
||||
/* Use the symbols just to make sure they won't be optimized away */
|
||||
printf(".eh_frame start: %p, end: %p\n", EH_FRAME_ADDR, EH_FRAME_END_ADDR);
|
||||
printf(".eh_frame_hdr start: %p, end: %p\n", EH_FRAME_HDR_ADDR, EH_FRAME_HDR_END_ADDR);
|
||||
|
||||
unity_run_menu();
|
||||
}
|
||||
|
34
tools/test_apps/system/eh_frame/pytest_eh_frame.py
Normal file
34
tools/test_apps/system/eh_frame/pytest_eh_frame.py
Normal file
@ -0,0 +1,34 @@
|
||||
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.esp32c2
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c5
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32h2
|
||||
@pytest.mark.esp32p4
|
||||
@pytest.mark.generic
|
||||
def test_eh_frame_wdt(dut: Dut) -> None:
|
||||
dut.expect_exact('Press ENTER to see the list of tests')
|
||||
dut.confirm_write('"Test task wdt can print backtrace with eh-frame"', expect_str=f'Running')
|
||||
|
||||
# Expect a backtrace which is at least 3 PC-SP pairs deep
|
||||
dut.expect(r'Backtrace: (0x[a-fA-F0-9]+:0x[a-fA-F0-9]+\s*){3,}')
|
||||
|
||||
|
||||
@pytest.mark.esp32c2
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c5
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32h2
|
||||
@pytest.mark.esp32p4
|
||||
@pytest.mark.generic
|
||||
def test_eh_frame_panic(dut: Dut) -> None:
|
||||
dut.expect_exact('Press ENTER to see the list of tests')
|
||||
dut.confirm_write('"Test panic can print backtrace with eh-frame"', expect_str=f'Running')
|
||||
|
||||
# Expect a backtrace which is at least 3 PC-SP pairs deep
|
||||
dut.expect(r'Backtrace: (0x[a-fA-F0-9]+:0x[a-fA-F0-9]+\s*){3,}')
|
@ -1,2 +1,4 @@
|
||||
# Enable eh_frame sections generation
|
||||
CONFIG_ESP_SYSTEM_USE_EH_FRAME=y
|
||||
# use non-rom systimer implementation, can't backtrace functions in ROM
|
||||
CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=n
|
||||
|
Loading…
Reference in New Issue
Block a user