Koozali SME Server Debugging

From SME Server
Revision as of 12:46, 27 June 2016 by ReetP (talk | contribs) (Created page with "===Server debugging=== One issue that is often found to be problematic by new developers is debugging perl code on your SME server. There are several ways to do this, both l...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Server debugging

One issue that is often found to be problematic by new developers is debugging perl code on your SME server.

There are several ways to do this, both locally and remotely.

Locally using perl -d

There are a number of tutorials online.

To start you use

perl -d myFile.pl

There are then a number of options you can use to control the debugger

l 10 - list line 10
l get_pattern - find lines matching 'pattern'
b 22 - set breakpoint at line 22
s - step forward a line including all subroutines
n - step forward a line but jump through subroutines
c - continue to next break point
c 47 - continue to line 47
p $variable - print variable

q - quit


Remotely using an IDE

I have been using Komodoedit IDE courtesy of an Open Source Developers licence from Activestate

The simplest mode to use with Komodo is to just use the IDE as a debugger to step through code without actually editing in the IDE.

http://docs.komodoide.com/Manual/debugperl


Server setup

Single machine setup

This will enable us to work with one desktop and one server. See the section on debug proxy for multiple connections

From your installed Komodo directory we need to copy a set of files to the server.

I actually copied the entire dbgp directory as there are other files in there that are useful including the debug proxy.

scp -r ~/komdoeditDirectory/lib/support/dbgp root@some.server://opt/

We should now have /opt/dbgp on the server

We now need to set some paths on the server:

export PERL5LIB=/opt/dbgp/perllib:$$PERL5LIB
export PERLDB_OPTS=RemotePort=your.desktop.i.p:9020 async=1

Note: As with local debugging, the Break Now function is disabled by default and enabled with async - see the docs for more information

On your desktop we need to set up the Listener for Komodo.

Edit/Preferences/Debugger/Connection
Set a specific port to 9020 (match the port above)

Now we need to start a program on the server. The debug code will then call Komodo.

The following forms should work

perl -d myFile.pl

Add -d to the header of your file e.g.

#!/usr/bin/perl -w -d

Then do

perl myFile.pl

Add -d to /sbin/e-smith/signal-event

Then do

signal-event some-event

You should get a popup from Komodo stating that a remote application has requested a debugger session. When you click yes you will get a second box stating that a mapping could not be opened. If we are just going to use Komodo as a debugger then we can answer no and you are then in debug mode allowing you to step through the code and view variables.

Mapping for editing

Should you wish to actually edit code as well you will need to set up some form of file mapping between the remote copy and your local copy.

Note that without some of the esmith libraries installed locally you will get some warnings about only being able to open files read only but if you are not actually editing those libraries with warnings can be ignored and the files opened read only to step through

In Komodo preferences you need to setup a Server/Remote Account for the remote server. scp should work.

You can then set up a mapping similar to this:

URI : file://v9-test/etc/e-smith/
Maps To : /home/john/git/smeserver-libreswan/smeserver-libreswan/root/etc/e-smith/

You should now be able to edit any files that are present on your local machine

Multiple machine debug proxy

TBA