home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man1 / cdb.1 < prev    next >
Encoding:
Text File  |  1975-06-26  |  6.3 KB  |  221 lines

  1. .th CDB I 2/8/75
  2. .sh NAME
  3. cdb \*- C debugger
  4. .sh SYNOPSIS
  5. .bd cdb
  6. [ a.out [ core ] ]
  7. .sh DESCRIPTION
  8. .it Cdb
  9. is a debugger for use with C programs.
  10. It is useful for both post-mortem and interactive debugging.
  11. An important feature of
  12. .it cdb
  13. is that even in the interactive case no
  14. advance planning is necessary to use it;
  15. in particular it is not necessary to compile or load the program
  16. in any special way nor to include any special
  17. routines in the object file.
  18. .s3
  19. The first argument to
  20. .it cdb
  21. is an object
  22. program, preferably containing a symbol table;
  23. if not given ``a.out'' is used.
  24. The second argument is the name of a core-image file;
  25. if it is not given, ``core'' is used.
  26. The core file need not be present.
  27. .s3
  28. Commands to
  29. .it cdb
  30. consist of an address,
  31. followed by a single command character,
  32. possibly followed by a command modifier.
  33. Usually if no address is given the last-printed
  34. address is used.
  35. An address may be followed by a comma and
  36. a number,
  37. in which case the command applies
  38. to the appropriate number of successive addresses.
  39. .s3
  40. Addresses are expressions composed of names,
  41. decimal numbers, and octal numbers
  42. (which begin with ``0'') and separated by
  43. ``+'' and ``\*-''.
  44. Evaluation proceeds left-to-right.
  45. .s3
  46. Names of external variables are written just as they are in C.
  47. For various reasons the external names generated by C
  48. all begin with an underscore, which is automatically tacked on by
  49. .it cdb.
  50. Currently it is not possible to suppress this feature, so
  51. symbols (defined in assembly-language programs) which do not begin with
  52. underscore are inaccessible.
  53. .s3
  54. Variables
  55. local to a function
  56. (automatic, static, and arguments)
  57. are accessible by writing the name of the function, a colon ``:'',
  58. and the name of the local variable
  59. (e.g. ``main:argc'').
  60. There is no notion of the ``current'' function;
  61. its name must always be written explicitly.
  62. .s3
  63. A number which begins with ``0'' is taken to be octal; otherwise
  64. numbers are decimal, just as in C.
  65. There is no provision for input of floating numbers.
  66. .s3
  67. The construction ``name[expression]''
  68. assumes that
  69. .it name
  70. is a pointer to an integer
  71. and is equivalent
  72. to the contents of the named cell plus twice the expression.
  73. Notice that
  74. .it name
  75. has to be a genuine pointer and that arrays
  76. are not accessible in this way.
  77. This is a consequence of the fact that types of variables are
  78. not currently saved in the symbol table.
  79. .s3
  80. The command characters are:
  81. .s3
  82. .lp +4 4
  83. /\fIm\fR    print the addressed words.
  84. .it m
  85. indicates the mode of printout;
  86. specifying a mode sets the mode until it is explicitly changed again:
  87. .lp +8 4
  88. \fBo\fR    octal (default)
  89. .lp +8 4
  90. \fBi\fR    decimal
  91. .lp +8 4
  92. \fBf\fR    single-precision floating-point
  93. .lp +8 4
  94. \fBd\fR    double-precision floating-point
  95. .s3
  96. .i0
  97. .lp +4 4
  98. \\    Print the specified bytes in octal.
  99. .s3
  100. .lp +4 4
  101. =    print the value of the addressed expression in octal.
  102. .c2 @
  103. .s3
  104. .lp +4 4
  105. \*a    print the addressed bytes as characters.
  106. Control and non-ASCII characters are escaped in octal.
  107. .c2 '
  108. .s3
  109. .lp +4 4
  110. "    take the contents of the address as a pointer to a sequence
  111. of characters, and print the characters up to a null byte.
  112. Control and non-ASCII characters are escaped as octal.
  113. .s3
  114. .lp +4 4
  115. &    Try to interpret the contents
  116. of the address as a pointer,
  117. and print symbolically where the pointer points.
  118. The typeout contains the name of an external symbol
  119. and, if required,
  120. the smallest possible positive offset.
  121. Only external symbols are considered.
  122. .s3
  123. .lp +4 4
  124. ?    Interpret the addressed location as a PDP-11 instruction.
  125. .s3
  126. .lp +4 4
  127. $\fIm\fR    If no
  128. .it m
  129. is given,
  130. print a stack trace of the terminated or stopped program.
  131. The last call made is listed first;
  132. the actual arguments to each routine are
  133. given in octal.
  134. (If this is inappropriate, the arguments may be examined by
  135. name in the desired format using ``/''.)
  136. If
  137. .it m
  138. is ``r'', the contents of the PDP-11 general registers are
  139. listed.
  140. If
  141. .it m
  142. is ``f'', the contents of the floating-point registers are listed.
  143. In all cases, the reason why the program stopped or terminated
  144. is indicated.
  145. .s3
  146. .lp +4 4
  147. %\fIm\fR    According to
  148. .it m,
  149. set or delete a breakpoint,
  150. or run or continue the program:
  151. .s3
  152. .lp +8 4
  153. \fBb\fR    An address within the program must
  154. be given;
  155. a breakpoint is set there.
  156. Ordinarily, breakpoints will be set on the entry points of functions,
  157. but any location is possible as long as it is the first word of an instruction.
  158. (Labels don't appear in the symbol table yet.)
  159. Stopping at the actual first instruction of a function is undesirable
  160. because to make symbolic printouts work,
  161. the function's save sequence has to be completed;
  162. therefore
  163. .it cdb
  164. automatically moves breakpoints at the start of functions
  165. down to the first real code.
  166. .s3
  167. It is impossible to set breakpoints on pure-procedure programs
  168. (\-n flag on cc or ld) because the program text is write-protected.
  169. .s3
  170. .lp +8 4
  171. \fBd\fR    An address must be given;
  172. the breakpoint at that address is removed.
  173. .s3
  174. .lp +8 4
  175. \fBr\fR    Run the program being debugged.
  176. Following the ``%r'', arguments may be given;
  177. they cannot specify I/O redirection
  178. (``>'', ``<'')
  179. or filters.
  180. No address is permissible, and the program is restarted from scratch,
  181. not continued.
  182. Breakpoints should have been set if any were desired.
  183. The program will stop
  184. if any signal is generated,
  185. such as illegal instruction (including simulated floating point),
  186. bus error, or interrupt (see signal(II));
  187. it will also stop when a breakpoint occurs
  188. and in any case announce the reason.
  189. Then a stack trace can be printed, named locations examined, etc.
  190. .s3
  191. .lp +8 4
  192. \fBc\fR    Continue after
  193. a breakpoint.
  194. It is possible but probably useless to continue after
  195. an error since there is no way to repair the cause of the error.
  196. .s3
  197. .i0
  198. .sh "SEE ALSO"
  199. cc (I), db (I), C Reference Manual
  200. .sh BUGS
  201. Use caution in believing
  202. values of register variables at the lowest levels
  203. of the call stack;
  204. the value of a register is found by looking at the place where it was
  205. supposed to have been saved by the callee.
  206. .s3
  207. Some things are still needed to make
  208. .it cdb
  209. uniformly better than
  210. .it db:
  211. non-C symbols, patching files, patching core images of programs
  212. being run.
  213. It would be desirable to have the types of variables around
  214. to make the correct style printout more automatic.
  215. Structure members should be available.
  216. .s3
  217. Naturally, there are all sorts of neat features
  218. not handled, like conditional breakpoints, optional stopping on certain signals
  219. (like illegal instructions, to allow breakpointing
  220. of simulated floating-point programs).
  221.