Skip to content

Commit c766134

Browse files
committed
feat(system): add exception handler for load store exception
internal gitlab: a3b74e9c
1 parent 67bdd07 commit c766134

19 files changed

+62
-36
lines changed

VERSION

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
gwen:
2-
at : 754dddb
3-
crypto : 350448e
4-
espnow : 350448e
5-
json : ce90efd
6-
main : 754dddb
7-
net80211 : 350448e
8-
pp : 097de86
9-
smartconfig : 350448e
10-
ssl : b19a6f7
11-
upgrade : 5287040
12-
wpa : 350448e
13-
wpa2 : 350448e
14-
wps : 350448e
2+
at : bc85feb
3+
crypto : bc85feb
4+
espnow : bc85feb
5+
json : bc85feb
6+
main : bc85feb
7+
net80211 : bc85feb
8+
pp : bc85feb
9+
smartconfig : bc85feb
10+
ssl : bc85feb
11+
upgrade : bc85feb
12+
wpa : bc85feb
13+
wpa2 : bc85feb
14+
wps : bc85feb
1515

1616
phy:
1717
phy : 1136
1818

1919
gitlab:
2020
driver : 68fc7b06
21-
lwip : c097d4cf
22-
mbedtls : e4dace14
21+
lwip : 3c7a0dbe
22+
mbedtls : 3c7a0dbe

include/mem.h

100644100755
+14-7
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ bool ICACHE_FLASH_ATTR check_memleak_debug_enable(void)
3737
}
3838
*/
3939

40-
void *pvPortMalloc (size_t sz, const char *, unsigned);
40+
void *pvPortMalloc (size_t sz, const char *, unsigned, bool);
4141
void vPortFree (void *p, const char *, unsigned);
4242
void *pvPortZalloc (size_t sz, const char *, unsigned);
4343
void *pvPortRealloc (void *p, size_t n, const char *, unsigned);
4444

4545
#ifndef MEMLEAK_DEBUG
4646
#define MEMLEAK_DEBUG_ENABLE 0
47-
#define os_free(s) vPortFree(s, "", 0)
48-
#define os_malloc(s) pvPortMalloc(s, "", 0)
49-
#define os_calloc(l, s) pvPortCalloc(l, s, "", 0);
50-
#define os_realloc(p, s) pvPortRealloc(p, s, "", 0)
51-
#define os_zalloc(s) pvPortZalloc(s, "", 0)
47+
#define os_free(s) vPortFree(s, "", __LINE__)
48+
#define os_malloc(s) pvPortMalloc(s, "", __LINE__,true)
49+
#define os_malloc_dram(s) pvPortMalloc(s, "", __LINE__,false)
50+
#define os_calloc(l, s) ({void* ptr = (void*)os_malloc((l) * (s));if(ptr){os_memset(ptr,0x0,(l) * (s));} ptr;})// pvPortCalloc(l, s, "", __LINE__)
51+
#define os_realloc(p, s) pvPortRealloc(p, s, "", __LINE__)
52+
#define os_zalloc(s) os_calloc(1, s)// pvPortZalloc(s, "", __LINE__)
5253
#else
5354
#define MEMLEAK_DEBUG_ENABLE 1
5455

