2022-06-27 03:24:07 -04:00
|
|
|
/*
|
2024-01-29 20:40:10 -05:00
|
|
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
2022-06-27 03:24:07 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-02-02 10:23:16 -05:00
|
|
|
#include <stdbool.h>
|
2021-01-25 23:04:33 -05:00
|
|
|
#include <stdlib.h>
|
2020-02-02 10:23:16 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "esp_err.h"
|
2022-06-27 03:24:07 -04:00
|
|
|
#include "esp_private/cache_utils.h"
|
2020-02-02 10:23:16 -05:00
|
|
|
|
2020-07-21 01:07:34 -04:00
|
|
|
#include "esp_rom_sys.h"
|
2020-02-02 10:23:16 -05:00
|
|
|
|
2022-06-23 10:41:23 -04:00
|
|
|
#ifndef CONFIG_IDF_TARGET_LINUX
|
2024-01-29 20:40:10 -05:00
|
|
|
#include "esp_cpu.h"
|
2022-06-23 10:41:23 -04:00
|
|
|
#else
|
2024-01-29 20:40:10 -05:00
|
|
|
/* esp_cpu.h isn't available when building for Linux */
|
|
|
|
static intptr_t esp_cpu_get_call_addr(intptr_t return_address)
|
|
|
|
{
|
|
|
|
/* on x86, there is no hope to get the address of the previous instruction */
|
|
|
|
return return_address;
|
|
|
|
}
|
2022-06-23 10:41:23 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void esp_error_check_failed_print(const char *msg, esp_err_t rc, const char *file, int line, const char *function, const char *expression, intptr_t addr)
|
2020-02-02 10:23:16 -05:00
|
|
|
{
|
2020-07-21 01:07:34 -04:00
|
|
|
esp_rom_printf("%s failed: esp_err_t 0x%x", msg, rc);
|
2020-02-02 10:23:16 -05:00
|
|
|
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2020-07-21 01:07:34 -04:00
|
|
|
esp_rom_printf(" (%s)", esp_err_to_name(rc));
|
2020-02-02 10:23:16 -05:00
|
|
|
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
2022-06-23 10:41:23 -04:00
|
|
|
esp_rom_printf(" at 0x%08x\n", esp_cpu_get_call_addr(addr));
|
2023-01-30 05:03:41 -05:00
|
|
|
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
|
|
|
if (spi_flash_cache_enabled()) // strings may be in flash cache
|
|
|
|
#endif
|
|
|
|
{
|
2020-07-21 01:07:34 -04:00
|
|
|
esp_rom_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
|
2020-02-02 10:23:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
|
|
|
|
{
|
2022-06-23 10:41:23 -04:00
|
|
|
esp_error_check_failed_print("ESP_ERROR_CHECK_WITHOUT_ABORT", rc, file, line, function, expression, (intptr_t)__builtin_return_address(0));
|
2020-02-02 10:23:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
|
|
|
|
{
|
2022-06-23 10:41:23 -04:00
|
|
|
esp_error_check_failed_print("ESP_ERROR_CHECK", rc, file, line, function, expression, (intptr_t)__builtin_return_address(0));
|
2020-02-02 10:23:16 -05:00
|
|
|
abort();
|
2020-11-10 02:40:01 -05:00
|
|
|
}
|