debian/0000755000000000000000000000000011771635111007171 5ustar debian/libdmalloc-dev.install0000644000000000000000000000014611734065424013443 0ustar usr/bin usr/include/* usr/lib/*/*.a usr/lib/*/*.so dmallocc.cc usr/share/doc/libdmalloc-dev/examples/ debian/libdmalloc-dev.docs0000644000000000000000000000014311617304064012716 0ustar README RELEASE.html NEWS docs/NOTES docs/TODO docs/dmalloc.html docs/dmalloc.texi docs/dmalloc.pdf debian/libdmalloc5.install0000644000000000000000000000002111734065405012743 0ustar usr/lib/*/*.so.* debian/libdmalloc-dev.info0000644000000000000000000000002211617304064012715 0ustar docs/dmalloc.info debian/dmalloc-dev.info0000644000000000000000000000002211617313150012222 0ustar docs/dmalloc.info debian/libdmalloc5.shlibs0000644000000000000000000000023211617304064012562 0ustar libdmalloc 5 libdmalloc5 (>= 5.5.1) libdmalloccxx 5 libdmalloc5 (>= 5.5.1) libdmallocth 5 libdmalloc5 (>= 5.5.1) libdmallocthcxx 5 libdmalloc5 (>= 5.5.1) debian/source/0000755000000000000000000000000011734050065010467 5ustar debian/source/format0000644000000000000000000000001411617304421011673 0ustar 3.0 (quilt) debian/libdmalloc-dev.manpages0000644000000000000000000000002111617304064013554 0ustar debian/manpage/* debian/patches/0000755000000000000000000000000011766445117010631 5ustar debian/patches/series0000644000000000000000000000035711766445102012045 0ustar 01-configure.ac.patch 02-Makefile.in.patch 03-threads.patch 04-fix-strndup-macro.patch 05-posix-memalign.patch 06-dmalloc-tag.patch 07-doc-update.patch 08-align2.patch 09-strdup-macro-fix.patch 10-recursion-fix.patch 11-pnt-info-fix.patch debian/patches/06-dmalloc-tag.patch0000644000000000000000000001336711765101372014262 0ustar Description: added dmalloc_tag() A macro and functions that allow setting the pointer's file and line number information. Useful for pointers from outside like curses' item_new(). . dmalloc (5.5.2-3) unstable; urgency=low . *Added dmalloc_tag() Author: Johann Klammer Index: dmalloc-5.5.2/malloc.c =================================================================== --- dmalloc-5.5.2.orig/malloc.c 2012-06-08 11:58:10.000000000 +0200 +++ dmalloc-5.5.2/malloc.c 2012-06-10 13:19:34.000000000 +0200 @@ -2039,6 +2039,47 @@ } /* + * int dmalloc_tag_pnt + * + * DESCRIPTION: + * + * Look for a specific address in the skip list. If it exist + * set the file and line fields to given value. Handy for tagging + * pointers from external libraries whithout dmalloc macros. + * Do _not_ use this function directly, use the dmalloc_tag #define instead. + * As it can be transparently disabled using DMALLOC_DISABLE. + * + * RETURNS: + * + * Success - 1 + * + * Failure - 0 + * + * ARGUMENTS: + * + * pnt -> Address we are looking for. + * + * file -> should typically point to filename of source file. String is _not_ + * copied. + * + * line -> source file line number + * + */ +extern +int dmalloc_tag_pnt(const DMALLOC_PNT pnt,char *file,int line) +{ + DMALLOC_PNT p; + p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); + if (! dmalloc_in(DMALLOC_DEFAULT_FILE, DMALLOC_DEFAULT_LINE, 1)) { + return; + } + _dmalloc_chunk_tag_pnt(p,1,file,line); + dmalloc_out(); + +} + + +/* * void dmalloc_track * * DESCRIPTION: Index: dmalloc-5.5.2/chunk.c =================================================================== --- dmalloc-5.5.2.orig/chunk.c 2012-06-08 11:58:10.000000000 +0200 +++ dmalloc-5.5.2/chunk.c 2012-06-10 13:20:09.000000000 +0200 @@ -1898,6 +1898,68 @@ } /* + * int _dmalloc_chunk_tag_pnt + * + * DESCRIPTION: + * + * Look for a specific address in the skip list. If it exist + * set the file and line fields to given value. Handy for tagging + * pointers from external libraries whithout dmalloc macros. + * + * RETURNS: + * + * Success - 1 + * + * Failure - 0 + * + * ARGUMENTS: + * + * user_pnt -> Address we are looking for. + * + * exact_b -> Set to 1 to find the exact pointer. If 0 then the + * address could be inside a block. + * + * file -> should typically point to filename of source file. String is _not_ + * copied. + * + * line -> source file line number + * + */ +int _dmalloc_chunk_tag_pnt(const void * user_pnt,int exact_b,char *file,int line) +{ + skip_alloc_t *slot_p; + char * u_p=user_pnt; + + if (BIT_IS_SET(_dmalloc_flags, DEBUG_LOG_TRANS)) { + dmalloc_message("tagging pointer '%#lx'", + (unsigned long)user_pnt); + } + + if(exact_b) { + /* + of course this may fail, if _dmalloc_flags is changed at certain points + */ + if (BIT_IS_SET(_dmalloc_flags, DEBUG_CHECK_FENCE)) { + u_p-=FENCE_BOTTOM_SIZE; + } + } + + /* find the pointer with loose checking for fence */ + slot_p = find_address(u_p, 0 /* used list */, exact_b, + skip_update); + if (slot_p == NULL) { + dmalloc_errno = ERROR_NOT_FOUND; + log_error_info(NULL, 0, user_pnt, NULL, "finding address in heap", "_dmalloc_chunk_tag_pnt"); + return 0; + } + + slot_p->sa_file = file; + slot_p->sa_line = line; + + return 1; +} + +/* * char *_dmalloc_chunk_desc_pnt * * DESCRIPTION: Index: dmalloc-5.5.2/dmalloc.h.3 =================================================================== --- dmalloc-5.5.2.orig/dmalloc.h.3 2012-06-08 11:58:10.000000000 +0200 +++ dmalloc-5.5.2/dmalloc.h.3 2012-06-10 13:19:34.000000000 +0200 @@ -612,6 +612,40 @@ const int min_size); /* + * int dmalloc_tag_pnt + * + * DESCRIPTION: + * + * Look for a specific address in the skip list. If it exist + * set the file and line fields to given value. Handy for tagging + * pointers from external libraries whithout dmalloc macros. + * Do _not_ use this function directly, use the dmalloc_tag #define instead. + * As it can be transparently disabled using DMALLOC_DISABLE. + * + * RETURNS: + * + * Success - 1 + * + * Failure - 0 + * + * ARGUMENTS: + * + * pnt -> Address we are looking for. + * + * file -> should typically point to filename of source file. String is _not_ + * copied. + * + * line -> source file line number + * + */ +extern +int dmalloc_tag_pnt(const DMALLOC_PNT pnt,char *file,int line); + +/* The other (real) one is further below. This one always succeeds */ +#define dmalloc_tag(p_,f_,l_) (1) + + +/* * int dmalloc_verify_pnt * * DESCRIPTION: @@ -1068,6 +1102,9 @@ #ifndef DMALLOC_DISABLE +#undef dmalloc_tag +#define dmalloc_tag(p_,f_,l_) dmalloc_tag_pnt(p_,f_,l_) + #undef malloc #define malloc(size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0) Index: dmalloc-5.5.2/chunk.h =================================================================== --- dmalloc-5.5.2.orig/chunk.h 2007-05-14 19:26:14.000000000 +0200 +++ dmalloc-5.5.2/chunk.h 2012-06-10 13:19:34.000000000 +0200 @@ -55,6 +55,37 @@ int _dmalloc_chunk_startup(void); /* + * int _dmalloc_chunk_tag_pnt + * + * DESCRIPTION: + * + * Look for a specific address in the skip list. If it exist + * set the file and line fields to given value. Handy for tagging + * pointers from external libraries whithout dmalloc macros. + * + * RETURNS: + * + * Success - 1 + * + * Failure - 0 + * + * ARGUMENTS: + * + * user_pnt -> Address we are looking for. + * + * exact_b -> Set to 1 to find the exact pointer. If 0 then the + * address could be inside a block. + * + * file -> should typically point to filename of source file. String is _not_ + * copied. + * + * line -> source file line number + * + */ +extern +int _dmalloc_chunk_tag_pnt(const void * user_pnt,int exact_b,char *file,int line); + +/* * char *_dmalloc_chunk_desc_pnt * * DESCRIPTION: debian/patches/10-recursion-fix.patch0000644000000000000000000000131011766444477014670 0ustar Description: fix a recursion error libc6-2.13-33 causes an infinite recursion in vfprintf which calls free(0). This patch disables error reporting on free(0). As a consequence it will fail one of the special tests, but it fixes the segfaults. . dmalloc (5.5.2-3) unstable; urgency=low . * fix recursion in libc Author: Johann Klammer --- dmalloc-5.5.2.orig/malloc.c +++ dmalloc-5.5.2/malloc.c @@ -1030,7 +1030,9 @@ int dmalloc_free(const char *file, const const int func_id) { int ret; - + if(NULL==pnt) + return FREE_NOERROR; + if (! dmalloc_in(file, line, 1)) { if (tracking_func != NULL) { tracking_func(file, line, func_id, 0, 0, pnt, NULL); debian/patches/01-configure.ac.patch0000644000000000000000000000126011617323131014414 0ustar Description: Removes explicit checking of CXX in configure.in This patch removes explicit checking of CXX that indeed avoids the --enable-cxx user option. Author: Daniel Rus Morales --- dmalloc-5.5.1.orig/configure.ac 2007-03-25 21:16:44.000000000 +0200 +++ dmalloc-5.5.1/configure.ac 2007-05-02 10:00:28.000000000 +0200 @@ -55,12 +55,6 @@ AC_PROG_CC AC_PROG_CXX -# see if we actually have a CXX program -if test "$ac_cv_prog_CXX" = "" -o ! -x "$ac_cv_prog_CXX"; then - AC_MSG_WARN(could not find C++ compiler $ac_cv_prog_CXX) - enable_cxx=no -fi - # hopefully we have a stdc c-compiler if test "$ac_cv_prog_cc_stdc" = "no" ; then AC_MSG_WARN() debian/patches/03-threads.patch0000644000000000000000000000106411617324314013513 0ustar Description: Fix LOCK_THREADS in settings.dist This patch takes into account that if --enable-threads is used, LOCK_THREADS doesn't get updated Author: Markus Stenberg Author: Daniel Rus Morales Bug-Debian: http://bugs.debian.org/276457 --- dmalloc-5.5.1.orig/settings.dist 2007-03-25 21:16:43.000000000 +0200 +++ dmalloc-5.5.1/settings.dist 2007-04-27 20:56:49.000000000 +0200 @@ -409,7 +409,7 @@ */ #ifndef LOCK_THREADS -#define LOCK_THREADS 0 +#define LOCK_THREADS 1 #endif #if LOCK_THREADS debian/patches/05-posix-memalign.patch0000644000000000000000000004266211764346066015040 0ustar Description: Aligned memory allocation Changes to the allocators, to allow for aligned allocation. Not very well tested. May not be portable. Also changed GET_RET_ADDR macro. . dmalloc (5.5.2-2) unstable; urgency=low . * Added posix_memalign * changed GET_RET_ADDR() to use __builtin_return_address Author: Johann Klammer Bug-Debian: http://bugs.debian.org/676585 Bug-Debian: http://bugs.debian.org/676587 --- dmalloc-5.5.2.orig/malloc.c +++ dmalloc-5.5.2/malloc.c @@ -38,6 +38,20 @@ # include /* for write */ #endif +#if HAVE_ERRNO_H +# include /* for ENOMEM EINVAL */ +#else + +#ifndef ENOMEM +#define ENOMEM 1 +#endif /*ENOMEM*/ + +#ifndef EINVAL +#define EINVAL 2 +#endif /*EINVAL*/ + +#endif /*HAVE_ERRNO_H*/ + /* * cygwin includes */ @@ -719,6 +733,12 @@ void __fini_dmalloc(void) } #endif + +static int is_aligned_to(const char * rv,const DMALLOC_SIZE alignment) +{ + return 0==(((DMALLOC_SIZE)rv)%alignment);//alignment must not be zero +} + /* * DMALLOC_PNT dmalloc_malloc * @@ -754,6 +774,41 @@ DMALLOC_PNT dmalloc_malloc(const char *f const DMALLOC_SIZE alignment, const int xalloc_b) { + DMALLOC_SIZE align=(alignment==0)?1:alignment;//0==bad + DMALLOC_SIZE overhead=align-1+sizeof(DMALLOC_SIZE); + DMALLOC_SIZE offset=0,sz; + DMALLOC_PNT base; + char * rv; + + sz=size+overhead; +#if ALLOW_ALLOC_ZERO_SIZE == 0 + if (size == 0) { + sz=0; + } +#endif + + base=dmalloc_malloc_real(file, line, sz, func_id, 0, xalloc_b); + rv=base; + + if(NULL==rv) + return NULL; + /*byte addressable?*/ + while(! is_aligned_to(rv+sizeof(offset),align)) + { + offset++; + rv++; + } + + memmove(rv,&offset,sizeof(offset)); + rv+=sizeof(offset); + return rv; +} + +DMALLOC_PNT dmalloc_malloc_real(const char *file, const int line, + const DMALLOC_SIZE size, const int func_id, + const DMALLOC_SIZE alignment, + const int xalloc_b) +{ void *new_p; DMALLOC_SIZE align; @@ -825,12 +880,79 @@ DMALLOC_PNT dmalloc_malloc(const char *f return new_p; } + +static int power_of_two(DMALLOC_SIZE v) +{ + unsigned i; + for(i=0;i<(sizeof(v)*8);i++) { + if((((DMALLOC_SIZE)1)< pointer will be returned here on success + * + * alignment -> Value to which the allocation must be aligned. This + * should probably be a multiple of 2 with a maximum value equivalent + * to the block-size which is often 1k or 4k. + * + * size -> Number of bytes requested. + * + * file -> File-name or return-address of the caller. + * + * line -> Line-number of the caller. + * + * func_id -> Function-id to identify the type of call. See + * dmalloc.h. + * + * xalloc_b -> If set to 1 then print an error and exit if we run out + * of memory. + */ +extern +int dmalloc_posix_memalign(const char *file, const int line, DMALLOC_PNT *memptr, + const DMALLOC_SIZE size, const int func_id, + const DMALLOC_SIZE alignment, + const int xalloc_b) +{ + DMALLOC_PNT rv; + if((NULL==memptr)||(!power_of_two(alignment))||(alignment If set to 1 then print an error and exit if we run out * of memory. */ + DMALLOC_PNT dmalloc_realloc(const char *file, const int line, + DMALLOC_PNT old_p, DMALLOC_SIZE new_size, + const int func_id, const int xalloc_b) +{ + DMALLOC_PNT old_pnt=NULL; + DMALLOC_PNT new_pnt=NULL; + DMALLOC_SIZE old_offs=0,offs=0,nsz=0;//no alignment + + if(NULL!=old_p) { + old_pnt=_dmalloc_chunk_get_baseptr(old_p); + memmove(&old_offs,old_p-sizeof(old_offs),sizeof(old_offs)); + } + + nsz=new_size+sizeof(offs)+old_offs; + + //hope I got those right now.. + if(0==new_size) { + +#if ALLOW_REALLOC_SIZE_ZERO + nsz=0; +#else +#if ALLOW_ALLOC_ZERO_SIZE == 0 + nsz=0; +#else + nsz=sizeof(offs); +#endif +#endif + } + /* + something like this.. + if((0==ALLOW_ALLOC_ZERO_SIZE)&&(1==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) + { + //dmalloc_chunk_free + } + if((1==ALLOW_ALLOC_ZERO_SIZE)&&(1==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) + { + //dmalloc_chunk_free + } + if((0==ALLOW_ALLOC_ZERO_SIZE)&&(0==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) + { + //should generate error (and we get a NULL back)... the same as dmalloc_chunk_free, but no free + } + if((1==ALLOW_ALLOC_ZERO_SIZE)&&(0==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) + { + //allocate a min sized block(offset should fit) + } + */ + + + + new_pnt=dmalloc_realloc_real(file, line, old_pnt, nsz, + func_id, xalloc_b); + if(NULL==new_pnt) + return NULL; + + memmove(new_pnt,&offs,sizeof(offs)); + if((0!=old_offs)&&(0!=new_size)) + memmove(new_pnt+sizeof(offs),new_pnt+sizeof(offs)+old_offs,new_size); + return new_pnt+sizeof(offs); +} + +DMALLOC_PNT dmalloc_realloc_real(const char *file, const int line, DMALLOC_PNT old_pnt, DMALLOC_SIZE new_size, const int func_id, const int xalloc_b) { @@ -932,6 +1116,7 @@ DMALLOC_PNT dmalloc_realloc(const char * return new_p; } + /* * int dmalloc_free * @@ -962,6 +1147,14 @@ DMALLOC_PNT dmalloc_realloc(const char * int dmalloc_free(const char *file, const int line, DMALLOC_PNT pnt, const int func_id) { + DMALLOC_PNT p; + p=_dmalloc_chunk_get_baseptr(pnt); + return dmalloc_free_real(file,line,p,func_id); +} + +int dmalloc_free_real(const char *file, const int line, DMALLOC_PNT pnt, + const int func_id) +{ int ret; if (! dmalloc_in(file, line, 1)) { @@ -1209,6 +1402,40 @@ DMALLOC_PNT memalign(DMALLOC_SIZE alignm 0 /* no xalloc messages */); } + +/* + * int posix_memalign + * + * DESCRIPTION: + * + * Overloading the posix_memalign(3) function. Allocate and return a memory + * block of a certain size which has been aligned to a certain + * alignment. + * + * RETURNS: + * + * Success - zero. + * EINVAL The alignment argument was not a power of two, or was not a multiple of sizeof(void *). + * ENOMEM There was insufficient memory to fulfill the allocation request. + * + * + * ARGUMENTS: + * memptr -> pointer will be returned here on success + * alignment -> Value to which the allocation must be aligned. This + * should probably be a multiple of 2 with a maximum value equivalent + * to the block-size which is often 1k or 4k. + * + * size -> Number of bytes requested. + */ +#undef posix_memalign +int posix_memalign(DMALLOC_PNT *memptr, DMALLOC_SIZE alignment, DMALLOC_SIZE size) +{ + char *file; + GET_RET_ADDR(file); + return dmalloc_posix_memalign(file, DMALLOC_DEFAULT_LINE, memptr, + size, DMALLOC_FUNC_POSIX_MEMALIGN, alignment, + 0); +} /* * DMALLOC_PNT valloc * @@ -1428,6 +1655,13 @@ DMALLOC_FREE_RET cfree(DMALLOC_PNT pnt) */ int dmalloc_verify(const DMALLOC_PNT pnt) { + DMALLOC_PNT p; + p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); + return dmalloc_verify_real(p); +} + +int dmalloc_verify_real(const DMALLOC_PNT pnt) +{ int ret; if (! dmalloc_in(DMALLOC_DEFAULT_FILE, DMALLOC_DEFAULT_LINE, 0)) { @@ -1526,6 +1760,9 @@ int dmalloc_verify_pnt_strsize(const cha if (! dmalloc_in(file, line, 0)) { return MALLOC_VERIFY_NOERROR; } + + if(exact_b)/* we need the exact ptr... may weaken checks... */ + pnt=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); /* call the pnt checking chunk code */ ret = _dmalloc_chunk_pnt_check(func, pnt, exact_b, strlen_b, min_size); @@ -1737,6 +1974,34 @@ int dmalloc_examine(const DMALLOC_PNT pn unsigned int *line_p, DMALLOC_PNT *ret_attr_p, unsigned long *used_mark_p, unsigned long *seen_p) { + DMALLOC_PNT p; + int rv; + DMALLOC_SIZE s,offs,u_s; + if(NULL!=user_size_p) + s=*user_size_p; + + p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); + rv=dmalloc_examine_real(p, &s, + total_size_p, file_p,line_p, ret_attr_p,used_mark_p, seen_p); + if(NULL!=p) + { + memmove(&offs,((char *)pnt)-sizeof(offs),sizeof(offs)); + u_s=s-sizeof(offs)-offs; + } + else + { + u_s=s; + } + if(NULL!=user_size_p) + *user_size_p=u_s; + return rv; +} + +int dmalloc_examine_real(const DMALLOC_PNT pnt, DMALLOC_SIZE *user_size_p, + DMALLOC_SIZE *total_size_p, char **file_p, + unsigned int *line_p, DMALLOC_PNT *ret_attr_p, + unsigned long *used_mark_p, unsigned long *seen_p) +{ int ret; unsigned int user_size_map, tot_size_map; unsigned long *loc_seen_p; --- dmalloc-5.5.2.orig/chunk.c +++ dmalloc-5.5.2/chunk.c @@ -2463,6 +2463,9 @@ void *_dmalloc_chunk_malloc(const char * case DMALLOC_FUNC_MEMALIGN: trans_log = "memalign"; break; + case DMALLOC_FUNC_POSIX_MEMALIGN: + trans_log = "posix_memalign"; + break; case DMALLOC_FUNC_VALLOC: trans_log = "valloc"; break; @@ -3130,6 +3133,19 @@ void _dmalloc_chunk_log_changed(const un } } +DMALLOC_PNT _dmalloc_chunk_get_baseptr(DMALLOC_PNT p) +{ + char * rv=p; + DMALLOC_SIZE offset=0; + if(NULL==p) + return NULL; + rv-=sizeof(offset); + memmove(&offset,rv,sizeof(offset)); + rv-=offset; + return rv; +} + + /* * unsigned long _dmalloc_chunk_count_changed * @@ -3207,6 +3223,7 @@ unsigned long _dmalloc_chunk_count_chang mem_count += slot_p->sa_user_size; } else if (count_freed_b && freed_b) { + char * a,*b; mem_count += slot_p->sa_user_size; } } --- dmalloc-5.5.2.orig/dmalloc.h.3 +++ dmalloc-5.5.2/dmalloc.h.3 @@ -41,15 +41,16 @@ #define DMALLOC_FUNC_REALLOC 12 /* realloc function called */ #define DMALLOC_FUNC_RECALLOC 13 /* recalloc called */ #define DMALLOC_FUNC_MEMALIGN 14 /* memalign function called */ -#define DMALLOC_FUNC_VALLOC 15 /* valloc function called */ -#define DMALLOC_FUNC_STRDUP 16 /* strdup function called */ -#define DMALLOC_FUNC_FREE 17 /* free function called */ -#define DMALLOC_FUNC_CFREE 18 /* cfree function called */ - -#define DMALLOC_FUNC_NEW 20 /* new function called */ -#define DMALLOC_FUNC_NEW_ARRAY 21 /* new[] function called */ -#define DMALLOC_FUNC_DELETE 22 /* delete function called */ -#define DMALLOC_FUNC_DELETE_ARRAY 23 /* delete[] function called */ +#define DMALLOC_FUNC_POSIX_MEMALIGN 15 /* memalign function called */ +#define DMALLOC_FUNC_VALLOC 16 /* valloc function called */ +#define DMALLOC_FUNC_STRDUP 17 /* strdup function called */ +#define DMALLOC_FUNC_FREE 18 /* free function called */ +#define DMALLOC_FUNC_CFREE 19 /* cfree function called */ + +#define DMALLOC_FUNC_NEW 21 /* new function called */ +#define DMALLOC_FUNC_NEW_ARRAY 22 /* new[] function called */ +#define DMALLOC_FUNC_DELETE 23 /* delete function called */ +#define DMALLOC_FUNC_DELETE_ARRAY 24 /* delete[] function called */ #ifdef __cplusplus extern "C" { @@ -148,6 +149,52 @@ DMALLOC_PNT dmalloc_malloc(const char *f const DMALLOC_SIZE alignment, const int xalloc_b); +extern +DMALLOC_PNT dmalloc_malloc_real(const char *file, const int line, + const DMALLOC_SIZE size, const int func_id, + const DMALLOC_SIZE alignment, + const int xalloc_b); + +/* + * int dmalloc_posix_memalign + * + * DESCRIPTION: + * + * Overloading the posix_memalign(3) function. Allocate and return a memory + * block of a certain size which has been aligned to a certain + * alignment. + * + * RETURNS: + * + * Success - zero. + * EINVAL The alignment argument was not a power of two, or was not a multiple of sizeof(void *). + * ENOMEM There was insufficient memory to fulfill the allocation request. + * + * + * ARGUMENTS: + * memptr -> pointer will be returned here on success + * + * alignment -> Value to which the allocation must be aligned. This + * should probably be a multiple of 2 with a maximum value equivalent + * to the block-size which is often 1k or 4k. + * + * size -> Number of bytes requested. + * + * file -> File-name or return-address of the caller. + * + * line -> Line-number of the caller. + * + * func_id -> Function-id to identify the type of call. See + * dmalloc.h. + * + * xalloc_b -> If set to 1 then print an error and exit if we run out + * of memory. + */ +extern +int dmalloc_posix_memalign(const char *file, const int line, DMALLOC_PNT *memptr, + const DMALLOC_SIZE size, const int func_id, + const DMALLOC_SIZE alignment, + const int xalloc_b); /* * DMALLOC_PNT dmalloc_realloc * @@ -182,6 +229,10 @@ extern DMALLOC_PNT dmalloc_realloc(const char *file, const int line, DMALLOC_PNT old_pnt, DMALLOC_SIZE new_size, const int func_id, const int xalloc_b); +extern +DMALLOC_PNT dmalloc_realloc_real(const char *file, const int line, + DMALLOC_PNT old_pnt, DMALLOC_SIZE new_size, + const int func_id, const int xalloc_b); /* * int dmalloc_free @@ -213,6 +264,9 @@ DMALLOC_PNT dmalloc_realloc(const char * extern int dmalloc_free(const char *file, const int line, DMALLOC_PNT pnt, const int func_id); +extern +int dmalloc_free_real(const char *file, const int line, DMALLOC_PNT pnt, + const int func_id); /* * DMALLOC_PNT dmalloc_strndup @@ -1030,10 +1084,14 @@ const char *dmalloc_strerror(const int e #define memalign(alignment, size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MEMALIGN, \ (alignment), 0 /* no xalloc */) +#undef posix_memalign +#define posix_memalign(memptr,alignment, size) \ + dmalloc_posix_memalign(__FILE__, __LINE__, (memptr), (size), DMALLOC_FUNC_POSIX_MEMALIGN, \ + (alignment), 0 /* no xalloc */) #undef valloc #define valloc(size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_VALLOC, \ - 0 /* special case */, 0 /* no xalloc */) + BLOCK_SIZE, 0 /* no xalloc */) #ifndef DMALLOC_STRDUP_MACRO #undef strdup #define strdup(str) \ --- dmalloc-5.5.2.orig/configure.ac +++ dmalloc-5.5.2/configure.ac @@ -79,6 +79,9 @@ AC_CHECK_HEADER([string.h], AC_CHECK_HEADER([unistd.h], [AC_DEFINE(HAVE_UNISTD_H,1) AC_SUBST([HAVE_UNISTD_H],1)], [AC_DEFINE(HAVE_UNISTD_H,0) AC_SUBST([HAVE_UNISTD_H],0)]) +AC_CHECK_HEADER([errno.h], + [AC_DEFINE(HAVE_ERRNO_H,1) AC_SUBST([HAVE_ERRNO_H],1)], + [AC_DEFINE(HAVE_ERRNO_H,0) AC_SUBST([HAVE_ERRNO_H],0)]) AC_CHECK_HEADER([sys/types.h], [AC_DEFINE(HAVE_SYS_TYPES_H,1) AC_SUBST([HAVE_SYS_TYPES_H],1)], [AC_DEFINE(HAVE_SYS_TYPES_H,0) AC_SUBST([HAVE_SYS_TYPES_H],0)]) --- dmalloc-5.5.2.orig/dmalloc_t.c +++ dmalloc-5.5.2/dmalloc_t.c @@ -3945,6 +3945,10 @@ static void track_alloc_trxn(const char (void)printf("%s memalign %d bytes alignment %d got %#lx\n", file_line, byte_size, alignment, (long)new_addr); break; + case DMALLOC_FUNC_POSIX_MEMALIGN: + (void)printf("%s posix_memalign %d bytes alignment %d got %#lx\n", + file_line, byte_size, alignment, (long)new_addr); + break; case DMALLOC_FUNC_VALLOC: (void)printf("%s valloc %d bytes alignment %d got %#lx\n", file_line, byte_size, alignment, (long)new_addr); --- dmalloc-5.5.2.orig/Makefile.in +++ dmalloc-5.5.2/Makefile.in @@ -25,6 +25,7 @@ DEFS = -DHAVE_STDARG_H=@HAVE_STDARG_H@ \ -DHAVE_STDLIB_H=@HAVE_STDLIB_H@ \ -DHAVE_STRING_H=@HAVE_STRING_H@ \ -DHAVE_UNISTD_H=@HAVE_UNISTD_H@ \ + -DHAVE_ERRNO_H=@HAVE_ERRNO_H@ \ -DHAVE_SYS_MMAN_H=@HAVE_SYS_MMAN_H@ \ -DHAVE_SYS_TYPES_H=@HAVE_SYS_TYPES_H@ \ -DHAVE_W32API_WINBASE_H=@HAVE_W32API_WINBASE_H@ \ --- dmalloc-5.5.2.orig/return.h +++ dmalloc-5.5.2/return.h @@ -94,7 +94,50 @@ /*************************************/ /* for i[34]86 machines with GCC */ -#if __i386 && __GNUC__ > 1 +/*assembly... blechhh.. the first opcode segfaults dmalloc_fc_t -s... somewhere in the argument checking*/ +/* +Dump of assembler code for function malloc: + 0x08053870 <+0>: sub esp,0x2c +=> 0x08053873 <+3>: mov eax,DWORD PTR [ebp+0x4] + 0x08053876 <+6>: mov edx,eax + + + +(gdb) backtrace +#0 malloc (size=8) at malloc.c:1226 +#1 0x0804f906 in argv_process_no_env (args=0x805f120, arg_n=2, + argv=0xbffffcc4) at dmalloc_argv.c:3201 +#2 0x0804fc61 in argv_process (args=0x805f120, argc=2, argv=0xbffffcc4) + at dmalloc_argv.c:3290 +#3 0x080496e6 in main (argc=2, argv=0xbffffcc4) at dmalloc_fc_t.c:1078 + +(gdb) info registers +eax 0x8 8 +ecx 0x805f770 134608752 +edx 0x7b 123 +ebx 0x0 0 +esp 0xbffffb20 0xbffffb20 +ebp 0x14 0x14 +esi 0xf7fa0ee0 -134607136 +edi 0x805f138 134607160 +eip 0x8053873 0x8053873 +eflags 0x10282 [ SF IF RF ] +cs 0x73 115 +ss 0x7b 123 +ds 0x7b 123 +es 0x7b 123 +fs 0x0 0 +gs 0x33 51 + +turns out ebp is never written... +I wonder if it might be that -fstack_protector +gcc version (Debian 4.6.2-11) +changing to use __builtin_ +*/ +#if __i386 && __GNUC__ > 3 +#define GET_RET_ADDR(file) ((file)=(char *)__builtin_return_address(0)) + +#elif __i386 && __GNUC__ > 1 #define GET_RET_ADDR(file) asm("movl 4(%%ebp),%%eax ; movl %%eax,%0" : \ "=g" (file) : \ debian/patches/09-strdup-macro-fix.patch0000644000000000000000000000102511765152254015276 0ustar Description: undefined strdup macro compilation on sid fails due to strdup define in string2.h system header. Added #undef to dmalloc.h.3 to fix . dmalloc (5.5.2-2) unstable; urgency=low . * Undefined strdup Author: Johann Klammer --- dmalloc-5.5.2.orig/dmalloc.h.3 +++ dmalloc-5.5.2/dmalloc.h.3 @@ -459,6 +459,7 @@ DMALLOC_PNT valloc(DMALLOC_SIZE size); * * string -> String we are duplicating. */ +#undef strdup extern char *strdup(const char *string); #endif /* ifndef DMALLOC_STRDUP_MACRO */ debian/patches/02-Makefile.in.patch0000644000000000000000000003072511617323652014214 0ustar Description: Changes for building shared libraries This patch includes changes for building shared libraries with PIC object files and the correct soname and libname. Author: Daniel Rus Morales --- dmalloc-5.5.2.orig/Makefile.in +++ dmalloc-5.5.2/Makefile.in @@ -41,7 +41,7 @@ LIBRARY = lib$(MODULE).a # thread version of the library LIB_TH = lib$(MODULE)th.a -LIB_TH_SL = lib$(MODULE)th.@shlibext@ +LIB_TH_SL = lib$(MODULE)th.@shlibext@.5.5.2 @TH_ON@BUILD_ALL_1 = threads @TH_ON@INSTALL_LIB_1 = installth @SL_ON@BUILD_THREADS_1 = $(LIB_TH_SL) @@ -50,8 +50,8 @@ LIB_TH_SL = lib$(MODULE)th.@shlibext@ @TH_ON@@SL_ON@INSTALL_LIB_2 = installthsl # C++ version of the library -LIB_CXX = lib$(MODULE)xx.a -LIB_CXX_SL = lib$(MODULE)xx.@shlibext@ +LIB_CXX = lib$(MODULE)cxx.a +LIB_CXX_SL = lib$(MODULE)cxx.@shlibext@.5.5.2 @CXX_ON@BUILD_ALL_3 = $(LIB_CXX) @CXX_ON@INSTALL_LIB_3 = installcxx @SL_ON@BUILD_CXX_3 = $(LIB_CXX_SL) @@ -61,7 +61,7 @@ LIB_CXX_SL = lib$(MODULE)xx.@shlibext@ # threads + C++ LIB_TH_CXX = lib$(MODULE)thcxx.a -LIB_TH_CXX_SL = lib$(MODULE)thcxx.@shlibext@ +LIB_TH_CXX_SL = lib$(MODULE)thcxx.@shlibext@.5.5.2 @TH_ON@@CXX_ON@BUILD_ALL_5 = $(LIB_TH_CXX) @TH_ON@@CXX_ON@INSTALL_LIB_5 = installthcxx @TH_ON@BUILD_CXX_5 = $(LIB_TH_CXX) @@ -76,7 +76,7 @@ LIB_TH_CXX_SL = lib$(MODULE)thcxx.@shlib @CXX_ON@@SL_ON@INSTALL_THREADS_6 = installthcxxsl # shared versions of the libraries -LIB_SL = lib$(MODULE).@shlibext@ +LIB_SL = lib$(MODULE).@shlibext@.5.5.2 @SL_ON@BUILD_ALL_7 = $(LIB_SL) @SL_ON@INSTALL_LIB_7 = installsl @SL_ON@BUILD_TH_CXX_7 = $(LIB_TH_CXX_SL) @@ -145,9 +145,13 @@ SHELL = /bin/sh HFLS = dmalloc.h OBJS = arg_check.o compat.o dmalloc_rand.o dmalloc_tab.o env.o heap.o +OBJS_SL = arg_check_sl.o compat_sl.o dmalloc_rand_sl.o dmalloc_tab_sl.o env_sl.o heap_sl.o NORMAL_OBJS = chunk.o error.o malloc.o +NORMAL_OBJS_SL = chunk_sl.o error_sl.o malloc_sl.o THREAD_OBJS = chunk_th.o error_th.o malloc_th.o +THREAD_OBJS_SL = chunk_th_sl.o error_th_sl.o malloc_th_sl.o CXX_OBJS = dmallocc.o +CXX_OBJS_SL = dmallocc_sl.o CFLAGS = $(CCFLAGS) TEST = $(MODULE)_t @@ -160,9 +164,9 @@ all : $(BUILD_ALL) clean : rm -f $(A_OUT) core *.o *.t - rm -f $(LIBRARY) $(LIB_TH) $(LIB_CXX) $(LIB_TH_CXX) $(TEST) $(TEST_FC) - rm -f $(LIB_TH_SL) $(LIB_CXX_SL) $(LIB_TH_CXX_SL) $(LIB_SL) + rm -f $(TEST) $(TEST_FC) rm -f $(UTIL) dmalloc.h + rm -f lib$(MODULE)*.* realclean : clean @@ -181,43 +185,43 @@ installincs : $(HFLS) $(INSTALL_DATA) $(HFLS) $(includedir) installthsl : $(LIB_TH_SL) - $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIB_TH_SL) $(libdir) + $(srcdir)/mkinstalldirs $(shlibdir) + $(INSTALL) $(LIB_TH_SL) $(shlibdir) installth : $(INSTALL_THREADS) $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIB_TH) $(libdir) + $(INSTALL) $(LIB_TH) $(libdir) @CXX_OFF@ @echo "Enter 'make installthcxx' to install the threaded C++ library" @SL_OFF@ @echo "Enter 'make installthsl' to install the threaded shared-library" installthcxxsl : $(LIB_TH_CXX_SL) $(srcdir)/mkinstalldirs $(shlibdir) - $(INSTALL_PROGRAM) $(LIB_TH_CXX_SL) $(shlibdir) + $(INSTALL) $(LIB_TH_CXX_SL) $(shlibdir) installthcxx : $(INSTALL_TH_CXX) $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIB_TH_CXX) $(libdir) + $(INSTALL) $(LIB_TH_CXX) $(libdir) @SL_OFF@ @echo "Enter 'make installthcxxsl' to install the threaded C++ shared-library" installcxxsl : $(LIB_CXX_SL) - $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIB_CXX_SL) $(libdir) + $(srcdir)/mkinstalldirs $(shlibdir) + $(INSTALL) $(LIB_CXX_SL) $(shlibdir) installcxx : $(INSTALL_CXX) $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIB_CXX) $(libdir) + $(INSTALL) $(LIB_CXX) $(libdir) @TH_OFF@ @echo "Enter 'make installthcxx' to install the threaded C++ library" @SL_OFF@ @echo "Enter 'make installcxxsl' to install the C++ shared-library" installsl : $(LIB_SL) $(srcdir)/mkinstalldirs $(shlibdir) - $(INSTALL_PROGRAM) $(LIB_SL) $(shlibdir) + $(INSTALL) $(LIB_SL) $(shlibdir) @CXX_OFF@ @echo "Enter 'make installcxxsl' to install the C++ shared-library" @TH_OFF@ @echo "Enter 'make installthsl' to install thread shared-library" installlib : $(INSTALL_LIB) $(srcdir)/mkinstalldirs $(libdir) - $(INSTALL_PROGRAM) $(LIBRARY) $(libdir) + $(INSTALL) $(LIBRARY) $(libdir) @RANLIB@ $(libdir)/$(LIBRARY) @SL_OFF@ @echo "Enter 'make installsl' to install $(LIB_SL) in $(shlibdir)" @CXX_OFF@ @echo "Enter 'make installcxx' to install the C++ library" @@ -255,10 +259,8 @@ shlib : $(BUILD_SL) # NOTE: you may have to edit the configure.ac script to get this to # work on your operating system. Please send feedback to the author # via: http://256.com/gray/email.html -$(LIB_SL) : $(LIBRARY) - rm -f $@ $@.t - @shlinkargs@ $(LIBRARY) $(OBJS) $(NORMAL_OBJS) - mv $@.t $@ +$(LIB_SL) : $(OBJS_SL) $(NORMAL_OBJS_SL) + $(CC) -shared -Wl,-soname,libdmalloc.so.5 -o $@ $(OBJS_SL) $(NORMAL_OBJS_SL) $(LIBRARY) : $(OBJS) $(NORMAL_OBJS) ar cr $@ $? @@ -268,32 +270,26 @@ $(LIB_TH) : $(OBJS) $(THREAD_OBJS) ar cr $@ $? @RANLIB@ $@ -$(LIB_TH_SL) : $(LIB_TH) - rm -f $@ $@.t - @shlinkargs@ $(LIB_TH) $(OBJS) $(THREAD_OBJS) - mv $@.t $@ +$(LIB_TH_SL) : $(OBJS_SL) $(THREAD_OBJS_SL) + $(CC) -shared -Wl,-soname,libdmallocth.so.5 -o $@ $(OBJS_SL) $(THREAD_OBJS_SL) $(LIB_CXX) : $(OBJS) $(NORMAL_OBJS) $(CXX_OBJS) ar cr $@ $? @RANLIB@ $@ -$(LIB_CXX_SL) : $(LIB_CXX) - rm -f $@ $@.t - @shlinkargs@ $(LIB_CXX) $(OBJS) $(NORMAL_OBJS) $(CXX_OBJS) - mv $@.t $@ +$(LIB_CXX_SL) : $(OBJS_SL) $(NORMAL_OBJS_SL) $(CXX_OBJS_SL) + $(CC) -shared -Wl,-soname,libdmalloccxx.so.5 -o $@ $(OBJS_SL) $(NORMAL_OBJS_SL) $(CXX_OBJS_SL) $(LIB_TH_CXX) : $(OBJS) $(THREAD_OBJS) $(CXX_OBJS) ar cr $@ $? @RANLIB@ $@ -$(LIB_TH_CXX_SL) : $(LIB_TH_CXX) - rm -f $@ $@.t - @shlinkargs@ $(LIB_TH_CXX) $(OBJS) $(THREAD_OBJS) $(CXX_OBJS) - mv $@.t $@ +$(LIB_TH_CXX_SL) : $(OBJS_SL) $(THREAD_OBJS_SL) $(CXX_OBJS_SL) + $(CC) -shared -Wl,-soname,libdmallocthcxx.so.5 -o $@ $(OBJS_SL) $(THREAD_OBJS_SL) $(CXX_OBJS_SL) -threadssl : $(LIB_TH_SL) +threadssl : $(LIB_TH_SL)$(ver) -threadscxxsl : $(LIB_TH_CXX_SL) +threadscxxsl : $(LIB_TH_CXX_SL)$(ver) threadscxx : $(BUILD_TH_CXX) @SL_OFF@ @echo "Enter 'make threadscxxsl' to build the threaded C++ shared-library" @@ -302,7 +298,7 @@ threads : $(BUILD_THREADS) @CXX_OFF@ @echo "Enter 'make threadscxx' to build the threaded C++ library" @SL_OFF@ @echo "Enter 'make threadssl' to build the threaded shared library" -cxxsl : $(LIB_CXX_SL) +cxxsl : $(LIB_CXX_SL)$(ver) cxx : $(BUILD_CXX) @SL_OFF@ @echo "Enter 'make cxxsl' to build the cxx shared library" @@ -371,6 +367,11 @@ dmallocc.o : $(srcdir)/dmallocc.cc $(CXX) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(INCS) -c $(srcdir)/dmallocc.cc \ -o ./$@ +dmallocc_sl.o : $(srcdir)/dmallocc.cc + rm -f $@ + $(CXX) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $(srcdir)/dmallocc.cc \ + -o ./$@ + # # auto configure settings - uncomment if you are doing configure # development on the library @@ -395,38 +396,109 @@ dmallocc.o : $(srcdir)/dmallocc.cc arg_check.o: arg_check.c conf.h settings.h dmalloc.h chunk.h debug_tok.h \ dmalloc_loc.h error.h arg_check.h +arg_check_sl.o: arg_check.c conf.h settings.h dmalloc.h chunk.h debug_tok.h \ + dmalloc_loc.h error.h arg_check.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ chunk.o: chunk.c conf.h settings.h dmalloc.h chunk.h chunk_loc.h \ dmalloc_loc.h compat.h debug_tok.h dmalloc_rand.h dmalloc_tab.h error.h \ error_val.h heap.h +chunk_sl.o: chunk.c conf.h settings.h dmalloc.h chunk.h chunk_loc.h \ + dmalloc_loc.h compat.h debug_tok.h dmalloc_rand.h dmalloc_tab.h error.h \ + error_val.h heap.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ compat.o: compat.c conf.h settings.h dmalloc.h compat.h dmalloc_loc.h +compat_sl.o: compat.c conf.h settings.h dmalloc.h compat.h dmalloc_loc.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc.o: dmalloc.c conf.h settings.h dmalloc_argv.h dmalloc.h compat.h \ debug_tok.h dmalloc_loc.h env.h error_val.h version.h +dmalloc_sl.o: dmalloc.c conf.h settings.h dmalloc_argv.h dmalloc.h compat.h \ + debug_tok.h dmalloc_loc.h env.h error_val.h version.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc_argv.o: dmalloc_argv.c conf.h settings.h dmalloc_argv.h \ dmalloc_argv_loc.h compat.h +dmalloc_argv_sl.o: dmalloc_argv.c conf.h settings.h dmalloc_argv.h \ + dmalloc_argv_loc.h compat.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc_fc_t.o: dmalloc_fc_t.c conf.h settings.h dmalloc.h dmalloc_argv.h \ dmalloc_rand.h debug_tok.h dmalloc_loc.h error_val.h +dmalloc_fc_t_sl.o: dmalloc_fc_t.c conf.h settings.h dmalloc.h dmalloc_argv.h \ + dmalloc_rand.h debug_tok.h dmalloc_loc.h error_val.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc_rand.o: dmalloc_rand.c dmalloc_rand.h +dmalloc_rand_sl.o: dmalloc_rand.c dmalloc_rand.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc_t.o: dmalloc_t.c conf.h settings.h compat.h dmalloc.h \ dmalloc_argv.h dmalloc_rand.h arg_check.h debug_tok.h dmalloc_loc.h \ error_val.h heap.h +dmalloc_t_sl.o: dmalloc_t.c conf.h settings.h compat.h dmalloc.h \ + dmalloc_argv.h dmalloc_rand.h arg_check.h debug_tok.h dmalloc_loc.h \ + error_val.h heap.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ dmalloc_tab.o: dmalloc_tab.c conf.h settings.h chunk.h compat.h dmalloc.h \ dmalloc_loc.h error.h error_val.h dmalloc_tab.h dmalloc_tab_loc.h +dmalloc_tab_sl.o: dmalloc_tab.c conf.h settings.h chunk.h compat.h dmalloc.h \ + dmalloc_loc.h error.h error_val.h dmalloc_tab.h dmalloc_tab_loc.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ env.o: env.c conf.h settings.h dmalloc.h compat.h dmalloc_loc.h \ debug_tok.h env.h error.h +env_sl.o: env.c conf.h settings.h dmalloc.h compat.h dmalloc_loc.h \ + debug_tok.h env.h error.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ error.o: error.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ dmalloc_loc.h env.h error.h error_val.h version.h +error_sl.o: error.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ + dmalloc_loc.h env.h error.h error_val.h version.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ heap.o: heap.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ dmalloc_loc.h error.h error_val.h heap.h +heap_sl.o: heap.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ + dmalloc_loc.h error.h error_val.h heap.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ malloc.o: malloc.c conf.h settings.h dmalloc.h chunk.h compat.h \ debug_tok.h dmalloc_loc.h env.h error.h error_val.h heap.h \ malloc_funcs.h return.h +malloc_sl.o: malloc.c conf.h settings.h dmalloc.h chunk.h compat.h \ + debug_tok.h dmalloc_loc.h env.h error.h error_val.h heap.h \ + malloc_funcs.h return.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ protect.o: protect.c conf.h settings.h dmalloc.h dmalloc_loc.h error.h \ heap.h protect.h +protect_sl.o: protect.c conf.h settings.h dmalloc.h dmalloc_loc.h error.h \ + heap.h protect.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ chunk_th.o: chunk.c conf.h settings.h dmalloc.h chunk.h chunk_loc.h \ dmalloc_loc.h compat.h debug_tok.h dmalloc_rand.h dmalloc_tab.h error.h \ error_val.h heap.h +chunk_th_sl.o: chunk.c conf.h settings.h dmalloc.h chunk.h chunk_loc.h \ + dmalloc_loc.h compat.h debug_tok.h dmalloc_rand.h dmalloc_tab.h error.h \ + error_val.h heap.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ error_th.o: error.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ dmalloc_loc.h env.h error.h error_val.h version.h +error_th_sl.o: error.c conf.h settings.h dmalloc.h chunk.h compat.h debug_tok.h \ + dmalloc_loc.h env.h error.h error_val.h version.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ malloc_th.o: malloc.c conf.h settings.h dmalloc.h chunk.h compat.h \ debug_tok.h dmalloc_loc.h env.h error.h error_val.h heap.h \ malloc_funcs.h return.h +malloc_th_sl.o: malloc.c conf.h settings.h dmalloc.h chunk.h compat.h \ + debug_tok.h dmalloc_loc.h env.h error.h error_val.h heap.h \ + malloc_funcs.h return.h + rm -f $@ + $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o ./$@ debian/patches/04-fix-strndup-macro.patch0000644000000000000000000000061711734035032015443 0ustar Index: dmalloc-5.5.2/dmalloc.h.3 =================================================================== --- dmalloc-5.5.2.orig/dmalloc.h.3 2007-05-14 19:26:14.000000000 +0200 +++ dmalloc-5.5.2/dmalloc.h.3 2012-03-26 11:42:45.000000000 +0200 @@ -429,6 +429,7 @@ * * len -> Length of the string to duplicate. */ +#undef strndup extern char *strndup(const char *string, const DMALLOC_SIZE len); debian/patches/11-pnt-info-fix.patch0000644000000000000000000000133111766445117014405 0ustar Description: minor fix to pointer information Realloc is a tad more efficient that way. . dmalloc (5.5.2-2) unstable; urgency=low . *Fix pointer information Author: Johann Klammer Index: dmalloc-5.5.2/chunk.c =================================================================== --- dmalloc-5.5.2.orig/chunk.c 2012-06-10 13:21:14.000000000 +0200 +++ dmalloc-5.5.2/chunk.c 2012-06-14 22:32:06.000000000 +0200 @@ -934,7 +934,7 @@ if (info_p->pi_fence_b) { info_p->pi_fence_top = info_p->pi_user_bounds; - info_p->pi_upper_bounds = (char *)info_p->pi_fence_top; + info_p->pi_upper_bounds = (char *)info_p->pi_alloc_bounds - FENCE_TOP_SIZE; } else { info_p->pi_fence_top = NULL; debian/patches/07-doc-update.patch0000644000000000000000000000271611765100377014124 0ustar Description: Update docs Added information on dmalloc_tag and posix_memalign to texinfo file . dmalloc (5.5.2-3) unstable; urgency=low . *Document dmalloc tag and posix_memalign Author: Johann Klammer --- dmalloc-5.5.2.orig/docs/dmalloc.texi +++ dmalloc-5.5.2/docs/dmalloc.texi @@ -870,7 +870,7 @@ checking the heap after it sees a call f @cindex dmalloc.h file By including @file{dmalloc.h} in your C files, your calls to malloc, -calloc, realloc, recalloc, memalign, valloc, strdup, and free are +calloc, realloc, recalloc, memalign, posix_memalign, valloc, strdup, and free are replaced with calls to _dmalloc_malloc, _dmalloc_realloc, and _dmalloc_free with various flags. Additionally the library replaces calls to xmalloc, xcalloc, xrealloc, xrecalloc, xmemalign, xvalloc, @@ -890,6 +890,7 @@ This line from a log file shows that mem @cindex recalloc @cindex memalign +@cindex posix_memalign @cindex valloc @cindex strdup @@ -1252,6 +1253,18 @@ not all other malloc libraries. @c -------------------------------- +@cindex dmalloc_tag function +@cindex tag a pointer + +@deftypefun int dmalloc_tag ( const DMALLOC_PNT @var{pnt}, char *@var{file},int @var{line}) + +This function sets a pointer's file and line information to the supplied values. +@var{file} @emph{must} be a constant string, it is not copied. + +@end deftypefun + +@c -------------------------------- + @cindex dmalloc_track function @cindex track memory calls debian/patches/08-align2.patch0000644000000000000000000005646111765101470013255 0ustar Description: move alignment into chunk.c This patch integrates the alignment fixes with chunk.c allocator. This resolves some errors that the make heavy tests gave. The allocation sizes are now accounted for properly and fence overruns are more likely to be detected. make heavy tests pass without error. . dmalloc (5.5.2-3) unstable; urgency=low . * Integrate alignment into chunk.c Author: Johann Klammer Index: dmalloc-5.5.2/malloc.c =================================================================== --- dmalloc-5.5.2.orig/malloc.c 2012-06-10 13:19:34.000000000 +0200 +++ dmalloc-5.5.2/malloc.c 2012-06-10 13:21:14.000000000 +0200 @@ -734,11 +734,6 @@ #endif -static int is_aligned_to(const char * rv,const DMALLOC_SIZE alignment) -{ - return 0==(((DMALLOC_SIZE)rv)%alignment);//alignment must not be zero -} - /* * DMALLOC_PNT dmalloc_malloc * @@ -774,41 +769,6 @@ const DMALLOC_SIZE alignment, const int xalloc_b) { - DMALLOC_SIZE align=(alignment==0)?1:alignment;//0==bad - DMALLOC_SIZE overhead=align-1+sizeof(DMALLOC_SIZE); - DMALLOC_SIZE offset=0,sz; - DMALLOC_PNT base; - char * rv; - - sz=size+overhead; -#if ALLOW_ALLOC_ZERO_SIZE == 0 - if (size == 0) { - sz=0; - } -#endif - - base=dmalloc_malloc_real(file, line, sz, func_id, 0, xalloc_b); - rv=base; - - if(NULL==rv) - return NULL; - /*byte addressable?*/ - while(! is_aligned_to(rv+sizeof(offset),align)) - { - offset++; - rv++; - } - - memmove(rv,&offset,sizeof(offset)); - rv+=sizeof(offset); - return rv; -} - -DMALLOC_PNT dmalloc_malloc_real(const char *file, const int line, - const DMALLOC_SIZE size, const int func_id, - const DMALLOC_SIZE alignment, - const int xalloc_b) -{ void *new_p; DMALLOC_SIZE align; @@ -841,21 +801,7 @@ else if (alignment >= BLOCK_SIZE) { align = BLOCK_SIZE; } - else { - /* - * NOTE: Currently, there is no support in the library for - * memalign on less than block boundaries. It will be non-trivial - * to support valloc with fence-post checking and the lack of the - * flag width for dblock allocations. - */ - if (! memalign_warn_b) { - dmalloc_message("WARNING: memalign called without library support"); - memalign_warn_b = 1; - } - align = 0; - /* align = alignment */ - } - + new_p = _dmalloc_chunk_malloc(file, line, size, func_id, align); check_pnt(file, line, new_p, "malloc"); @@ -880,17 +826,18 @@ return new_p; } - -static int power_of_two(DMALLOC_SIZE v) +/*return one if v is a power of two, zero otherwise*/ +static int power_of_two(unsigned int v) { unsigned i; for(i=0;i<(sizeof(v)*8);i++) { - if((((DMALLOC_SIZE)1)< If set to 1 then print an error and exit if we run out * of memory. */ - DMALLOC_PNT dmalloc_realloc(const char *file, const int line, - DMALLOC_PNT old_p, DMALLOC_SIZE new_size, - const int func_id, const int xalloc_b) -{ - DMALLOC_PNT old_pnt=NULL; - DMALLOC_PNT new_pnt=NULL; - DMALLOC_SIZE old_offs=0,offs=0,nsz=0;//no alignment - - if(NULL!=old_p) { - old_pnt=_dmalloc_chunk_get_baseptr(old_p); - memmove(&old_offs,old_p-sizeof(old_offs),sizeof(old_offs)); - } - - nsz=new_size+sizeof(offs)+old_offs; - - //hope I got those right now.. - if(0==new_size) { - -#if ALLOW_REALLOC_SIZE_ZERO - nsz=0; -#else -#if ALLOW_ALLOC_ZERO_SIZE == 0 - nsz=0; -#else - nsz=sizeof(offs); -#endif -#endif - } - /* - something like this.. - if((0==ALLOW_ALLOC_ZERO_SIZE)&&(1==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) - { - //dmalloc_chunk_free - } - if((1==ALLOW_ALLOC_ZERO_SIZE)&&(1==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) - { - //dmalloc_chunk_free - } - if((0==ALLOW_ALLOC_ZERO_SIZE)&&(0==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) - { - //should generate error (and we get a NULL back)... the same as dmalloc_chunk_free, but no free - } - if((1==ALLOW_ALLOC_ZERO_SIZE)&&(0==ALLOW_REALLOC_SIZE_ZERO)&&(0==new_size)) - { - //allocate a min sized block(offset should fit) - } - */ - - - - new_pnt=dmalloc_realloc_real(file, line, old_pnt, nsz, - func_id, xalloc_b); - if(NULL==new_pnt) - return NULL; - - memmove(new_pnt,&offs,sizeof(offs)); - if((0!=old_offs)&&(0!=new_size)) - memmove(new_pnt+sizeof(offs),new_pnt+sizeof(offs)+old_offs,new_size); - return new_pnt+sizeof(offs); -} - -DMALLOC_PNT dmalloc_realloc_real(const char *file, const int line, DMALLOC_PNT old_pnt, DMALLOC_SIZE new_size, const int func_id, const int xalloc_b) { @@ -1147,14 +1029,6 @@ int dmalloc_free(const char *file, const int line, DMALLOC_PNT pnt, const int func_id) { - DMALLOC_PNT p; - p=_dmalloc_chunk_get_baseptr(pnt); - return dmalloc_free_real(file,line,p,func_id); -} - -int dmalloc_free_real(const char *file, const int line, DMALLOC_PNT pnt, - const int func_id) -{ int ret; if (! dmalloc_in(file, line, 1)) { @@ -1655,13 +1529,6 @@ */ int dmalloc_verify(const DMALLOC_PNT pnt) { - DMALLOC_PNT p; - p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); - return dmalloc_verify_real(p); -} - -int dmalloc_verify_real(const DMALLOC_PNT pnt) -{ int ret; if (! dmalloc_in(DMALLOC_DEFAULT_FILE, DMALLOC_DEFAULT_LINE, 0)) { @@ -1761,9 +1628,6 @@ return MALLOC_VERIFY_NOERROR; } - if(exact_b)/* we need the exact ptr... may weaken checks... */ - pnt=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); - /* call the pnt checking chunk code */ ret = _dmalloc_chunk_pnt_check(func, pnt, exact_b, strlen_b, min_size); dmalloc_out(); @@ -1974,34 +1838,6 @@ unsigned int *line_p, DMALLOC_PNT *ret_attr_p, unsigned long *used_mark_p, unsigned long *seen_p) { - DMALLOC_PNT p; - int rv; - DMALLOC_SIZE s,offs,u_s; - if(NULL!=user_size_p) - s=*user_size_p; - - p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); - rv=dmalloc_examine_real(p, &s, - total_size_p, file_p,line_p, ret_attr_p,used_mark_p, seen_p); - if(NULL!=p) - { - memmove(&offs,((char *)pnt)-sizeof(offs),sizeof(offs)); - u_s=s-sizeof(offs)-offs; - } - else - { - u_s=s; - } - if(NULL!=user_size_p) - *user_size_p=u_s; - return rv; -} - -int dmalloc_examine_real(const DMALLOC_PNT pnt, DMALLOC_SIZE *user_size_p, - DMALLOC_SIZE *total_size_p, char **file_p, - unsigned int *line_p, DMALLOC_PNT *ret_attr_p, - unsigned long *used_mark_p, unsigned long *seen_p) -{ int ret; unsigned int user_size_map, tot_size_map; unsigned long *loc_seen_p; @@ -2068,12 +1904,11 @@ extern int dmalloc_tag_pnt(const DMALLOC_PNT pnt,char *file,int line) { - DMALLOC_PNT p; - p=_dmalloc_chunk_get_baseptr((DMALLOC_PNT)pnt); + DMALLOC_PNT p=(DMALLOC_PNT)pnt; if (! dmalloc_in(DMALLOC_DEFAULT_FILE, DMALLOC_DEFAULT_LINE, 1)) { return; } - _dmalloc_chunk_tag_pnt(p,1,file,line); + _dmalloc_chunk_tag_pnt(p,file,line); dmalloc_out(); } Index: dmalloc-5.5.2/chunk.c =================================================================== --- dmalloc-5.5.2.orig/chunk.c 2012-06-10 13:20:09.000000000 +0200 +++ dmalloc-5.5.2/chunk.c 2012-06-10 13:21:14.000000000 +0200 @@ -158,6 +158,7 @@ static unsigned long func_realloc_c = 0; /* count the reallocs */ static unsigned long func_recalloc_c = 0; /* count the reallocs */ static unsigned long func_memalign_c = 0; /* count the memaligns */ +static unsigned long func_posix_memalign_c = 0; /* count the posix_memaligns */ static unsigned long func_valloc_c = 0; /* count the veallocs */ static unsigned long func_new_c = 0; /* count the news */ static unsigned long func_free_c = 0; /* count the frees */ @@ -741,6 +742,69 @@ return new_p; } +/************************** alignment utility functions *************************/ + +/* +currently(5.5.2-3) alignment looks like this: +|FENCE|???|offs|USER|G|FENCE| + +what I want alignment to look like is: + +|???|offs|FENCE|USER|FENCE|G| + ^u_p + +...the fences should be right besides the user portion... +addresses increasing from left to right +??? is variable size depending on required alignment. +in the worst case +offs is the size of the ??? portion. +FENCE are the fence posts. they may not always be there. +G is a variable-sized gap caused by alignment. +USER is the user area. users get a u_p pointer pointing. +to USER's base. this is also what free() etc get back +from user space. + +USER should be aligned to some alignment +to find the base pointer for dmalloc (to free etc..) +we have to go downward, skip the lower FENCE bytes(conditionally) +skip sizeof offs, read the offs, skip the offs. +Now to find out if the fence bytes are there and should be skipped, +we fetch the slot pointer and examine the +BIT_SET(slot_p->sa_flags, ALLOC_FLAG_FENCE); + +removed the offs altogether. alignment is stored in the lot +and offset generated on-the-fly. +*/ + +/*calculate alignment overhead*/ +static unsigned int get_align_overhead(unsigned int align,int fence_b) +{ + unsigned int rv=0; + + if(align==0) + align=1; + if(fence_b) + rv=FENCE_OVERHEAD_SIZE; + + return rv+align-1;//sizes of fence + alignment overhead +} + +/*just tests if the remainder is zero*/ +static int is_aligned_to(char * p, unsigned int alignment) +{ + return 0==(((unsigned int)p)%alignment);//alignment must not be zero +} + +/*advance the pointer bytewise until it is aligned. returns result*/ +static char * align_to(char * p, unsigned int alignment) +{ + /*byte addressable?*/ + while(! is_aligned_to(p,(alignment==0)?1:alignment)) + { + p++; + } + return p; +} /******************************* misc routines *******************************/ @@ -847,28 +911,22 @@ static void get_pnt_info(const skip_alloc_t *slot_p, pnt_info_t *info_p) { info_p->pi_fence_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_FENCE); - info_p->pi_valloc_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_VALLOC); info_p->pi_blanked_b = BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_BLANK); info_p->pi_alloc_start = slot_p->sa_mem; if (info_p->pi_fence_b) { - if (info_p->pi_valloc_b) { - info_p->pi_user_start = (char *)info_p->pi_alloc_start + BLOCK_SIZE; - info_p->pi_fence_bottom = (char *)info_p->pi_user_start - - FENCE_BOTTOM_SIZE; - } - else { - info_p->pi_fence_bottom = info_p->pi_alloc_start; - info_p->pi_user_start = (char *)info_p->pi_alloc_start + - FENCE_BOTTOM_SIZE; - } + char * a_p; + a_p=align_to((char *)info_p->pi_alloc_start +FENCE_BOTTOM_SIZE,slot_p->sa_align); + info_p->pi_fence_bottom = a_p-FENCE_BOTTOM_SIZE;//the fence is directly before user_start + info_p->pi_user_start = a_p; } else { info_p->pi_fence_bottom = NULL; - info_p->pi_user_start = info_p->pi_alloc_start; + info_p->pi_user_start = align_to((char *)info_p->pi_alloc_start,slot_p->sa_align); } + info_p->pi_align=slot_p->sa_align; info_p->pi_user_bounds = (char *)info_p->pi_user_start + slot_p->sa_user_size; @@ -876,7 +934,7 @@ if (info_p->pi_fence_b) { info_p->pi_fence_top = info_p->pi_user_bounds; - info_p->pi_upper_bounds = (char *)info_p->pi_alloc_bounds - FENCE_TOP_SIZE; + info_p->pi_upper_bounds = (char *)info_p->pi_fence_top; } else { info_p->pi_fence_top = NULL; @@ -1125,9 +1183,13 @@ } /* find the previous pointer in case it ran over */ - if (dmalloc_errno == ERROR_UNDER_FENCE && start_user != NULL) { - other_p = find_address((char *)start_user - FENCE_BOTTOM_SIZE - 1, - 0 /* used list */, 1 /* not exact pointer */, + if (dmalloc_errno == ERROR_UNDER_FENCE && start_user != NULL + && slot_p != NULL) { + /* argh.. without slot_p I cannot find the prev ptr precisely. this is now wrong. */ + other_p = find_address((char *)slot_p->sa_mem-1, + //(char *)start_user - FENCE_BOTTOM_SIZE - 1, how can this have worked? It points to the last byte of prev block, but he's looking for exact base ptr match. +// 0 /* used list */, 1 /* exact pointer */, + 0 /* used list */, 0 /* not exact pointer */, skip_update); if (other_p != NULL) { dmalloc_message(" prev pointer '%#lx' (size %u) may have run over from '%s'", @@ -1142,7 +1204,7 @@ && start_user != NULL && slot_p != NULL) { other_p = find_address((char *)slot_p->sa_mem + slot_p->sa_total_size, - 0 /* used list */, 1 /* not exact pointer */, + 0 /* used list */, 1 /* exact pointer */, skip_update); if (other_p != NULL) { dmalloc_message(" next pointer '%#lx' (size %u) may have run under from '%s'", @@ -1650,36 +1712,22 @@ } /* - * If we have a valloc allocation then the _user_ pnt should be - * block aligned otherwise the chunk_pnt should be. - */ - if (pnt_info.pi_valloc_b) { - - if ((long)pnt_info.pi_user_start % BLOCK_SIZE != 0) { - dmalloc_errno = ERROR_NOT_ON_BLOCK; + check that the contents does not exceed allocated size + */ + + if (pnt_info.pi_fence_b) { + if((pnt_info.pi_fence_top+FENCE_TOP_SIZE)>pnt_info.pi_alloc_bounds) { + dmalloc_errno = ERROR_SLOT_CORRUPT; return 0; } - if (slot_p->sa_total_size < BLOCK_SIZE) { + } + else { + if(pnt_info.pi_user_bounds>pnt_info.pi_alloc_bounds) { dmalloc_errno = ERROR_SLOT_CORRUPT; return 0; } - - /* now check the below space to make sure it is still clear */ - if (pnt_info.pi_fence_b && pnt_info.pi_blanked_b) { - num = (char *)pnt_info.pi_fence_bottom - (char *)pnt_info.pi_alloc_start; - if (num > 0) { - for (mem_p = pnt_info.pi_alloc_start; - mem_p < (char *)pnt_info.pi_fence_bottom; - mem_p++) { - if (*mem_p != ALLOC_BLANK_CHAR) { - dmalloc_errno = ERROR_FREE_OVERWRITTEN; - return 0; - } - } - } - } } - + /* check out the fence-posts */ if (pnt_info.pi_fence_b && (! fence_read(&pnt_info))) { /* errno set in fence_read */ @@ -1916,36 +1964,23 @@ * * user_pnt -> Address we are looking for. * - * exact_b -> Set to 1 to find the exact pointer. If 0 then the - * address could be inside a block. - * * file -> should typically point to filename of source file. String is _not_ * copied. * * line -> source file line number * */ -int _dmalloc_chunk_tag_pnt(const void * user_pnt,int exact_b,char *file,int line) +int _dmalloc_chunk_tag_pnt(const void * user_pnt,char *file,int line) { - skip_alloc_t *slot_p; - char * u_p=user_pnt; + skip_alloc_t *slot_p; if (BIT_IS_SET(_dmalloc_flags, DEBUG_LOG_TRANS)) { dmalloc_message("tagging pointer '%#lx'", (unsigned long)user_pnt); } - if(exact_b) { - /* - of course this may fail, if _dmalloc_flags is changed at certain points - */ - if (BIT_IS_SET(_dmalloc_flags, DEBUG_CHECK_FENCE)) { - u_p-=FENCE_BOTTOM_SIZE; - } - } - /* find the pointer with loose checking for fence */ - slot_p = find_address(u_p, 0 /* used list */, exact_b, + slot_p = find_address(user_pnt, 0 /* used list */, 0/* it would not work.. */, skip_update); if (slot_p == NULL) { dmalloc_errno = ERROR_NOT_FOUND; @@ -2102,7 +2137,7 @@ SET_POINTER(seen_cp, NULL); #endif SET_POINTER(used_p, slot_p->sa_use_iter); - SET_POINTER(valloc_bp, BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_VALLOC)); + SET_POINTER(valloc_bp, 0);//BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_VALLOC)); SET_POINTER(fence_bp, BIT_IS_SET(slot_p->sa_flags, ALLOC_FLAG_FENCE)); return 1; @@ -2367,6 +2402,7 @@ return 1; } + /************************** low-level user functions *************************/ /* @@ -2400,23 +2436,27 @@ const unsigned int alignment) { unsigned long needed_size; - int valloc_b = 0, memalign_b = 0, fence_b = 0; + int fence_b = 0; char where_buf[MAX_FILE_LENGTH + 64], disp_buf[64]; skip_alloc_t *slot_p; pnt_info_t pnt_info; const char *trans_log; + unsigned int align=alignment; + if(0==alignment) + align=1; /* counts calls to malloc */ if (func_id == DMALLOC_FUNC_CALLOC) { func_calloc_c++; } - else if (alignment == BLOCK_SIZE) { + else if (func_id == DMALLOC_FUNC_POSIX_MEMALIGN) { + func_posix_memalign_c++; + } + else if (func_id == DMALLOC_FUNC_VALLOC) { func_valloc_c++; - valloc_b = 1; } - else if (alignment > 0) { + else if (func_id == DMALLOC_FUNC_MEMALIGN) { func_memalign_c++; - memalign_b = 1; } else if (func_id == DMALLOC_FUNC_NEW) { func_new_c++; @@ -2444,30 +2484,7 @@ } #endif - needed_size = size; - - /* adjust the size */ - if (BIT_IS_SET(_dmalloc_flags, DEBUG_CHECK_FENCE)) { - needed_size += FENCE_OVERHEAD_SIZE; - fence_b = 1; - - /* - * If the user is requesting a page-aligned block of data then we - * will need another block below the allocation just for the fence - * information. Ugh. - */ - if (valloc_b) { - needed_size += BLOCK_SIZE; - } - } - else if (valloc_b && needed_size <= BLOCK_SIZE / 2) { - /* - * If we are valloc-ing, make sure that we get a blocksized chunk - * because they are always block aligned. We know here that fence - * posting is not on otherwise it would have been set above. - */ - needed_size = BLOCK_SIZE; - } + needed_size=get_align_overhead(align,fence_b=BIT_IS_SET(_dmalloc_flags, DEBUG_CHECK_FENCE))+size; /* get some space for our memory */ slot_p = get_memory(needed_size); @@ -2478,10 +2495,8 @@ if (fence_b) { BIT_SET(slot_p->sa_flags, ALLOC_FLAG_FENCE); } - if (valloc_b) { - BIT_SET(slot_p->sa_flags, ALLOC_FLAG_VALLOC); - } - slot_p->sa_user_size = size; + slot_p->sa_user_size = size;//this is different... just the user size. excludes alignment overhead. where is it used.. do I need additional info? + slot_p->sa_align = align;//that should do... /* initialize the bblocks */ alloc_cur_given += slot_p->sa_total_size; @@ -2807,7 +2822,9 @@ pnt_info_t pnt_info; void *new_user_pnt; unsigned int old_size, old_line; - + char where_buf[MAX_FILE_LENGTH + 64]; + char where_buf2[MAX_FILE_LENGTH + 64]; + /* counts calls to realloc */ if (func_id == DMALLOC_FUNC_RECALLOC) { func_recalloc_c++; @@ -2843,6 +2860,13 @@ return 0; } + if(slot_p->sa_align!=1) + dmalloc_message("WARNING: reallocating aligned ptr from '%s' at '%s'", + _dmalloc_chunk_desc_pnt(where_buf, sizeof(where_buf), + slot_p->sa_file, slot_p->sa_line), + _dmalloc_chunk_desc_pnt(where_buf2, sizeof(where_buf), + file, line)); + /* get info about the pointer */ get_pnt_info(slot_p, &pnt_info); old_file = slot_p->sa_file; @@ -3000,8 +3024,8 @@ /* log user allocation information */ dmalloc_message("alloc calls: malloc %lu, calloc %lu, realloc %lu, free %lu", func_malloc_c, func_calloc_c, func_realloc_c, func_free_c); - dmalloc_message("alloc calls: recalloc %lu, memalign %lu, valloc %lu", - func_recalloc_c, func_memalign_c, func_valloc_c); + dmalloc_message("alloc calls: recalloc %lu, memalign %lu, posix_memalign %lu, valloc %lu", + func_recalloc_c, func_memalign_c, func_posix_memalign_c, func_valloc_c); dmalloc_message("alloc calls: new %lu, delete %lu", func_new_c, func_delete_c); dmalloc_message(" current memory in use: %lu bytes (%lu pnts)", @@ -3195,18 +3219,6 @@ } } -DMALLOC_PNT _dmalloc_chunk_get_baseptr(DMALLOC_PNT p) -{ - char * rv=p; - DMALLOC_SIZE offset=0; - if(NULL==p) - return NULL; - rv-=sizeof(offset); - memmove(&offset,rv,sizeof(offset)); - rv-=offset; - return rv; -} - /* * unsigned long _dmalloc_chunk_count_changed Index: dmalloc-5.5.2/dmalloc.h.3 =================================================================== --- dmalloc-5.5.2.orig/dmalloc.h.3 2012-06-10 13:19:34.000000000 +0200 +++ dmalloc-5.5.2/dmalloc.h.3 2012-06-10 13:21:14.000000000 +0200 @@ -639,7 +639,7 @@ * */ extern -int dmalloc_tag_pnt(const DMALLOC_PNT pnt,char *file,int line); +int dmalloc_tag_pnt(const DMALLOC_PNT pnt, char *file, int line); /* The other (real) one is further below. This one always succeeds */ #define dmalloc_tag(p_,f_,l_) (1) Index: dmalloc-5.5.2/chunk_loc.h =================================================================== --- dmalloc-5.5.2.orig/chunk_loc.h 2007-05-14 19:26:14.000000000 +0200 +++ dmalloc-5.5.2/chunk_loc.h 2012-06-10 13:21:14.000000000 +0200 @@ -75,7 +75,6 @@ #define ALLOC_FLAG_ADMIN BIT_FLAG(3) /* administrative space */ #define ALLOC_FLAG_BLANK BIT_FLAG(4) /* slot has been blanked */ #define ALLOC_FLAG_FENCE BIT_FLAG(5) /* slot is fence posted */ -#define ALLOC_FLAG_VALLOC BIT_FLAG(6) /* slot is block aligned */ /* * Below defines an allocation structure either on the free or used @@ -91,8 +90,9 @@ unsigned char sa_level_n; /* how tall our node is */ unsigned short sa_line; /* line where it was allocated */ - unsigned int sa_user_size; /* size requested by user (wo fence) */ + unsigned int sa_user_size; /* size requested by user (wo fence or align) */ unsigned int sa_total_size; /* total size of the block */ + unsigned int sa_align; /* alignment of user portion */ void *sa_mem; /* pointer to the memory in question */ const char *sa_file; /* .c filename where allocated */ @@ -112,7 +112,7 @@ #endif #endif #if LOG_PNT_THREAD_ID - THREAD_TYPE sa_thread_id; /* thread id which allocaed pnt */ + THREAD_TYPE sa_thread_id; /* thread id which allocated pnt */ #endif /* @@ -166,7 +166,7 @@ */ typedef struct { int pi_fence_b; /* fence-posts are on for pointer */ - int pi_valloc_b; /* pointer is valloc-aligned */ +// int pi_valloc_b; /* pointer is valloc-aligned */ int pi_blanked_b; /* pointer was blanked */ void *pi_alloc_start; /* pnt to start of allocation */ void *pi_fence_bottom; /* pnt to the bottom fence area */ @@ -175,6 +175,8 @@ void *pi_fence_top; /* pnt to the top fence area */ void *pi_upper_bounds; /* pnt to highest available user area*/ void *pi_alloc_bounds; /* pnt past end of total allocation */ + unsigned int pi_align; /* alignment */ } pnt_info_t; + #endif /* ! __CHUNK_LOC_H__ */ Index: dmalloc-5.5.2/chunk.h =================================================================== --- dmalloc-5.5.2.orig/chunk.h 2012-06-10 13:19:34.000000000 +0200 +++ dmalloc-5.5.2/chunk.h 2012-06-10 13:21:14.000000000 +0200 @@ -73,9 +73,6 @@ * * user_pnt -> Address we are looking for. * - * exact_b -> Set to 1 to find the exact pointer. If 0 then the - * address could be inside a block. - * * file -> should typically point to filename of source file. String is _not_ * copied. * @@ -83,7 +80,7 @@ * */ extern -int _dmalloc_chunk_tag_pnt(const void * user_pnt,int exact_b,char *file,int line); +int _dmalloc_chunk_tag_pnt(const void * user_pnt, char *file, int line); /* * char *_dmalloc_chunk_desc_pnt Index: dmalloc-5.5.2/docs/dmalloc.texi =================================================================== --- dmalloc-5.5.2.orig/docs/dmalloc.texi 2012-06-10 13:21:05.000000000 +0200 +++ dmalloc-5.5.2/docs/dmalloc.texi 2012-06-10 13:21:14.000000000 +0200 @@ -1256,9 +1256,9 @@ @cindex dmalloc_tag function @cindex tag a pointer -@deftypefun int dmalloc_tag ( const DMALLOC_PNT @var{pnt}, char *@var{file},int @var{line}) +@deftypefun int dmalloc_tag ( const DMALLOC_PNT @var{pnt}, char *@var{file}, int @var{line}) -This function sets a pointer's file and line information to the supplied values. +This macro sets a pointer's file and line information to the supplied values. @var{file} @emph{must} be a constant string, it is not copied. @end deftypefun debian/clean0000644000000000000000000000002211617320151010162 0ustar docs/dmalloc.info debian/compat0000644000000000000000000000000211734065041010365 0ustar 9 debian/libdmalloc-dev.doc-base0000644000000000000000000000065211617304064013450 0ustar Document: dmalloc Title: Debian dmalloc Manual Author: Gray Watson Abstract: This manual describes dmalloc, the debugging memmory allocator Section: Programming Format: info Index: /usr/share/info/dmalloc.info.gz Files: /usr/share/info/dmalloc.info.gz Format: HTML Index: /usr/share/doc/libdmalloc-dev/dmalloc.html Files: /usr/share/doc/libdmalloc-dev/*.html Format: PDF Files: /usr/share/doc/libdmalloc-dev/dmalloc.pdf.gz debian/control0000644000000000000000000000277711734070300010601 0ustar Source: dmalloc Section: devel Priority: extra Maintainer: Roland Stigge Build-Depends: debhelper (>= 9), autoconf, texinfo Standards-Version: 3.9.3 Homepage: http://www.dmalloc.com/ Package: libdmalloc5 Section: libs Architecture: any Pre-Depends: multiarch-support Depends: ${shlibs:Depends}, ${misc:Depends} Conflicts: libdmalloc4 Replaces: libdmalloc4 Suggests: gcc, gdb Description: debug memory allocation library Drop in replacement for the system's `malloc', `realloc', `calloc', `free' and other memory management routines while providing powerful debugging facilities configurable at runtime. . These facilities include such things as memory-leak tracking, fence-post write detection, file/line number reporting, and general logging of statistics. . This package contains only the shared libraries, the development files and documentation is in the libdmalloc-dev package. Package: libdmalloc-dev Section: libdevel Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libdmalloc5 (= ${binary:Version}) Description: debug memory allocation library (development files and doc) Drop in replacement for the system's `malloc', `realloc', `calloc', `free' and other memory management routines while providing powerful debugging facilities configurable at runtime. . These facilities include such things as memory-leak tracking, fence-post write detection, file/line number reporting, and general logging of statistics. . This package contains the static libraries and documentation. debian/libdmalloc-dev.README.Debian0000644000000000000000000000040111617304064014101 0ustar libdmalloc5 for Debian ---------------------- The manual page for dmalloc is based on an older version of the info file, refer to the info or html documents for uptodate information. -- Daniel Baumann Thu, 26 Jul 2005 17:49:00 +0200 debian/changelog0000644000000000000000000002513511771635110011050 0ustar dmalloc (5.5.2-5) unstable; urgency=low * Re-upload to unstable -- Roland Stigge Sun, 24 Jun 2012 18:03:03 +0200 dmalloc (5.5.2-4) experimental; urgency=low * Added patches fixing "make heavy" test (Closes: #676862) - 06-dmalloc-tag.patch - 07-doc-update.patch - 08-align2.patch - 09-strdup-macro-fix.patch - 10-recursion-fix.patch - 11-pnt-info-fix.patch -- Roland Stigge Sun, 10 Jun 2012 13:24:36 +0200 dmalloc (5.5.2-3) experimental; urgency=low * Added patch 05-posix-memalign.patch by Johann Klammer to fix test program and add missing symbol (Closes: #676585, #676587) -- Roland Stigge Fri, 08 Jun 2012 12:13:38 +0200 dmalloc (5.5.2-2) unstable; urgency=low * Added patch to fix strndup-as-macro issue (Closes: #633945) * debian/control: Standards-Version: 3.9.3 * debian/compat: 9 -- Roland Stigge Mon, 26 Mar 2012 11:42:55 +0200 dmalloc (5.5.2-1) unstable; urgency=low * New upstream release * New maintainer * debian/control: Standards-Version: 3.9.2 * Install dmallocc.cc to /usr/share/doc/libdmalloc-dev/examples/ (Closes: #580620) * debian/rules: new debhelper dh rules * debian/source/format: 3.0 (quilt) -- Roland Stigge Sat, 06 Aug 2011 20:30:13 +0200 dmalloc (5.5.1-1.1) unstable; urgency=low * Non-maintainer upload. * Add ${shlibs:Depends} on -dev package. (Closes: #553232). * Add ${misc:Depends} on -dev package. * Fix doc-base section for -dev package. * Move URL from package description to Homepage field. * Minor clean-up to debian/copyright. * Make clean not ignore errors. -- Barry deFreese Sat, 31 Oct 2009 14:06:48 -0400 dmalloc (5.5.1-1) unstable; urgency=low * New maintainer (Closes: #407637). * New upstream release. * debian/patches/01-configure.ac.dpatch: new dpatch file. * debian/patches/02-Makefile.in.dpatch: new dpatch file. * debian/patches/02-threads.dpatch: renamed to 03-threads.dpatch, to be the 3rd patch applied. * debian/patches/03-info.dpatch: removed, fixed in upstream. * debian/patches/00list: delete entry for 03-info and 04-inline-asm. Upstream source related with 04-inline-asm patch has changed. -- Daniel Rus Morales Sat, 5 May 2007 10:36:54 +0200 dmalloc (5.4.2-8) unstable; urgency=medium * QA upload. * debian/libdmalloc-dev.doc-base: Add Index field to info stanza. Closes: #418799. * debian/rules: Don't copy config.{guess,sub} from autotools-dev since configure doesn't actually use them. * debian/watch: Update upstream URL. * Change priority to extra, catching up with the override file. -- Matej Vela Thu, 12 Apr 2007 08:38:54 +0200 dmalloc (5.4.2-7) unstable; urgency=low * Orphaning package. -- Daniel Baumann Sat, 20 Jan 2007 11:02:00 +0100 dmalloc (5.4.2-6) unstable; urgency=low * Minor cleanups. -- Daniel Baumann Fri, 19 Jan 2007 12:02:00 +0100 dmalloc (5.4.2-5) unstable; urgency=low * New email address. * Bumped policy version. * Broken out remaining patches from diff.gz into dedicated dpatches. * Removed texinfo from doc-base. -- Daniel Baumann Tue, 15 Aug 2006 20:44:00 +0200 dmalloc (5.4.2-4) unstable; urgency=low * Don't compress examples, moving contrib to examples, keep permissions (Closes: #349499). -- Daniel Baumann Fri, 24 Feb 2006 11:50:00 +0100 dmalloc (5.4.2-3) unstable; urgency=low * Added patch to fix bad inline asm (Closes: #343061). -- Daniel Baumann Mon, 12 Dec 2005 13:20:00 +0100 dmalloc (5.4.2-2) unstable; urgency=low * New maintainer (Closes: #317427). * Changed priority to optional. * Changed package name of libdmalloc4-dev to libdmalloc-dev. * Removed old dmalloc transitional package. * Bumped policy version. * debian/ redone. -- Daniel Baumann Tue, 26 Jul 2005 17:49:00 +0200 dmalloc (5.4.2-1) unstable; urgency=low * New upstream release * settings.dist: #define LOCK_THREADS 1 (Closes: #276457) * debian/watch: better match and added ftp2.sf.net -- Luk Claes Sat, 6 Nov 2004 13:04:26 +0100 dmalloc (5.3.0-5) unstable; urgency=high * Provide a smooth upgrade path (Closes: #271119) -- Luk Claes Tue, 14 Sep 2004 09:01:46 +0200 dmalloc (5.3.0-4) unstable; urgency=high * Urgency high because of uninstallable in sarge * debian/control: removed Conflicts (Closes: #267743) * debian/control: dmalloc in oldlibs * debian/rules: dmalloc in binary-indep (Closes: #265019) -- Luk Claes Mon, 30 Aug 2004 14:52:22 +0200 dmalloc (5.3.0-3) unstable; urgency=low * No changes. This is to sort out the fubar made while uploading without -sa the first time (Closes: #238633) - fixed in -2 -- Luk Claes Wed, 28 Jul 2004 13:22:32 +0100 dmalloc (5.3.0-2) unstable; urgency=low * Fixed grammatical and spelling errors in dmalloc.texi (Closes: #238633) -- Luk Claes Thu, 20 May 2004 16:11:27 +0200 dmalloc (5.3.0-1) unstable; urgency=low * New upstream release * Split in libdmalloc4 and libdmalloc4-dev * Rectified paths in manpage * Documentation in the right places (Closes: #229201) * Fixed autoconf stuff * Exported CFLAGS in debian/rules * Added me to debian/copyright * Corrected debian/watch -- Luk Claes Tue, 10 Feb 2004 10:19:39 +0100 dmalloc (5.2.3-1) unstable; urgency=low * New upstream release (Closes: #216622). * Updated to standards version 3.6.1 * ANSI compliant __STDC__ handling -- Luk Claes Mon, 20 Oct 2003 09:39:35 +0200 dmalloc (5.2.1-3) unstable; urgency=low * Shareld libs in correct format (Closes: #206453). -- Luk Claes Thu, 21 Aug 2003 19:16:46 +0200 dmalloc (5.2.1-2) unstable; urgency=low * New maintainer (Closes: #202571) * Shared lib compiled with -fPIC (Closes: #202777) * Readded dmalloc manpage as it is required by policy an users want it (Closes: #62692) * Updated to standards version 3.6.0 -- Luk Claes Mon, 11 Aug 2003 17:05:16 +0200 dmalloc (5.2.1-1) unstable; urgency=low * New upstream release (Closes: #199257) * dmalloc_logpath is fixed in this release (Closes: #113688) * Remove dmalloc man page, dmalloc doesnt have an official man page, the offical documentation is in texi format. -- Glenn McGrath Mon, 21 Jul 2003 14:27:29 +0000 dmalloc (4.8.2-7) unstable; urgency=low * Fix doc-base (Closes: #149541) * Bump standards version to 3.5.8 * Build depend on higher debhelper version to prevent lintian warning -- Glenn McGrath Mon, 30 Dec 2002 18:37:01 +1100 dmalloc (4.8.2-6) unstable; urgency=low * Recompile against a newer glibc * Remove pthread avoidance code for GNU/Hurd, GNU/Hurd has pthreads now! -- Glenn McGrath Sun, 24 Nov 2002 11:28:18 +1100 dmalloc (4.8.2-5) unstable; urgency=low * Rename docbase title (Closes: #146998) * Fix man page (Closes: #138291) -- Glenn McGrath Thu, 16 May 2002 16:06:25 +1000 dmalloc (4.8.2-4) unstable; urgency=low * Fix docbase section, remove extra space (Closes: #133218) -- Glenn McGrath Thu, 14 Feb 2002 15:12:21 +1100 dmalloc (4.8.2-3) unstable; urgency=low * Use gcc as a linker in preference to ld (Closes: #131871) * I am now the debian dmalloc maintainer -- Glenn McGrath Tue, 5 Feb 2002 15:55:31 +1100 dmalloc (4.8.2-2) unstable; urgency=low * pass CFLAGS ./configure to compile with -fPIC (closes #131222) -- Glenn McGrath Fri, 1 Feb 2002 00:32:18 +1100 dmalloc (4.8.2-1) unstable; urgency=low * New upstream version (Closes #76773) * Version 4.8.x includes DMALLOC_VERIFY_NOERROR (Closes #89711) * Declare build dependencies (Closes #122429) * Use doc-base instead of dhelp (Closes #63928) * Fix doc-base html declaration (Closes #85203) * Include dmalloc_loc.h for c++ example (Closes #89768) -- Glenn McGrath Sat, 26 Jan 2002 04:06:44 +1100 dmalloc (4.6.0-2) unstable; urgency=low * Fixed compilation error for architectures that are not supported for GET_RET_ADDR() (Closes#66394) -- Luis Francisco Gonzalez Sun, 2 Jul 2000 16:07:20 +0100 dmalloc (4.6.0-1) unstable; urgency=low * New upstream source -- Luis Francisco Gonzalez Mon, 26 Jun 2000 21:21:35 +0100 dmalloc (4.3.0-1) unstable; urgency=low * New upstream source * Bumped up standards * Moved docs to /usr/share -- Luis Francisco Gonzalez Wed, 22 Dec 1999 21:40:51 +0000 dmalloc (4.2.0-2.1) unstable; urgency=low * NMU * link ordering glibc2.1 stuff, closes: #49376 -- Brian M. Almeida Sat, 20 Nov 1999 13:33:13 -0500 dmalloc (4.2.0-2) unstable; urgency=low * Fixed symbols problem. Fixes Bug#40371 -- Luis Francisco Gonzalez Thu, 8 Jul 1999 17:20:44 +0100 dmalloc (4.2.0-1) unstable; urgency=low * New upstream version. Fixes Bug#32115 -- Luis Francisco Gonzalez Mon, 7 Jun 1999 22:39:00 +0100 dmalloc (3.3.1-3) frozen unstable; urgency=low * Fixed the manpage for dmalloc ".SH NAME". Fixes Bug#20387 -- Luis Francisco Gonzalez Sun, 29 Mar 1998 18:12:33 +0100 dmalloc (3.3.1-2) frozen unstable; urgency=low * Moved build process to shared and static directories to force recompile of object files. (Bug#20023). -- Luis Francisco Gonzalez Sun, 22 Mar 1998 15:52:52 +0000 dmalloc (3.3.1-1) unstable; urgency=low * New upstream source * Added a symlink from libdmalloc.so.3 to libdmalloc.so * Added Conflicts, Replaces in order to upgrade from the previous dmalloc packages (Bug#16372) and (Bug#17921). * Explicitly linked against libc (Bug#16526) * Changed the maintainer address to -- Luis Francisco Gonzalez Fri, 27 Feb 1998 18:54:35 +0000 dmalloc (3.2.1-2) unstable; urgency=low * Corrected some problems with the library names. * Changed dmalloc.h to dmalloc1-dev. * Added the content of the contrib directory to usr/doc/dmalloc/contrib. -- Luis Francisco Gonzalez Tue, 25 Nov 1997 17:41:54 +0000 dmalloc (3.2.1-1) unstable; urgency=low * New upstream source * New maintainer -- Luis Francisco Gonzalez Mon, 10 Nov 1997 11:38:57 +0000 debian/rules0000755000000000000000000000264311766445535010273 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 ver=$(shell dpkg-parsechangelog | sed -ne '/^Version:/s/^.*:[ ]*\([^-]*\).*/\1/p') ver_major=$(shell dpkg-parsechangelog | sed -ne '/^Version:/s/^.*:[ ]*\([^\.]*\).*/\1/p') %: dh $@ override_dh_auto_configure: mv -f configure configure.orig autoconf dh_auto_configure -- --enable-threads --enable-shlib mv -f configure.orig configure override_dh_auto_build: dh_auto_build cd docs && $(MAKE) dmalloc.info override_dh_auto_test: # special tests are known to fail -$(MAKE) heavy override_dh_auto_install: $(MAKE) install prefix=$(CURDIR)/debian/tmp/usr # Creating symlinks cd $(CURDIR)/debian/tmp/usr/lib/* && \ ln -s libdmalloc.so.$(ver) libdmalloc.so.$(ver_major) && \ ln -s libdmalloc.so.$(ver) libdmalloc.so cd $(CURDIR)/debian/tmp/usr/lib/* && \ ln -s libdmallocth.so.$(ver) libdmallocth.so.$(ver_major) && \ ln -s libdmallocth.so.$(ver) libdmallocth.so cd $(CURDIR)/debian/tmp/usr/lib/* && \ ln -s libdmalloccxx.so.$(ver) libdmalloccxx.so.$(ver_major) && \ ln -s libdmalloccxx.so.$(ver) libdmalloccxx.so cd $(CURDIR)/debian/tmp/usr/lib/* && \ ln -s libdmallocthcxx.so.$(ver) libdmallocthcxx.so.$(ver_major) && \ ln -s libdmallocthcxx.so.$(ver) libdmallocthcxx.so override_dh_installchangelogs: dh_installchangelogs ChangeLog.1 override_dh_compress: dh_compress -Xusr/share/doc/libdmalloc-dev/examples debian/watch0000644000000000000000000000007011617304064010216 0ustar version=3 http://dmalloc.com/releases/dmalloc-(.*)\.tgz debian/libdmalloc-dev.examples0000644000000000000000000000002211617304064013600 0ustar contrib dmallocrc debian/copyright0000644000000000000000000000201411617326216011123 0ustar This package was debianized by Daniel Baumann on Tue, 26 Jul 2005 17:49:00 +0200. It was downloaded from . Copyright: Copyright (C) 1992-2003 Gray Watson License: Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies, and that the name of Gray Watson not be used in advertising or publicity pertaining to distribution of the document or software without specific, written prior permission. Gray Watson makes no representations about the suitability of the software described herein for any purpose. It is provided ``as is'' without express or implied warranty. The author may be contacted via . The Debian packaging is Copyright (C) 2005-2007 Daniel Baumann , Copyright (C) 2011 Roland Stigge and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. debian/manpage/0000755000000000000000000000000011617304064010600 5ustar debian/manpage/dmalloc.10000644000000000000000000001341711617304064012303 0ustar .TH DMALLOC 1 .SH NAME dmalloc \- program used to set the environment for debugging using the dmalloc debugging library. .SH SYNOPSIS .B dmalloc .I [options] .SH "DESCRIPTION" This manual page documents the .BR dmalloc command. It was written for the Debian GNU/Linux distribution based, almost verbatim, on the original documentation provided by the library in GNU Info format; see below. .PP The .B dmalloc program is designed to assist in the setting of the environment variable .B DMALLOC_OPTIONS. It is designed to print the shell commands necessary to make the appropriate changes to the environment. Unfortunately, it cannot make the changes on its own so the output from dmalloc should be sent through the `eval' shell command which will do the commands. With shells that have aliasing or macro capabilities: csh, bash, ksh, tcsh, zsh, etc., setting up an alias to dmalloc to do the eval call is recommended. Csh/tcsh users (for example) should put the following in their `.cshrc' file: alias dmalloc 'eval `\\dmalloc \-C \!*`' Bash and Zsh users on the other hand should put the following in their `.zshrc' file: function dmalloc { eval `command dmalloc \-b $*` } This allows the user to execute the dmalloc command as `dmalloc arguments'. The most basic usage for the program is .B `dmalloc [\-bC] tag'. The .B `\-b' or .B `\-C' (either but not both flags used at a time) are for generating Bourne or C shell type commands respectively. dmalloc will try and use the .B `SHELL' environment variable to determine whether bourne or C shell commands should be generated but you may want to explicitly specify the correct flag. The .I tag argument to dmalloc should match a line from the user's run-time configuration file or should be one of the built-in tags. If no tag is specified and no other option-commands used, dmalloc will display the current settings of the environment variable. It is useful to specify one of the verbose options when doing this. To find out the usage for the debug malloc program try .B dmalloc \-\-usage\-long. The standardized usage message that will be displayed is one of the many features of the argv library included with this package. It is available via ftp from `ftp.letters.com' in the `/src/argv' directory. See `argv.info' there for more information. .SH OPTIONS .TP .B \-a .I address Set the `addr' part of the .B DMALLOC_OPTIONS variable to address (or alternatively address:number). .TP .B \-b Output Bourne shell type commands. .TP .B \-C Output C shell type commands. .TP .B \-c Clear/unset all of the settings not specified with other arguments. Clear will never unset the `debug' setting. Use .B \-d 0 or a tag to `none' to achieve this. .TP .B \-d .I bitmask Set the `debug' part of the .B DMALLOC_OPTIONS env variable to the bitmask value which should be in hex. This is overridden (and unnecessary) if a tag is specified. .TP .B \-D List all of the debug-tokens. Useful for finding a token to be used with the .B \-p or .B \-m options. Use with .B \-v or .B \-V verbose options. .TP .B \-e .I errno Print the dmalloc error string that corresponds to the error number errno. .TP .B \-f .I filename Use this configuration file instead of the RC file .I ~/.dmallocrc. .TP .B \-i .I number Set the checking interval to number. .TP .B \-k Keep the settings when using a tag. This overrides .B \-r . .TP .B \-l .I filename Set the log-file to filename. .TP .B \-L Output the debug-value not in hex but by individual debug-tokens in long form. .TP .B \-m .I token(s) Remove (minus) the debug capabilities of token(s) from the current debug setting or from the selected tag (or .B \-d value). Multiple .B \-m's can be specified. .TP .B \-n Without changing the environment, output the commands resulting from the supplied options. .TP .B \-p .I token(s) Add (plus) the debug capabilities of token(s) to the current debug setting or to the selected tag (or .B \-d value). Multiple .B \-p's can be specified. .TP .B \-r Remove (unset) all settings when using a tag. This is useful when you are returning to a standard development tag and want the logfile, address, and interval settings to be cleared automatically. If you want this behavior by default, this can be put into the dmalloc alias. .TP .B \-s .I number Set the `start' part of the .B DMALLOC_OPTIONS env variable to number (alternatively `file:line'). .TP .B \-S Output the debug-value not in hex but by individual debug-tokens in short form. .TP .B \-t List all of the tags in the rc-file. Use with .B \-v or .B \-V verbose options. .TP .B \-v Give verbose output. Especially useful when dumping current settings or listing all of the tags. .PP If no arguments are specified, dmalloc dumps out the current settings that you have for the environment variable. For example: Debug-Flags '0x40005c7' (runtime) Address 0x1f008, count = 3 Interval 100 Logpath 'malloc' Start-File not-set With a .B \-v option and no arguments, dmalloc dumps out the current settings in a verbose manner. For example: Debug-Flags '0x40005c7' (runtime) log-stats, log-non-free, log-blocks, log-unknown, log-bad-space, check-fence, catch-null Address 0x1f008, count = 10 Interval 100 Logpath 'malloc' Start-File not-set .SH "SEE ALSO" The documetation for the library is in GNU Info format. Please check the file .IR /usr/share/info/dmalloc.info.gz for more details. .SH FILES .TP .I /usr/share/info/dmalloc.info.gz The real documentation for the dmalloc library. .TP .I ~/.dmallocrc User's configuration file. .SH AUTHOR This manual page was written by Luis Francisco Gonz\['a]lez , for the Debian GNU/Linux system (but may be used by others). The library was written by .B Gray Watson. Please see the copyright file in .I /usr/share/doc/libdmalloc-dev for details. debian/libdmalloc5.docs0000644000000000000000000000000511617304064012224 0ustar NEWS