    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Debuggers Are Still For Wimps</title>
        <link>https://members.accu.org/index.php/journals/2035</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 26, #5 - November 2014 + Programming Topics</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c343/">265</a>
                    (10)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c65/">Programming</a>
                    (877)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c343-65/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c343+65/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Debuggers Are Still For Wimps</h1>
<p><strong>Author:</strong>&nbsp;Martin Moene</p>
<p>
<strong>Date:</strong> 04 November 2014 18:52:12 +00:00 or Tue, 04 November 2014 18:52:12 +00:00</p>
<p><strong>Summary:</strong>&nbsp;Frances Buontempo shows how to remote debug python from Visual Studio.</p>
<p><strong>Body:</strong>&nbsp;<p>Suppose you have a script you want to run on Linux and you only know how to drive the Visual Studio debugger. By installing an add-in for Visual Studio locally, installing the python tools for Visual Studio debugging on the remote machine, e.g. withÂ pip install ptvsd==2.0.0pr1Â and adding a (minimum of) a couple of lines to your script you can debug in Visual Studio even if the remote machine is running Linux. The additional lines are highlighted in the script in Listing 1.</p>

<table class="sidebartable">
	<tr>
		<td>
			<pre class="programlisting">
#!/usr/bin/python

&quot;&quot;&quot;
You will need to insert both these in your script
The remote box requires the ptvsd package (otherwise the import fails)
&quot;&quot;&quot;
import ptvsd
ptvsd.enable_attach(secret = 'joshua')
#use None instead of joshua but that is not secure
#The secret can be any string - but this is not
#properly secure

def say_it(it):
Â  &quot;&quot;&quot;
Â  This inserts a breakpoint
Â  but you can add new breakpoints in Visual Studio
Â  if required too/instead
Â  &quot;&quot;&quot;
Â Â ptvsd.break_into_debugger()
Â  print(it)

if __name__ == &quot;__main__&quot;:
Â  #pause this script til we attach to it
Â Â ptvsd.wait_for_attach()
Â  say_it(&quot;Hello world&quot;)
			</pre>
		</td>
	</tr>
	<tr>
		<td class="title">Listing 1</td>
	</tr>
</table>

<p>Be wary of line endings in VS, which may be inappropriate for Linux. More details are available online. [<a href="#[1]">1</a>]
Youâ€™ll also need to install the ptvs from the relevant msi for your version of Visual Studio. Then start the script on the Linux box:</p>

<pre class="programlisting">
  $python VSPyNoodle.py</pre>
  
<p>It will hang, since it has aÂ wait_for_attachÂ call in main. ctrl-Z will stop it on the remote box if something goes wrong.</p>

<p>Select â€˜Attach to processâ€™ in the Debug menu on Visual Studio, and change the â€˜Transportâ€™ to â€˜Python remote debugging (unsecured)â€™. Add the secret (joshua in this script) @ hostname to Qualifier, for example:</p>

<pre class="programlisting">
  joshua@hostname</pre>

<p>Hit â€˜Refreshâ€™. It should find the process running on the Linux box and add the port it uses to the Qualifier. Select your process in the list box and hit â€˜Attachâ€™ then debug as you are used to in VS.</p>

<p>If it complains about stack frames and not being able to see the code you may need to make a VS project from a local version of the code. having made sure it exactly matches the remote code.</p>

<h2>Reference</h2>

<p class="bibliomixed"><a id="[1]"></a>[1]	SeeÂ <a href="https://pytools.codeplex.com/wikipage?title=Remote%20Debugging%20for%20Windows%2C%20Linux%20and%20OS%20X">https://pytools.codeplex.com/wikipage?title=Remote%20Debugging%20for%20Windows%2C%20Linux%20and%20OS%20X</a></p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
