perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject Re: [Patch] MP_GTOP=1
Date Mon, 19 May 2003 13:44:36 GMT
On Mon, 2003-05-19 at 11:55, Stas Bekman wrote:
> How come we don't see any gcc-3.3-compiency patches, yet? ;)

That won't be very long... Expect the reports to come a little bit later
this week. Do not fear, they will come.

> Philippe M. Chiasson wrote:
> > # $Id: gtop.patch,v 1.1 2003/05/19 03:29:19 gozer Exp $
> > 
> > Recently tried building with MP_GTOP=1 and noticed that things don't quite
> > work for me anymore. As per gcc documentation __func__ and __FUNCTION__ should
not
> > be used in string concatenation. 
> 
> Then the API should be changed to either accept 2 strings, or (...). Probably 
> the former will do, with a second argument being an optional NULL. Whereas 
> your patch removes important info.

Yeah, I didn't think of that.

> > Also in modperl_imterp, encountered some
> > scfg without a valid gtop structure, so create it if not already there.
> 
> +1 (as a separate patch), but let me repeat: identation, identation, identation


I've been away from the code for just a few weeks, and I am starting to
get my old habits back ;-(

I think I got it right this time, and in 2 separate patches, one for the
possible segfault, the other for the added func argument to the gtop
API.

Patches follows:

# $Id: gtop.patch,v 1.2 2003/05/19 13:43:06 gozer Exp $

Recently tried building with MP_GTOP=1 and noticed that things don't quite
work anymore. As per gcc documentation __func__ and __FUNCTION__ should not
be used in string concatenation. Also in modperl_imterp, encountered some
scfg without a valid gtop structure, so create it if not already there


Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.170
diff -u -I$Id -r1.170 mod_perl.c
--- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
+++ src/modules/perl/mod_perl.c	19 May 2003 09:56:45 -0000
@@ -147,7 +147,9 @@
 
 #ifdef MP_USE_GTOP
     MP_TRACE_m_do(
-        scfg->gtop = modperl_gtop_new(p);
+        if (!scfg->gtop) {
+            scfg->gtop = modperl_gtop_new(p);
+        }
         modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
     );
 #endif
Index: src/modules/perl/modperl_interp.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v
retrieving revision 1.58
diff -u -I$Id -r1.58 modperl_interp.c
--- src/modules/perl/modperl_interp.c	6 Apr 2003 23:49:46 -0000	1.58
+++ src/modules/perl/modperl_interp.c	19 May 2003 09:56:45 -0000
@@ -51,6 +51,9 @@
 #ifdef MP_USE_GTOP
         MP_dSCFG(mip->server);
         MP_TRACE_m_do(
+            if (!scfg->gtop) {
+                scfg->gtop = modperl_gtop_new(scfg->server->process->pool);
+            }
             modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_clone");
         );
 #endif

This patches fixes the concatenation problem with MP_FUNC (aka __func__ )

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.170
diff -u -I$Id -r1.170 mod_perl.c
--- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
+++ src/modules/perl/mod_perl.c	19 May 2003 13:29:48 -0000
@@ -150,7 +150,7 @@
         if (!scfg->gtop) {
             scfg->gtop = modperl_gtop_new(p);
         }
+        modperl_gtop_do_proc_mem_before(MP_FUNC, "perl_parse");
-        modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
     );
 #endif

@@ -205,7 +205,7 @@

 #ifdef MP_USE_GTOP
     MP_TRACE_m_do(
+        modperl_gtop_do_proc_mem_after(MP_FUNC, "perl_parse");
-        modperl_gtop_do_proc_mem_after(MP_FUNC ": perl_parse");
     );
 #endif

 
Index: src/modules/perl/modperl_gtop.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_gtop.c,v
retrieving revision 1.7
diff -u -I$Id -r1.7 modperl_gtop.c
--- src/modules/perl/modperl_gtop.c	15 Mar 2001 01:55:44 -0000	1.7
+++ src/modules/perl/modperl_gtop.c	19 May 2003 13:29:48 -0000
@@ -95,12 +95,12 @@
 }
 
 void modperl_gtop_report_proc_mem(modperl_gtop_t *gtop, 
-                                  char *when, char *msg)
+                                  char *when, const char *func, char *msg)
 {
 #define ss_item(item) gtop->proc_mem_ss.item
 
-    fprintf(stderr, "%s %s: " ss_fmt "\n",
-            msg, when,
+    fprintf(stderr, "%s : %s %s: " ss_fmt "\n",
+            func, msg, when,
             ss_item(size),
             ss_item(vsize),
             ss_item(resident),
@@ -110,22 +110,22 @@
 #undef ss_item
 }
 
-void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_DIFF);
-    modperl_gtop_report_proc_mem(gtop, "diff", msg);
+    modperl_gtop_report_proc_mem(gtop, "diff", func, msg);
 }
 
