Mar 31, 2015

Wing IDE Pro's debugger makes it easier to work interactively with Python. In addition to debugging, it is also a great way to navigate and understand unfamiliar code, and to write new code interactively in the live runtime state for which it is being designed.

Debug Probe

The Debug Probe is an important part of Wing's support for interactive development. This is a Python shell that works in the current debug stack frame when the debug process is paused by a breakpoint or exception.

Debug Probe

To use the Debug Probe, set a breakpoint in your code and start debugging from the toolbar icon debug or Debug menu. When you reach the breakpoint or any exception, you can start working interactively in the Debug Probe.

The menus at the top of the Debug Probe are used to select the process, thread, and stack frame you want to work within. Any changes made in the Debug Probe, or side effects of code that is invoked here, are made within the selected stack frame.

The Debug Probe provides auto-completion that is integrated with Wing's Source Assistant, where you can see call signature, documentation, and other information relevant to the code you are typing.

Source Assistant

You can easily jump to point of definition of symbols in the debug probe or their types by pressing F4 or by navigating from the links in the Source Assistant.

Conditional Breakpoints

Conditional breakpoints are handy for isolating a particular case for which new code is being written, giving you direct and convenient access to the actual data being passed to the code that you are working on. Everything you write can immediately be tested against the live runtime state.

Setting a Conditional Breakpoint

To set or edit a conditional breakpoint, right click on the left-most margin in the editor. Breakpoints can also be ignore-counted or enabled/disabled from here, and an overview of breakpoints with statistics is available in the Breakpoints tool in the Tools menu.

Active Ranges

In some cases it's useful to set a range of code in the editor as active in the Debug Probe, in order to make it easier to execute while working on it. This is done with the icons in the upper right corner of the Debug Probe.

Active Range in the Debug Probe

Once an active range is set, it is highlighted in the editor and can be sent to the Debug Probe by pressing the icon in the top right of the Debug Probe or by binding a key to the command debug-probe-evaluate-active-range.

Getting Started with Wing IDE

A quick introduction to Wing IDE's features can be found in our Feature Overview Screencast.

Or just download Wing IDE and give it a try. The Tutorial in Wing's Help menu is a great way to get started.

Share this article:






Mar 20, 2015

Wing IDE Pro's debugger makes is easier to work interactively with Python. In addition to debugging, it is also a great way to navigate and understand unfamiliar code, and to write new code interactively in the live runtime state for which the code is being designed.

Starting with Wing 5.1, multiple debug connections can be made at once, so it is much easier to write and debug multi-process code.

Multi-Process Debugging

Wing 5.1 adds a process selector wherever a stack selector is shown in the user interface, in addition to a thread selector if there are multiple threads in the debug process. The process selector groups processes into a process tree, showing the relationship between them regardless of how they were created or debug-enabled.

Process Selector

When multiple processes are being debugging, pressing the Alt key causes the Debug/Continue, Stop, Restart, and Pause toolbar icons to apply that operation to all the active processes:

/images/blog/multiprocess-debug/toolbar.png

These operations are also in the Debug > Processes menu, along with commands for starting additional new debug processes from the IDE.

Options to control multi-process debugging are in the Debugger > Processes preferences group. For example, you can control when Wing switches to a newly attached debug process and which processes to kill when killing a single debug process.

Multi-Process Debug Preferences

Automatically Debugging Child Processes

Optionally, you can also automatically debug-enable sub-processes created with multiprocessing, via sys.executable, and (on Posix) with os.fork().

Automatically debugging child processes is off by default since it can be confusing or unwanted in some code bases. It can be enabled with the Debugger > Processes > Debug Child Processes preference or (preferably, in most cases) on a project-by-project basis with the Debug/Execute > Debug Child Properties setting in Project Properties.

Enabling Child Process Debugging

This option is useful when working with auto-reloading web application frameworks like Flask or Google App Engine, because Wing will automatically debug the reloaded server processes.

Manually Debugging Child Processes

There are cases where sub- processes cannot be automatically debugged, such as when os.exec() is used (on Posix) or if the process is started without referencing sys.executable. In these cases, the process can still be debugged by importing wingdbstub, which is a module provided by Wing IDE to initiate debugging from outside of the IDE.

In these cases, you will need to enable Accept Debug Connections by clicking on the bug icon in the lower left of Wing's window. This causes Wing to use a fixed port for accepting debug connections. The default matches the port configured wingdbstub.py in your Wing IDE installation.

Details on doing this are in Debugging Externally Launched Code in Wing's reference manual.

Resources

More information can be found in Multi-Process Debugging in the Wing IDE manual.

A quick introduction to Wing IDE's features can be found in our Feature Overview Screencast.

Or just download Wing IDE and give it a try. The Tutorial in Wing's Help menu is a great way to get started.

Share this article:






Mar 11, 2015

Wing IDE Pro's debugger makes is easier to work interactively with Python. In addition to debugging, it is also a great way to navigate and understand unfamiliar code, and to write new code interactively in the live runtime state for which the code is being designed.

A great little feature in Wing's debugger is the ability to move the program counter back to code you have already executed. This way, if you debug too far you can go back without having to restart your debug process.

This is done by right-clicking on the line where you want to move the program counter and selecting Move Program Counter Here:

Move Program Counter

That's all there is to it!

Move Program Counter Result

Note that due to the way Python is implemented, the program counter can only be moved within the current bottom-most stack frame.

To try this out, download Wing now!

Share this article:






Sep 12, 2014

An often-requested feature that we've added to Wing IDE version 5.0.9 is the ability to mark a range of code in the editor as "active" so it is easily reevaluated in the Python Shell or Debug Probe. This makes it easier to work interactively with Python without having to copy and paste code between the Python Shell or Debug Probe and the editor.

To use this feature, select a range of code in the editor and press the Set Active Range icon setactiverange in the top right of the Python Shell or Debug Probe. This marks the range in the editor and adds an Evaluate Active Range icon evaluate-active-range for evaluating the range and a Visit Active Range icon visit-active-range for visiting the active range in the editor to the top right of the shell tool. The Remove Active Range remove-active-range icon can be used to remove the active range.

Here is an example of this feature in action, in the integrated Python Shell:



The same capability exists in the Debug Probe, which is a Python Shell that acts in the context of the currently active debug stack frame.

Setting up Key Bindings

There are no default key bindings for these actions, but keys can be bound to them using the User Interface > Keyboard > Custom Key Bindings preference. The commands defined are:

python-shell-toggle-active-range sets or clears the active range in the Python Shell, using the current selection or current line in the editor when setting the range.

python-shell-evaluate-active-range evaluates the current active range in the Python Shell.

python-shell-show-active-range shows the Python Shell's active range in the editor.

Similar commands are defined for the Debug Probe: debug-probe-toggle-active-range, debug-probe-evaluate-active-range, and debug-probe-show-active-range.

Share this article:






Jun 24, 2014

Check out our new screencast, which shows some of the features of Wing IDE Professional version 5 in action:



Share this article:




Older Articles

2014

How to get the most out of Wing IDE Pro's auto-completer and source assistant for Python.   Read more Learn how to use Wing IDE Pro's advanced auto-editing features to speed up writing and modifying Python code.   Read more

Wingware Blog