Archive:Debug python scripts with WinPDB: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Anarchintosh
(→‎Create a symlink for the debugger: added entry for making symlink in Windows)
>Anarchintosh
Line 6: Line 6:


==Create a symlink for the debugger==
==Create a symlink for the debugger==
'''How to make a symlink on Linux'''
'''How to make a symlink in Linux'''
* Assuming your script's name is Foo
* Assuming your script's name is Foo
<pre>
<pre>
Line 13: Line 13:
</pre>
</pre>


'''How to make a symlink on Windows'''
'''How to make a symlink in Windows'''
* Get and open the program [http://dirlinker.codeplex.com/ Directory Linker]
* Get and open the program [http://dirlinker.codeplex.com/ Directory Linker]
* For '''Link Location:''' point to your addon folder in XBMC, and then add winpdb.py on the end of the path. For example:
* For '''Link Location:''' point to your addon folder in XBMC, and then add winpdb.py on the end of the path. For example:

Revision as of 13:23, 3 November 2010

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

How to make a symlink in Linux

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

How to make a symlink in Windows

  • Get and open the program Directory Linker
  • For Link Location: point to your addon folder in XBMC, and then add winpdb.py on the end of the path. For example:
C:\Program Files (x86)\XBMC\addons\plugin.video.icefilms\winpdb.py
  • For Link To: point to where the original winpdp.py file can be found. (Should be with your other Python modules) For example:
C:\Python27\Scripts\winpdb.py
  • Click Go! button

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

Winpdb-session.png