Merge branch 'feature/add_macro_of_filename' into 'master'

Add macro "__ESP_FILE__" and its configuration

See merge request sdk/ESP8266_RTOS_SDK!511
This commit is contained in:
Dong Heng
2018-09-25 11:25:53 +08:00
11 changed files with 54 additions and 18 deletions

View File

@ -28,6 +28,27 @@ config NEWLIB_STDOUT_LINE_ENDING_CR
bool "CR" bool "CR"
endchoice endchoice
choice ESP_FILENAME_MACRO
prompt "File name macro text"
default ESP_FILENAME_MACRO_NO_PATH
help
This option allows configuring the macro __ESP_FILE__ text.
Three options are possible:
no PATH: strip the path of macro __FILE__, for example: __FILE__="a/b/c/d.h", then __ESP_FILE__="d.h"
raw: same as macro __FILE__
null: text is string "null"
config ESP_FILENAME_MACRO_NO_PATH
bool "no PATH"
config ESP_FILENAME_MACRO_RAW
bool "raw"
config ESP_FILENAME_MACRO_NULL
bool "null"
endchoice
config SOC_FULL_ICACHE config SOC_FULL_ICACHE
bool "Enable full cache mode" bool "Enable full cache mode"
default n default n

View File

@ -66,3 +66,18 @@ endif
# global CFLAGS for ESP8266 # global CFLAGS for ESP8266
CFLAGS += -DICACHE_FLASH CFLAGS += -DICACHE_FLASH
ifdef CONFIG_ESP_FILENAME_MACRO_NO_PATH
CFLAGS += -D__ESP_FILE__='"$$(subst $$(dir $$<),,$$<)"'
CXXFLAGS += -D__ESP_FILE__='"$$(subst $$(dir $$<),,$$<)"'
endif
ifdef CONFIG_ESP_FILENAME_MACRO_RAW
CFLAGS += -D__ESP_FILE__=__FILE__
CXXFLAGS += -D__ESP_FILE__=__FILE__
endif
ifdef CONFIG_ESP_FILENAME_MACRO_NULL
CFLAGS += -D__ESP_FILE__='"null"'
CXXFLAGS += -D__ESP_FILE__='"null"'
endif

View File

@ -105,7 +105,7 @@ void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const cha
#define ESP_ERROR_CHECK(x) do { \ #define ESP_ERROR_CHECK(x) do { \
esp_err_t __err_rc = (x); \ esp_err_t __err_rc = (x); \
if (__err_rc != ESP_OK) { \ if (__err_rc != ESP_OK) { \
_esp_error_check_failed(__err_rc, __FILE__, __LINE__, \ _esp_error_check_failed(__err_rc, __ESP_FILE__, __LINE__, \
__ASSERT_FUNC, #x); \ __ASSERT_FUNC, #x); \
} \ } \
} while(0); } while(0);

View File

@ -126,19 +126,19 @@ extern wifi_osi_funcs_t s_wifi_osi_funcs;
s_wifi_osi_funcs.timer_delete(t, tk) s_wifi_osi_funcs.timer_delete(t, tk)
#define wifi_malloc(s, c) \ #define wifi_malloc(s, c) \
s_wifi_osi_funcs.malloc(s, c, __FILE__, __LINE__) s_wifi_osi_funcs.malloc(s, c, __ESP_FILE__, __LINE__)
#define wifi_zalloc(s, c) \ #define wifi_zalloc(s, c) \
s_wifi_osi_funcs.zalloc(s, c, __FILE__, __LINE__) s_wifi_osi_funcs.zalloc(s, c, __ESP_FILE__, __LINE__)
#define wifi_calloc(cnt, s, c) \ #define wifi_calloc(cnt, s, c) \
s_wifi_osi_funcs.calloc(cnt, s, c, __FILE__, __LINE__) s_wifi_osi_funcs.calloc(cnt, s, c, __ESP_FILE__, __LINE__)
#define wifi_realloc(ptr, s, c) \ #define wifi_realloc(ptr, s, c) \
s_wifi_osi_funcs.realloc(ptr, s, c, __FILE__, __LINE__) s_wifi_osi_funcs.realloc(ptr, s, c, __ESP_FILE__, __LINE__)
#define wifi_free(p) \ #define wifi_free(p) \
s_wifi_osi_funcs.free(p, __FILE__, __LINE__) s_wifi_osi_funcs.free(p, __ESP_FILE__, __LINE__)
#define wifi_get_free_heap_size() \ #define wifi_get_free_heap_size() \
s_wifi_osi_funcs.get_free_heap_size() s_wifi_osi_funcs.get_free_heap_size()

