Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you invoke interactive Perl debugging with hypnotoad or morbo?

I'm new to mojolicious but have been using Perl for some time. I have to jump through some hoops but I can get the interactive Perl debugger (and Komodo) working with remote connections for Apache but I can't find anything about interactive debugging with hypnotoad or morbo.

The command line examples in the basic tutorial on http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Hello-World work fine because you can launch them with perl -d, but I don't see anyway to tell the hypnotoadctl script to put the service in interactive debug mode ala apache.

Is this not possible? Hints? Tips? Pointers?

like image 588
George Menyhert Avatar asked Aug 14 '15 15:08

George Menyhert


2 Answers

morbo and hypnotoad are perl programs, so you can launch them with the -d switch.

perl -d $(which morbo) myMojoApp.pl

It's probably easiest to sprinkle a bunch of $DB::single = 1 statements around you app where you want your initial breakpoints to go and run c as the first debugger command. When you run a request that hits a breakpoint, you'll get a debugger prompt in the terminal that launched morbo.

hypnotoad will be trickier to use with the debugger because it quickly closes all the standard filehandles, calls fork several times, and becomes a daemon.

like image 155
mob Avatar answered Sep 25 '22 08:09

mob


As JHThorsen points out, standard Mojolicious tests are actually ordinary Perl scripts, so you can debug your tests with:

perl -d t/mytest.t

The -Ilib adds the lib/ directory to the @INC include list so your modules will be loaded.

One catch is that many modules are not loaded until execution time, so if the debugger hassles you about symbols that aren't loaded yet, you'll probably want to set breakpoints after forcing a debug prompt with a carefully inserted

$DB::single = 1;
like image 26
William Lindley Avatar answered Sep 25 '22 08:09

William Lindley