The article covers the usage of the tool ‘Komodo’ (An Active State Perl editing and debugging tool), to debug a Perl program running in a remote Linux box, from a local windows machine.
When debugging a Perl program remotely, the program is executed on the remote system and the debug output is sent to Komodo. Komodo controls the debugging session (e.g. stepping and breakpoints) once the session starts on the remote system. Perl remote debugging works on any system that can run the version of perl5db.pl distributed with Komodo. ActivePerl and most other distributions of Perl (version 5.6 or greater) will work.
To know more about Komodo visit: - http://www.activestate.com/Products/komodo_ide/
Scenario:
There is a Perl script which is invoked by a nightly cron job, which reads through multiple data sources and creates XML feeds.
You neither want to take pain to invoke the Perl debugger in your remote box, using –d switch or to run it from your local by replicating the entire environment by taking database dumps and all that.
All you want to do is to use a tool, which will allow you to run the perl program in the remote machine, and debug it in a GUI tool in your windows, so that, you can watch out for expressions, and check out the values of the variables, and a lot more.
(If you are interested to debug your perl program, the conventional way, visit: - http://debugger.perl.org/)
Assumptions:-
1) You have perl installed in both your local and remote machines.
2) Very IMPORTANT: - Check whether you have connectivity between both the remote and local machines. I.e., two way connectivity. Test by pinging remote machine from local and local machine from remote. The firewall installed in any of the machines should not block the incoming connection from the linux box to the windows box.
Steps to set up the environment:-
In your local windows machine:-
1) Install komodo.
a. You can get a trial version of the latest Komodo from:-http://www.activestate.com/store/evallicense.aspx?PliGuid=8E08763F-FC3D-456F-BE10-F0D725F660F8&
In your remote linux/solaris machine:-
1) Copy Komodo's perl debugger and its associated libraries to the remote machine by copying the entire dbgp/perllib sub-directory of the Komodo installation to the new machine, or download a package from the Komodo Remote Debugging page.
Note: Do not copy perl5db.pl to the standard "lib" directory of the Perl installation on the remote machine, as this will overwrite the standard perl5db.pl file.
On the remote machine, set the PERL5LIB environment variable to the location of the new perl5db.pl and its libraries.
For example:
If perllib was copied to the /home/me/perl/komodo_perl_debugging directory, set the variable as follows:
export PERL5LIB=/home/me/perl/komodo_perl_debugging/perllib
2) On the remote machine, set the PERLDB_OPTS and DBGP_IDEKEY variables.
This tells the Perl interpreter on the remote machine where to connect to Komodo or the DBGP Proxy and how to identify itself.On the remote machine, set the PERLDB_OPTS and DBGP_IDEKEY variables.
PERLDB_OPTS=RemotePort=
DBGP_IDEKEY=
a.The port number must match the port number specified in
i. Goto Edit|Preferences|Debugger.
ii. Click Debug|Listener Status to check the current port.
b.Replace
c.If DBGP_IDEKEY is unset, the USER or USERNAME environment variable is used as the IDE Key.
d.The variable definitions must be on one line.
For example:
export PERLDB_OPTS="RemotePort=127.0.0.1:9000"
export DBGP_IDEKEY="jdoe"
Steps to debug the code:-
1) Listen for Debugger Connections
a. In Komodo, on the Debug menu, click Listen for Debugger Connections.
2) Start the Perl Program on the Remote Machine
a. Start the debugging process using the "-d" flag:
perl -d program_name.pl
3) A Perl Debug tab (a pop-up) is displayed in Komodo, which would say that there is an incoming connection.
4) Debug the Perl Program using Komodo
5) Click Step In, or Go/Continue to run to the first breakpoint. See Komodo Debugger Functions for full instructions on using Komodo's debugging functionality.
Disabling and Enabling the Perl Dev Kit (PDK) Debugger (This may not be always required):-
If you have installed the ActiveState Perl Development Kit (PDK) on the remote machine, the system may be configured to use the PDK debugger when a Perl debug session (perl -d) is launched.
To use Komodo's debugger, disable the PDK debugger on the remote machine first. If necessary, you can re-enable the PDK debugger on the remote machine later.
Disabling the PDK Debugger on the Remote Machine:-
To disable the PDK debugger on the remote machine, perform the following procedures:
export PERLDB_OPTS=
i.e., set the PERL5DB variable to an empty string.
Thursday, January 31, 2008
How to debug a Perl program running in remote Linux machine, from a local windows machine?
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment