summaryrefslogtreecommitdiff
path: root/common/malloc_simple.c
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-04-11 10:15:06 -0400
committerTom Rini <[email protected]>2022-04-11 10:15:06 -0400
commitc45d38d6515811c05469fe4df6d351d7e4f990f0 (patch)
treef965f66f82242027746ba8bba0abb442aeed09be /common/malloc_simple.c
parentb598957206e541b3f8876ae34a15fac6da90dcef (diff)
parent02fc867810866904966d45c3e290810c4a196543 (diff)
Merge branch '2022-04-11-initial-valgrind-support'
To quote the author: This series adds support for running valgrind against U-Boot's internal malloc. This allows for much more useful reports to be generated. Some example output of valgrind run against u-boot/master with this branch applied may be found at [1]. Note that valgrind gives up around acpi. This feature still needs a lot of work on suppressions/hints to filter out the noise properly. [1] https://gist.githubusercontent.com/Forty-Bot/199bf06f9cdd6871e54f8f484c16e111/raw/2a2f99108eef84b48e27a54332f3f71f4e2e5342/gistfile1.txt
Diffstat (limited to 'common/malloc_simple.c')
-rw-r--r--common/malloc_simple.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 67ee623850e..0a004d40e1e 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -13,6 +13,7 @@
#include <mapmem.h>
#include <asm/global_data.h>
#include <asm/io.h>
+#include <valgrind/valgrind.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -45,6 +46,7 @@ void *malloc_simple(size_t bytes)
return ptr;
log_debug("%lx\n", (ulong)ptr);
+ VALGRIND_MALLOCLIKE_BLOCK(ptr, bytes, 0, false);
return ptr;
}
@@ -57,6 +59,7 @@ void *memalign_simple(size_t align, size_t bytes)
if (!ptr)
return ptr;
log_debug("aligned to %lx\n", (ulong)ptr);
+ VALGRIND_MALLOCLIKE_BLOCK(ptr, bytes, 0, false);
return ptr;
}
@@ -74,6 +77,13 @@ void *calloc(size_t nmemb, size_t elem_size)
return ptr;
}
+
+#if IS_ENABLED(CONFIG_VALGRIND)
+void free_simple(void *ptr)
+{
+ VALGRIND_FREELIKE_BLOCK(ptr, 0);
+}
+#endif
#endif
void malloc_simple_info(void)