Skip to content

Commit c9eaddd

Browse files
author
Cruz Monrreal
authored
Merge pull request #8487 from kegilbert/mbed_mem_trace_config_patch2
Update mbed_mem_tracing config option
2 parents 13d6703 + a2ac895 commit c9eaddd

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

TESTS/mbed_drivers/mem_trace/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <stdio.h>
2525
#include <stdarg.h>
2626

27-
#if !MBED_MEM_TRACING_ENABLED
27+
#ifndef MBED_MEM_TRACING_ENABLED
2828
#error [NOT_SUPPORTED] test not supported
2929
#endif
3030

platform/mbed_alloc_wrappers.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* There are two memory tracers in mbed OS:
2828
2929
- the first can be used to detect the maximum heap usage at runtime. It is
30-
activated by defining the MBED_HEAP_STATS_ENABLED macro.
30+
activated by setting the configuration option MBED_HEAP_STATS_ENABLED to true.
3131
- the second can be used to trace each memory call by automatically invoking
3232
a callback on each memory operation (see hal/api/mbed_mem_trace.h). It is
3333
activated by setting the configuration option MBED_MEM_TRACING_ENABLED to true.
@@ -99,7 +99,7 @@ extern "C" void *__wrap__malloc_r(struct _reent *r, size_t size)
9999
extern "C" void *malloc_wrapper(struct _reent *r, size_t size, void *caller)
100100
{
101101
void *ptr = NULL;
102-
#if MBED_MEM_TRACING_ENABLED
102+
#ifdef MBED_MEM_TRACING_ENABLED
103103
mbed_mem_trace_lock();
104104
#endif
105105
#ifdef MBED_HEAP_STATS_ENABLED
@@ -123,17 +123,17 @@ extern "C" void *malloc_wrapper(struct _reent *r, size_t size, void *caller)
123123
#else // #ifdef MBED_HEAP_STATS_ENABLED
124124
ptr = __real__malloc_r(r, size);
125125
#endif // #ifdef MBED_HEAP_STATS_ENABLED
126-
#if MBED_MEM_TRACING_ENABLED
126+
#ifdef MBED_MEM_TRACING_ENABLED
127127
mbed_mem_trace_malloc(ptr, size, caller);
128128
mbed_mem_trace_unlock();
129-
#endif // #if MBED_MEM_TRACING_ENABLED
129+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
130130
return ptr;
131131
}
132132

133133
extern "C" void *__wrap__realloc_r(struct _reent *r, void *ptr, size_t size)
134134
{
135135
void *new_ptr = NULL;
136-
#if MBED_MEM_TRACING_ENABLED
136+
#ifdef MBED_MEM_TRACING_ENABLED
137137
mbed_mem_trace_lock();
138138
#endif
139139
#ifdef MBED_HEAP_STATS_ENABLED
@@ -166,10 +166,10 @@ extern "C" void *__wrap__realloc_r(struct _reent *r, void *ptr, size_t size)
166166
#else // #ifdef MBED_HEAP_STATS_ENABLED
167167
new_ptr = __real__realloc_r(r, ptr, size);
168168
#endif // #ifdef MBED_HEAP_STATS_ENABLED
169-
#if MBED_MEM_TRACING_ENABLED
169+
#ifdef MBED_MEM_TRACING_ENABLED
170170
mbed_mem_trace_realloc(new_ptr, ptr, size, MBED_CALLER_ADDR());
171171
mbed_mem_trace_unlock();
172-
#endif // #if MBED_MEM_TRACING_ENABLED
172+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
173173
return new_ptr;
174174
}
175175

@@ -180,7 +180,7 @@ extern "C" void __wrap__free_r(struct _reent *r, void *ptr)
180180

