home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March / PCWK3A99.iso / Linux / DDD331 / DDD-3_1_.000 / DDD-3_1_ / ddd-3.1.1 / pydb / Notes next >
Encoding:
Text File  |  1998-11-12  |  7.2 KB  |  152 lines

  1. Files included:
  2.  
  3.   Notes       --  This file
  4.   Release     --  The announcement
  5.   pydb.py     --  The python debugger
  6.   pydbsupt.py --  Support for pydb
  7.   pydbcmd.py  --  A modified version of cmd.py
  8.  
  9.   and either
  10.    cxxtest    --  A test program compiled from cxxtest.C
  11.    cxxtest.C  --  the source for the test program
  12.    ddd.man    --  The ddd manual (man page format, no pictures)
  13.    ddd.ps     --  The ddd manual in postscript format (original ddd-3.0 version)
  14.    ddd        --  DDD as a stripped solaris2.6 binary (compiled with gcc)
  15.   or the directory
  16.    ddd-3.0/   --  The source code for ddd including manuals and test programs
  17.      
  18. INSTALL and Usage notes:
  19.  
  20. 1) You need to copy the pydb.py to some location that is on your PATH,
  21. such as /usr/local/bin.  (While you can leave it in '.', DDD may not
  22. include it in its menu of available debuggers (a quirk!).  Aside from
  23. that, it will work fine in the local directory.)  But wherever you
  24. copy/move the file, be sure to (re)name it 'pydb' (no extension).  The
  25. support files pydbcmd.py (a very slightly modified version of cmd.py)
  26. and pydbsupt.py need to be somewhere where 'import' can find them.
  27.  
  28. 2) Build DDD if you aren't using the prebuilt binary by changing to the
  29. DDD-3.0 directory and following the directions (the usual ./configure,
  30. make, make install).  The prebuilt binary was built without any flags
  31. to "configure" and so expects to land in the default location,
  32. /usr/local/bin.  DDD comes with a small suite of test programs.  With
  33. the binary, I've included one (cxxtest) which may be helpful if you're
  34. exploring DDD for the first time (use 'ddd --gdb').
  35.  
  36. 3) Invoke DDD as 'ddd --pydb' to force it to start up with pydb the
  37. first time (default is gdb).  Under Edit/Preferences/Source, be sure
  38. the 'Refer to Program Source' is set to 'by Full Path Name'.  If you
  39. want line numbers, set the 'Source Indentation' to about 8.
  40. Then invoke 'Edit/Save Options' to record these choices.
  41.  
  42. 4) The DDD manual is quite complete, but, except for the fact that the
  43. Python debugger is called 'pydb', for now there's nothing in the on-line
  44. manual (or the man) page specific to Python; that is, all generic statements
  45. about DDD and its interaction with any inferior debugger (gdb, pydb, etc.)
  46. should work as advertised.  While pydb tries to mimic what gdb can do, gdb
  47. is far more "full-featured" and complex than pydb.  In addition, there are
  48. inherent differences between debugging a compiled C or C++ program and
  49. debugging an interpreted Python one.  The postscript version of the manual
  50. is from the original ddd-3.0 distribution and does not mention pydb at all.
  51.  
  52. 5) Select a .py file from the 'File/Open Source' listing.  In Java, you
  53. would select a class to debug; in C or C++, you'd select an
  54. executable.  From such choices, the possible relevant source files can be
  55. determined.  For Python, you just get a list of .py files in the
  56. current directory, from which you can select one. 
  57.  
  58. RESTRICTION:  Currently, the .py file is both imported and executed.
  59. This means that pydb will prematurely run the code if the file ends
  60. in something like
  61.   main() .  To allow for the import and to be able to 'run' the .py
  62. code once breakpoints are in place, the code should read
  63.   if __name__ == '__main__':
  64.      main()
  65.  
  66. 6) Set a breakpoint or two, and click on the 'Run' button on the
  67. detached command toolbar.  Note that window that shows part of the
  68. chatter between DDD and pydb says to issue a continue command.  Click
  69. on 'cont', and then, per prompt, once more.  Your program should be
  70. running now.
  71.  
  72. 7) Currently, breakpoints cannot be set on the 'def' line for a
  73. method.  The breakpoint is automatically moved to the next executable
  74. line.  Setting a breakpoint on a blank or comment line is not allowed
  75. (nor does it make sense).  Setting one in the middle of a triply quoted
  76. string is makes no sense either, but is not dis-allowed, because I don't
  77. know of a clean and easy way to recognize this case.
  78.  
  79. 8) If the mouse pointer rests on a variable for a bit, a tool tip box
  80. will pop up with the value of the variable.  Due to Python's scope
  81. rules, only variables currently in the local or global namespaces can
  82. be displayed; after all, 'eval' is only so clever.
  83.  
  84. 9) Breakpoints are recognized as the relevant line is about to be
  85. executed.  This means that you can't ask for the value of a local
  86. variable 'i' in i = f(3) until after that line has been executed at
  87. least once and you are still in the relevant namespace.  DDD's
  88. graphical displays necessarily have the same restriction.
  89.  
  90. 10) Since the breakpoint checking mechanism in p(y)db depends on string
  91. comparisons of file names, a breakpoint in XXX.py won't be recognized
  92. as pertaining to /usr/local/lib/python1.5/XXX.py unless full path names
  93. are in use.
  94.  
  95. 11) If you have breakpoints set for one source file, and switch to
  96. another, the breakpoints are *not* removed.  You can readily do so in
  97. the breakpoint editor: select all breakpoints and press 'delete'.
  98.  
  99. 12) The display mechanism in DDD has provision for a format specification.
  100. The format specifiers currently supported are two characters sequences:
  101. a '/' followed by one key from
  102. convert = {'c':"char", 'x':"hex", 'o':"octal", 'f':"float", 's':"string",
  103.            't':"binary [twos]"}.
  104. If no format is given, the result of applying 'str()' is used.  In the
  105. dialog box where these are set are examples of use.
  106.  
  107. 13) Displays of lists don't work properly.  If you ask for a display of
  108. list 't', for instance, you'll just get the first element of the list.
  109. To see the full list, right click on the display of 't' to get the popup
  110. menu and select 'new display' and then a format.  This new display will show
  111. the full list, but it won't update.
  112.  
  113.  
  114. Things for later:
  115.  
  116.     No "until" capability
  117.     Display of "structures" (lists, etc.) doesn't work properly (yet)
  118.     Pydb shouldn't require the "if __name__ == '__main__'" construct
  119.     Sessions don't handle displays correctly.
  120.     No class Browser
  121.     No ability to define your own commands
  122.     ... and several others of course...
  123.  
  124.  
  125. Pydb run standalone:
  126.  
  127. Note that you don't need DDD to use pydb.  You just invoke it, issue
  128. the command "file file_name.py", set some breakpoints (as in "b
  129. xfd.py:244" or "b whrandom.random"), and then "run".  "info
  130. breakpoints" is useful.  "help" isn't a bad choice either.
  131.  
  132. Why 'pydb'?:
  133.  
  134. The obvious choice is 'pdb' for the debugger.  But this would lead to
  135. confusion with the canonical pdb, and there's been some discussion
  136. about connecting DDD and Perl (and hence pdb).  Besides, 'pdb' feels a
  137. little leaden to me, and 'pie-db' ought to lead to a nice play on words
  138. (Simple Simon met a pieman...) once I figure it out.
  139.  
  140. Debugging the debugger:
  141.  
  142. The number of possible programs and interactions between any program,
  143. pydb, and DDD makes for a vast sea.  There are likely to be shoals and
  144. reefs.  If you should run aground, some immediately useful information
  145. may be found in the command window.  You can also issue commands to
  146. pydb in that window.  If the problem is that the interaction between
  147. DDD and pydb is at fault, save the log file that you'll find in your
  148. home directory (unless you changed the default): ~/.ddd/log.  All the
  149. dialog between pydb and DDD is recorded there, along with some DDD
  150. state changes.  For complex problems, I'll need that file and your
  151. Python code to debug the debugger.
  152.