Debugging in VIM

From Koha Wiki

Jump to: navigation, search
Koha > Technical


Debugging Perl CGI mode with VIM

Install the plugin VIM Vdebug

With pathogen

  • Download the plugin
cd ~/.vim/bundle
git clone
  • Add the following line to vimrc
call pathogen#helptags()
  • You can now access Vdebug using the following command
:h Vdebug

Note:Vdebug require vim with compiled in python support. If you're useing Debian Wheezy, then the 'default' vim package does not have this. You can try vim-nox instead ;)

Install Perl module "remote debugging"

This module is provided by ActiveState at the following address [1]

tar xzf Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86.tar.gz

Edit the Apache vHosts

It is necessary to add some environment variables and change the PERL5LIB variable in the virtualhost:

SetEnv PERL5LIB "/home/koha/src:/home/koha/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86"
SetEnv PERL5DB "BEGIN { require q(/home/koha/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86/}"
SetEnv PERLDB_OPTS "RemotePort=localhost:9000"
SetEnv DBGP_IDEKEY "whatever"
SetEnv PERL5OPT "-d"

Remote Debugging won't work under plack; you'll also have to disable plack in the virtualhost as well.

Disable Plack

Restart Apache

Start a debug session

In Vim, open the perl script to debug and press <F5>. From there, you have 20 seconds to launch the web page through a browser. If all went well, 3 new windows open in Vim: you are in debug mode!

Commands available to you in debug mode

<F2> Step over
<F3> Step in
<F4> Step out
<F5> Run
<F6> Stop/Close
<F9> Run to cursor
<F12> Evaluate variable under cursor

See :h Vdebug for more information

Configuration under kohadevbox

Before you run vagrant up, make the following changes to vars/user.yml:

plack: false
# ...
 - vim
# ...
editor: vim

If you're changing an existing kohadevbox, run

vagrant up --provision

Neither the Vdebug vim plugin, nor the PerlRemoteDebugging script are installed ( yet). The steps for installation are the same as above, but should be installed under the vagrant user. You *will* have to install vim-nox:

sudo apt-get install vim-nox

Edit /etc/apache2/sites-enabled/kohadev.conf:

Comment out apache-shared-opac-plack.conf and apache-shared-intranet-plack.conf if they're not commented out already.

Replace SetEnv PERL5LIB line in both the opac and staff sections with the following lines:

   SetEnv PERL5LIB "/home/vagrant/kohaclone:/home/vagrant/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86"
   SetEnv PERL5DB "BEGIN { require q(/home/vagrant/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86/}"
   SetEnv PERLDB_OPTS "RemotePort=localhost:9000"
   SetEnv DBGP_IDEKEY "whatever"
   SetEnv PERL5OPT "-d"

Developer handbook

Personal tools