181181
extern "C" void free_wrapper(struct _reent *r, void *ptr, void *caller)
182182
{
183-
#if MBED_MEM_TRACING_ENABLED
183+
#ifdef MBED_MEM_TRACING_ENABLED
184184
mbed_mem_trace_lock();
185185
#endif
186186
#ifdef MBED_HEAP_STATS_ENABLED
@@ -205,16 +205,16 @@ extern "C" void free_wrapper(struct _reent *r, void *ptr, void *caller)
205205
#else // #ifdef MBED_HEAP_STATS_ENABLED
206206
__real__free_r(r, ptr);
207207
#endif // #ifdef MBED_HEAP_STATS_ENABLED
208-
#if MBED_MEM_TRACING_ENABLED
208+
#ifdef MBED_MEM_TRACING_ENABLED
209209
mbed_mem_trace_free(ptr, caller);
210210
mbed_mem_trace_unlock();
211-
#endif // #if MBED_MEM_TRACING_ENABLED
211+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
212212
}
213213

214214
extern "C" void *__wrap__calloc_r(struct _reent *r, size_t nmemb, size_t size)
215215
{
216216
void *ptr = NULL;
217-
#if MBED_MEM_TRACING_ENABLED
217+
#ifdef MBED_MEM_TRACING_ENABLED
218218
mbed_mem_trace_lock();
219219
#endif
220220
#ifdef MBED_HEAP_STATS_ENABLED
@@ -227,10 +227,10 @@ extern "C" void *__wrap__calloc_r(struct _reent *r, size_t nmemb, size_t size)
227227
#else // #ifdef MBED_HEAP_STATS_ENABLED
228228
ptr = __real__calloc_r(r, nmemb, size);
229229
#endif // #ifdef MBED_HEAP_STATS_ENABLED
230-
#if MBED_MEM_TRACING_ENABLED
230+
#ifdef MBED_MEM_TRACING_ENABLED
231231
mbed_mem_trace_calloc(ptr, nmemb, size, MBED_CALLER_ADDR());
232232
mbed_mem_trace_unlock();
233-
#endif // #if MBED_MEM_TRACING_ENABLED
233+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
234234
return ptr;
235235
}
236236

@@ -286,7 +286,7 @@ extern "C" void *SUB_MALLOC(size_t size)
286286
extern "C" void *malloc_wrapper(size_t size, void *caller)
287287
{
288288
void *ptr = NULL;
289-
#if MBED_MEM_TRACING_ENABLED
289+
#ifdef MBED_MEM_TRACING_ENABLED
290290
mbed_mem_trace_lock();
291291
#endif
292292
#ifdef MBED_HEAP_STATS_ENABLED
@@ -310,18 +310,18 @@ extern "C" void *malloc_wrapper(size_t size, void *caller)
310310
#else // #ifdef MBED_HEAP_STATS_ENABLED
311311
ptr = SUPER_MALLOC(size);
312312
#endif // #ifdef MBED_HEAP_STATS_ENABLED
313-
#if MBED_MEM_TRACING_ENABLED
313+
#ifdef MBED_MEM_TRACING_ENABLED
314314
mbed_mem_trace_malloc(ptr, size, caller);
315315
mbed_mem_trace_unlock();
316-
#endif // #if MBED_MEM_TRACING_ENABLED
316+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
317317
return ptr;
318318
}
319319

320320

321321
extern "C" void *SUB_REALLOC(void *ptr, size_t size)
322322
{
323323
void *new_ptr = NULL;
324-
#if MBED_MEM_TRACING_ENABLED
324+
#ifdef MBED_MEM_TRACING_ENABLED
325325
mbed_mem_trace_lock();
326326
#endif
327327
#ifdef MBED_HEAP_STATS_ENABLED
@@ -349,17 +349,17 @@ extern "C" void *SUB_REALLOC(void *ptr, size_t size)
349349
#else // #ifdef MBED_HEAP_STATS_ENABLED
350350
new_ptr = SUPER_REALLOC(ptr, size);
351351
#endif // #ifdef MBED_HEAP_STATS_ENABLED
352-
#if MBED_MEM_TRACING_ENABLED
352+
#ifdef MBED_MEM_TRACING_ENABLED
353353
mbed_mem_trace_realloc(new_ptr, ptr, size, MBED_CALLER_ADDR());
354354
mbed_mem_trace_unlock();
355-
#endif // #if MBED_MEM_TRACING_ENABLED
355+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
356356
return new_ptr;
357357
}
358358

