[perl #46957] [PATCH] make Devel::Peek::mstat always available  # New Ticket Created by  djzyiw@cpan.org 
# Please include the string:  [perl #46957]
# in the subject line of all future correspondence about this issue. 
# 


This is a bug report for perl from djzyiw@cpan.org,
generated with the help of perlbug 1.36 running under perl 5.10.0.


-----------------------------------------------------------------
The patch below makes Devel::Peek::mstat and mstats_fillhash always
available if perl was compiled with MYMALLOC. The current situation is
that this functionality is only available if either PERL_DEBUGGING_MSTATS
or DEBUGGING_MSTATS is defined. In malloc.c, DEBUGGING_MSTATS is normally
always defined, but this macro is not set when compiling Devel::Peek.

The patch also makes the #if condition easier by moving the error message to
malloc.c itself.

In my tests, I also noted that PLAIN_MALLOC does not compile anymore.

Regards,
    Slaven

# 
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####

#### Patch data follows ####
diff -up '../bleedperl-amd64/ext/Devel/Peek/Peek.xs' 'ext/Devel/Peek/Peek.xs'
Index: ./ext/Devel/Peek/Peek.xs
--- ./ext/Devel/Peek/Peek.xs	Wed Jun 20 18:26:55 2007
+++ ./ext/Devel/Peek/Peek.xs	Sat Oct 27 17:35:54 2007
@@ -127,16 +127,14 @@ DeadCode(pTHX)
 #endif /* !PURIFY */
 }
 
-#if (defined(PERL_DEBUGGING_MSTATS) || defined(DEBUGGING_MSTATS)) \\
-	&& (defined(MYMALLOC) && !defined(PLAIN_MALLOC))
+#if defined(MYMALLOC)
 #   define mstat(str) dump_mstats(str)
 #else
 #   define mstat(str) \\
-	PerlIO_printf(Perl_debug_log, "%s: perl not compiled with DEBUGGING_MSTATS\\n",str);
+	PerlIO_printf(Perl_debug_log, "%s: perl not compiled with MYMALLOC\\n",str);
 #endif
 
-#if (defined(PERL_DEBUGGING_MSTATS) || defined(DEBUGGING_MSTATS)) \\
-	&& (defined(MYMALLOC) && !defined(PLAIN_MALLOC))
+#if defined(MYMALLOC)
 
 /* Very coarse overestimate, 2-per-power-of-2, one more to determine NBUCKETS. */
 #  define _NBUCKETS (2*8*IVSIZE+1)
@@ -293,7 +291,7 @@ mstats2hash(SV *sv, SV *rv, int level)
 	croak("Wrong size for a value with a mstats buffer");
     _mstats_to_hv((HV *)SvRV(rv), (struct mstats_buffer*)SvPVX(sv), level);
 }
-#else	/* !( defined(PERL_DEBUGGING_MSTATS) || defined(DEBUGGING_MSTATS) \\ ) */ 
+#else	/* defined(MYMALLOC) */ 
 static void
 fill_mstats(SV *sv, int level)
 {
@@ -311,7 +309,7 @@ mstats2hash(SV *sv, SV *rv, int level)
 {
     croak("Cannot report mstats without Perl malloc");
 }
-#endif	/* defined(PERL_DEBUGGING_MSTATS) || defined(DEBUGGING_MSTATS)... */ 
+#endif	/* defined(MYMALLOC) */ 
 
 #define _CvGV(cv)					\\
 	(SvROK(cv) && (SvTYPE(SvRV(cv))==SVt_PVCV)	\\
diff -up '../bleedperl-amd64/malloc.c' 'malloc.c'
Index: ./malloc.c
--- ./malloc.c	Mon Apr 16 01:25:50 2007
+++ ./malloc.c	Sat Oct 27 17:58:16 2007
@@ -2430,6 +2430,8 @@ Perl_get_mstats(pTHX_ perl_mstats_t *buf
 		buf->bucket_available_size[i] = BUCKET_SIZE_REAL(i);
 	    }
 	}
+#else /* defined DEBUGGING_MSTATS */
+	PerlIO_printf(Perl_error_log, "perl not compiled with DEBUGGING_MSTATS\\n");
 #endif	/* defined DEBUGGING_MSTATS */
 	return 0;		/* XXX unused */
 }
