New compile time option -DCRYPTO_MDEBUG_THREAD.
This commit is contained in:
parent
458cddc104
commit
e391116a48
5
CHANGES
5
CHANGES
@ -71,6 +71,11 @@
|
|||||||
-DCRYPTO_MDEBUG_TIME is new and additionally stores the current time
|
-DCRYPTO_MDEBUG_TIME is new and additionally stores the current time
|
||||||
with each memory chunk allocated; this is occasionally more helpful
|
with each memory chunk allocated; this is occasionally more helpful
|
||||||
than just having a counter.
|
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]
|
[Bodo Moeller]
|
||||||
|
|
||||||
*) Introduce "mode" for SSL structures (with defaults in SSL_CTX),
|
*) Introduce "mode" for SSL structures (with defaults in SSL_CTX),
|
||||||
|
@ -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-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-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-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):::::",
|
"dist", "cc:-O::(unknown):::::",
|
||||||
|
|
||||||
# Basic configs that should work on any box
|
# 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-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-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:",
|
"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-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_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-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
|
# 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:::",
|
"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
6
TABLE
@ -631,7 +631,7 @@ $rc5_obj =
|
|||||||
|
|
||||||
*** debug-bodo
|
*** debug-bodo
|
||||||
$cc = gcc
|
$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 =
|
$unistd =
|
||||||
$thread_cflag = -D_REENTRANT
|
$thread_cflag = -D_REENTRANT
|
||||||
$lflags =
|
$lflags =
|
||||||
@ -699,7 +699,7 @@ $rc5_obj = asm/r586-elf.o
|
|||||||
|
|
||||||
*** debug-solaris-sparc-gcc
|
*** debug-solaris-sparc-gcc
|
||||||
$cc = 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 =
|
$unistd =
|
||||||
$thread_cflag = -D_REENTRANT
|
$thread_cflag = -D_REENTRANT
|
||||||
$lflags = -lsocket -lnsl
|
$lflags = -lsocket -lnsl
|
||||||
@ -716,7 +716,7 @@ $rc5_obj =
|
|||||||
|
|
||||||
*** debug-solaris-usparc-gcc
|
*** debug-solaris-usparc-gcc
|
||||||
$cc = 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 =
|
$unistd =
|
||||||
$thread_cflag = -D_REENTRANT
|
$thread_cflag = -D_REENTRANT
|
||||||
$lflags = -lsocket -lnsl
|
$lflags = -lsocket -lnsl
|
||||||
|
@ -200,7 +200,16 @@ typedef struct crypto_ex_data_func_st
|
|||||||
(char *(*)())realloc,\
|
(char *(*)())realloc,\
|
||||||
(void (*)())free)
|
(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 */
|
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
|
||||||
# define CRYPTO_MDEBUG
|
# define CRYPTO_MDEBUG
|
||||||
# endif
|
# endif
|
||||||
|
39
crypto/mem.c
39
crypto/mem.c
@ -92,6 +92,9 @@ typedef struct mem_st
|
|||||||
int num;
|
int num;
|
||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
|
#ifdef CRYPTO_MDEBUG_THREAD
|
||||||
|
unsigned long thread;
|
||||||
|
#endif
|
||||||
unsigned long order;
|
unsigned long order;
|
||||||
#ifdef CRYPTO_MDEBUG_TIME
|
#ifdef CRYPTO_MDEBUG_TIME
|
||||||
time_t time;
|
time_t time;
|
||||||
@ -239,6 +242,9 @@ void *CRYPTO_dbg_malloc(int num, const char *file, int line)
|
|||||||
m->file=file;
|
m->file=file;
|
||||||
m->line=line;
|
m->line=line;
|
||||||
m->num=num;
|
m->num=num;
|
||||||
|
#ifdef CRYPTO_MDEBUG_THREAD
|
||||||
|
m->thread=CRYPTO_thread_id();
|
||||||
|
#endif
|
||||||
if (order == break_order_num)
|
if (order == break_order_num)
|
||||||
{
|
{
|
||||||
/* BREAK HERE */
|
/* BREAK HERE */
|
||||||
@ -329,20 +335,35 @@ typedef struct mem_leak_st
|
|||||||
static void print_leak(MEM *m, MEM_LEAK *l)
|
static void print_leak(MEM *m, MEM_LEAK *l)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
#ifdef CRYPTO_MDEBUG_TIME
|
||||||
|
struct tm *lcl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(m->addr == (char *)l->bio)
|
if(m->addr == (char *)l->bio)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef CRYPTO_MDEBUG_TIME
|
#ifdef CRYPTO_MDEBUG_TIME
|
||||||
{
|
lcl = localtime(&m->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
|
#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);
|
BIO_puts(l->bio,buf);
|
||||||
l->chunks++;
|
l->chunks++;
|
||||||
l->bytes+=m->num;
|
l->bytes+=m->num;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user