Bug 18964 - Add a --debugger flag to koha-plack
Summary: Add a --debugger flag to koha-plack
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 20079
  Show dependency treegraph
 
Reported: 2017-07-20 13:48 UTC by Tomás Cohen Arazi
Modified: 2018-12-03 20:05 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Remote debugging capabilities are added to the koha-plack script. This is very important for developers.
Version(s) released in:


Attachments
Bug 18964: Add --debugger option to koha-plack (5.74 KB, patch)
2017-07-21 19:56 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 18964: Add --debugger option to koha-plack (5.92 KB, patch)
2017-07-24 14:56 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 18964: Add --debugger option to koha-plack (6.94 KB, patch)
2017-07-28 18:05 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 18964: Add --debugger option to koha-plack (7.02 KB, patch)
2018-01-10 13:20 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2017-07-20 13:48:31 UTC
It should be great to enhance koha-plack so it provides the following option flags:

--debug: enable debugging mode
--debugger: the remote debugger IP:PORT combination
--ide-key: a string containing the IDE key required by the remote debugging tool in use.
--debugger-dir: the remote debugging library PATH, so it overloads Perl default (i.e. the path to Komodo tool, or Devel::DBGP or whatever is needed by the developer).
Comment 1 Tomás Cohen Arazi 2017-07-21 19:56:35 UTC
Created attachment 65190 [details] [review]
Bug 18964: Add --debugger option to koha-plack

This patch is WIP for people to take a look!
The explanation on how to use it assumes you are running kohadevbox.

This patch adds the following option switches to koha-plack:

--debugger
----------
Toggle debugging

--debugger-key
--------------
Some IDEs require a key, this needs to match because they are picky about it

--debugger-location
-------------------
This option switch is used to specify the host:port your IDE is listening at.
Inside kohadevbox (using Vdebug with Vim) this would be localhost:9000. Outside
kohadevbox it would be 192.168.50.1:9000

--debugger-path
---------------
This is the path in which you installed the Komodo Remote Debugger libraryi [1]. In kohadevbox
you could put the contents of the downloaded .tar.gz in /home/vagrant/dbgp/perllib. That
perllib seems to be required for things to work [2].

You can test with a simple CLI script things work:

PERL5LIB=/home/vagrant/dbgp/perllib:$PERL5LIB \
PERLDB="BEGIN { require q(/home/vagrant/dbgp/perllib/perl5db.pl) }" \
PERLDB_OPTS="RemotePort=192.168.50.1:9000" perl -d t/Prices.t

If you see action on your IDE, you are on the right track.

WARNING: The main difficulty I found was setting the right dir/file mappings.

[1] http://code.activestate.com/komodo/remotedebugging/
[2] https://github.com/Komodo/KomodoEdit/issues/644#issuecomment-236268012
Comment 2 Tomás Cohen Arazi 2017-07-21 19:57:23 UTC
Hi, I put this together so you can actually help me making it work properly.
Comment 3 Tomás Cohen Arazi 2017-07-24 14:56:57 UTC
Created attachment 65196 [details] [review]
Bug 18964: Add --debugger option to koha-plack

This patch is WIP for people to take a look!
The explanation on how to use it assumes you are running kohadevbox.

This patch adds the following option switches to koha-plack:

--debugger
----------
Toggle debugging

--debugger-key
--------------
Some IDEs require a key, this needs to match because they are picky about it

--debugger-location
-------------------
This option switch is used to specify the host:port your IDE is listening at.
Inside kohadevbox (using Vdebug with Vim) this would be localhost:9000. Outside
kohadevbox it would be 192.168.50.1:9000

--debugger-path
---------------
This is the path in which you installed the Komodo Remote Debugger libraryi [1]. In kohadevbox
you could put the contents of the downloaded .tar.gz in /home/vagrant/dbgp/perllib. That
perllib seems to be required for things to work [2].

You can test with a simple CLI script things work:

PERL5LIB=/home/vagrant/dbgp/perllib:$PERL5LIB \
PERLDB="BEGIN { require q(/home/vagrant/dbgp/perllib/perl5db.pl) }" \
PERLDB_OPTS="RemotePort=192.168.50.1:9000" perl -d t/Prices.t

If you see action on your IDE, you are on the right track.

WARNING: The main difficulty I found was setting the right dir/file mappings.

[1] http://code.activestate.com/komodo/remotedebugging/
[2] https://github.com/Komodo/KomodoEdit/issues/644#issuecomment-236268012
Comment 4 Tomás Cohen Arazi 2017-07-28 18:05:08 UTC
Created attachment 65318 [details] [review]
Bug 18964: Add --debugger option to koha-plack

CAVEAT: This patch is only about allowing koha-plack to start a debugging
session on a remote target. Configuring all the needed pieces to make it
work is out of the scope of the bug. Testing should be focused (mainly) on
making sure this introduces NO REGRESSIONS on regular use (i.e. not debugging).

This patch adds the following option switches to koha-plack:

