• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #include <stdbool.h>
15 #include <string.h>
16 
17 #include "esp_err.h"
18 #include "esp_spi_flash.h"
19 
20 #include "esp_rom_sys.h"
21 
esp_error_check_failed_print(const char * msg,esp_err_t rc,const char * file,int line,const char * function,const char * expression)22 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)
23 {
24     esp_rom_printf("%s failed: esp_err_t 0x%x", msg, rc);
25 #ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
26     esp_rom_printf(" (%s)", esp_err_to_name(rc));
27 #endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
28     esp_rom_printf(" at 0x%08x\n", (intptr_t)__builtin_return_address(0) - 3);
29     if (spi_flash_cache_enabled()) { // strings may be in flash cache
30         esp_rom_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
31     }
32 }
33 
_esp_error_check_failed_without_abort(esp_err_t rc,const char * file,int line,const char * function,const char * expression)34 void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
35 {
36     esp_error_check_failed_print("ESP_ERROR_CHECK_WITHOUT_ABORT", rc, file, line, function, expression);
37 }
38 
_esp_error_check_failed(esp_err_t rc,const char * file,int line,const char * function,const char * expression)39 void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
40 {
41     esp_error_check_failed_print("ESP_ERROR_CHECK", rc, file, line, function, expression);
42     abort();
43 }
44