home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / d / debugger_c next >
Encoding:
Text File  |  1996-11-14  |  4.9 KB  |  105 lines

  1. <TITLE>Debugger Commands -- Python library reference</TITLE>
  2. Next: <A HREF="../h/how_it_works" TYPE="Next">How It Works</A>  
  3. Prev: <A HREF="../t/the_python_debugger" TYPE="Prev">The Python Debugger</A>  
  4. Up: <A HREF="../t/the_python_debugger" TYPE="Up">The Python Debugger</A>  
  5. Top: <A HREF="../t/top" TYPE="Top">Top</A>  
  6. <H1>8.1. Debugger Commands</H1>
  7. The debugger recognizes the following commands.  Most commands can be
  8. abbreviated to one or two letters; e.g. ``<CODE>h(elp)</CODE>'' means that
  9. either ``<CODE>h</CODE>'' or ``<CODE>help</CODE>'' can be used to enter the help
  10. command (but not ``<CODE>he</CODE>'' or ``<CODE>hel</CODE>'', nor ``<CODE>H</CODE>'' or
  11. ``<CODE>Help</CODE> or ``<CODE>HELP</CODE>'').  Arguments to commands must be
  12. separated by whitespace (spaces or tabs).  Optional arguments are
  13. enclosed in square brackets (``<CODE>[]</CODE>'') in the command syntax; the
  14. square brackets must not be typed.  Alternatives in the command syntax
  15. are separated by a vertical bar (``<CODE>|</CODE>'').
  16. <P>
  17. Entering a blank line repeats the last command entered.  Exception: if
  18. the last command was a ``<CODE>list</CODE>'' command, the next 11 lines are
  19. listed.
  20. <P>
  21. Commands that the debugger doesn't recognize are assumed to be Python
  22. statements and are executed in the context of the program being
  23. debugged.  Python statements can also be prefixed with an exclamation
  24. point (``<CODE>!</CODE>'').  This is a powerful way to inspect the program
  25. being debugged; it is even possible to change a variable or call a
  26. function.  When an
  27. exception occurs in such a statement, the exception name is printed
  28. but the debugger's state is not changed.
  29. <P>
  30. <DL>
  31. <DT><B>h(elp) [<VAR>command</VAR></B><DD>]
  32. <P>
  33. Without argument, print the list of available commands.
  34. With a <VAR>command</VAR> as argument, print help about that command.
  35. ``<CODE>help pdb</CODE>'' displays the full documentation file; if the
  36. environment variable <CODE>PAGER</CODE> is defined, the file is piped
  37. through that command instead.  Since the <VAR>command</VAR> argument must be
  38. an identifier, ``<CODE>help exec</CODE>'' must be entered to get help on the
  39. ``<CODE>!</CODE>'' command.
  40. <P>
  41. <DT><B>w(here)</B><DD>Print a stack trace, with the most recent frame at the bottom.
  42. An arrow indicates the current frame, which determines the
  43. context of most commands.
  44. <P>
  45. <DT><B>d(own)</B><DD>Move the current frame one level down in the stack trace
  46. (to an older frame).
  47. <P>
  48. <DT><B>u(p)</B><DD>Move the current frame one level up in the stack trace
  49. (to a newer frame).
  50. <P>
  51. <DT><B>b(reak) [<VAR>lineno</VAR><CODE>|</CODE><VAR>function</VAR></B><DD>]
  52. <P>
  53. With a <VAR>lineno</VAR> argument, set a break there in the current
  54. file.  With a <VAR>function</VAR> argument, set a break at the entry of
  55. that function.  Without argument, list all breaks.
  56. <P>
  57. <DT><B>cl(ear) [<VAR>lineno</VAR></B><DD>]
  58. <P>
  59. With a <VAR>lineno</VAR> argument, clear that break in the current file.
  60. Without argument, clear all breaks (but first ask confirmation).
  61. <P>
  62. <DT><B>s(tep)</B><DD>Execute the current line, stop at the first possible occasion
  63. (either in a function that is called or on the next line in the
  64. current function).
  65. <P>
  66. <DT><B>n(ext)</B><DD>Continue execution until the next line in the current function
  67. is reached or it returns.  (The difference between <CODE>next</CODE> and
  68. <CODE>step</CODE> is that <CODE>step</CODE> stops inside a called function, while
  69. <CODE>next</CODE> executes called functions at (nearly) full speed, only
  70. stopping at the next line in the current function.)
  71. <P>
  72. <DT><B>r(eturn)</B><DD>Continue execution until the current function returns.
  73. <P>
  74. <DT><B>c(ont(inue))</B><DD>Continue execution, only stop when a breakpoint is encountered.
  75. <P>
  76. <DT><B>l(ist) [<VAR>first</VAR> [, <VAR>last</VAR></B><DD>]]
  77. <P>
  78. List source code for the current file.  Without arguments, list 11
  79. lines around the current line or continue the previous listing.  With
  80. one argument, list 11 lines around at that line.  With two arguments,
  81. list the given range; if the second argument is less than the first,
  82. it is interpreted as a count.
  83. <P>
  84. <DT><B>a(rgs)</B><DD>Print the argument list of the current function.
  85. <P>
  86. <DT><B>p <VAR>expression</VAR></B><DD>Evaluate the <VAR>expression</VAR> in the current context and print its
  87. value.  (Note: <CODE>print</CODE> can also be used, but is not a debugger
  88. command --- this executes the Python <CODE>print</CODE> statement.)
  89. <P>
  90. <DT><B>[!</B><DD><VAR>statement</VAR>]
  91. <P>
  92. Execute the (one-line) <VAR>statement</VAR> in the context of
  93. the current stack frame.
  94. The exclamation point can be omitted unless the first word
  95. of the statement resembles a debugger command.
  96. To set a global variable, you can prefix the assignment
  97. command with a ``<CODE>global</CODE>'' command on the same line, e.g.:
  98. <UL COMPACT><CODE>(Pdb) global list_options; list_options = ['-l']<P>
  99. (Pdb)<P>
  100. </CODE></UL>
  101. <DT><B>q(uit)</B><DD>Quit from the debugger.
  102. The program being executed is aborted.
  103. <P>
  104. </DL>
  105.