display heap pointer with debug enabled

This commit is contained in:
JacobBarthelmeh
2024-10-14 10:30:34 -06:00
parent 72306b9a67
commit bc56129ed8

View File

@@ -1030,7 +1030,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
#endif #endif
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Alloc: %p -> %u at %s:%d\n", res, (word32)size, func, line); fprintf(stderr, "[HEAP %p] Alloc: %p -> %u at %s:%d\n", heap,
res, (word32)size, func, line);
#endif #endif
#else #else
WOLFSSL_MSG("No heap hint found to use and no malloc"); WOLFSSL_MSG("No heap hint found to use and no malloc");
@@ -1097,8 +1098,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
} }
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY #ifdef WOLFSSL_DEBUG_STATIC_MEMORY
else { else {
fprintf(stderr, "Size: %lu, Empty: %d\n", (unsigned long) size, fprintf(stderr, "Size: %lu, Empty: %d\n",
mem->sizeList[i]); (unsigned long) size, mem->sizeList[i]);
} }
#endif #endif
} }
@@ -1114,7 +1115,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
pt->szUsed = size; pt->szUsed = size;
fprintf(stderr, "Alloc: %p -> %lu at %s:%d\n", pt->buffer, size, func, line); fprintf(stderr, "[HEAP %p] Alloc: %p -> %lu at %s:%d\n", heap,
pt->buffer, size, func, line);
#endif #endif
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK #ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) { if (DebugCb) {
@@ -1143,8 +1145,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
WOLFSSL_MSG("ERROR ran out of static memory"); WOLFSSL_MSG("ERROR ran out of static memory");
res = NULL; res = NULL;
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Looking for %lu bytes at %s:%d\n", (unsigned long) size, func, fprintf(stderr, "Looking for %lu bytes at %s:%d\n",
line); (unsigned long) size, func, line);
#endif #endif
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK #ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) { if (DebugCb) {
@@ -1187,7 +1189,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#ifdef WOLFSSL_HEAP_TEST #ifdef WOLFSSL_HEAP_TEST
if (heap == (void*)WOLFSSL_HEAP_TEST) { if (heap == (void*)WOLFSSL_HEAP_TEST) {
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Free: %p at %s:%d\n", pt, func, line); fprintf(stderr, "[HEAP %p] Free: %p at %s:%d\n", heap, pt, func,
line);
#endif #endif
return free(ptr); return free(ptr);
} }
@@ -1205,6 +1208,10 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
} }
#endif #endif
#ifndef WOLFSSL_NO_MALLOC #ifndef WOLFSSL_NO_MALLOC
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "[HEAP %p] Free: %p at %s:%d\n", heap, pt, func,
line);
#endif
#ifdef FREERTOS #ifdef FREERTOS
vPortFree(ptr); vPortFree(ptr);
#elif defined(WOLFSSL_EMBOS) #elif defined(WOLFSSL_EMBOS)
@@ -1212,9 +1219,6 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#else #else
free(ptr); free(ptr);
#endif #endif
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Free: %p at %s:%d\n", ptr, func, line);
#endif
#else #else
WOLFSSL_MSG("Error trying to call free when turned off"); WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */ #endif /* WOLFSSL_NO_MALLOC */
@@ -1286,8 +1290,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#endif #endif
#ifdef WOLFSSL_DEBUG_MEMORY #ifdef WOLFSSL_DEBUG_MEMORY
fprintf (stderr, "Free: %p -> %u at %s:%d\n", pt->buffer, fprintf(stderr, "[HEAP %p] Free: %p -> %u at %s:%d\n", heap,
pt->szUsed, func, line); pt->buffer, pt->szUsed, func, line);
#endif #endif
#ifndef WOLFSSL_STATIC_MEMORY_LEAN #ifndef WOLFSSL_STATIC_MEMORY_LEAN