Archive:Debug python scripts with WinPDB

From Official Kodi Wiki
Revision as of 18:20, 3 April 2010 by >Analogue (initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can easily debug python scripts running inside XBMC in a few simple steps!

Requirements

  • XBMC installed on Ubuntu (should work just fine on Windows and Mac too)
  • Install WinPDB
    $ sudo apt-get install winpdb

Create a symlink for the debugger

  • Assuming your script's name is Foo
$ cd /home/<user>/.xbmc/scripts/Foo
$ ln -s `find /usr/lib/pymodules -name rpdb2.py`

Modify your script to enable debugger

  • Edit /home/<user>/.xbmc/scripts/Foo/default.py and add the following code to the top
import rpdb2 
rpdb2.start_embedded_debugger('pw')

Start debugging session

  • From within XBMC, start your script (it will appear to sit there and hang)
  • Start up WinPDB (Desktop Menu Bar -> Applications -> Programming -> Winpdb
  • In WinPDB, select File->Password and enter "pw" (no quotes)
  • Select File->Attach. You should see your running script in the list box along with its PID and filename.
  • Select your script and click OK. The debugger is now attached to your script.

Setting breakpoints

TBD

Screenshot