Skip to content

Commit fbf535b

Browse files
authored
Merge pull request #2607 from 0xc0170/fix_uvisor_memory_tracing
Fix uvisor memory tracing
2 parents cc3a382 + 2df2227 commit fbf535b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

hal/common/mbed_alloc_wrappers.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats)
6767
#include "uvisor-lib/uvisor-lib.h"
6868
#endif/* FEATURE_UVISOR */
6969

70-
// TODO: memory tracing doesn't work with uVisor enabled.
71-
#if !defined(FEATURE_UVISOR)
72-
7370
extern "C" {
7471
void * __real__malloc_r(struct _reent * r, size_t size);
7572
void * __real__realloc_r(struct _reent * r, void * ptr, size_t size);
7673
void __real__free_r(struct _reent * r, void * ptr);
7774
void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size);
7875
}
7976

77+
// TODO: memory tracing doesn't work with uVisor enabled.
78+
#if !defined(FEATURE_UVISOR)
79+
8080
extern "C" void * __wrap__malloc_r(struct _reent * r, size_t size) {
8181
void *ptr = NULL;
8282
#ifdef MBED_HEAP_STATS_ENABLED
@@ -167,6 +167,8 @@ extern "C" void __wrap__free_r(struct _reent * r, void * ptr) {
167167
#endif // #ifdef MBED_MEM_TRACING_ENABLED
168168
}
169169

170+
#endif // if !defined(FEATURE_UVISOR)
171+
170172
extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) {
171173
void *ptr = NULL;
172174
#ifdef MBED_HEAP_STATS_ENABLED
@@ -187,7 +189,6 @@ extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size)
187189
return ptr;
188190
}
189191

190-
#endif // if !defined(FEATURE_UVISOR)
191192

192193
/******************************************************************************/
193194
/* ARMCC memory allocation wrappers */

hal/common/retarget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,9 @@ extern "C" WEAK void __cxa_pure_virtual(void) {
480480
#endif
481481

482482
#if defined(TOOLCHAIN_GCC)
483-
/* uVisor wraps malloc_r, realloc_r and free_r, but not calloc_r! */
484-
#ifndef FEATURE_UVISOR
485-
486483

484+
#ifdef FEATURE_UVISOR
485+
#include "uvisor-lib/uvisor-lib.h"
487486
#endif/* FEATURE_UVISOR */
488487

489488

0 commit comments

Comments
 (0)