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 / TIPS < prev    next >
Encoding:
Text File  |  1998-11-29  |  10.7 KB  |  279 lines

  1. # $Id: TIPS,v 1.43 1998/11/29 11:25:08 zeller Exp $ -*- autoconf -*-
  2. # DDD tips of the day.
  3.  
  4. # Copyright (C) 1998 Technische Universitaet Braunschweig, Germany.
  5. # Written by Andreas Zeller <zeller@ips.cs.tu-bs.de>.
  6. # This file is part of DDD.
  7. # DDD is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. # DDD is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. # See the GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public
  16. # License along with DDD -- see the file COPYING.
  17. # If not, write to the Free Software Foundation, Inc.,
  18. # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. # DDD is the data display debugger.
  20. # For details, see the DDD World-Wide-Web page, 
  21. # `http://www.cs.tu-bs.de/softech/ddd/',
  22. # or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.
  23.  
  24. # This is a list of tips for DDD.  Every time DDD is started, one tip
  25. # will be selected from this file and will be displayed in the `Tip of
  26. # the day' dialog.
  27. #
  28. # - Lines starting with `#' and `!' are comments.
  29. #   `!` comments will appear in the resource file, `#' comments will not.
  30. # - Blank lines or comments separate two tips (they are not ignored).
  31. #   Multiple blank lines are treated as one.  If you want to have a
  32. #   blank line in a tip, put a space or tab in it.
  33. # - Text will appear in the dialog as it is in this file.  This is
  34. #   done on purpose in order to have more freedom in the layout of the
  35. #   tips than with automatic word-wrapping, but this also means that
  36. #   you have to avoid excessively long lines in this file.
  37. # - This file is processed by M4 and may contain typesetting macros.
  38. #   See `ddd/macros.m4' for details.
  39. # - Tips should be concise: 3 lines or less.
  40.  
  41. # Include Macro definitions
  42. include(ifdef(`macros',macros(),ifdef(`srcdir',srcdir()/macros.m4,macros.m4)))
  43.  
  44.  
  45. ! Initial tip (number 0) - shown after wrap-around.
  46.  
  47. If you have any more DDD tips of the day,
  48. please send them to the DDD developers EMAIL([ddd]@ ips.cs.tu-bs.de).
  49.  
  50.  
  51. ! First tips.
  52.  
  53. Welcome to DDD!
  54. You can get help on all items by pointing at them and pressing F1.
  55. And don't worry, you can undo most mistakes...
  56.  
  57. Whenever you're stuck, try LBL(Help, What Now).  This will analyze the
  58. current DDD state and give you some hints on what to do next.
  59.  
  60. Buttons with a small triangle in the upper right corner are special:
  61. pressing and holding BUTTON(1) on them will pop up a menu 
  62. with additional options.
  63.  
  64. You can interrupt @GDB@ and the current program by clicking on
  65. LBL(Program, Interrupt) or pressing KEY(Esc).
  66.  
  67. If you made a mistake, try LBL(Edit, Undo).  This will undo the most
  68. recent debugger command and redisplay the previous program state.
  69.  
  70. There are three ways to show the value of a variable:
  71. ITEM You can view its value, simply by pointing at it;
  72. ITEM You can print its value in the debugger console, using LBL(Print ());
  73. ITEM You can display it graphically, using LBL(Display ()).
  74.  
  75. A quick way to manipulate variables, breakpoints, and displays
  76. is to press BUTTON(3) on them.
  77.  
  78. Double-clicking on any value in the data display 
  79. will toggle more details.
  80.  
  81. If your program needs special terminal capabilities such as readline
  82. or curses, let it run in the separate execution window 
  83. (LBL(Program, Run in Execution Window)).
  84.  
  85.  
  86. ! Intermediate tips.
  87.  
  88. If you want to customize the DDD fonts, see
  89. LBL(Edit, Preferences, Fonts).
  90.  
  91. To change the text background color, write into FILE(~/.[ddd]/init):
  92. CODE([Ddd]*XmText.background:      ) VAR(color)
  93. CODE([Ddd]*XmTextField.background: ) VAR(color)
  94. CODE([Ddd]*XmList.background:      ) VAR(color)
  95.  
  96. When using GDB, all text fields have command and argument completion
  97. with KEY(Tab), just like the shell.  In a file selection box, type part of
  98. a filename, hit KEY(Tab), and voila!  It's completed.
  99.  
  100. You can always recenter the command tool
  101. by selecting LBL(View, Command Tool),
  102. or by pressing KEY(Alt+8).
  103.  
  104. To scroll the data display, most users find a EMPH(panner)
  105. much more convenient than two scrollbars.
  106. Check out LBL(Edit, Preferences, Startup, Data Scrolling).
  107.  
  108. To limit the number of array elements in a data display, set
  109. LBL(Edit, GDB Settings, Limit on array elements to print).
  110.  
  111. If DDD cannot find a source, set the @GDB@ source path via 
  112. LBL(Edit, @GDB@ Settings) or enter 
  113. SAMP(dir sourcedir_1:sourcedir_2:...:sourcedir_n) at the GDB prompt.
  114.  
  115. To save the window size, use LBL(Edit, Save Options).
  116.  
  117. You can quickly set breakpoints
  118. by double-clicking in the breakpoint area.
  119.  
  120. To see the EMPH(actual) type of a C++ object in GDB, set
  121. LBL(Edit, GDB Settings, Set printing of object's derived type).
  122.  
  123. To display VAR(data) in hexadecimal format, display it and choose
  124. LBL(Convert to Hex) from the LBL(Display ()) menu, 
  125. or enter KBD(graph display /x VAR(data)) at the GDB prompt.
  126.  
  127. To send a signal to your program,
  128. use LBL(Status, Signals, Send).
  129.  
  130. To quickly display variable values,
  131. double-click on the variable name.
  132.  
  133. After looking up an item or stepping through the program, you can use
  134. LBL(Edit, Undo) and LBL(Edit, Redo) to return to earlier locations.
  135.  
  136. You can repeat the last command by hitting KEY_RETURN.
  137. Use KEY(Ctrl+B) and KEY(Ctrl+F) to search the command history.
  138.  
  139. You can move breakpoints by dragging them.  
  140. Just press and hold BUTTON(1) on a breakpoint,
  141. move it to the new position and release BUTTON(1) again.
  142.  
  143. To make your program ignore signals, use LBL(Status, Signals) and
  144. unset the LBL(Pass) button for the appropriate signal.
  145.  
  146. You can save space by disabling toolbar captions.
  147. See LBL(Edit, Preferences, Startup, Toolbar Appearance).
  148.  
  149. To quickly edit breakpoint properties, 
  150. double-click on a breakpoint symbol.
  151.  
  152. To have GDB start your program automatically upon startup,
  153. put the following lines in your FILE(.gdbinit) file:
  154. CODE(break main)      - or some other initial function
  155. CODE(run       )      - possibly giving arguments here
  156.  
  157.  
  158. ! Advanced tips.
  159.  
  160. To get rid of these tips of the day, unset
  161. LBL(Edit, Preferences, Startup, Show Tip of the Day).
  162.  
  163. To redirect stderr from the execution window to the debugger console,
  164. add SAMP(2>/dev/tty) to the arguments of your program.
  165.  
  166. To display the first VAR(n) elements of a variable-length array VAR(ptr),
  167. enter KBD(graph display VAR(ptr)\1330\135@ VAR(n)) at the GDB prompt.
  168.  
  169. You can have each of DDD, @GDB@ and the debugged program run on
  170. different machines.  See the DDD KBD(--rhost) option for details.
  171.  
  172. You can copy breakpoints by dragging them while pressing KEY(Shift).
  173. Just press and hold KEY(Shift)+BUTTON(1) on a breakpoint,
  174. move it to the new position and release BUTTON(1) again.
  175.  
  176. To save and restore data displays, cut, copy and paste them via
  177. the LBL(Edit) menu.  Together with CODE(xclipboard), you can manage
  178. arbitrary collections of data displays.
  179.  
  180. Do you want to stop this debugging session and resume later?
  181. Use LBL(File, Save Session)!
  182.  
  183. To debug a child process, put a call to SAMP(sleep) in the child right
  184. after the SAMP(fork) call.  Run the program and attach to the child process
  185. using LBL(File, Attach to Process).
  186.  
  187. If your program prints a lot of text on standard error, try
  188. redirecting standard error to a file (via SAMP(2> VAR(FILE))), or add
  189. to FILE(~/.[ddd]/init): CODE([Ddd]*lineBufferedConsole: off).
  190.  
  191. If the inferior debugger does not support stderr redirection, try
  192. invoking DDD using KBD(--debugger 'VAR(NAME) 2> VAR(FILE)').
  193.  
  194. Using GDB, you can define your own canned sequences of commands.
  195. Try LBL(Commands, Define Command).
  196.  
  197. To use GDB with Solaris CC, compile with SAMP(-xs).
  198. GDB wants debugging info in the executable.
  199.  
  200. To use GDB with G77, compile with SAMP(-fdebug-kludge).  This gives
  201. rudimentary information on COMMON and EQUIVALENCE variables in GDB.
  202. See the G77 documentation for details.
  203.  
  204. Double-clicking on a function call will lead you to the definition of
  205. the function.  Use LBL(Edit, Undo) to return to the function call.
  206.  
  207. Disabled breakpoints can be used as bookmarks.
  208. Use LBL(Source, Edit Breakpoints) to list all breakpoints;
  209. then, click on LBL(Lookup) to jump to a breakpoint location.
  210.  
  211. You can assign user-defined buttons to frequently used commands.
  212. Try LBL(Commands, Edit Buttons).
  213.  
  214. In the Breakpoint and Display Editors,
  215. you can toggle the selection with KEY(Ctrl)+BUTTON(1).
  216. This allows you to select non-contiguous ranges of items.
  217.  
  218. To change the properties of multiple breakpoints at once,
  219. select them in the breakpoint editor (LBL(Source, Edit Breakpoints))
  220. and click on LBL(Properties).
  221.  
  222. Even while in the source window, 
  223. you can enter and edit GDB commands:
  224. Just type the command and press KEY_RETURN.
  225.  
  226. You can record commands to be executed when a breakpoint is hit.
  227. In the LBL(Breakpoint Properties) panel, try LBL(Record) and LBL(End).
  228.  
  229. You can easily resume a saved DDD VAR(session)
  230. by invoking DDD as KBD([ddd] =VAR(session)).
  231.  
  232. If the DDD source window keeps on scrolling until the end of source is
  233. reached, try changing the SAMP(glyphUpdateDelay) resource.  See the
  234. DDD manual for details.
  235.  
  236. For further DDD customization (e.g. colors), see the FILE([Ddd])
  237. app-defaults file from the DDD WWW Site or the DDD source
  238. distribution.  Copy resources to FILE(~/.[ddd]/init) and edit as desired.
  239.  
  240.  
  241. ! Professional tips.
  242.  
  243. In GCC, SAMP(-Wall) does not enable all warnings.  See the GCC
  244. documentation for other warnings you might consider useful.
  245. BY(J.H.M. Dassen, jdassen@ wi.leidenuniv.nl)
  246.  
  247. To get a global idea of what a process or program does or is doing,
  248. use a system call tracer, like SAMP(strace), SAMP(truss), or SAMP(trace).
  249. BY(J.H.M. Dassen, jdassen@ wi.leidenuniv.nl)
  250.  
  251. If you suspect memory corruption caused by problematic pointers, 
  252. try linking with Electric Fence SAMP(efence) or the SAMP(dbmalloc) library.
  253. See the DDD WWW page for links.
  254. BY(J.H.M. Dassen, jdassen@ wi.leidenuniv.nl)
  255.  
  256. Prevention is better than cure.  Document your assumptions using
  257. CODE(<assert.h>) or GNU NANA.  See the DDD WWW page for links.
  258. BY(J.H.M. Dassen, jdassen@ wi.leidenuniv.nl)
  259.  
  260. The debugger isn't a substitute for good thinking.  But, in some
  261. cases, thinking isn't a substitute for a good debugger either.  The
  262. most effective combination is good thinking and a good debugger.
  263. QUOTE(Steve McConnell, Code Complete)
  264.  
  265. When you're totally stuck, try to find a helpful ear.  In my experience,
  266. nothing helps you more in debugging than to try to explain your problem
  267. (what your code should do, and what it actually does) to someone else.
  268. BY(J.H.M. Dassen, jdassen@ wi.leidenuniv.nl)
  269.  
  270. ! If you have other questions, comments or suggestions, contact The King via
  271. ! electronic mail to EMAIL(elvis@ graceland.gnu.ai.mit.edu).  The King will
  272. ! try to help you out, although he may not have time to fix your problems.
  273. ! QUOTE(Free Software Foundation, GNU Hello Manual)
  274.