OLD | NEW |
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 Loading... |
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 |
OLD | NEW |