Last Site Update: February 21st, 2024 | Latest Version: 12.0.0


Main

Download

Screenshots

Manual

Developers

About/Contact


PyDev LiClipse




Previous (Type-hinting with comments) Root Next (Auto Reload in Debugger)


This section is targetted at explaining how to use the debugger. 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: example.py

The first thing we'll want to do is add a breakpoint. Let's do that at line 5 (print(i)). There are some ways for adding a breakpoint:

  • Double-clicking the left ruler;
  • Use Ctrl+F10 to open the context-menu and then select Add Breakpoint;
  • Right-click the left bar to open the context-menu and then select Add Breakpoint;
  • Use Ctrl+Shift+B to toggle the breakpoint in the line (if it doesn't work, go to the customize perspective and enable Breakpoints in Action Set Availability.

If everything goes ok, you'll have the breakpoint shown in your sidebar (as below).

Image: Breakpoint added

Now, to debug that file, you can use Shift+F9 (the editor must be focused). NOTE: if you want to re-run the last executed file, you can use F11 to debug it (if you haven't configured F11 to always launch the last launch in debug mode, make sure you read the Getting Started on Running a program).

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

  • 1. Stack view: You can see the variables in previous stacks by clicking on the stack you want to see.
  • 2. Variables view: It allows you to see the globals and locals for the selected stack.
  • 3. Breakpoints view:Selecting this tab you can see the breakpoints available and enable/disable any breakpoint.
  • 4. Editor: Shows the code and highlights the line that is about to be executed.
  • 5. Console: When you run a file through the PyDev debugger, the first thing that appears is a 'pydev debugger' string, to indicate that you're running the file through the debugger.
  • 6. Console evaluation: You can enter commands to be evaluated in the context of the selected stack (1).

Now, the basic things you can do in the debugger have some keybindings:

  • Step in: F5
  • Step over: F6
  • Step out: F7
  • Resume: F8
  • Toggle Breakpoint: Ctrl+Shift+B
  • Set Next Statement: Ctrl+Alt+R (note that it will set the next line to be executed, not run until some line is hit).
  • Use line prefixed with >>> in the console to evaluate expressions.

And you can also add a watch for some expression or make the breakpoint a conditional breakpoint. We'll see how this works below.

Adding a watch

To 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 breakpoints

To make some breakpoint a conditional breakpoint, you have to go to some line that already has a breakpoint, open the context menu Ctrl+F10 and select breakpoint properties.

Image: Adding a condition to a breakpoint

Doing that will get you to the breakpoint properties panel, where it's possible to enable some condition for the breakpoint to be hit.

Image: Enabling some condition

So, now, if you resume execution, it will only hit that breakpoint again when the condition is evaluated to True.

What more?

Now, on to the Remote Debugger and the Debug Console...





Previous (Type-hinting with comments) Root Next (Auto Reload in Debugger)

PyDev development

PyDev is open source and depends on your contributions! This may be in the form of bug fixes, answers on stackoverflow, new features...

Another option is financially supporting it at: Patreon (which provides a way to support it monthly and get rewards starting with $1).



Or through 1-time contributions at:

  Paypal




Search PyDev-related content







Copyright: Brainwy Software Ltda, 2014-2021