~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/debug-with-emacs.html

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
 
2
  <head>
 
3
<title>Twisted Documentation: Debugging Python(Twisted) with Emacs</title>
 
4
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
 
5
  </head>
 
6
 
 
7
  <body bgcolor="white">
 
8
    <h1 class="title">Debugging Python(Twisted) with Emacs</h1>
 
9
    <div class="toc"><ol/></div>
 
10
    <div class="content">
 
11
<span/>
 
12
 
 
13
<img src="http://yellow5.com/pokey/archive/pokey411_3.gif"/>
 
14
<a href="#footnote-1" title="POKEY THE PENGUIN IS COPYRIGHT © 1998-2002 THE AUTHORS"><super>1</super></a>
 
15
 
 
16
<ul>
 
17
  <li>Open up your project files. sometimes emacs can't find them if you
 
18
   don't have them open before-hand.</li>
 
19
 
 
20
  <li>Make sure you have a program called <code class="shell">pdb</code> somewhere
 
21
  in your PATH, with the following contents:
 
22
 
 
23
  <pre class="shell" xml:space="preserve">#!/bin/sh
 
24
exec python2.3 /usr/lib/python2.3/pdb.py $1 $2 $3 $4 $5 $6 $7 $8 $9
 
25
  </pre></li>
 
26
  
 
27
  <li>Run <code class="shell">M-x pdb</code> in emacs. If you usually run your
 
28
  program as <code class="shell">python foo.py</code>, your command line should be <code class="shell">pdb
 
29
  foo.py</code>, for <code class="shell">twistd</code> and <code class="shell">trial</code> just
 
30
  add -b to the command line, e.g.: <code class="shell">twistd -b -y  my.tac</code></li>
 
31
 
 
32
  <li>while pdb waits for your input, go to a place in your code and hit
 
33
   <code class="shell">C-x SPC</code> to insert a break-point. pdb should say something happy.
 
34
   Do this in as many points as you wish.</li>
 
35
 
 
36
   <li>Go to your pdb buffer and hit <code class="shell">c</code>; this runs as normal until a
 
37
   break-point is found.</li>
 
38
 
 
39
   <li>once you get to a breakpoint, use <code class="shell">s</code> to step, <code class="shell">n</code> to run the
 
40
   current line without stepping through the functions it calls, <code class="shell">w</code>
 
41
   to print out the current stack, <code class="shell">u</code> and <code class="shell">d</code> to go up and down a
 
42
   level in the stack, <code class="shell">p foo</code> to print result of expression <code class="shell">foo</code>.</li>
 
43
 
 
44
   <li>recommendations for effective debugging:
 
45
   <ul>
 
46
     <li>use <code class="shell">p self</code> a lot; just knowing the class where the current code
 
47
     is isn't enough most of the time.</li>
 
48
     <li>use <code class="shell">w</code> to get your bearings, it'll re-display the current-line/arrow</li>
 
49
     <li>after you use <code class="shell">w</code>, use <code class="shell">u</code> and <code class="shell">d</code> and lots more <code class="shell">p self</code> on the
 
50
     different stack-levels.</li>
 
51
     <li>If you've got a big code-path that you need to grok, keep another
 
52
      buffer open and list the code-path there (e.g., I had a
 
53
      nasty-evil Deferred recursion, and this helped me tons)</li>
 
54
    </ul>
 
55
  </li>
 
56
</ul>
 
57
 
 
58
 
 
59
<h2>Footnotes</h2><ol><li><a name="footnote-1"><span class="footnote">POKEY THE PENGUIN IS COPYRIGHT © 1998-2002
 
60
THE AUTHORS</span></a></li></ol></div>
 
61
 
 
62
    <p><a href="index.html">Index</a></p>
 
63
    <span class="version">Version: 10.0.0</span>
 
64
  </body>
 
65
</html>
 
 
b'\\ No newline at end of file'