Windows Monks,

Do you use Notepad++ as your preferred editor? Have you done some things with NppExec to move towards an IDE? Do you want integrated debugger support?

I was out of luck on the last one and a myriad of Google-ing didn't help. There was a debugger plugin for Notepad++ (DBGp - http://sourceforge.net/projects/npp-plugins/files/DBGP%20Plugin/) but it was for PHP debugging with XDebug ... originally. I set out to get Perl working with it and lo and behold - I did it!

UPDATE: I'm on Windows 7 x64 and using Strawberry Perl 5.18.1 MSWin32-x64-multi-thread.

The gory details can be found here:

http://vinsworldcom.blogspot.com/2015/08/debugging-perl-debugger-part-1-notepad.html
http://vinsworldcom.blogspot.com/2015/08/debugging-perl-debugger-part-2-variable.html
http://vinsworldcom.blogspot.com/2015/08/debugging-perl-debugger-part-3.html

Essentially, you need:

DBGp plugin

Get it from the SourceForge page at http://sourceforge.net/projects/npp-plugins/files/DBGP%20Plugin/. Get the latest (0.13 beta as of this writing) and you'll only need the DLL. Current file name is: DBGpPlugin_0_13b_dll.zip. Unzip the DLL to your Notepad++\plugins directory.

Perl Debugger for Komodo IDE

We only need this since there isn't a "Perl Debugger for Notepad++ IDE". It essentially supplies the interface via "perl5db.pl" and subdirectory "DB" of various supporting modules. You get it here: http://downloads.activestate.com/Komodo/releases/archive/4.x/4.4.1/remotedebugging/ and you'll want the Komodo-PerlRemoteDebugging-4.4.1-20896-win32-x86.zip file. NOTE: I tried newer releases, but found other issues cropped up in addition to the ones I show you how to fix below, so use this version, or the rest of this won't make much sense.

I created a directory in my Notepad++\plugins directory called "PerlDebug"; so, (...)\Notepad++\plugins\PerlDebug. I unzipped only the "perl5db.pl" file and the entire "DB" directory and its sub directories into that PerlDebug directory.

Getting it to Work

You need to make some edits to the Perl Debugger scripts from the Komodo IDE as well as set some environment variables. First, the edits.

Edit DB\DBgrProperties.pm

Open the Notepad++\plugins\PerlDebug\DB\DBgrProperties.pm file. Line 657-659 is something like:

$res .= sprintf(qq(<value%s><![CDATA[%s]]></value>\n), $encoding ? qq( encoding="$encoding") : "", $encVal);

Change that to:

$res .= sprintf(qq(<![CDATA[%s]]>\n), $encVal);

Also, further up on line 131, you'll see:

context_id="%d"

Change that to:

context="%d"
Edit perl5db.pl

Open the Notepad++\plugins\PerlDebug\perl5db.pl file. On line 1525:

$res .= sprintf(' line="%s"',

change to:

$res .= sprintf(' lineno="%s"',

And, after line 2898, which should read:

my $bpInfo = getBreakpointInfoString($bkptID, function => $bFuncti +on);

add the following three lines:

if ($bpInfo) { $res .= $bpInfo; }
Environment Variables

You'll need some environment variables to get this to work. I wanted them to be volatile so as not to upset normal operations. This where I used NppExec. I'll assume you have it installed as it's an awesome plugin that you should have installed. If not, get if from the Plugin Manager.

The only essential environment variables to set are:

set PERL5LIB=C:\path\to\Notepad++\plugins\PerlDebug set PERLDB_OPTS=RemotePort=127.0.0.1:9000

where "\path\to\Notepad++" is your directory path to Notepad++. I have mine at "C:\usr\bin\npp\plugins\PerlDebug". Yours may be "C:\Program Files\Notepad++\plugins\PerlDebug". Note if your path has a space (like between "Program" and "Files" in the example, you'll probably need to double-quote the entire path assigned to PERL5LIB like: set PERL5LIB="C:\Program Files\Notepad++\plugins\PerlDebug".

I set my variables with an NppExec script:

NPP_SAVE cd "$(CURRENT_DIRECTORY)" NPP_MENUCOMMAND Plugins\DBGp\Debugger ENV_SET PERLDB_OPTS=RemotePort=127.0.0.1:9000 ENV_SET PERL5LIB=$(SYS.PERL5LIB);$(NPP_DIRECTORY)\plugins\PerlDebug INPUTBOX "Command Line Arguments: " cmd /c start "Perl Debug" cmd /c perl.exe -d "$(FILE_NAME)" $(INPUT)

I saved it as "Perl - Debug" and used NppExec to add it to my "Macro" menu in Notepad++. It saves the current file, changes to the working directory, enables the DBGp plugin, sets the environment variables (only temporarily within the Notepad++ context, and careful not to step on a current value that may be in PERL5LIB), prompts for any command-line input to pass to your script to get it to run and finally starts the Perl debugging session - integrated in Notepad++!

Some options I used to tune the DBGp plugin; from the Notepad++ "Plugins" menu, select "DBGp" and then "Config...".

Hope it works for you - happy debugging!


In reply to Notepad++ Integrated Perl Debugging by VinsWorldcom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.