You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@ectoplasm.org> on 2004/05/18 20:23:59 UTC
[patch] Devel::Cover and mod_perl
Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl being what
it is, things aren't quite working right. After a little bit of probing, I've
found the source of the problem.
Under mod_perl, we are managing the PL_endav/PL_initav ourselves, as we need to
somewhat alter their behaviour, and they can be temporarly null, so following
patch avoids a possible segfault.
The other issue is that CHECK/INIT blocks are not being called proprely under
mod_perl 1.x, so moving the CHECK/INIT code in a sub of its own, allows the
mod_perl user to do this in his/her startup script:
use Devel::Cover;
Devel::Cover::check;
Devel::Cover::set_first_init_and_end;
With these 2 simple modifications, all Devel-Cover tests still passing, mod_perl
can now benefit from the coolness of Devel::Cover.
Hope this is helpfull and I hope you'll be able to integrate this in your next
scheduled release of Devel::Cover
diff -p -ru Devel-Cover-0.43/Cover.xs Devel-Cover/Cover.xs
--- Devel-Cover-0.43/Cover.xs 2004-05-01 15:27:00.000000000 -0700
+++ Devel-Cover/Cover.xs 2004-05-18 10:58:27.277892570 -0700
@@ -176,7 +176,7 @@ static void set_firsts_if_neeed()
SV *init = (SV *)get_cv("Devel::Cover::first_init", 0);
SV *end = (SV *)get_cv("Devel::Cover::first_end", 0);
NDEB(svdump(end));
- if (av_len(PL_initav) >= 0)
+ if (PL_initav && (av_len(PL_initav) >= 0))
{
SV **cv = av_fetch(PL_initav, 0, 0);
if (*cv != init)
@@ -185,7 +185,7 @@ static void set_firsts_if_neeed()
av_store(PL_initav, 0, init);
}
}
- if (av_len(PL_endav) >= 0)
+ if (PL_endav && (av_len(PL_endav) >= 0))
{
SV **cv = av_fetch(PL_endav, 0, 0);
if (*cv != end)
diff -p -ru Devel-Cover-0.43/lib/Devel/Cover.pm Devel-Cover/lib/Devel/Cover.pm
--- Devel-Cover-0.43/lib/Devel/Cover.pm 2004-05-01 15:27:00.000000000 -0700
+++ Devel-Cover/lib/Devel/Cover.pm 2004-05-18 10:56:28.185024129 -0700
@@ -84,7 +84,7 @@ BEGIN { $^P = 0x004 | 0x100 | 0x200 }
no warnings "void"; # Avoid "Too late to run CHECK block" warning.
-CHECK
+sub check
{
return unless $Initialised;
@@ -124,6 +124,8 @@ EOM
$Run{start} = get_elapsed();
}
+CHECK { check() }
+
}
{
--
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Re: [patch] Devel::Cover and mod_perl
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
>
>> Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl
>> being what
>> it is, things aren't quite working right. After a little bit of
>> probing, I've found the source of the problem.
>>
>> Under mod_perl, we are managing the PL_endav/PL_initav ourselves, as
>> we need to
>> somewhat alter their behaviour, and they can be temporarly null, so
>> following
>> patch avoids a possible segfault.
>
>
> That's mp1, right? Since handling of endav has changed recently in mp2
> to not hijack it.
Yes, absolutely, I am talking about mod_perl 1.x, since that's what I am
trying to get
Devel::Cover to work with at the moment. Haven't even tried with mp2 yet.
I'll try with mp2 and see what happens.
> __________________________________________________________________
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Devel::Cover and mod_perl
Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl
> being what
> it is, things aren't quite working right. After a little bit of probing,
> I've found the source of the problem.
>
> Under mod_perl, we are managing the PL_endav/PL_initav ourselves, as we
> need to
> somewhat alter their behaviour, and they can be temporarly null, so
> following
> patch avoids a possible segfault.
That's mp1, right? Since handling of endav has changed recently in mp2 to not
hijack it.
__________________________________________________________________
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
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Devel::Cover and mod_perl
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> OK, I've just released Devel::Cover 0.45 which includes this change. It
> seems to work OK for me on simple examples, but I'd be grateful for any
> feedback.
paul++
>
>
>>>I need to set up an environment to check all this, too.
>>>
>>
>>Grab geoff's mp1 test skeleton here:
>>
>>http://www.apache.org/~geoff/bug-reporting-skeleton-mp1.tar.gz
>>
>>And just add :
>>
>>use Devel::Cover to t/conf/modperl_extra.pl
>
>
> Ooh, that's nice! And suspiciously similar to a tarball Geoff sent me
> for a bug in Devel:Cover ;-)
imagine that :)
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Devel::Cover and mod_perl
Posted by Paul Johnson <pa...@pjcj.net>.
On Fri, May 21, 2004 at 06:25:17PM -0700, Philippe M. Chiasson wrote:
> Paul Johnson wrote:
>
> >On Tue, May 18, 2004 at 11:23:59AM -0700, Philippe M. Chiasson wrote:
> >
> >>The other issue is that CHECK/INIT blocks are not being called proprely
> >>under
> >>mod_perl 1.x, so moving the CHECK/INIT code in a sub of its own, allows
> >>the
> >>mod_perl user to do this in his/her startup script:
> >>
> >>use Devel::Cover;
> >>Devel::Cover::check;
> >>Devel::Cover::set_first_init_and_end;
> >
> >I'm probably showing my lack of knowledge, but is there any reason why I
> >couldn't check $ENV{MOD_PERL} and call those two subs in
> >Devel::Cover::import() ?
> >
> That would probably work, yes. My plan, after you introduced my patch
> was to write a simple Devel::Cover::Apache module for mod_perl users
> to use in place of Devel::Cover that would call those 2 subs. But it
> would be certainly simpler if Devel::Cover detected a mod_perl
> environment and took care of things by itself.
OK, I've just released Devel::Cover 0.45 which includes this change. It
seems to work OK for me on simple examples, but I'd be grateful for any
feedback.
> >I need to set up an environment to check all this, too.
> >
> Grab geoff's mp1 test skeleton here:
>
> http://www.apache.org/~geoff/bug-reporting-skeleton-mp1.tar.gz
>
> And just add :
>
> use Devel::Cover to t/conf/modperl_extra.pl
Ooh, that's nice! And suspiciously similar to a tarball Geoff sent me
for a bug in Devel:Cover ;-)
--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Devel::Cover and mod_perl
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Paul Johnson wrote:
>On Tue, May 18, 2004 at 11:23:59AM -0700, Philippe M. Chiasson wrote:
>
>
>
>>Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl
>>being what it is, things aren't quite working right. After a little
>>bit of probing, I've found the source of the problem.
>>
>>
>
>[ snip problems and solutions ]
>
>Thanks very much for the diagnosis and patch
>
>
>
>>The other issue is that CHECK/INIT blocks are not being called proprely
>>under
>>mod_perl 1.x, so moving the CHECK/INIT code in a sub of its own, allows the
>>mod_perl user to do this in his/her startup script:
>>
>> use Devel::Cover;
>> Devel::Cover::check;
>> Devel::Cover::set_first_init_and_end;
>>
>>
>
>I'm probably showing my lack of knowledge, but is there any reason why I
>couldn't check $ENV{MOD_PERL} and call those two subs in
>Devel::Cover::import() ?
>
>
That would probably work, yes. My plan, after you introduced my patch
was to write a simple
Devel::Cover::Apache module for mod_perl users to use in place of
Devel::Cover that would
call those 2 subs. But it would be certainly simpler if Devel::Cover
detected a mod_perl environment
and took care of things by itself.
> [...]
>
>
>I need to set up an environment to check all this, too.
>
>
Grab geoff's mp1 test skeleton here:
http://www.apache.org/~geoff/bug-reporting-skeleton-mp1.tar.gz
And just add :
use Devel::Cover to t/conf/modperl_extra.pl
And you'll have a good test skeleton for playing with Devel::Cover with mp1
>Thanks again,
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Devel::Cover and mod_perl
Posted by Paul Johnson <pa...@pjcj.net>.
On Tue, May 18, 2004 at 11:23:59AM -0700, Philippe M. Chiasson wrote:
> Hi, I've been trying to use Devel::Cover under mod_perl, and mod_perl
> being what it is, things aren't quite working right. After a little
> bit of probing, I've found the source of the problem.
[ snip problems and solutions ]
Thanks very much for the diagnosis and patch.
> The other issue is that CHECK/INIT blocks are not being called proprely
> under
> mod_perl 1.x, so moving the CHECK/INIT code in a sub of its own, allows the
> mod_perl user to do this in his/her startup script:
>
> use Devel::Cover;
> Devel::Cover::check;
> Devel::Cover::set_first_init_and_end;
I'm probably showing my lack of knowledge, but is there any reason why I
couldn't check $ENV{MOD_PERL} and call those two subs in
Devel::Cover::import() ?
> Hope this is helpfull and I hope you'll be able to integrate this in
> your next scheduled release of Devel::Cover
I'm not much on schedules - I generally just release something when
there's enough to warrant it and I've got a little time to put the
release together. I wanted to get a release out this week, but I won't
be able to do that now, so it will have to be next week.
Your patch is very helpful, and I've already integrated it into my
development version. I've also added a little documentation, based on
your message, but I want to flesh it out a little.
I need to set up an environment to check all this, too.
Thanks again,
--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org