From: Bodo Möller Date: Sun, 18 Jul 1999 22:39:45 +0000 (+0000) Subject: Add optional (compile-time configurable) time to CRYPTO_mem_leaks output. X-Git-Tag: OpenSSL_0_9_4~92 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3dff94c2e4f48a1f222aba613d2cee2911ea9c3f;p=oweals%2Fopenssl.git Add optional (compile-time configurable) time to CRYPTO_mem_leaks output. This is much more helpful than the counter when doing tests with the library interactively. --- diff --git a/Configure b/Configure index b823037c33..221ea7cc11 100755 --- a/Configure +++ b/Configure @@ -97,7 +97,7 @@ my %table=( "debug-ben-debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown):::::", "debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown):::::", "debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown)::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", -"debug-bodo", "gcc:-DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DCRYPTO_MDEBUG -g -m486 -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", +"debug-bodo", "gcc:-DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DCRYPTO_MDEBUG -DCRYPTO_MDEBUG_TIME -g -m486 -Wall::-D_REENTRANT::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm", "dist", "cc:-O::(unknown):::::", # Basic configs that should work on any box diff --git a/crypto/mem.c b/crypto/mem.c index 8a74507716..9693842ec3 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -58,6 +58,9 @@ #include #include +#ifdef CRYPTO_MDEBUG_TIME +# include +#endif #include #include #include @@ -89,6 +92,9 @@ typedef struct mem_st const char *file; int line; unsigned long order; +#ifdef CRYPTO_MDEBUG_TIME + time_t time; +#endif } MEM; int CRYPTO_mem_ctrl(int mode) @@ -238,6 +244,9 @@ void *CRYPTO_dbg_malloc(int num, const char *file, int line) m->order=order; } m->order=order++; +#ifdef CRYPTO_MDEBUG_TIME + m->time=time(NULL); +#endif if ((mm=(MEM *)lh_insert(mh,(char *)m)) != NULL) { /* Not good, but don't sweat it */ @@ -322,8 +331,17 @@ static void print_leak(MEM *m, MEM_LEAK *l) if(m->addr == (char *)l->bio) return; +#ifdef CRYPTO_MDEBUG_TIME + { + struct tm *lcl = localtime(&m->time); + sprintf(buf,"[%02d:%02d:%02d] %5lu file=%s, line=%d, number=%d, address=%08lX\n", + lcl->tm_hour,lcl->tm_min,lcl->tm_sec, + m->order,m->file,m->line,m->num,(unsigned long)m->addr); + } +#else sprintf(buf,"%5lu file=%s, line=%d, number=%d, address=%08lX\n", m->order,m->file,m->line,m->num,(unsigned long)m->addr); +#endif BIO_puts(l->bio,buf); l->chunks++; l->bytes+=m->num;