malloc: Add a log for malloc() traffic
Add a malloc()-traffic log that records all malloc()-related calls with their addresses, sizes, and caller information. This is useful for debugging allocation patterns and finding the source of allocations that lack caller info in heap dumps. Each entry stores: - Operation type (alloc/free/realloc/memalign) - Pointer address - Size (and old size for realloc) - Full caller backtrace string On sandbox, the log buffer is allocated from host memory using os_malloc(), so it does not affect U-Boot's heap. The size is controlled by CONFIG_MCHECK_LOG_SIZE (default 512K entries). If the log fills up, it wraps around (circular buffer) and a warning is shown when dumping to indicate how many entries were lost. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -385,6 +385,20 @@ allocation was made::
|
||||
This caller information makes it easy to track down memory leaks by showing
|
||||
exactly where each allocation originated.
|
||||
|
||||
Malloc-Traffic Log
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
On sandbox, when mcheck is enabled, a malloc-traffic log can record all
|
||||
malloc/free/realloc calls. This is useful for debugging allocation patterns
|
||||
and finding where allocations without caller info originate.
|
||||
|
||||
The log buffer is allocated from host memory using ``os_malloc()``, so it
|
||||
does not affect U-Boot's heap. The size is controlled by
|
||||
``CONFIG_MCHECK_LOG_SIZE`` (default 512K entries, about 80MB).
|
||||
|
||||
If the log fills up, it wraps around and overwrites the oldest entries.
|
||||
A warning is shown when dumping if entries were lost.
|
||||
|
||||
Valgrind
|
||||
~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user