Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: src/libplatform/tracing/trace-writer.cc

Issue 2200113003: [Tracing] V8 Tracing Controller - Fix async trace event bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merge async test as part of TestJSONTraceWriter Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/libplatform/test-tracing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/libplatform/tracing/trace-writer.h" 5 #include "src/libplatform/tracing/trace-writer.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/trace_event/common/trace_event_common.h" 9 #include "base/trace_event/common/trace_event_common.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 << TracingController::GetCategoryGroupName( 100 << TracingController::GetCategoryGroupName(
101 trace_event->category_enabled_flag()) 101 trace_event->category_enabled_flag())
102 << "\",\"name\":\"" << trace_event->name() 102 << "\",\"name\":\"" << trace_event->name()
103 << "\",\"dur\":" << trace_event->duration() 103 << "\",\"dur\":" << trace_event->duration()
104 << ",\"tdur\":" << trace_event->cpu_duration(); 104 << ",\"tdur\":" << trace_event->cpu_duration();
105 if (trace_event->flags() & TRACE_EVENT_FLAG_HAS_ID) { 105 if (trace_event->flags() & TRACE_EVENT_FLAG_HAS_ID) {
106 if (trace_event->scope() != nullptr) { 106 if (trace_event->scope() != nullptr) {
107 stream_ << ",\"scope\":\"" << trace_event->scope() << "\""; 107 stream_ << ",\"scope\":\"" << trace_event->scope() << "\"";
108 } 108 }
109 // So as not to lose bits from a 64-bit integer, output as a hex string. 109 // So as not to lose bits from a 64-bit integer, output as a hex string.
110 stream_ << ",\"id\":\"0x" << std::hex << trace_event->id() << "\""; 110 stream_ << ",\"id\":\"0x" << std::hex << trace_event->id() << "\""
111 << std::dec;
111 } 112 }
112 stream_ << ",\"args\":{"; 113 stream_ << ",\"args\":{";
113 const char** arg_names = trace_event->arg_names(); 114 const char** arg_names = trace_event->arg_names();
114 const uint8_t* arg_types = trace_event->arg_types(); 115 const uint8_t* arg_types = trace_event->arg_types();
115 TraceObject::ArgValue* arg_values = trace_event->arg_values(); 116 TraceObject::ArgValue* arg_values = trace_event->arg_values();
116 for (int i = 0; i < trace_event->num_args(); ++i) { 117 for (int i = 0; i < trace_event->num_args(); ++i) {
117 if (i > 0) stream_ << ","; 118 if (i > 0) stream_ << ",";
118 stream_ << "\"" << arg_names[i] << "\":"; 119 stream_ << "\"" << arg_names[i] << "\":";
119 AppendArgValue(arg_types[i], arg_values[i]); 120 AppendArgValue(arg_types[i], arg_values[i]);
120 } 121 }
121 stream_ << "}}"; 122 stream_ << "}}";
122 // TODO(fmeawad): Add support for Flow Events. 123 // TODO(fmeawad): Add support for Flow Events.
123 } 124 }
124 125
125 void JSONTraceWriter::Flush() {} 126 void JSONTraceWriter::Flush() {}
126 127
127 TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) { 128 TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream) {
128 return new JSONTraceWriter(stream); 129 return new JSONTraceWriter(stream);
129 } 130 }
130 131
131 } // namespace tracing 132 } // namespace tracing
132 } // namespace platform 133 } // namespace platform
133 } // namespace v8 134 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/libplatform/test-tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698