-void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_BEFORE);
-    modperl_gtop_report_proc_mem(gtop, "before", msg);
+    modperl_gtop_report_proc_mem(gtop, "before", func, msg);
 }
 
-void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_AFTER);
-    modperl_gtop_report_proc_mem(gtop, "after", msg);
+    modperl_gtop_report_proc_mem(gtop, "after", func, msg);
 }
 
 #endif /* MP_USE_GTOP */
Index: src/modules/perl/modperl_gtop.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_gtop.h,v
retrieving revision 1.3
diff -u -I$Id -r1.3 modperl_gtop.h
--- src/modules/perl/modperl_gtop.h	15 Mar 2001 01:55:44 -0000	1.3
+++ src/modules/perl/modperl_gtop.h	19 May 2003 13:29:48 -0000
@@ -36,19 +36,19 @@
 void modperl_gtop_get_proc_mem_before(modperl_gtop_t *gtop);
 void modperl_gtop_get_proc_mem_after(modperl_gtop_t *gtop);
 void modperl_gtop_report_proc_mem(modperl_gtop_t *gtop, 
-                                  char *when, char *msg);
-void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, char *msg);
-void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, char *msg);
-void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, char *msg);
+                                  char *when, const char *func, char *msg);
+void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, const char* func, char *msg);
+void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, const char* func, char *msg);
+void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, const char* func, char *msg);
 
-#define modperl_gtop_do_proc_mem_before(msg) \
+#define modperl_gtop_do_proc_mem_before(func, msg) \
         modperl_gtop_get_proc_mem_before(scfg->gtop); \
-        modperl_gtop_report_proc_mem_before(scfg->gtop, msg)
+        modperl_gtop_report_proc_mem_before(scfg->gtop, func, msg)
 
-#define modperl_gtop_do_proc_mem_after(msg) \
+#define modperl_gtop_do_proc_mem_after(func, msg) \
         modperl_gtop_get_proc_mem_after(scfg->gtop); \
-        modperl_gtop_report_proc_mem_after(scfg->gtop, msg); \
-        modperl_gtop_report_proc_mem_diff(scfg->gtop, msg)
+        modperl_gtop_report_proc_mem_after(scfg->gtop, func, msg); \
+        modperl_gtop_report_proc_mem_diff(scfg->gtop, func, msg)
 
 #endif /* MP_USE_GTOP */
 
Index: src/modules/perl/modperl_interp.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v
retrieving revision 1.58
diff -u -I$Id -r1.58 modperl_interp.c
--- src/modules/perl/modperl_interp.c	6 Apr 2003 23:49:46 -0000	1.58
+++ src/modules/perl/modperl_interp.c	19 May 2003 13:29:48 -0000
@@ -54,7 +54,7 @@
             if (!scfg->gtop) {
                 scfg->gtop = modperl_gtop_new(scfg->server->process->pool);
             }
+            modperl_gtop_do_proc_mem_before(MP_FUNC, "perl_clone");
-            modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_clone");
         );
 #endif

@@ -102,7 +102,7 @@

 #ifdef MP_USE_GTOP
         MP_TRACE_m_do(
+            modperl_gtop_do_proc_mem_after(MP_FUNC, "perl_clone");
-            modperl_gtop_do_proc_mem_after(MP_FUNC ": perl_clone");
         );
 #endif
     }




> > Index: src/modules/perl/mod_perl.c
> > ===================================================================
> > RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
> > retrieving revision 1.170
> > diff -u -b -B -I$Id -r1.170 mod_perl.c
> > --- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
> > +++ src/modules/perl/mod_perl.c	19 May 2003 03:25:48 -0000
> > @@ -147,8 +147,10 @@
> >  
> >  #ifdef MP_USE_GTOP
> >      MP_TRACE_m_do(
> > +        if(!scfg->gtop) {
> >          scfg->gtop = modperl_gtop_new(p);
> > -        modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
> > +        }
> > +        modperl_gtop_do_proc_mem_before(MP_FUNC);
> 
> tabs?
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
-- 
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Mime
View raw message