--debugger
----------
Toggle debugging

--debugger-key
--------------
Some IDEs require a key, this needs to match because they are picky about it

--debugger-location
-------------------
This option switch is used to specify the host:port your IDE is listening at.
Inside kohadevbox (using Vdebug with Vim) this would be localhost:9000. Outside
kohadevbox it would be 192.168.50.1:9000

--debugger-path
---------------
This is the path in which you installed the Komodo Remote Debugger library [1]. In kohadevbox
you could put the contents of the downloaded .tar.gz in /home/vagrant/dbgp/perllib. That
perllib seems to be required for things to work [2].

You can test with a simple CLI script things work:

PERL5LIB=/home/vagrant/dbgp/perllib:$PERL5LIB \
PERLDB="BEGIN { require q(/home/vagrant/dbgp/perllib/perl5db.pl) }" \
PERLDB_OPTS="RemotePort=192.168.50.1:9000" perl -d t/Prices.t

If you see action on your IDE, you are on the right track on the IDE side.

To test:
- Apply this patch
- Enable remote debugging on your IDE, on port 9000 (or adjust the command
  below to match your IDE's listening port).
- Download the Komodo Remote Debugger package, and place the package's contents
  in /home/vagrant/dbgp/perllib (you should see perl5db.pl in there).
- Run:
  $ sudo koha-plack --stop kohadev
  $ sudo kohaclone/debian/koha-plack --start \
                                     --debugger \
                                     --debugger-path /home/vagrant/dbgp/perllib \
                                     --debugger-location 192.168.50.1:9000 \
                                     kohadev
=> SUCCESS: You IDE/tool gets a connection from the Plack process.
- Sign off :-D

The explanation on how to use it assumes you are running kohadevbox.

WARNING: The main difficulty I found was setting the right dir/file mappings.

[1] http://code.activestate.com/komodo/remotedebugging/
[2] https://github.com/Komodo/KomodoEdit/issues/644#issuecomment-236268012
Comment 5 Jonathan Druart 2018-01-10 13:20:52 UTC
Created attachment 70401 [details] [review]
Bug 18964: Add --debugger option to koha-plack

CAVEAT: This patch is only about allowing koha-plack to start a debugging
session on a remote target. Configuring all the needed pieces to make it
work is out of the scope of the bug. Testing should be focused (mainly) on
making sure this introduces NO REGRESSIONS on regular use (i.e. not debugging).

This patch adds the following option switches to koha-plack:

--debugger
----------
Toggle debugging

--debugger-key
--------------
Some IDEs require a key, this needs to match because they are picky about it

--debugger-location
-------------------
This option switch is used to specify the host:port your IDE is listening at.
Inside kohadevbox (using Vdebug with Vim) this would be localhost:9000. Outside
kohadevbox it would be 192.168.50.1:9000

--debugger-path
---------------
This is the path in which you installed the Komodo Remote Debugger library [1]. In kohadevbox
you could put the contents of the downloaded .tar.gz in /home/vagrant/dbgp/perllib. That
perllib seems to be required for things to work [2].

You can test with a simple CLI script things work:

PERL5LIB=/home/vagrant/dbgp/perllib:$PERL5LIB \
PERLDB="BEGIN { require q(/home/vagrant/dbgp/perllib/perl5db.pl) }" \
PERLDB_OPTS="RemotePort=192.168.50.1:9000" perl -d t/Prices.t

If you see action on your IDE, you are on the right track on the IDE side.

To test:
- Apply this patch
- Enable remote debugging on your IDE, on port 9000 (or adjust the command
  below to match your IDE's listening port).
- Download the Komodo Remote Debugger package, and place the package's contents
  in /home/vagrant/dbgp/perllib (you should see perl5db.pl in there).
- Run:
  $ sudo koha-plack --stop kohadev
  $ sudo kohaclone/debian/koha-plack --start \
                                     --debugger \
                                     --debugger-path /home/vagrant/dbgp/perllib \
                                     --debugger-location 192.168.50.1:9000 \
                                     kohadev
=> SUCCESS: You IDE/tool gets a connection from the Plack process.
- Sign off :-D

The explanation on how to use it assumes you are running kohadevbox.

WARNING: The main difficulty I found was setting the right dir/file mappings.

[1] http://code.activestate.com/komodo/remotedebugging/
[2] https://github.com/Komodo/KomodoEdit/issues/644#issuecomment-236268012

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2018-01-10 13:23:39 UTC
Note: You will need the python3 version of vdebug if you are running python3: https://github.com/markkimsal/vdebug/tree/python3
(which does not work really well)
Comment 7 Jonathan Druart 2018-01-23 19:07:59 UTC
Waiting for too long, skipping QA.
Comment 8 Jonathan Druart 2018-01-30 16:38:31 UTC
Pushed to master for 18.05
Comment 9 Nick Clemens 2018-02-02 14:21:52 UTC
Awesome work all, enhancement, not backported for 17.11.x