|
Last Site Update: 26 August 2008 | Latest Version: 1.3.20 |
|
|
|
|
|
|
|
|
|
|
||||||
The debugger is available for both, the Pydev 'Open Source' version and the Pydev Extensions, however, the Pydev Extensions plugin allows you to debug from a program that is not launched from within Eclipse. That's the only difference between them. You can use both to debug multi-threaded programs, evaluate expressions, etc. This section is targetted at explaining how to use the debugger from any version of Pydev. If you want more details on how to use the remote debugger, please check the Remote Debugger page. Ok, probably the first thing you'll want to do is: add a breakpoint to some file and then run the file (and wait for it to hit the breakpoint). To do that, let's start with the example below:
Image: mod1.py The first thing we'll want to do is add a breakpoint. Let's do that at line 5 (print i). There are 2 ways of adding a breakpoint:
Image: Context-menu If everything goes ok, you'll have the breakpoint shown in your sidebar (as below).
Image: Breakpoint added NOTE: if you are putting the breakpoint in an external file (e.g.: some file in the site-packages), the left ruler will not appear, so, you'll not see the breakpoint. That's an Eclipse bug in version 3.1. It appears to be fixed for Eclipse 3.2, but as Eclipse 3.2 currently only has only 'development' releases, it is unsupported. Now, to run that file, you can rigth click the file and choose to debug the file as a 'python run'. NOTE: if you want to re-run the last executed file, you can click F11 to debug it.
Image: Running the file in the debugger When it hits the breakpoint, it will ask you to go to the debug perspective (you should say YES to this dialog).
Image: Go to perspective dialog This perspective has the actions needed for debugging and allows you to see the variables and evaluate expressions.
Image: Debug perspective
Now, the basic things you can do in the debugger have some keybindings:
And you can also evaluate some expression or make the breakpoint a conditional breakpoint. We'll see how this works below. Evaluating some expressionTo evaluate some expression, you can simply select the piece of code you want to evaluate, right-click it and select 'watch'
Image: Evaluating expression Doing so will open a new view that allows you to view the result of evaluating that piece of code in the current context. It allows you to edit some existing watch, add a new one or remove an existing (right clicking it provides all those actions).
Image: Evaluate Expression view Conditional breakpointsTo make some breakpoint a 'conditional breakpoint', you have to go to some line that already has a breakpoint, type Ctrl+F10 and select breakpoint properties.
Image: Adding a condition to a breakpoint Doing that will give you the following screen:
Image: Breakpoint Properties In this screen, you can enable some condition...
Image: Enabling some condition So, now, if you resume execution, it will only hit that breakpoint again when the condition is evaluated to True. Remote debuggerNow, the only thing missing is the remote debugger (available only in Pydev Extensions). To see how to use it, just click 'next'...
|
|||||||
|
© Copyright: Aptana, Inc. 2008 |