Difficulty Getting Remote Debugging Working with Perl 5.22 on Ubuntu 16.04 LTS

I need to get Komodo IDE working to debug a Perl script on a remote Ubuntu 16.04 LTS server that I have running on a provider. This server is setup specifically to develop and test this Perl script. The reason I’m using it is that I’m writing scripts to manipulate text that’s stored in Movable Type (a Perl-based Content Management System). My scripts to do this manipulation have to be written in Perl to access Movable Type’s most-widely-used API.

I set up debugging as follows:

I added the following code to .bashrc:

Set PERL5LIB, PERLDB_OPTS, and DBGP_IDEKEY for Komodo Remote Perl Debugger

export PERL5LIB=/usr/share/perl/5.22.1/dbgp/perllib
export PERLDB_OPTS=RemotePort=“127.0.0.1:9000”
export DGBP_IDEKEY=“daveaiello”

Pretty certain that I am not exposing anything secret above.

I am invoking the proxy as follows:

root@localhost:~/debug-proxy# ./pydbgpproxy -i 9001 -d 9000

I believe that Komodo IDE is setup correctly. See the attached screenshots.

I invoke my script in the following manner (the server IP address is intentionally blurred):

root@localhost:/usr/lib/cgi-bin/mt# perl -d build/l10n/pageapply.pl --author After6 --basefile 2019-3-29-base-new_ES.file --website 81 > pageapply-output.txt

The output from the pydbgpproxy is as follows:

root@localhost:~/debug-proxy# ./pydbgpproxy -i 9001 -d 9000

INFO: dbgp.proxy: starting proxy listeners. appid: 10001

INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000

INFO: dbgp.proxy: IDE listener on 127.0.0.1:9001

INFO: dbgp.proxy: connection from 127.0.0.1:32942 [<main.sessionProxy instance at 0x7f5c0b886ea8>]

WARNING: dbgp.proxy: No server with key , stopping request [<main.sessionProxy instance at 0x7f5c0b886ea8>]

INFO: dbgp.proxy: session stopped

Sorry to ask in such an open-ended way, but, can anyone see what am I doing incorrectly?

Hey @daveaiello,

That all looks good too me. You could try adding -l DEBUG to the ./pydbgpproxy -i 9001 -d 9000 to see if we can get some additional information from the proxy about what it thinks is going on.

  • Carey

root@localhost:~/debug-proxy# ./pydbgpproxy -i 9001 -d 9000 -l DEBUG

INFO: dbgp.proxy: starting proxy listeners. appid: 14244

INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000

INFO: dbgp.proxy: IDE listener on 127.0.0.1:9001

INFO: dbgp.proxy: connection from 127.0.0.1:32946 [<main.sessionProxy instance at 0x7fcac00efef0>]

DEBUG: dbgp.proxy: session getting data

