diff options
author | Mike Rapoport <rppt@linux.ibm.com> | 2020-05-25 22:00:48 +0300 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-05-27 06:49:16 -0700 |
commit | d9c9ae5ecf135518935099ceab105956d80910f7 (patch) | |
tree | 93755a919ce60fde70a53b461586f97e18179dfd | |
parent | 924c285a95aa52dabdf1303832acf54ac7057e61 (diff) | |
download | secret-memory-preloader-d9c9ae5ecf135518935099ceab105956d80910f7.tar.gz |
Add INFO verbosity level
and use it for reporting CRYPTO_malloc and CRYPTO_free invocations.
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
-rw-r--r-- | preload.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -30,7 +30,8 @@ static inline int memfd_create(const char *name, unsigned int flags) static int debug = 0; -#define DEBUG(...) do { if (debug) printf(__VA_ARGS__); } while(0) +#define DEBUG(...) do { if (debug > 1) printf(__VA_ARGS__); } while(0) +#define INFO(...) do { if (debug) printf(__VA_ARGS__); } while(0) #define PINUSE_BIT 0x01 #define CINUSE_BIT 0x02 @@ -163,7 +164,7 @@ static void show_segment(void) struct segptr *seg; int i; - if (!debug) + if (debug < 2) return; for (i = 0, seg = m.seg; seg != NULL; i++, seg = seg->next) { @@ -241,7 +242,7 @@ void __attribute__ ((constructor)) preload_setup(void) */ ASSERT(sizeof(struct malloc_chunk) < MIN_CHUNK); if (getenv("MALLOC_DEBUG") != NULL) - debug = 1; + debug = atoi(getenv("MALLOC_DEBUG")); if (getenv("NO_SECRET_MEM") != NULL) use_secret = 0; @@ -326,7 +327,7 @@ void *CRYPTO_malloc(size_t size, const char *file, int line) void *ret = NULL; if (size < SEG_SIZE) ret = dlmalloc(size); - DEBUG("in crypto malloc from %s:%d size=%x ret=%p\n", file, line, size, ret); + INFO("in crypto malloc from %s:%d size=%x ret=%p\n", file, line, size, ret); show_segment(); return ret; } @@ -335,7 +336,7 @@ void CRYPTO_free(void *ptr, const char *file, int line) { struct malloc_chunk *c, *n; - DEBUG("in crypto free from %s:%d; ptr=%p\n", file, line, ptr); + INFO("in crypto free from %s:%d; ptr=%p\n", file, line, ptr); if (ptr == NULL) return; |