Skip to content

Fix uvisor memory tracing #2607

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

Merged
merged 2 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions hal/common/mbed_alloc_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats)
#include "uvisor-lib/uvisor-lib.h"
#endif/* FEATURE_UVISOR */

// TODO: memory tracing doesn't work with uVisor enabled.
#if !defined(FEATURE_UVISOR)

extern "C" {
void * __real__malloc_r(struct _reent * r, size_t size);
void * __real__realloc_r(struct _reent * r, void * ptr, size_t size);
void __real__free_r(struct _reent * r, void * ptr);
void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size);
}

// TODO: memory tracing doesn't work with uVisor enabled.
#if !defined(FEATURE_UVISOR)

extern "C" void * __wrap__malloc_r(struct _reent * r, size_t size) {
void *ptr = NULL;
#ifdef MBED_HEAP_STATS_ENABLED
Expand Down Expand Up @@ -167,6 +167,8 @@ extern "C" void __wrap__free_r(struct _reent * r, void * ptr) {
#endif // #ifdef MBED_MEM_TRACING_ENABLED
}

#endif // if !defined(FEATURE_UVISOR)

extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) {
void *ptr = NULL;
#ifdef MBED_HEAP_STATS_ENABLED
Expand All @@ -187,7 +189,6 @@ extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size)
return ptr;
}

#endif // if !defined(FEATURE_UVISOR)

/******************************************************************************/
/* ARMCC memory allocation wrappers */
Expand Down
5 changes: 2 additions & 3 deletions hal/common/retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,9 @@ extern "C" WEAK void __cxa_pure_virtual(void) {
#endif

#if defined(TOOLCHAIN_GCC)
/* uVisor wraps malloc_r, realloc_r and free_r, but not calloc_r! */
#ifndef FEATURE_UVISOR


#ifdef FEATURE_UVISOR
#include "uvisor-lib/uvisor-lib.h"
#endif/* FEATURE_UVISOR */


Expand Down