DEBUG: dbgp.proxy: data: [‘289\x00<?xml version=“1.0” encoding=“UTF-8” ?>\n<init xmlns=“urn:debugger_protocol_v1”\n\t\t\t\tappid=“14263”\n\t\t\t\tidekey=“”\n\t\t\t\tparent=“”\n\t\t\t thread=“0”\n\t\t\t language=“Perl”\n\t\t\t protocol_version=“1.0” fileuri=“file:///usr/lib/cgi-bin/mt/build/l10n/pageapply.pl” hostname=“localhost”/>\x00’]

DEBUG: dbgp.proxy: session dispatching call ‘<?xml version=“1.0” encoding=“UTF-8” ?>\n<init xmlns=“urn:debugger_protocol_v1”\n\t\t\t\tappid=“14263”\n\t\t\t\tidekey=“”\n\t\t\t\tparent=“”\n\t\t\t thread=“0”\n\t\t\t language=“Perl”\n\t\t\t protocol_version=“1.0” fileuri=“file:///usr/lib/cgi-bin/mt/build/l10n/pageapply.pl” hostname=“localhost”/>’

WARNING: dbgp.proxy: No server with key , stopping request [<main.sessionProxy instance at 0x7fcac00efef0>]

INFO: dbgp.proxy: session stopped

DEBUG: dbgp.proxy: destructor [<main.sessionProxy instance at 0x7fcac00efef0>]

Sorry I didn’t notice this the first time but it’s DBGP_IDEKEY.

  • Carey

OK, thanks! I changed the setting in .bashrc:

export PERL5LIB=/usr/share/perl/5.22.1/dbgp/perllib
export PERLDB_OPTS=RemotePort="127.0.0.1:9000"
export DBGP_IDEKEY="daveaiello"

Then I reloaded .bashrc:

root@localhost:~# source .bashrc 

Then I started the proxy:

root@localhost:~/debug-proxy# ./pydbgpproxy -i 9001 -d 9000 -l DEBUG

And ran my script:

root@localhost:/usr/lib/cgi-bin/mt# perl -d build/l10n/pageapply.pl --author After6 --basefile 2019-3-29-base-new_ES.file --website 81 > pageapply-output.txt

… but I think I’m still getting the same error.

INFO: dbgp.proxy: starting proxy listeners. appid: 16944
INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000
INFO: dbgp.proxy: IDE listener on 127.0.0.1:9001
INFO: dbgp.proxy: connection from 127.0.0.1:32994 [<main.sessionProxy instance at 0x7f8d4b62cef0>]
DEBUG: dbgp.proxy: session getting data
DEBUG: dbgp.proxy: data: [‘289\x00<?xml version="1.0" encoding="UTF-8" ?>\n<init xmlns=“urn:debugger_protocol_v1”\n\t\t\t\tappid=“16963”\n\t\t\t\tidekey=“”\n\t\t\t\tparent=“”\n\t\t\t thread=“0”\n\t\t\t language=“Perl”\n\t\t\t protocol_version=“1.0” fileuri=“file:///usr/lib/cgi-bin/mt/build/l10n/pageapply.pl” hostname=“localhost”/>\x00’]
DEBUG: dbgp.proxy: session dispatching call ‘<?xml version="1.0" encoding="UTF-8" ?>\n<init xmlns=“urn:debugger_protocol_v1”\n\t\t\t\tappid=“16963”\n\t\t\t\tidekey=“”\n\t\t\t\tparent=“”\n\t\t\t thread=“0”\n\t\t\t language=“Perl”\n\t\t\t protocol_version=“1.0” fileuri=“file:///usr/lib/cgi-bin/mt/build/l10n/pageapply.pl” hostname=“localhost”/>’
WARNING: dbgp.proxy: No server with key , stopping request [<main.sessionProxy instance at 0x7f8d4b62cef0>]
INFO: dbgp.proxy: session stopped
DEBUG: dbgp.proxy: destructor [<main.sessionProxy instance at 0x7f8d4b62cef0>]

Did I miss something?
Any other suggestions?

Thanks,

–Dave

@daveaiello, I suppose a safe thing would be to double check that the envvar got set by echoing it. I’ll see if I can reproduce.

  • Carey

I wasn’t able to get a debug sessions started but I did get interesting info back:

C:\Users\cgcho\Komodo IDE 11.1.2\lib\support\dbgp\bin>pydbgpproxy.exe -i 9001 -d 9000 -l DEBUG
INFO: dbgp.proxy: starting proxy listeners.  appid: 144032
INFO: dbgp.proxy:     dbgp listener on 127.0.0.1:9000
INFO: dbgp.proxy:     IDE listener on  127.0.0.1:9001
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 60556) [proxyinit -p 60555 -k [...]  -m 1]
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 60557) [proxystop -k cgcho]
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 60560) [proxyinit -p 60559 -k daveaiello -m 1]
[...]

[…] means i snippets lines or details.
Note that your debug output shows no connect from Komodo to the proxy. Make sure Komodo is able to reach the server and that the assigned ports aren’t blocked for some reason.

