<type>how-to</type>
<domain>install</domain>
<id>idapython</id>
<title>Using Wing with IDA Python</title>
<date>$Date: 2006-12-28 17:21:05 -0500 (Thu, 28 Dec 2006) $</date>
<product>per+</product>
<summary>Learn how Wing can be used to develop Python code written for the Hex-Rays IDA multi-processor disassembler and debugger.</summary>

.. image:: /images/screenshots/wing7-screenshot-linen.png
  :alt: Wing Screen Shot
  :width: 574
  :height: 423
  :popup: 1

`Wing <https://wingware.com>`__ is a Python IDE that can be used to develop, test, and
debug Python code written for `Hex-Rays IDA
<https://www.hex-rays.com/products/ida/index.shtml>`__ multi-processor disassembler and
debugger. 

Two versions of Wing are appropriate for use with this document: Wing Pro is the
full-featured Python IDE for professional developers, and Wing Personal is a free
alternative with reduced feature set.

If you do not already have Wing installed, `download it now <https://wingware.com/downloads>`__.

This document describes how to configure Wing for IDA. To get started using Wing as your
Python IDE, please refer to the tutorial in Wing's ``Help`` menu or read the `Quickstart
Guide <ref:howtos/quickstart>`__.

**Note:** This document is not maintained and was last tested in 2012.

Debugging IDA Python in Wing
----------------------------

IDA embeds a Python interpreter that can be used to write scripts for the system. In order
to debug Python code that is run within IDA, you need to import a special module in your
code, as follows::

  import wingdbstub
  wingdbstub.Ensure()
  
You will need to copy ``wingdbstub.py`` out of your Wing installation and may need to set
``WINGHOME`` inside ``wingdbstub.py`` to the location where Wing is installed. On OS X,
this is the full path of Wing's ``.app`` folder. 

Even though this is an embedded instance of Python, leave the ``kEmbedded`` flag set to
``0``.

Next click on the bug icon in the lower left of Wing's main window and make sure that
``Accept Debug Connections`` is checked. Then restart IDA and the debug connection will be
made as soon as the above code is executed.

At that point, any breakpoints set in Python code will be reached and Wing can be used to
inspect the runtime state, step through code, and try out new code interactively.

For more information on this configuration, see `Debugging Externally Launched Code
<ref:debug/debugging-externally-launched-code>`__.

Related Documents
-----------------

For more information see:

* `Hex-Rays IDA home page <https://www.hex-rays.com/products/ida/index.shtml>`__ 
  provides links to documentation.

* `Quickstart Guide <ref:howtos/quickstart>`__ contains additional basic information
  about getting started with Wing.
  
* `Tutorial <ref:intro/tutorial>`__ provides a gentler introduction to Wing's features.

* `Wing Reference Manual <ref:manual>`__ documents Wing in detail.
