Pablo Velasquez wrote:
Hello,
I've been searching for guidance on using DDD with mod_perl. (DDD is fantastic)
[...]
I've been reading online for the answer and there are some hints:
"Debugging mod_perl C Internals"
http://perl.apache.org/docs/2.0/devel/debug/c.html

This document explains how to debug C internals, not perl.


I've done some googling and found a post from Gerald answering a similar question for embperl. To debug mod_perl handlers under ddd, you need to configure Apache::DB normally, and next instead of starting httpd -x, you need to do:

ddd --debugger '/home/httpd/httpd_perl/bin/httpd -f /home/httpd/httpd_perl/conf/httpd.conf -X -DPERLDB' --perl

(adjust the paths)

Now when you issue a request ddd will give you an interactive shell, just like you get with perl -d. It won't open the source file for you, since it doesn't know what that source file is. You have to open it manually via menu item 'Open Source' and finish the first execution in the interactive shell window. Only on the next request you will be able to step through with the source window.

Moreover you won't be able to step through using the source window for registry scripts. This is because registry scripts aren't executed as files, but evaled as a string.

Here is an example:

httpd.conf:

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

  <Location />
    PerlFixupHandler Apache::DB
    #PerlFixupHandler Apache::SmallProf
  </Location>
</IfDefine>

<Location /hello-world>
    SetHandler perl-script
    PerlHandler Apache::HelloWorld
</Location>


#file:Apache/HelloWorld.pm package Apache::HelloWorld; use strict;

sub handler {
    my $r = shift;

    $r->send_http_header('text/plain');
    print "Hello ";
    print "world\n"
    return 0;
}

1;

1) start ddd:

ddd --debugger '/home/httpd/httpd_perl/bin/httpd -f /home/httpd/httpd_perl/conf/httpd.conf -X -DPERLDB' --perl

2) using the menu 'open source' for Apache/HelloWorld.pm.

3) issue a request:

lynx --dump http://localhost:8000/hello-world

using the DDD commands menu do 'finish' (sometimes twice). At this point all the output will go to the interactive shell console and not the client.

4) issue the request second time (this time in browser if wanted):

lynx --dump http://localhost:8000/hello-world

now you can step through the source code with ddd's commands menu, and even look at the contents of the variables in the 'Data' window.

The pain is that you have to manually open the source file. If you can find how to make it programmatically please share with us.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to