New compile time option -DCRYPTO_MDEBUG_THREAD.

This commit is contained in:
Bodo Möller 1999-07-19 10:36:10 +00:00
parent 458cddc104
commit e391116a48
5 changed files with 51 additions and 16 deletions

View File

@ -71,6 +71,11 @@
-DCRYPTO_MDEBUG_TIME is new and additionally stores the current time
with each memory chunk allocated; this is occasionally more helpful
than just having a counter.
-DCRYPTO_MDEBUG_THREAD is also new and adds the thread ID.
-DCRYPTO_MDEBUG_ALL enables all of the above, plus any future
extensions.
[Bodo Moeller]
*) Introduce "mode" for SSL structures (with defaults in SSL_CTX),

View File

@ -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_TIME -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_ALL -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
@ -109,8 +109,8 @@ my %table=(
"solaris-sparc-gcc","gcc:-O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8.o::",
"solaris-usparc-gcc","gcc:-O3 -fomit-frame-pointer -mcpu=ultrasparc -Wall -DB_ENDIAN -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus-gcc.o:::asm/md5-sparcv8plus.o:",
"solaris-usparc-oldgcc","gcc:-O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN -DULTRASPARC::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus-gcc.o:::asm/md5-sparcv8plus.o:",
"debug-solaris-sparc-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_TIME -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:::",
"debug-solaris-usparc-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_TIME -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus-gcc.o::",
"debug-solaris-sparc-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:::",
"debug-solaris-usparc-gcc","gcc:-DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_UNROLL BF_PTR:asm/sparcv8plus-gcc.o::",
# DO NOT use /xO[34] on sparc with SC3.0. It is broken, and will not pass the tests
"solaris-sparc-sc3","cc:-fast -O -Xa -DB_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR DES_PTR DES_UNROLL BF_PTR:::",

6
TABLE
View File

@ -631,7 +631,7 @@ $rc5_obj =
*** debug-bodo
$cc = gcc
$cflags = -DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DCRYPTO_MDEBUG_TIME -g -m486 -Wall
$cflags = -DBIO_PAIR_DEBUG -DL_ENDIAN -DREF_CHECK -DCRYPTO_MDEBUG_ALL -g -m486 -Wall
$unistd =
$thread_cflag = -D_REENTRANT
$lflags =
@ -699,7 +699,7 @@ $rc5_obj = asm/r586-elf.o
*** debug-solaris-sparc-gcc
$cc = gcc
$cflags = -DREF_CHECK -DCRYPTO_MDEBUG_TIME -O -g -mv8 -Wall -DB_ENDIAN
$cflags = -DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mv8 -Wall -DB_ENDIAN
$unistd =
$thread_cflag = -D_REENTRANT
$lflags = -lsocket -lnsl
@ -716,7 +716,7 @@ $rc5_obj =
*** debug-solaris-usparc-gcc
$cc = gcc
$cflags = -DREF_CHECK -DCRYPTO_MDEBUG_TIME -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN
$cflags = -DREF_CHECK -DCRYPTO_MDEBUG_ALL -O -g -mcpu=ultrasparc -Wall -DB_ENDIAN
$unistd =
$thread_cflag = -D_REENTRANT
$lflags = -lsocket -lnsl

View File

@ -200,7 +200,16 @@ typedef struct crypto_ex_data_func_st
(char *(*)())realloc,\
(void (*)())free)
#ifdef CRYPTO_MDEBUG_TIME
#ifdef CRYPTO_MDEBUG_ALL
# ifndef CRYPTO_MDEBUG_TIME
# define CRYPTO_MDEBUG_TIME
# endif
# ifndef CRYPTO_MDEBUG_THREAD
# define CRYPTO_MDEBUG_THREAD
# endif
#endif
#if defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
# define CRYPTO_MDEBUG
# endif

View File

@ -92,6 +92,9 @@ typedef struct mem_st
int num;
const char *file;
int line;
#ifdef CRYPTO_MDEBUG_THREAD
unsigned long thread;
#endif
unsigned long order;
#ifdef CRYPTO_MDEBUG_TIME
time_t time;
@ -239,6 +242,9 @@ void *CRYPTO_dbg_malloc(int num, const char *file, int line)
m->file=file;
m->line=line;
m->num=num;
#ifdef CRYPTO_MDEBUG_THREAD
m->thread=CRYPTO_thread_id();
#endif
if (order == break_order_num)
{
/* BREAK HERE */
@ -329,20 +335,35 @@ typedef struct mem_leak_st
static void print_leak(MEM *m, MEM_LEAK *l)
{
char buf[128];
#ifdef CRYPTO_MDEBUG_TIME
struct tm *lcl;
#endif
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);
lcl = localtime(&m->time);
#endif
sprintf(buf,
#ifdef CRYPTO_MDEBUG_TIME
"[%02d:%02d:%02d] "
#endif
"%5lu file=%s, line=%d, "
#ifdef CRYPTO_MDEBUG_THREAD
"thread=%lu, "
#endif
"number=%d, address=%08lX\n",
#ifdef CRYPTO_MDEBUG_TIME
lcl->tm_hour,lcl->tm_min,lcl->tm_sec,
#endif
m->order,m->file,m->line,
#ifdef CRYPTO_MDEBUG_THREAD
m->thread,
#endif
m->num,(unsigned long)m->addr);
BIO_puts(l->bio,buf);
l->chunks++;
l->bytes+=m->num;