@@ -61,9 +62,15 @@ do{\
6162
#define os_malloc(s) \
6263
({ \
6364
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
64-
pvPortMalloc(s, mem_debug_file, __LINE__); \
65+
pvPortMalloc(s, mem_debug_file, __LINE__,true); \
6566
})
6667

68+
#define os_malloc_dram(s) \
69+
({ \
70+
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
71+
pvPortMalloc(s, mem_debug_file, __LINE__,false); \
72+
})
73+
6774
#define os_calloc(l, s) \
6875
({ \
6976
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \

lib/libat.a

304 Bytes
Binary file not shown.

lib/libcrypto.a

12 Bytes
Binary file not shown.

lib/libespnow.a

0 Bytes
Binary file not shown.

lib/libjson.a

0 Bytes
Binary file not shown.

lib/liblwip.a

5.63 KB
Binary file not shown.

lib/libmain.a

6.1 KB
Binary file not shown.

lib/libmbedtls.a

20 KB
Binary file not shown.

lib/libnet80211.a

4 Bytes
Binary file not shown.

lib/libpp.a

2.47 KB
Binary file not shown.

lib/libsmartconfig.a

0 Bytes
Binary file not shown.

lib/libssl.a

20 Bytes
Binary file not shown.

lib/libupgrade.a

0 Bytes
Binary file not shown.

lib/libwpa.a

32 Bytes
Binary file not shown.

lib/libwpa2.a

136 Bytes
Binary file not shown.

lib/libwps.a

32 Bytes
Binary file not shown.

third_party/include/lwip/mem.h

+12-7
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ typedef size_t mem_size_t;
5252
*/
5353
#ifndef MEMLEAK_DEBUG
5454
#ifndef mem_free
55-
#define mem_free vPortFree
55+
#define mem_free(s) vPortFree(s, "", __LINE__)
5656
#endif
5757
#ifndef mem_malloc
58-
#define mem_malloc pvPortMalloc
58+
#define mem_malloc(s) pvPortMalloc(s, "", __LINE__,false)
5959
#endif
6060
#ifndef mem_calloc
61-
#define mem_calloc pvPortCalloc
61+
#define mem_calloc(l, s) ({void* ptr = (void*)pvPortMalloc((l) * (s), "", __LINE__,true);if(ptr){os_memset(ptr,0x0,(l) * (s));} ptr;})// pvPortCalloc(l, s, "", __LINE__)
6262
#endif
6363
#ifndef mem_realloc
64-
#define mem_realloc pvPortRealloc
64+
#define mem_realloc(p, s) pvPortRealloc(p, s, "", __LINE__)
6565
#endif
6666
#ifndef mem_zalloc
67-
#define mem_zalloc pvPortZalloc
67+
#define mem_zalloc(s) mem_calloc(1,s) // pvPortZalloc(s, "", __LINE__)
6868
#endif
6969
#else
7070
#ifndef mem_free
@@ -74,8 +74,9 @@ do{\
7474
vPortFree(s, file, __LINE__);\
7575
}while(0)
7676
#endif
77+
7778
#ifndef mem_malloc
78-
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
79+
#define mem_malloc(s) (const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__,false);})
7980
#endif
8081
#ifndef mem_calloc
8182
#define mem_calloc(l, s) ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);})
@@ -90,7 +91,11 @@ do{\
9091
#endif
9192

9293
#ifndef os_malloc
93-
#define os_malloc(s) mem_malloc((s))
94+
#ifndef MEMLEAK_DEBUG
95+
#define os_malloc(s) pvPortMalloc(s, "", __LINE__,true)
96+
#else
97+
#define os_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__,true);})
98+
#endif
9499
#endif
95100
#ifndef os_realloc
96101
#define os_realloc(p, s) mem_realloc((p), (s))

third_party/include/mbedtls/platform.h

+21-7
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@
3333
extern "C" {
3434
#endif
3535

36+
#include "osapi.h"
3637
/**
3738
* \name SECTION: Module settings
3839
*
3940
* The configuration options you can set for this module are in this section.
4041
* Either change them in config.h or define them on the compiler command line.
4142
* \{
4243
*/
43-
extern int ets_snprintf(char *buf, unsigned int size, const char *format, ...);
44-
extern void *pvPortCalloc(unsigned int count, unsigned int size);
45-
extern void vPortFree( void *pv );
44+
// extern int ets_snprintf(char *buf, unsigned int size, const char *format, ...);
45+
void *pvPortCalloc(unsigned int count, unsigned int size, const char*, unsigned);
46+
void vPortFree (void *p, const char *, unsigned);
4647
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
4748
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
4849
#include <stdio.h>
@@ -61,10 +62,18 @@ extern void vPortFree( void *pv );
6162
#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
6263
#endif
6364
#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
64-
#define MBEDTLS_PLATFORM_STD_CALLOC pvPortCalloc /**< Default allocator to use */
65+
#ifndef MEMLEAK_DEBUG
66+
#define MBEDTLS_PLATFORM_STD_CALLOC(l, s) ({void* p = pvPortMalloc((l) * (s), "", __LINE__,true);if(p){os_memset(p,0x0,(l) * (s));} p;})// pvPortCalloc(l, s, "", __LINE__) // pvPortCalloc /**< Default allocator to use */
67+
#else
68+
#define MBEDTLS_PLATFORM_STD_CALLOC(l, s) ({const char *file = mem_debug_file;void* p = pvPortMalloc((l) * (s), file, __LINE__,true);if(p){os_memset(p,0x0,(l) * (s));} p;})// ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);})
69+
#endif
6570
#endif
6671
#if !defined(MBEDTLS_PLATFORM_STD_FREE)
67-
#define MBEDTLS_PLATFORM_STD_FREE vPortFree /**< Default free to use */
72+
#ifndef MEMLEAK_DEBUG
73+
#define MBEDTLS_PLATFORM_STD_FREE(s) vPortFree(s, "", __LINE__) // vPortFree /**< Default free to use */
74+
#else
75+
#define MBEDTLS_PLATFORM_STD_FREE(s) do{const char *file = mem_debug_file;vPortFree(s, file, __LINE__);}while(0)
76+
#endif
6877
#endif
6978
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
7079
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default free to use */
@@ -103,8 +112,13 @@ int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
103112
void (*free_func)( void * ) );
104113
#endif /* MBEDTLS_PLATFORM_FREE_MACRO && MBEDTLS_PLATFORM_CALLOC_MACRO */
105114
#else /* !MBEDTLS_PLATFORM_MEMORY */
106-
#define mbedtls_free vPortFree
107-
#define mbedtls_calloc pvPortCalloc
115+
#ifndef MEMLEAK_DEBUG
116+
#define mbedtls_free(s) vPortFree(s, "", __LINE__)
117+
#define mbedtls_calloc(l, s) ({void* p = (void*)pvPortMalloc((l) * (s), "", __LINE__,true);if(p){os_memset(p,0x0,(l) * (s));} p;})// pvPortCalloc(l, s, "", __LINE__)
118+
#else
119+
#define mbedtls_free(s) do{const char *file = mem_debug_file;vPortFree(s, file, __LINE__);}while(0)
120+
#define mbedtls_calloc(l, s) ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);})
121+
#endif
108122
#endif /* MBEDTLS_PLATFORM_MEMORY && !MBEDTLS_PLATFORM_{FREE,CALLOC}_MACRO */
109123

110124
/*

0 commit comments

Comments
 (0)