modperl_debugging_with_gdb

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Shane Adams <shane@viralon.com>
From: sterling <sterling@covalent.net>
Subject: Re: Debugging mod_perl with gdb
Date: Tue, 6 Feb 2001 12:32:45 -0800 (PST)

On Tue, 6 Feb 2001, Shane Adams wrote:

> On Tue, 30 Jan 2001 chris@sixlegs.com wrote:

> > Castor (for Java, from www.exolab.com), uses an actual
> > XML Schema for this. The advantage is that you can
> > leverage off the fairly rich existing set of defined
> > datatypes.

> Sorry, it's www.exolab.org, don't you hate that?

> I've successfully built apache/mod_perl with full debugging.  In
> addition, I'm running the whole setup through insure, a commercial
> memory leak/corruption tool.  
> 
> I've found a "write to a dangling pointer" when apache/mod_perl
> evaluates a <perl> section of the apache config file.
> 
> My question:  How do I go about attacking this problem?  I only know
> that I'm in a <Perl> section due to printing out some variables
> somewhere at ap_read_config() to invoke_cmd().  I guess I'm trying to
> find out what the perl script is doing when the memory corruption
> occurs.  Obviously if I could narrow the offending line of code (if
> possible) I might be able to better understand where the real bug is.


If you're looking for which piece of perl code being processed, there
are some gdb macros to help.  If you source the .gdbinit in the root of
your modperl dir you have access to a bunch of cool macros to use.  In
this case, curinfo will give you the current line number in your perl
code.

here's the macro: 
define curinfo
   printf "%d:%s\n", PL_curcop->cop_line, \
   ((XPV*)(*(XPVGV*)PL_curcop->cop_filegv->sv_any)\
   ->xgv_gp->gp_sv->sv_any)->xpv_pv 
end

hope that helps.

===

To: modperl@apache.org, perl5-porters@perl.org
From: Vivek Khera <khera@kciLink.com>
Subject: Re: Debugging mod_perl with gdb
Date: Wed, 7 Feb 2001 11:06:10 -0500

>>>>> "TB" == Tim Bunce <Tim.Bunce@ig.co.uk> writes:

TB> I recall someone once created a whole bunch of gdb macros for debugging
TB> perl.  I've CC'd this to p5p in the hope that someone remembers.

In the mod_perl source tree (at least in CVS) there's a nice .gdbinit
file that may be of use.

===

To: "Wang, Pin-Chieh" <Pin-Chieh.Wang@COMPAQ.com>
From: "G.W. Haywood" <ged@www.jubileegroup.co.uk>
Subject: Re: Debug perl package in Apache
Date: Thu, 8 Feb 2001 22:23:50 +0000 (GMT)

Hi there,

On Thu, 8 Feb 2001, Wang, Pin-Chieh wrote:

> But AuthenNISPlus.pm exited with "Not an ARRAY reference at line 58
> look at this program from line 57 are
> 
>   foreach ($pwd_table->list()){

print STDERR "Argument list = [", $_, "]\n";

>     if(@{$_}[0] eq $name){
>       $pwd = @{$_}[1];
>       $group = @{$_}[3];
>       last;

> Any body has any ideals?  Also How can I debug an perl package under
> this environment?

http://perl/apache.org/guide

===

To: "Wang, Pin-Chieh" <Pin-Chieh.Wang@COMPAQ.com>
From: Sander van Zoest <sander@covalent.net>
Subject: Re: Debug perl package in Apache
Date: Thu, 8 Feb 2001 15:04:19 -0800 (PST)

On Thu, 8 Feb 2001, Wang, Pin-Chieh wrote:

> Any body has any ideals?  Also How can I debug an perl package under this
> environment?
> Appreciated for any help

Check out this useful article written by Dough MacEachern for PerlMonth.
<http://www.perlmonth.com/features/mod_perl/mod_perl.html?issue=2>

===

To: "'Sander van Zoest'" <sander@covalent.net>
From: "Wang, Pin-Chieh" <Pin-Chieh.Wang@COMPAQ.com>
Subject: RE: Debug perl package in Apache
Date: Sun, 11 Feb 2001 16:28:11 -0600

Hi Sander,
Thanks for the info, I read the article you suggested, and try to testout
the server-status (as oppose to the perl-status
as the example suggested,) but my testing was not quite right, hope you can
answer my questions

First I can't put the <IfDefine PERLDB> block at the beginning of the
http.conf (I got httpd.conf syntax error 
when I run httpd -X -DPERLDB; Then I move the block to the end of the
http.conf file re-run the command then I get
% ./bin/httpd -X -DPERLDB
[notice] Apache::DB initialized in child 23415

the system is waiting for my call the request.
But when I call http://localhost/server-status I still don't got the debug
prompt. here I called server-status instead of perl-status. I guess I don't
understand how Debuger is configured into perl-status when
http://localhost/perl-status is called.
can you share some light on this?

Thanks,
PC
 The following is the additions in httpd.conf as described in the article.


<IfDefine PERLDB>

   <Perl>
      use Apache::DB ();
      Apache::DB->init;
   </Perl>

   <Location />
      PerlFixupHandler Apache::DB
   </Location>

</IfDefine>

In our first example, we will debug the standard Apache::Status module,
which is configured like so: 
PerlModule Apache::Status
<Location /perl-status>
    PerlHandler Apache::Status
    SetHandler perl-script
</Location>

When the server is started with the debugging flag, a notice will be printed
to the console: 


===

To: "Wang, Pin-Chieh" <Pin-Chieh.Wang@COMPAQ.com>
From: Sander van Zoest <sander@covalent.net>
Subject: RE: Debug perl package in Apache
Date: Mon, 12 Feb 2001 12:11:28 -0800 (PST)

On Sun, 11 Feb 2001, Wang, Pin-Chieh wrote:

> First I can't put the <IfDefine PERLDB> block at the beginning of the
> http.conf (I got httpd.conf syntax error 
> when I run httpd -X -DPERLDB; Then I move the block to the end of the
> http.conf file re-run the command then I get
> % ./bin/httpd -X -DPERLDB
> [notice] Apache::DB initialized in child 23415

You can only call this after you have loaded modperl and such. 
So it might be related to that.
  
> the system is waiting for my call the request.
> But when I call http://localhost/server-status I still don't got the debug
> prompt. here I called server-status instead of perl-status. I guess I don't
> understand how Debuger is configured into perl-status when
> http://localhost/perl-status is called.
> can you share some light on this?

This is because you can only use Apache::DB to debug perl code. 
mod_status.c (i.e. server-status) is written in C, so you will need to
use a C debugger such as gdb or dbx. See the earlier thread on that for
some useful hints.
  
Hope that helps,

===

To: modperl@apache.org
From: Joe Brenner <doom@kzsu.stanford.edu>
Subject: mod_perl, Apache:DB and emacs
Date: Tue, 06 Mar 2001 01:04:13 -0800

I was just playing around a bit with running the perl
debugger with mod_perl, as described in the guide: 

   http://perl.apache.org/guide/debug.html#Interactive_mod_perl_Debugging

And while I see that there's a tweak described to use
ptkdb.pm, I don't see any information on how to get it to
use the emacs debugger frontend.  Has anyone here done 
this?  Got any hints? 

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu