Print this page
rev 4501 : 8014478: EnableTracing: output from multiple threads may be mixed together
Reviewed-by: dholmes, rbackman
Contributed-by: yunda.mly@taobao.com

Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/trace/traceEventClasses.xsl
          +++ new/src/share/vm/trace/traceEventClasses.xsl
↓ open down ↓ 111 lines elided ↑ open up ↑
 112  112   public:
 113  113    static const bool hasThread = <xsl:value-of select="@has_thread"/>;
 114  114    static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>;
 115  115    static const bool isInstant = <xsl:value-of select="@is_instant"/>;
 116  116    static const bool isRequestable = <xsl:value-of select="@is_requestable"/>;
 117  117    static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>;
 118  118  
 119  119   private:
 120  120  <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
 121  121  
      122 +  void writeEventContent(void) {
      123 +    TraceStream ts(*tty);
      124 +    ts.print("<xsl:value-of select="@label"/>: [");
      125 +<xsl:apply-templates select="value|structvalue" mode="write-data"/>
      126 +    ts.print("]\n");
      127 +  }
      128 +
 122  129   public:
 123  130  <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
 124  131  
 125  132    bool should_write(void) {
 126  133      return true;
 127  134    }
 128  135  <xsl:text>
 129  136  
 130  137  </xsl:text>
 131  138    <xsl:value-of select="concat('  Event', @id, '(EventStartTime timing=TIMED) : TraceEvent&lt;Event', @id, '&gt;(timing) {}', $newline)"/>
 132  139    void writeEvent(void) {
 133  140      ResourceMark rm;
 134  141      HandleMark hm;
 135      -    TraceStream ts(*tty);
 136      -    ts.print("<xsl:value-of select="@label"/>: [");
 137      -<xsl:apply-templates select="value|structvalue" mode="write-data"/>
 138      -    ts.print("]\n");
      142 +    if (UseLockedTracing) {
      143 +      ttyLocker lock;
      144 +      writeEventContent();
      145 +    } else {
      146 +      writeEventContent();
      147 +    }
 139  148    }
      149 +
 140  150  };
 141  151  
 142  152  </xsl:template>
 143  153  
 144  154  <xsl:template match="value|transition_value|relation" mode="write-empty-setters">
 145  155    <xsl:param name="cls"/>
 146  156    <xsl:variable name="type" select="@type"/>
 147  157    <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
 148  158    <xsl:value-of select="concat('  void set_', @field, '(', $wt, ' value) { }')"/>
 149  159    <xsl:if test="position() != last()">
↓ open down ↓ 88 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX