mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
7ce641f110
Hooking into the existing wrappers for `malloc()`, `calloc()`, `realloc()`, and `free()`, the new (pseudo) module `malloc_tracing` prints out the calls to the given functions, the program counter of the caller, as well as the return result. The intent is to aid debugging double-frees, invalid frees, or memory leaks.
34 lines
1.5 KiB
Plaintext
34 lines
1.5 KiB
Plaintext
# Copyright (C) 2020, 2022 Otto-von-Guericke-Universität Magdeburg
|
|
#
|
|
# This file is subject to the terms and conditions of the GNU Lesser
|
|
# General Public License v2.1. See the file LICENSE in the top level
|
|
# directory for more details.
|
|
#
|
|
|
|
config MODULE_MALLOC_THREAD_SAFE
|
|
bool
|
|
depends on TEST_KCONFIG
|
|
help
|
|
This module provides wrappers for malloc(), calloc(), realloc(), and
|
|
free() which guarantee mutually exclusive access to heap data
|
|
structures. This linker is also instructed to redirect all calls to
|
|
the corresponding wrappers. As a result, all allocations become thread
|
|
safe without touching the application code or the c library. This module
|
|
is intended to be pulled in automatically if needed. Hence, applications
|
|
never should manually use it.
|
|
|
|
config MODULE_MALLOC_TRACING
|
|
bool
|
|
depends on TEST_KCONFIG
|
|
depends on MODULE_MALLOC_THREAD_SAFE
|
|
help
|
|
This module enables hooks in the wrappers for malloc(), calloc(),
|
|
realloc(), and free() provided by MODULE_MALLOC_THREAD_SAFE that print
|
|
the arguments, caller program counter and return value of those
|
|
functions. The intent is to aid debugging invalid calls to free(),
|
|
duplicated calls to free(), or memory leaks.
|
|
|
|
Note that generally dynamic memory management is a bad idea on the
|
|
constrained devices RIOT is targeting. So maybe it is better to just
|
|
adapt your code to use static memory management instead.
|