Home ........ Blog ........ Travels ........ Software ........ Web 3D ........ LinkedIn

Monday, August 03, 2015

Debugging Perl Debugger: Part 1 - Notepad++ Integration

I use Notepad++ for most of my Windows text-based editing including Perl scripts. Every once in a while I'm stuck and need debugging, but I was too lazy to learn the Perl debugger command line. I had a simple Perl-specific IDE laying around solely to use for the integrated debugging in its Graphical User Interface (GUI). The ideal solution would be Perl debugger integration with Notepad++.

Google searches revealed there was no Perl-specific debugger integration in Notepad++; however, there was a debugger plugin - DBGP Plugin listed on the Notepad++ Plugins list. It was originally written for PHP and Xdebug integration. Further searches and the README lead me to believe it may support other programming languages as long as they supported the DBGP - common debug protocol. Could Perl work this way?

Since my other IDE supported integrated Perl debugging, I assumed the Perl debugger itself could support this so thought the best way was to simply try it out. I grabbed the DBGp plugin from SourceForge and installed the DLL to my Notepad++ plugins folder. Starting Notepad++ and turning on the Debugger plugin proved it started, but to get Perl integration, I'd need some work.

More research lead me to the VDebug GitHub repository; more specifically, the documentation. Section 3.4 talks about Perl set up. I made a big guess that the VDebug client and the DBGp plugin I downloaded would work more or less the same, so followed the steps for getting Perl to work.

  1. Download the Perl Debugger for the Komodo IDE.
  2. Extract the contents (specifically, only the 'DB' folder and all its sub folders and 'perl5db.pl' file) to a newly created directory called 'PerlDebug' in my Notepad++ plugins folder.
  3. In a Command Prompt (cmd.exe), create some environment variables:
  4. set PERL5LIB=%PERL5LIB%;C:\path\to\notepad++\plugins\PerlDebug
    set PERLDB_OPTS=RemotePort=127.0.0.1:9000
    

    where "\path\to\notepad++" is the directory path to Notepad++. Mine is "\usr\bin\npp"; you may have it under "\Program Files\Notepad++" or somewhere else.

  5. Open Notepad++ and enable the DBGp plugin (menu "Plugins"=>"DBGp"=>"Debugger")
  6. From the command prompt where you set the environment variables, launch the Perl debugger with a script:
  7. perl -d myscript.pl
    

IT WORKED!!!

Well OK, it mostly worked. I needed to update the DBGp plugin settings. That can be done in Notepad++ (menu "Plugins"=>"DBGp"=>"Config...").

  • Ensure the top checkbox "Bypass all mapping (local windows setup) is checked
  • No configuration in the "Remote Server IP", "IDE KEY" ... window
  • Under the "Misc" section, only check "Break at first line when debugging starts"; clear all other checkboxes

Re-running my script proved even more successful. This time I was able to step through with the buttons in the DBGp plugin console and get some variables to watch. However, I could only see the variable names and types, not their values.

What was wrong? What could be done? I had the DBGp plugin source code from SourceForge, but it was written in Delphi - which I don't know and wasn't about to learn. I had the Perl debugger source from the Komodo IDE I downloaded. Surely some poking and prodding could get this to work.

Read tomorrow's post to find out how I got it working.

 

Copyright © VinsWorld. All Rights Reserved.