Merge branch 'feature/esp_error_check_prints_error_text' into 'master'

ESP_ERROR_CHECK converts error code to text

See merge request idf/esp-idf!2488
This commit is contained in:
Ivan Grokhotkov 2018-06-01 16:43:37 +08:00
commit 28877e7868
3 changed files with 18 additions and 3 deletions

View file

@ -40,6 +40,7 @@
#include "esp_cache_err_int.h" #include "esp_cache_err_int.h"
#include "esp_app_trace.h" #include "esp_app_trace.h"
#include "esp_system.h" #include "esp_system.h"
#include "sdkconfig.h"
#if CONFIG_SYSVIEW_ENABLE #if CONFIG_SYSVIEW_ENABLE
#include "SEGGER_RTT.h" #include "SEGGER_RTT.h"
#endif #endif
@ -653,7 +654,11 @@ void esp_clear_watchpoint(int no)
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
{ {
ets_printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at 0x%08x\n", rc, (intptr_t)__builtin_return_address(0) - 3); ets_printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x", rc);
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
ets_printf(" (%s)", esp_err_to_name(rc));
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
ets_printf(" at 0x%08x\n", (intptr_t)__builtin_return_address(0) - 3);
if (spi_flash_cache_enabled()) { // strings may be in flash cache if (spi_flash_cache_enabled()) { // strings may be in flash cache
ets_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); ets_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
} }

View file

@ -1,9 +1,14 @@
#include "catch.hpp" #include "catch.hpp"
#include "esp_err.h" #include "esp_err.h"
#include "sdkconfig.h"
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
{ {
printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at %p\n", rc, __builtin_return_address(0)); printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x", rc);
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" (%s)", esp_err_to_name(rc));
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" at %p\n", __builtin_return_address(0));
printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
abort(); abort();
} }

View file

@ -1,9 +1,14 @@
#include "catch.hpp" #include "catch.hpp"
#include "esp_err.h" #include "esp_err.h"
#include "sdkconfig.h"
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
{ {
printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at %p\n", rc, __builtin_return_address(0)); printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x", rc);
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" (%s)", esp_err_to_name(rc));
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
printf(" at %p\n", __builtin_return_address(0));
printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
abort(); abort();
} }