changeset 4693:feb41fc13635

8014478: EnableTracing: output from multiple threads may be mixed together Reviewed-by: dholmes, rbackman Contributed-by: yunda.mly@taobao.com
author rbackman
date Tue, 14 May 2013 09:11:21 +0200
parents 091c3bd3fcdd
children 725d82a60081 f2ce8a7ee5a0
files src/share/vm/runtime/globals.hpp src/share/vm/trace/traceEventClasses.xsl
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/globals.hpp	Tue May 14 13:32:35 2013 +0200
+++ b/src/share/vm/runtime/globals.hpp	Tue May 14 09:11:21 2013 +0200
@@ -3634,7 +3634,9 @@
           "Include GC cause in GC logging")                                 \
                                                                             \
   product(bool, EnableTracing, false,                                       \
-                  "Enable event-based tracing")
+                  "Enable event-based tracing")                             \
+  product(bool, UseLockedTracing, false,                                    \
+          "Use locked-tracing when doing event-based tracing")
 
 /*
  *  Macros for factoring of globals
--- a/src/share/vm/trace/traceEventClasses.xsl	Tue May 14 13:32:35 2013 +0200
+++ b/src/share/vm/trace/traceEventClasses.xsl	Tue May 14 09:11:21 2013 +0200
@@ -119,6 +119,13 @@
  private:
 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
 
+  void writeEventContent(void) {
+    TraceStream ts(*tty);
+    ts.print("<xsl:value-of select="@label"/>: [");
+<xsl:apply-templates select="value|structvalue" mode="write-data"/>
+    ts.print("]\n");
+  }
+
  public:
 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
 
@@ -132,11 +139,14 @@
   void writeEvent(void) {
     ResourceMark rm;
     HandleMark hm;
-    TraceStream ts(*tty);
-    ts.print("<xsl:value-of select="@label"/>: [");
-<xsl:apply-templates select="value|structvalue" mode="write-data"/>
-    ts.print("]\n");
+    if (UseLockedTracing) {
+      ttyLocker lock;
+      writeEventContent();
+    } else {
+      writeEventContent();
+    }
   }
+
 };
 
 </xsl:template>