C++: use esp-backtrace as a panic handler on the esp platform

This commit is contained in:
Olivier Goffart 2023-07-24 11:03:12 +02:00 committed by Olivier Goffart
parent da55f4591a
commit ed0e4726d1
3 changed files with 9 additions and 1 deletions

View file

@ -153,6 +153,10 @@ endif()
if (NOT SLINT_FEATURE_STD)
list(APPEND features i-slint-core/libm i-slint-core/unsafe-single-threaded)
if (ESP_PLATFORM)
list(APPEND features "esp-backtrace/${IDF_TARGET}")
endif()
endif()
if (SLINT_FEATURE_STD AND SLINT_FEATURE_EXPERIMENTAL)

View file

@ -55,6 +55,8 @@ raw-window-handle = { version = "0.5", optional = true }
# Enable image-rs' default features to make all image formats to C++ users
image = { version = "0.24.0", optional = true }
esp-backtrace = { version = "0.7.0", features = ["panic-handler", "print-uart"], optional = true }
[build-dependencies]
anyhow = "1.0"
cbindgen = "0.24"

View file

@ -176,8 +176,10 @@ mod allocator {
static ALLOCATOR: CAlloc = CAlloc;
}
#[cfg(not(feature = "std"))]
#[cfg(all(not(feature = "std"), not(feature = "esp-backtrace")))]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[cfg(feature = "esp-backtrace")]
use esp_backtrace as _;