summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEugene Uriev <eugeneuriev@gmail.com>2024-03-31 23:03:26 +0300
committerTom Rini <trini@konsulko.com>2024-04-12 16:23:06 -0600
commita0ff152d4f336e0c205f5d27e33181a60156ee43 (patch)
treeb50686e6e02d178ac221f55c708e9caf77f1b5c7 /common
parent7bceb16106e5db971e3b9c457d6274f7dbd76f7d (diff)
downloadu-boot-a0ff152d4f336e0c205f5d27e33181a60156ee43.tar.gz
u-boot-a0ff152d4f336e0c205f5d27e33181a60156ee43.tar.bz2
u-boot-a0ff152d4f336e0c205f5d27e33181a60156ee43.zip
mcheck: add stats, add a comment with test results
My tests have been run on an U-Boot (of older version) for ARM (64bits). Signed-off-by: Eugene Uriev <eugeneuriev@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/mcheck_core.inc.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h
index bade03598f..2f11ac567f 100644
--- a/common/mcheck_core.inc.h
+++ b/common/mcheck_core.inc.h
@@ -48,6 +48,13 @@
* rather in compile-time, by MCHECK_HEAP_PROTECTION macro. That guarantees that
* we haven't missed first malloc.
*/
+
+/*
+ * Testing
+ * This library had been successfully tested for U-Boot @ ARM SoC chip / 64bits.
+ * Proven for both default and pedantic mode: confirms U-Boot to be clean, and catches
+ * intentional/testing corruptions. Working with malloc_trim is not tested.
+ */
#ifndef _MCHECKCORE_INC_H
#define _MCHECKCORE_INC_H 1
#include "mcheck.h"
@@ -70,6 +77,8 @@
// avoid problems with BSS at early stage:
static char mcheck_pedantic_flag __section(".data") = 0;
static void *mcheck_registry[REGISTRY_SZ] __section(".data") = {0};
+static size_t mcheck_chunk_count __section(".data") = 0;
+static size_t mcheck_chunk_count_max __section(".data") = 0;
typedef unsigned long long mcheck_elem;
typedef struct {
@@ -102,7 +111,7 @@ static void mcheck_default_abort(enum mcheck_status status)
msg = "bogus mcheck_status, library is buggy\n";
break;
}
- printf("\n\nmcheck: %s!!!\n\n", msg);
+ printf("\n\nmcheck: %s!!! [%zu]\n\n", msg, mcheck_chunk_count_max);
}
static mcheck_abortfunc_t mcheck_abortfunc = &mcheck_default_abort;
@@ -173,6 +182,7 @@ static void *mcheck_free_helper(void *ptr, int clean_content)
break;
}
+ --mcheck_chunk_count;
return (char *)hdr - hdr->aln_skip;
}
@@ -212,6 +222,10 @@ static void *mcheck_allocated_helper(void *altoghether_ptr, size_t customer_sz,
for (i = 0; i < CANARY_DEPTH; ++i)
tail->elems[i] = MAGICTAIL;
+ ++mcheck_chunk_count;
+ if (mcheck_chunk_count > mcheck_chunk_count_max)
+ mcheck_chunk_count_max = mcheck_chunk_count;
+
for (i = 0; i < REGISTRY_SZ; ++i)
if (!mcheck_registry[i]) {
mcheck_registry[i] = hdr;
@@ -283,6 +297,8 @@ void mcheck_on_ramrelocation(size_t offset)
printf("mcheck, WRN: forgetting %p chunk\n", p);
mcheck_registry[i] = 0;
}
+
+ mcheck_chunk_count = 0;
}
#endif
#endif