I’ll see if I can get an actual debug session going when I have another break.

  • Carey

Should I specify the IDE listener on the public IP address for the server and the dbgp listener on the private IP address, i.e. 127.0.0.1?

@careyh we might be making progress. Trying what I asked in my previous question:

I was able to run the following:

root@localhost:~/debug-proxy# ./pydbgpproxy -i 172.104.xxx.xxx:9001 -d 9000 l DEBUG

INFO: dbgp.proxy: starting proxy listeners. appid: 1925

INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000

INFO: dbgp.proxy: IDE listener on 172.104.xxx.xxx:9001

INFO: dbgp.proxy: Server:onConnect ('98.115.172.125', 62207) [proxyinit -p 62206 -k daveaiello -m 1]

INFO: dbgp.proxy: connection from 127.0.0.1:33462 [&lt;__main__.sessionProxy instance at 0x7fc99f9c5998&gt;]

Eventually I following messages get displayed:

ERROR: dbgp.proxy: Unable to connect to the server listener 98.115.172.125:62206 [&lt;__main__.sessionProxy instance at 0x7fc99f9c5998&gt;]

Traceback (most recent call last):

File "./pydbgpproxy", line 220, in startServer

self._server.connect((self._serverAddr[0], self._serverAddr[1]))

File "/usr/lib/python2.7/socket.py", line 228, in meth

return getattr(self._sock,name)(*args)

error: [Errno 110] Connection timed out

WARNING: dbgp.proxy: Unable to connect to server with key [daveaiello], stopping request [&lt;__main__.sessionProxy instance at 0x7fc99f9c5998&gt;]

INFO: dbgp.proxy: session stopped

It’s clear from this output that the proxy is receiving a connection from Komodo IDE 11 on my MacBook Pro. Is the log saying that the proxy isn’t able to send messages back to Komodo?

–Dave

My customer and I were discussing this situation on another messaging platform. He suggested that the proxy may not be able to connect with KomodoIDE because my firewall may be blocking incoming traffic.

We were able to use Port Forwarding on my network’s router to make the connection between the router and KomodoIDE work in some basic way.

The next step was to run the script to be debugged on the remote server via the bash shell. When I did this, I was able to get the output of the script to appear in the “Debug Output” pane of the KomodoIDE. See the screenshot below:

So far I have been unable to control execution remotely. How do I set breakpoints and get them to be respected by Perl running on the remote machine?

–Dave

Morning @daveaiello, Sorry for the delay. I had a msg half written then got distracted by meetings, etc.

Nice progress. I think your next step will be setting Prefs > Debugging: Initial Break Behavior to Break on first executable line. That should cause Komodo to open the file and stop execution. Then you can set breakpoints.

It should also ask you if you want to setup a Mapping between local files and remote files. I recommend you do that so you can then set break points in other file in the local files and Komodo will map to that file when debugging. This also allows you to edit the files thought the edits obviously won’t be reflected in the remote files, unless you’re syncing the changes there as you go.

  • Carey

Hi @careyh:

That did the trick. Now I need to familiarize myself with when to step in, step over, etc.

I want to map some of the files on the remote server to local files and leave some of the files on the remote server unmapped. The reason we are using a remote server in the first place is because of the impracticality of running the entire LAMP / MAMP stack and Movable Type on an SSD-based MacBook Pro.

I think I’m at the point where I need to be to get started with the code I’m trying to debug. Thanks very much for your help!

Morning @daveaiello,

Glad we’ve been able to get you going this far. How about this, if you want to setup mapping let’s start a new thread specifically about that. This thread wraps up pretty nicely at this point.

  • Carey

I should clarify; were you asking for guidance here?

Sorry I haven’t replied. I was away over Labor Day Weekend and fell behind this week.

I’m not really asking for guidance at the moment. If I run into situations I don’t understand, I will start a new issue.

Thanks!

1 Like