359359
extern "C" void *SUB_CALLOC(size_t nmemb, size_t size)
360360
{
361361
void *ptr = NULL;
362-
#if MBED_MEM_TRACING_ENABLED
362+
#ifdef MBED_MEM_TRACING_ENABLED
363363
mbed_mem_trace_lock();
364364
#endif
365365
#ifdef MBED_HEAP_STATS_ENABLED
@@ -371,10 +371,10 @@ extern "C" void *SUB_CALLOC(size_t nmemb, size_t size)
371371
#else // #ifdef MBED_HEAP_STATS_ENABLED
372372
ptr = SUPER_CALLOC(nmemb, size);
373373
#endif // #ifdef MBED_HEAP_STATS_ENABLED
374-
#if MBED_MEM_TRACING_ENABLED
374+
#ifdef MBED_MEM_TRACING_ENABLED
375375
mbed_mem_trace_calloc(ptr, nmemb, size, MBED_CALLER_ADDR());
376376
mbed_mem_trace_unlock();
377-
#endif // #if MBED_MEM_TRACING_ENABLED
377+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
378378
return ptr;
379379
}
380380

@@ -385,7 +385,7 @@ extern "C" void SUB_FREE(void *ptr)
385385

386386
extern "C" void free_wrapper(void *ptr, void *caller)
387387
{
388-
#if MBED_MEM_TRACING_ENABLED
388+
#ifdef MBED_MEM_TRACING_ENABLED
389389
mbed_mem_trace_lock();
390390
#endif
391391
#ifdef MBED_HEAP_STATS_ENABLED
@@ -410,10 +410,10 @@ extern "C" void free_wrapper(void *ptr, void *caller)
410410
#else // #ifdef MBED_HEAP_STATS_ENABLED
411411
SUPER_FREE(ptr);
412412
#endif // #ifdef MBED_HEAP_STATS_ENABLED
413-
#if MBED_MEM_TRACING_ENABLED
413+
#ifdef MBED_MEM_TRACING_ENABLED
414414
mbed_mem_trace_free(ptr, caller);
415415
mbed_mem_trace_unlock();
416-
#endif // #if MBED_MEM_TRACING_ENABLED
416+
#endif // #ifdef MBED_MEM_TRACING_ENABLED
417417
}
418418

419419
#endif // #if defined(MBED_MEM_TRACING_ENABLED) || defined(MBED_HEAP_STATS_ENABLED)
@@ -424,7 +424,7 @@ extern "C" void free_wrapper(void *ptr, void *caller)
424424

425425
#else
426426

427-
#if MBED_MEM_TRACING_ENABLED
427+
#ifdef MBED_MEM_TRACING_ENABLED
428428
#error Memory tracing is not supported with the current toolchain.
429429
#endif
430430

platform/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"memory-tracing-enabled": {
6969
"macro_name": "MBED_MEM_TRACING_ENABLED",
7070
"help": "Enable tracing of each memory call by invoking a callback on each memory operation. See mbed_mem_trace.h in the HAL API for more information",
71-
"value": false
71+
"value": null
7272
},
7373
"sys-stats-enabled": {
7474
"macro_name": "MBED_SYS_STATS_ENABLED",

platform/mbed_retarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ extern "C" void __cxa_guard_abort(int *guard_object_p)
14391439

14401440
#endif
14411441

1442-
#if MBED_MEM_TRACING_ENABLED && (defined(__CC_ARM) || defined(__ICCARM__) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)))
1442+
#if defined(MBED_MEM_TRACING_ENABLED) && (defined(__CC_ARM) || defined(__ICCARM__) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)))
14431443

14441444
// If the memory tracing is enabled, the wrappers in mbed_alloc_wrappers.cpp
14451445
// provide the implementation for these. Note: this needs to use the wrappers
@@ -1485,7 +1485,7 @@ void operator delete[](void *ptr)
14851485
free_wrapper(ptr, MBED_CALLER_ADDR());
14861486
}
14871487

1488-
#elif MBED_MEM_TRACING_ENABLED && defined(__GNUC__)
1488+
#elif defined(MBED_MEM_TRACING_ENABLED) && defined(__GNUC__)
14891489

14901490
#include <reent.h>
14911491

0 commit comments

Comments
 (0)