]> granicus.if.org Git - esp-idf/commitdiff
ESP_ERROR_CHECK converts error code to text
authorRoland Dobai <dobai.roland@gmail.com>
Thu, 31 May 2018 10:47:06 +0000 (12:47 +0200)
committerRoland Dobai <dobai.roland@gmail.com>
Thu, 31 May 2018 10:53:37 +0000 (12:53 +0200)
If CONFIG_ESP_ERR_TO_NAME_LOOKUP is enabled, ESP_ERROR_CHECK
prints error message in addition to the error code.

components/esp32/panic.c
components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp
components/wear_levelling/test_wl_host/esp_error_check_stub.cpp

index 83bc657f1a67ec282b063b469a43e1374231cff0..ab57307270474e2c6c09ff3f30f471499da4be64 100644 (file)
@@ -40,6 +40,7 @@
 #include "esp_cache_err_int.h"
 #include "esp_app_trace.h"
 #include "esp_system.h"
+#include "sdkconfig.h"
 #if CONFIG_SYSVIEW_ENABLE
 #include "SEGGER_RTT.h"
 #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)
 {
-    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
         ets_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
     }
index 9cff4af3107f45ab5182656cfbe31d0cdbb9267f..34d8704e7ba344ed3ad4b06c3b0198ea60e512d4 100644 (file)
@@ -1,9 +1,14 @@
 #include "catch.hpp"
 #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)
 {
-    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);
     abort();
 }
index 9cff4af3107f45ab5182656cfbe31d0cdbb9267f..1eb70e3e9f800356ed31b92f34a718058de67b13 100644 (file)
@@ -1,9 +1,14 @@
 #include "catch.hpp"
 #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)
 {
-    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);
     abort();
 }