<type>documentation</type>
<domain>debug</domain>
<id>remote-debugging-example</id>
<title>Manually Configured Remote Debugging Example</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>per+</product>

~~~if WINGPRO:
.. note::

  This example is for manually configured remote debugging only.  It is not
  relevant for users of Wing Pro's `Remote Hosts <ref:proj/remote-hosts>`__
  feature.
~~~

~~~if WINGPER:
.. note::

  This example is for manually configured remote debugging only.  It is not
  relevant for users of Wing Pro's `Remote Hosts <https://wingware.com/doc/proj/remote-hosts>`__
  feature.
~~~

Here is a simple example that enables debugging a process running on a Linux host with IP
address ``192.168.1.200``, using Wing running on a Windows host with IP address
``192.168.1.210``.

**Configuring the Connection**

On the Windows host, the following preferences must be specified:

* The `Debugger > Listening > Accept Debug Connections 
  <script:show_preferences_gui#prefname="debug.passive-listen">`__ preference should 
  be enabled
* The `Debugger > Listening > Server Host 
  <script:show_preferences_gui#prefname="debug.network-server">`__ preference should 
  be set to ``All Interfaces`` (this is the default)
* The `Debugger > Listening > Server Port 
  <script:show_preferences_gui#prefname="debug.network-port">`__ preference should 
  be set to 50005 (this is the default)
* The `Debugger > Advanced > Allowed Hosts 
  <script:show_preferences_gui#prefname="debug.passive-hosts">`__ preference should 
  be altered by adding ``192.168.1.200``

On the Linux host, the following value is needed in ``wingdbstub.py``::

  kWingHostPort='192.168.1.210:50005'

Once this is done and Wing has been restarted, you should be able to run code that imports
``wingdbstub`` on the Linux host and see the debug connection establish on the Windows
host.

**File Sharing and Location Map**

Next you will need to set up file sharing between the two machines (for example, with
Samba) and then establish a location map in your Wing preferences on the Windows host.

If your source code on the Linux host is in ``/home/myuser/mysource`` and you map
``/home/myuser`` to ``e:`` on the Windows host, then you would use the `Location Map
<script:show_preferences_gui#prefname="debug.location-map">`__ preference to add one
mapping for remote ip address ``192.168.1.20``, from remote directory
``/home/myuser/mysource`` to local directory ``e:/mysource``.

See `Manually Configured Location Map Examples`__ for other examples.

__ ref:debug/file-location-map-example

