Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ajdb.xml 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <refentry>
  2. <refnamediv>
  3. <refname>ajdb</refname>
  4. <refpurpose>debugger for .class files produced by ajc (early-access)</refpurpose>
  5. </refnamediv>
  6. <refsynopsisdiv>
  7. <cmdsynopsis>
  8. <command>ajdb</command>
  9. <arg>-classpath <replaceable>path</replaceable></arg>
  10. <arg>-D<replaceable>name</replaceable>=<replaceable>value</replaceable></arg>
  11. <arg>-help</arg>
  12. <arg>-gui</arg>
  13. <arg>-read <replaceable>file</replaceable></arg>
  14. <arg>-sourcepath <replaceable>dir</replaceable></arg>
  15. <arg>
  16. <group>
  17. <arg>-v</arg>
  18. <arg>-verbose</arg>
  19. <group>
  20. <arg>:class</arg>
  21. <arg>:gc</arg>
  22. <arg>:jni</arg>
  23. </group>
  24. </group>
  25. </arg>
  26. <arg>workingdir <replaceable>dir</replaceable></arg>
  27. <arg>-X<replaceable>option</replaceable></arg>
  28. <arg><replaceable>class</replaceable></arg>
  29. <arg><replaceable>arguments</replaceable>
  30. </arg>
  31. </cmdsynopsis>
  32. </refsynopsisdiv>
  33. <refsect1>
  34. <title>Description</title>
  35. <para>The command <command>ajdb</command> is used to debug AspectJ and
  36. Java programs. In addition to its command line interface,
  37. <command>adjb</command> also has a standalone, Swing-based GUI
  38. interface.
  39. </para>
  40. <para>
  41. Note: As of the 1.0.3 release, AspectJ supports JSR-45, which provides
  42. source-level debugging from many source files per class
  43. and non-Java source files.
  44. JSR-45 is implemented in the J2SE 1.4 debugger support, so
  45. you may be able to use your existing debugger to step through
  46. AspectJ source code if both the source and target VM's are
  47. running under Java 1.4 or later.
  48. However, existing debuggers will display synthetic methods
  49. in the stack frame.
  50. </para> <!-- todo find docs on JSR-45 -->
  51. <simplelist>
  52. <member>-classpath <emphasis>path</emphasis></member>
  53. <member>Specify where to find user class files.</member>
  54. <member>
  55. -D<replaceable>name</replaceable>=<replaceable>value</replaceable>
  56. </member>
  57. <member>Define the property <literal>name</literal> to have the value
  58. <literal>value</literal>.</member>
  59. <member>-help</member>
  60. <member>Print out <command>ajdb</command>'s usage summary.</member>
  61. <member>-read <emphasis>file</emphasis></member>
  62. <member>Read this file for initializatoin commands.</member>
  63. <member>-sourcepath <emphasis>path</emphasis></member>
  64. <member>Search this directory for source files.</member>
  65. <member>-gui</member>
  66. <member></member>
  67. <member>-v | -verbose [:class | :gc | :jni]</member>
  68. <member>Print out class loading, garbage collection or dynamic library
  69. loading information. Defaults to class loading.
  70. </member>
  71. <member>-workingdir <emphasis>directory</emphasis></member>
  72. <member>Set <command>ajdb</command>'s working directory.</member>
  73. <member>-X<emphasis>option</emphasis></member>
  74. <member>Pass a non-standard option to the VM</member>
  75. </simplelist>
  76. <refsect2>
  77. <title>Capabilities</title>
  78. <para>
  79. The AspectJ debugger implements all of <command>jdb</command>'s
  80. commands. In addition, the command <literal>workingdir</literal>
  81. allow you to set the AspectJ working directory, and the breakpoint
  82. command, <literal>stop on</literal>, has been extended to allow the
  83. setting of breakpoint on a source file line.
  84. </para>
  85. </refsect2>
  86. <refsect2>
  87. <title>Examples</title>
  88. <example id="ajdbcommandline">
  89. <title>Command line use</title>
  90. <para>Suppose you want to debug the file spacewar/Ship.java found in
  91. the examples directory. At the command line start up the debugger:
  92. <computeroutput>
  93. ajdb
  94. </computeroutput>
  95. </para>
  96. <para>
  97. The debugger will first look for initialization files in your
  98. home or current directory called either
  99. <filename>ajdb.ini</filename> or <filename>.ajdbrc</filename> and
  100. execute the commands contained in them. A useful command to have
  101. in this file is the <literal>source-path</literal> command which
  102. tells the debugger where to find source files.
  103. </para>
  104. <para>For this example, we need to set the source path by:
  105. <userinput>
  106. use C:\src
  107. </userinput>
  108. </para>
  109. <para>To view the file to debug, type <userinput>list
  110. spacewar/Ship.java</userinput> which generates the following
  111. output:
  112. <programlisting>
  113. 209 void fire() {
  114. 210 // firing a shot takes energy
  115. 211 if (!expendEnergy(BULLET_ENERGY))
  116. 212 return;
  117. 213
  118. 214 //create a bullet object so it doesn't hit the ship that's firing it
  119. 215 double xV = getXVel() + BULLET_SPEED * (Math.cos(orientation));
  120. 216 double yV = getYVel() + BULLET_SPEED * (Math.sin(orientation));
  121. 217
  122. 218 // create the actual bullet
  123. 219 new Bullet(
  124. 220 getGame(),
  125. 221 (getXPos() + ((getSize()/2 + 2) * (Math.cos(orientation))) + xV),
  126. 222 (getYPos() + ((getSize()/2 + 2) * (Math.sin(orientation))) + yV),
  127. 223 xV,
  128. 224 yV);
  129. 225 }
  130. </programlisting>
  131. </para>
  132. <para>This is different from <command>jdb</command> because it allows
  133. one to view files before the debugger has started. The
  134. <literal>list</literal> command has the following syntax: </para>
  135. <simplelist>
  136. <member><literal>list</literal></member>
  137. <member>list the source containing the location at which we are
  138. currently stopped (can only be used with a running VM)</member>
  139. <member><literal>list</literal>
  140. <emphasis><literal>source</literal></emphasis></member>
  141. <member>list the entire file source</member>
  142. <member><literal>list</literal> source line</member>
  143. <member>list source line line of file source</member>
  144. <member>
  145. list <emphasis><literal>source start-line
  146. end-line</literal></emphasis>
  147. </member>
  148. <member>
  149. list the lines from <emphasis>start-line</emphasis> to
  150. <emphasis>end-line</emphasis> of file
  151. <emphasis>source</emphasis>
  152. </member>
  153. </simplelist>
  154. <para>
  155. To set a breakpoint in the method <literal>Ship.fire</literal>, we
  156. would could type <userinput>stop in spacewar.Ship.fire</userinput>.
  157. </para>
  158. <para>The following message appears notifying the user that the
  159. breakpoint has been noted but will not be set until the class has
  160. been loaded by the VM: </para>
  161. <programlisting>
  162. Deferring breakpoint spacewar.Ship.fire()
  163. It will be set after the class is loaded.
  164. </programlisting>
  165. <para>
  166. To start Spacewar we type <userinput>run spacewar.Game</userinput>.
  167. </para>
  168. <para>
  169. When the breakpoint is set, the following message appears:
  170. <programlisting>
  171. Set deferred breakpoint spacewar.Ship.fire()
  172. </programlisting>
  173. </para>
  174. <para> We are notified that we've hit the breakpoint:
  175. <programlisting>
  176. Breakpoint hit: thread="Thread-2", spacewar.Ship.fire(), line=174, bci=0 209 void fire() {
  177. </programlisting></para>
  178. <para>
  179. The prompt changes to present the thread that has broken, and we
  180. can view the current stack with the <literal>where</literal>
  181. command, as follows:
  182. <programlisting>
  183. Thread-2[1] where
  184. [1] fire (spacewar\Ship.java:209)
  185. [2] run (spacewar\Robot.java:100)
  186. [3] run [class java.lang.Thread]
  187. </programlisting>
  188. </para>
  189. <para>
  190. Next, to stop on line 216 we
  191. type <userinput>stop on spacewar/Ship.java:216</userinput>
  192. </para>
  193. <para>
  194. The following message tells us the breakpoint was set:
  195. <programlisting>
  196. Set breakpoint Ship.java:216
  197. </programlisting>
  198. </para>
  199. <para>
  200. To continue execution, we type <userinput>cont</userinput> and the
  201. breakpoint at line 216 is hit
  202. <programlisting>
  203. Breakpoint hit: thread="Thread-2", spacewar.Ship.fire(), line=216, bci=28
  204. 216 double yV = getYVel() + BULLET_SPEED * (Math.sin(orientation));
  205. </programlisting></para>
  206. <para>
  207. To view the visible local variables, we type
  208. <userinput>locals</userinput> and ajdb responds with:
  209. <programlisting>
  210. Local variables
  211. xV = 12.242462584304468
  212. </programlisting></para>
  213. <para>
  214. To change the value of the local variable i to 15, we type
  215. <userinput>set xV = 16.1</userinput>
  216. <programlisting>
  217. Changed 'xV' from '12.242462584304468' to '16.1'
  218. </programlisting></para>
  219. <para>
  220. To see our changes we can print the value of <literal>i</literal>
  221. by the following:
  222. <programlisting>
  223. print xV
  224. Value for printing 'xV' = 12.242462584304468
  225. </programlisting></para>
  226. <para>We can now type exit or quit to leave the debugger, and we
  227. receive the following message:
  228. <programlisting>
  229. The application has exited.
  230. </programlisting></para>
  231. </example>
  232. </refsect2>
  233. <refsect2>
  234. <title>The AspectJ debugger API</title>
  235. <para>
  236. The AspectJ debugger is implemented completely in Java and can be
  237. called as a Java class. The only interface that should be
  238. considered public is the method
  239. <literal>org.aspectj.tools.debugger.Main.main(String[]
  240. args)</literal> where <literal>args</literal> are the standard
  241. <command>ajc</command> command line arguments. This means that an
  242. alternative way to run the compiler is </para>
  243. <cmdsynopsis>
  244. <command>
  245. <literal>java org.aspectj.tools.debugger.Main</literal>
  246. </command>
  247. <arg><replaceable>option</replaceable></arg>
  248. <arg><replaceable>class</replaceable></arg>
  249. <arg><replaceable>arguments</replaceable></arg>
  250. </cmdsynopsis>
  251. <!-- <note> -->
  252. <para>
  253. You must additionally include <filename>tools.jar</filename> from
  254. your Java developer's kit in your classpath.
  255. </para>
  256. <!-- </note> -->
  257. </refsect2>
  258. </refsect1>
  259. </refentry>
  260. <!-- Local variables: -->
  261. <!-- fill-column: 79 -->
  262. <!-- sgml-local-ecat-files: devguide.ced -->
  263. <!-- sgml-parent-document:("devguide.sgml" "book" "refentry") -->
  264. <!-- End: -->