3

I've recently started work on a project that uses mod_perl. I'm attempting to use the Perl debugger to debug some Perl scripts that are running under mod_perl. I start the debugger with the following command:

sudo OPTIONS="-X -DPERLDB" /etc/init.d/httpd restart

The relevant debugging section of perl.conf (included by httpd.conf) is:

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

That takes me into the debugger. When I load the required page in the browser, the debugger breaks on the first line of the Perl script that has been wrapped by mod_perl (the app is using PerlRun, btw). I can now step through the code, print variables, and so on.

My problem is that the commands to view source code (l, - and v), don't display anything when inside a Perl script. They work as expected inside a module - that is, if the code steps into a module that is used by the Perl script, the view source commands work.

Is this a known problem with debugging in mod_perl? Is there anything I can do to fix it?

I'm using Apache 2.2.3 and Perl 5.8.8 on CentOS 5.6 x86_64.

Mike
  • 21,301
  • 2
  • 42
  • 65
  • Is debugger really necessary? In many cases it is possible to use unit testing, logging to found out where problem is without using debugger. Also you can try using Plack - it has good means of debugging. – Alexandr Ciornii Sep 28 '11 at 15:43
  • @Alexandr Ciornii: this is a large legacy application to which we are slowly adding unit tests, and moving everything out of scripts into modules. At the moment there are definitely some areas where debugging is necessary, but hopefully this won't always be the case. – Mike Sep 28 '11 at 15:54
  • According to the [doc](http://search.cpan.org/~fwiles/Apache-DB-0.13/DB.pm), the perl code should be `use APR::Pool (); use Apache::DB (); Apache::DB->init();` – Fabien Jul 30 '14 at 11:21

1 Answers1

1

I've ran into the problem before, and have an educated guess about the problem. My current working theory is that the debugger doesn't show the code that perl parsed, because perl already threw it away during the compile phase. Instead, the debugger looks through relative paths to get the source code from the actual file. However, the debugger starts looking from the Apache server root, which may not be the same as where you started Apache. When it can't find the file, it shows up as a bunch of blank lines.

frezik
  • 2,316
  • 15
  • 13