Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display heap pointer with debug enabled #8071

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions wolfcrypt/src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
#endif

#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
#else
WOLFSSL_MSG("No heap hint found to use and no malloc");
Expand Down Expand Up @@ -1097,8 +1098,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
}
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY
else {
fprintf(stderr, "Size: %lu, Empty: %d\n", (unsigned long) size,
mem->sizeList[i]);
fprintf(stderr, "Size: %lu, Empty: %d\n",
(unsigned long) size, mem->sizeList[i]);
}
#endif
}
Expand All @@ -1114,7 +1115,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)

#ifdef WOLFSSL_DEBUG_MEMORY
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
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) {
Expand Down Expand Up @@ -1143,8 +1145,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
WOLFSSL_MSG("ERROR ran out of static memory");
res = NULL;
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Looking for %lu bytes at %s:%d\n", (unsigned long) size, func,
line);
fprintf(stderr, "Looking for %lu bytes at %s:%d\n",
(unsigned long) size, func, line);
#endif
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) {
Expand Down Expand Up @@ -1187,7 +1189,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#ifdef WOLFSSL_HEAP_TEST
if (heap == (void*)WOLFSSL_HEAP_TEST) {
#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
return free(ptr);
}
Expand All @@ -1205,16 +1208,17 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
}
#endif
#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
vPortFree(ptr);
#elif defined(WOLFSSL_EMBOS)
OS_HEAP_free(ptr);
#else
free(ptr);
#endif
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Free: %p at %s:%d\n", ptr, func, line);
#endif
#else
WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */
Expand Down Expand Up @@ -1286,8 +1290,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#endif

#ifdef WOLFSSL_DEBUG_MEMORY
fprintf (stderr, "Free: %p -> %u at %s:%d\n", pt->buffer,
pt->szUsed, func, line);
fprintf(stderr, "[HEAP %p] Free: %p -> %u at %s:%d\n", heap,
pt->buffer, pt->szUsed, func, line);
#endif

#ifndef WOLFSSL_STATIC_MEMORY_LEAN
Expand Down
Loading