View File

@ -214,7 +214,7 @@ void show_critical_info(void);
* @brief add trace information to allocated memory * @brief add trace information to allocated memory
* *
* @param ptr memory pointer allocated by "os_maloc", "malloc" and so on * @param ptr memory pointer allocated by "os_maloc", "malloc" and so on
* @param trace trace information, file name(__FILE__) or "__builtin_return_address(0)" is OK * @param trace trace information, file name(__ESP_FILE__) or "__builtin_return_address(0)" is OK
* @param no number of trace information, file line(__LINE__) or -1(using "__builtin_return_address(0)") * @param no number of trace information, file line(__LINE__) or -1(using "__builtin_return_address(0)")
*/ */
void esp_mem_trace(const void *ptr, const char *trace, int no); void esp_mem_trace(const void *ptr, const char *trace, int no);
@ -224,7 +224,7 @@ void esp_mem_trace(const void *ptr, const char *trace, int no);
* *
* @param ptr memory pointer allocated by "os_maloc", "malloc" and so on * @param ptr memory pointer allocated by "os_maloc", "malloc" and so on
*/ */
#define esp_mem_mark_file(ptr) esp_mem_trace((ptr), __FILE__, LINE__) #define esp_mem_mark_file(ptr) esp_mem_trace((ptr), __ESP_FILE__, LINE__)
/* /*
* @brief check if CPU core interrupt is disable * @brief check if CPU core interrupt is disable

View File

@ -121,7 +121,7 @@ void esp_heap_caps_init_region(heap_region_t *region, size_t max_num);
* *
* @return A pointer to the memory allocated on success, NULL on failure * @return A pointer to the memory allocated on success, NULL on failure
*/ */
#define heap_caps_malloc(size, caps) _heap_caps_malloc(size, caps, __FILE__, __LINE__) #define heap_caps_malloc(size, caps) _heap_caps_malloc(size, caps, __ESP_FILE__, __LINE__)
void *_heap_caps_malloc(size_t size, uint32_t caps, const char *file, size_t line); void *_heap_caps_malloc(size_t size, uint32_t caps, const char *file, size_t line);
@ -134,7 +134,7 @@ void *_heap_caps_malloc(size_t size, uint32_t caps, const char *file, size_t lin
* *
* @param ptr Pointer to memory previously returned from heap_caps_(m/c/re/z)alloc(). Can be NULL. * @param ptr Pointer to memory previously returned from heap_caps_(m/c/re/z)alloc(). Can be NULL.
*/ */
#define heap_caps_free(p) _heap_caps_free(p, __FILE__, __LINE__) #define heap_caps_free(p) _heap_caps_free(p, __ESP_FILE__, __LINE__)
void _heap_caps_free(void *ptr, const char *file, size_t line); void _heap_caps_free(void *ptr, const char *file, size_t line);
@ -151,7 +151,7 @@ void _heap_caps_free(void *ptr, const char *file, size_t line);
* *
* @return A pointer to the memory allocated on success, NULL on failure * @return A pointer to the memory allocated on success, NULL on failure
*/ */
#define heap_caps_calloc(n, size, caps) _heap_caps_calloc(n, size, caps, __FILE__, __LINE__) #define heap_caps_calloc(n, size, caps) _heap_caps_calloc(n, size, caps, __ESP_FILE__, __LINE__)
void *_heap_caps_calloc(size_t count, size_t size, uint32_t caps, const char *file, size_t line); void *_heap_caps_calloc(size_t count, size_t size, uint32_t caps, const char *file, size_t line);
@ -171,7 +171,7 @@ void *_heap_caps_calloc(size_t count, size_t size, uint32_t caps, const char *fi
* *
* @return Pointer to a new buffer of size 'size' with capabilities 'caps', or NULL if allocation failed. * @return Pointer to a new buffer of size 'size' with capabilities 'caps', or NULL if allocation failed.
*/ */
#define heap_caps_realloc(ptr, size, caps) _heap_caps_realloc(ptr, size, caps, __FILE__, __LINE__) #define heap_caps_realloc(ptr, size, caps) _heap_caps_realloc(ptr, size, caps, __ESP_FILE__, __LINE__)
void *_heap_caps_realloc(void *mem, size_t newsize, uint32_t caps, const char *file, size_t line); void *_heap_caps_realloc(void *mem, size_t newsize, uint32_t caps, const char *file, size_t line);
@ -188,7 +188,7 @@ void *_heap_caps_realloc(void *mem, size_t newsize, uint32_t caps, const char *f
* *
* @return A pointer to the memory allocated on success, NULL on failure * @return A pointer to the memory allocated on success, NULL on failure
*/ */
#define heap_caps_zalloc(size, caps) _heap_caps_zalloc(size, caps, __FILE__, __LINE__) #define heap_caps_zalloc(size, caps) _heap_caps_zalloc(size, caps, __ESP_FILE__, __LINE__)
void *_heap_caps_zalloc(size_t size, uint32_t caps, const char *file, size_t line); void *_heap_caps_zalloc(size_t size, uint32_t caps, const char *file, size_t line);

View File

@ -88,7 +88,7 @@
*/ */
#ifndef LWIP_PLATFORM_ASSERT #ifndef LWIP_PLATFORM_ASSERT
#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) x, __LINE__, __ESP_FILE__); fflush(NULL); abort();} while(0)
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#endif #endif

View File

@ -145,7 +145,7 @@ void memp_init(void);
#error "MEMP_OVERFLOW_CHECK && ESP_LWIP_MEM_DBG cannot used" #error "MEMP_OVERFLOW_CHECK && ESP_LWIP_MEM_DBG cannot used"
#endif #endif
void *memp_malloc_fn(memp_t type, const char* file, const int line); void *memp_malloc_fn(memp_t type, const char* file, const int line);
#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) #define memp_malloc(t) memp_malloc_fn((t), __ESP_FILE__, __LINE__)
#else #else
void *memp_malloc(memp_t type); void *memp_malloc(memp_t type);
#endif #endif

View File

@ -173,7 +173,7 @@ void memp_init_pool(const struct memp_desc *desc);
#error "MEMP_OVERFLOW_CHECK && ESP_LWIP_MEM_DBG cannot used" #error "MEMP_OVERFLOW_CHECK && ESP_LWIP_MEM_DBG cannot used"
#endif #endif
void *memp_malloc_pool_fn(const struct memp_desc* desc, const char* file, const int line); void *memp_malloc_pool_fn(const struct memp_desc* desc, const char* file, const int line);
#define memp_malloc_pool(d) memp_malloc_pool_fn((d), __FILE__, __LINE__) #define memp_malloc_pool(d) memp_malloc_pool_fn((d), __ESP_FILE__, __LINE__)
#else #else
void *memp_malloc_pool(const struct memp_desc *desc); void *memp_malloc_pool(const struct memp_desc *desc);
#endif #endif

View File

@ -66,7 +66,7 @@ typedef int sys_prot_t;
extern void sys_arch_assert(const char *file, int line); extern void sys_arch_assert(const char *file, int line);
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
#define LWIP_PLATFORM_ASSERT(x) do {printf(x); sys_arch_assert(__FILE__, __LINE__);} while(0) #define LWIP_PLATFORM_ASSERT(x) do {printf(x); sys_arch_assert(__ESP_FILE__, __LINE__);} while(0)
#else #else
#define LWIP_PLATFORM_DIAG(x) #define LWIP_PLATFORM_DIAG(x)
#define LWIP_PLATFORM_ASSERT(x) #define LWIP_PLATFORM_ASSERT(x)

View File

@ -13,7 +13,7 @@ extern "C" {
#ifdef NDEBUG /* required by ANSI standard */ #ifdef NDEBUG /* required by ANSI standard */
# define assert(__e) ((__e) ? (void)0 : (void)0) # define assert(__e) ((__e) ? (void)0 : (void)0)
#else #else
# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \ # define assert(__e) ((__e) ? (void)0 : __assert_func (__ESP_FILE__, __LINE__, \
__ASSERT_FUNC, #__e)) __ASSERT_FUNC, #__e))
# ifndef __ASSERT_FUNC # ifndef __ASSERT_FUNC