You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trace.xml 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <chapter id="trace" xreflabel="Tracing">
  2. <title>Tracing</title>
  3. <sect1 id="trace-introduction">
  4. <title>Introduction</title>
  5. <para>
  6. The AspectJ developers have instrumented the compiler/weaver with
  7. many "trace" messages for their own debugging use. These remain in
  8. the production releases because tracing helps when it is hard to
  9. isolate the problem in a test case. This sections describes how
  10. to enable tracing so you can provide trace information on bug reports.
  11. </para>
  12. <para>
  13. The usual approach to opening a report on Bugzilla is to describe the symptoms of the
  14. problem and attach a simple testcase. This allows the AspectJ team to try and reproduce the problem in
  15. an attempt to fix it as well as improve the test suite. Unfortunately it may not be possible
  16. to produce such a testcase either because your program is too large or is commercially sensitive. Alternatively
  17. the problem may relate to your specific environment where AspectJ is being used and will not be
  18. reproducible by the AspectJ team. In each of these situations you can produce a
  19. trace of the compiler when the problem occurs instead. This can then be attached to the bug report. </para>
  20. <sect2 id="trace-configuration" xreflabel="Configuring Tracing">
  21. <title>Configuring Tracing</title>
  22. <para> When available (Java 5 or later) AspectJ will use the
  23. <ulink url="http://java.sun.com/j2se/1.5.0/docs/guide/logging/index.html">
  24. java.util.logging</ulink> infrastructure
  25. configured using a <literal>logging.properties</literal> file. By default only error
  26. and fatal events will be logged but less severe warnings as well as fine-grained
  27. method entry and exit events can be obtained using the appropriate configuration. All
  28. regular compiler messages can also be logged through the infrastructure by setting the
  29. <literal>org.aspectj.weaving.messages</literal> System property. </para>
  30. <para> If you are running the AspectJ compiler/weaver under JDK 1.4 or earlier,
  31. AspectJ will use a simple built-in trace
  32. infrastructure that logs to stderr. This is enabled by setting the
  33. <literal>org.aspectj.weaving.tracing.enabled</literal> System property. You may also override
  34. the default behaviour or provide your own trace implementation using the
  35. <literal>org.aspectj.weaving.tracing.factory</literal> System property. </para>
  36. <para> The table below lists the System properties that can be used to configure tracing. </para>
  37. <informaltable>
  38. <tgroup cols="2">
  39. <thead>
  40. <row>
  41. <entry>Property</entry>
  42. <entry>Description</entry>
  43. </row>
  44. </thead>
  45. <tbody>
  46. <row>
  47. <entry>
  48. <literal>org.aspectj.tracing.debug</literal>
  49. </entry>
  50. <entry>
  51. Enable simple debugging of the trace infrastructure itself.
  52. <para> Default: <literal>false</literal>. </para>
  53. </entry>
  54. </row>
  55. <row>
  56. <entry>
  57. <literal>org.aspectj.tracing.enabled</literal>
  58. </entry>
  59. <entry>
  60. Enable the built-in AspectJ trace infrastructure.
  61. <para> Default: <literal>false</literal>. </para>
  62. </entry>
  63. </row>
  64. <row>
  65. <entry>
  66. <literal>org.aspectj.tracing.factory</literal>
  67. </entry>
  68. <entry>
  69. Select trace infrastructure. Specify the fully qualified class name
  70. of the <literal>org.aspectj.weaver.tools.TraceFactory</literal>
  71. interface to use a custom infrastructure. Specify a value of
  72. <literal>default</literal> to force AspectJ to use it's
  73. built-in infrastructure.
  74. </entry>
  75. </row>
  76. <row>
  77. <entry>
  78. <literal>org.aspectj.tracing.messages</literal>
  79. </entry>
  80. <entry>
  81. Enable tracing of compiler messages. The kind of messages logged
  82. is determined by the selected trace infrastructure not the message
  83. configuration.
  84. <para> Default: <literal>false</literal>. </para>
  85. </entry>
  86. </row>
  87. </tbody>
  88. </tgroup>
  89. </informaltable>
  90. </sect2>
  91. <sect2 id="trace-examples" xreflabel="trace-examples">
  92. <title>Examples</title>
  93. <para> Using <literal>-Dorg.aspectj.tracing.factory=default</literal>
  94. to force AspectJ to use its internal infrastructure,
  95. <literal>-Dorg.aspectj.tracing.enabled=true</literal> to turn it on and
  96. <literal>-Dorg.aspectj.tracing.messages=true</literal> to include messages
  97. running a simple HelloWorld with LTW will generate tracing to stderr. Below
  98. is an extract from that trace with method arguments removed.
  99. You will notice the millisecond time stamp,
  100. thread id and indication of entry/exit/event or message type for each line
  101. of trace.
  102. </para>
  103. <programlisting><![CDATA[
  104. 15:44:18.630 main > org.aspectj.weaver.loadtime.Aj.<init>
  105. 15:44:18.660 main < org.aspectj.weaver.loadtime.Aj.<init>
  106. 15:44:18.660 main > org.aspectj.weaver.loadtime.Aj.preProcess
  107. 15:44:18.660 main - org.aspectj.weaver.loadtime.Aj.preProcess
  108. 15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
  109. 15:44:18.730 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
  110. 15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
  111. 15:44:18.821 main I [AppClassLoader@92e78c] info AspectJ Weaver Version DEVELOPMENT ...
  112. 15:44:18.821 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  113. 15:44:18.821 main I [AppClassLoader@92e78c] info register classloader ...
  114. 15:44:18.821 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  115. 15:44:18.841 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  116. 15:44:18.841 main I [AppClassLoader@92e78c] info using configuration ...
  117. 15:44:18.891 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  118. 15:44:19.021 main > org.aspectj.weaver.World$TypeMap.<init>
  119. 15:44:19.021 main < org.aspectj.weaver.World$TypeMap.<init>
  120. 15:44:19.021 main > org.aspectj.weaver.CrosscuttingMembersSet.<init>
  121. 15:44:19.021 main < org.aspectj.weaver.CrosscuttingMembersSet.<init>
  122. 15:44:19.021 main > org.aspectj.weaver.Lint.<init>
  123. 15:44:19.021 main < org.aspectj.weaver.Lint.<init>
  124. 15:44:19.021 main > org.aspectj.weaver.World.<init>
  125. 15:44:19.111 main < org.aspectj.weaver.World.<init>
  126. 15:44:19.201 main > org.aspectj.weaver.bcel.BcelWeaver.<init>
  127. 15:44:19.201 main < org.aspectj.weaver.bcel.BcelWeaver.<init>
  128. 15:44:19.201 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
  129. 15:44:19.211 main > org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
  130. 15:44:19.351 main < org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
  131. 15:44:19.351 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
  132. 15:44:19.351 main I [AppClassLoader@92e78c] info register aspect Aspect
  133. 15:44:19.351 main > org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
  134. 15:44:19.501 main - org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass
  135. 15:44:19.632 main > org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
  136. 15:44:19.792 main < org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
  137. 15:44:19.792 main < org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
  138. 15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
  139. 15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
  140. 15:44:19.792 main > org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
  141. 15:44:19.822 main < org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
  142. 15:44:19.822 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
  143. 15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
  144. 15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
  145. 15:44:19.822 main > org.aspectj.weaver.tools.WeavingAdaptor.weaveClass
  146. ...
  147. ]]></programlisting>
  148. <para> Alternatively when running under Java 5 the <literal>logging.properties</literal>
  149. file below could be used to configure Java Logging. The resulting
  150. file, just containing trace for the
  151. <literal>org.aspectj.weaver.loadtime</literal> package, will be
  152. written to <literal>java0.log</literal> in your <literal>user.home</literal> directory.
  153. </para>
  154. <programlisting><![CDATA[
  155. handlers= java.util.logging.FileHandler
  156. .level= INFO
  157. java.util.logging.FileHandler.pattern = %h/java%u.log
  158. java.util.logging.FileHandler.count = 1
  159. java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
  160. java.util.logging.FileHandler.level = FINER
  161. org.aspectj.weaver.loadtime.level = FINER
  162. ]]></programlisting>
  163. <para>
  164. By setting the System property <literal>-Dorg.aspectj.tracing.debug=true</literal>
  165. you should see a message confirming which trace infrastructure is being used.
  166. </para>
  167. <programlisting><![CDATA[
  168. TraceFactory.instance=org.aspectj.weaver.tools.Jdk14TraceFactory@12dacd1
  169. ]]></programlisting>
  170. </sect2>
  171. </sect1>
  172. </chapter>