@@ -2501,6 +2503,8 @@ Perl_dump_mstats(pTHX_ char *s)
 		      buffer.total_sbrk, buffer.sbrks, buffer.sbrk_good,
 		      buffer.sbrk_slack, buffer.start_slack,
 		      buffer.total_chain, buffer.sbrked_remains);
+#else /* DEBUGGING_MSTATS */
+	PerlIO_printf(Perl_error_log, "%s: perl not compiled with DEBUGGING_MSTATS\\n",s);
 #endif /* DEBUGGING_MSTATS */
 }
 
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Sat Oct 27 18:05:41 2007
# Generated by        : makepatch 2.03
# Recurse directories : Yes
# Excluded files      : (\\A|/).*\\~\\Z
#                       (\\A|/).*\\.a\\Z
#                       (\\A|/).*\\.bak\\Z
#                       (\\A|/).*\\.BAK\\Z
#                       (\\A|/).*\\.elc\\Z
#                       (\\A|/).*\\.exe\\Z
#                       (\\A|/).*\\.gz\\Z
#                       (\\A|/).*\\.ln\\Z
#                       (\\A|/).*\\.o\\Z
#                       (\\A|/).*\\.obj\\Z
#                       (\\A|/).*\\.olb\\Z
#                       (\\A|/).*\\.old\\Z
#                       (\\A|/).*\\.orig\\Z
#                       (\\A|/).*\\.rej\\Z
#                       (\\A|/).*\\.so\\Z
#                       (\\A|/).*\\.Z\\Z
#                       (\\A|/)\\.del\\-.*\\Z
#                       (\\A|/)\\.make\\.state\\Z
#                       (\\A|/)\\.nse_depinfo\\Z
#                       (\\A|/)core\\Z
#                       (\\A|/)tags\\Z
#                       (\\A|/)TAGS\\Z
# v 'patchlevel.h' 4734 1189085187 33060
# p 'ext/Devel/Peek/Peek.xs' 10473 1193499354 0100444
# p 'malloc.c' 77651 1193500696 0100444
#### End of ApplyPatch data ####

#### End of Patch kit [created: Sat Oct 27 18:05:41 2007] ####
#### Patch checksum: 100 3771 64076 ####
#### Checksum: 118 4396 50114 ####
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=low
---
Site configuration information for perl 5.10.0:

Configured by eserte at Thu Oct 11 00:08:09 CEST 2007.

Summary of my perl5 (revision 5 version 10 subversion 0 patch 32096) configuration:
  Platform:
    osname=freebsd, osvers=6.2-release, archname=amd64-freebsd
    uname='freebsd biokovo-amd64.herceg.de 6.2-release freebsd 6.2-release #0: fri jan 12 08:32:24 utc 2007 vnga@portnoy.cse.buffalo.edu:usrobjusrsrcsysgeneric amd64 '
    config_args='-Dprefix=/usr/perl5.10.0 -D cc=ccache cc -Dgccansipedantic -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -I/usr/local/include',
    optimize='-O2 -pipe',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.4.6 [FreeBSD] 20060305', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ccache cc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lgdbm -lm -lcrypt -lutil -lc
    perllibs=-lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    DEVEL

---
@INC for perl 5.10.0:
    /usr/perl5.10.0/lib/5.10.0/amd64-freebsd
    /usr/perl5.10.0/lib/5.10.0
    /usr/perl5.10.0/lib/site_perl/5.10.0/amd64-freebsd
    /usr/perl5.10.0/lib/site_perl/5.10.0
    .

---
Environment for perl 5.10.0:
    HOME=/home/e/eserte
    LANG (unset)
    LANGUAGE (unset)
    LC_ALL=de_DE.ISO8859-1
    LC_CTYPE=de_DE.ISO8859-1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/X11R6/bin:/usr/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/gnu/bin:/usr/TeX/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/pilot/bin:/home/e/eserte/bin/FreeBSD:/home/e/eserte/bin/sh:/home/e/eserte/bin:/usr/X386/bin:/usr/games:/home/e/eserte/devel
    PERL_BADLANG (unset)
    PERL_HTML_DISPLAY_CLASS=HTML::Display::Mozilla
    SHELL=/bin/tcsh


