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

Side by Side Diff: tracing/tracing/extras/importer/trace_event_importer.html

Issue 2755943002: tracing: Stream processing for some importers (Closed)
Patch Set: review / sync Created 3 years, 8 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/base64.html"> 8 <link rel="import" href="/tracing/base/base64.html">
9 <link rel="import" href="/tracing/base/color_scheme.html"> 9 <link rel="import" href="/tracing/base/color_scheme.html">
10 <link rel="import" href="/tracing/base/math/range.html"> 10 <link rel="import" href="/tracing/base/math/range.html">
11 <link rel="import" href="/tracing/base/scalar.html"> 11 <link rel="import" href="/tracing/base/scalar.html">
12 <link rel="import" href="/tracing/base/trace_stream.html">
12 <link rel="import" href="/tracing/base/unit.html"> 13 <link rel="import" href="/tracing/base/unit.html">
13 <link rel="import" href="/tracing/base/utils.html"> 14 <link rel="import" href="/tracing/base/utils.html">
14 <link rel="import" href="/tracing/extras/importer/heap_dump_trace_event_importer .html"> 15 <link rel="import" href="/tracing/extras/importer/heap_dump_trace_event_importer .html">
16 <link rel="import" href="/tracing/extras/importer/oboe.html">
15 <link rel="import" href="/tracing/extras/importer/trace_code_entry.html"> 17 <link rel="import" href="/tracing/extras/importer/trace_code_entry.html">
16 <link rel="import" href="/tracing/extras/importer/trace_code_map.html"> 18 <link rel="import" href="/tracing/extras/importer/trace_code_map.html">
17 <link rel="import" href="/tracing/extras/importer/v8/codemap.html"> 19 <link rel="import" href="/tracing/extras/importer/v8/codemap.html">
18 <link rel="import" href="/tracing/importer/context_processor.html"> 20 <link rel="import" href="/tracing/importer/context_processor.html">
19 <link rel="import" href="/tracing/importer/importer.html"> 21 <link rel="import" href="/tracing/importer/importer.html">
20 <link rel="import" href="/tracing/model/comment_box_annotation.html"> 22 <link rel="import" href="/tracing/model/comment_box_annotation.html">
21 <link rel="import" href="/tracing/model/constants.html"> 23 <link rel="import" href="/tracing/model/constants.html">
22 <link rel="import" href="/tracing/model/container_memory_dump.html"> 24 <link rel="import" href="/tracing/model/container_memory_dump.html">
23 <link rel="import" href="/tracing/model/counter_series.html"> 25 <link rel="import" href="/tracing/model/counter_series.html">
24 <link rel="import" href="/tracing/model/flow_event.html"> 26 <link rel="import" href="/tracing/model/flow_event.html">
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 116
115 // The list of fields on the trace that are known to contain subtraces. 117 // The list of fields on the trace that are known to contain subtraces.
116 var SUBTRACE_FIELDS = new Set([ 118 var SUBTRACE_FIELDS = new Set([
117 'powerTraceAsString', 119 'powerTraceAsString',
118 'systemTraceEvents', 120 'systemTraceEvents',
119 ]); 121 ]);
120 122
121 // The complete list of fields on the trace that should not be treated as 123 // The complete list of fields on the trace that should not be treated as
122 // trace metadata. 124 // trace metadata.
123 var NON_METADATA_FIELDS = new Set([ 125 var NON_METADATA_FIELDS = new Set([
126 'displayTimeUnit',
124 'samples', 127 'samples',
125 'stackFrames', 128 'stackFrames',
126 'traceAnnotations', 129 'traceAnnotations',
127 'traceEvents', 130 'traceEvents',
128 ...SUBTRACE_FIELDS 131 ...SUBTRACE_FIELDS
129 ]); 132 ]);
130 133
131 function TraceEventImporter(model, eventData) { 134 function TraceEventImporter(model, eventData) {
135 this.hasEvents_ = undefined; // Set properly when importEvents is called.
132 this.importPriority = 1; 136 this.importPriority = 1;
133 this.model_ = model; 137 this.model_ = model;
134 this.events_ = undefined; 138 this.events_ = undefined;
135 this.sampleEvents_ = undefined; 139 this.sampleEvents_ = undefined;
136 this.stackFrameEvents_ = undefined; 140 this.stackFrameEvents_ = undefined;
137 this.stackFrameTree_ = new tr.model.ProfileTree(); 141 this.stackFrameTree_ = new tr.model.ProfileTree();
138 this.subtraces_ = []; 142 this.subtraces_ = [];
139 this.eventsWereFromString_ = false; 143 this.eventsWereFromString_ = false;
140 this.softwareMeasuredCpuCount_ = undefined; 144 this.softwareMeasuredCpuCount_ = undefined;
141 145
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 eventData = eventData + ']'; 193 eventData = eventData + ']';
190 } 194 }
191 } 195 }
192 196
193 this.events_ = JSON.parse(eventData); 197 this.events_ = JSON.parse(eventData);
194 this.eventsWereFromString_ = true; 198 this.eventsWereFromString_ = true;
195 } else { 199 } else {
196 this.events_ = eventData; 200 this.events_ = eventData;
197 } 201 }
198 202
199 this.traceAnnotations_ = this.events_.traceAnnotations;
200
201 // Some trace_event implementations put the actual trace events 203 // Some trace_event implementations put the actual trace events
202 // inside a container. E.g { ... , traceEvents: [ ] } 204 // inside a container. E.g { ... , traceEvents: [ ] }
203 // If we see that, just pull out the trace events. 205 // If we see that, just pull out the trace events.
204 if (this.events_.traceEvents) { 206 if (this.events_.traceEvents) {
205 var container = this.events_; 207 const container = this.events_;
206 this.events_ = this.events_.traceEvents; 208 this.events_ = this.events_.traceEvents;
207 209
208 // Some trace authors store subtraces as specific properties of the trace. 210 for (const subtraceField of SUBTRACE_FIELDS) {
209 for (var subtraceField of SUBTRACE_FIELDS) {
210 if (container[subtraceField]) { 211 if (container[subtraceField]) {
211 this.subtraces_.push(container[subtraceField]); 212 this.storeSubtrace_(container[subtraceField]);
212 } 213 }
213 } 214 }
214 215 this.storeSamples_(container.samples);
215 // Sampling data. 216 this.storeStackFrames_(container.stackFrames);
216 this.sampleEvents_ = container.samples; 217 this.storeDisplayTimeUnit_(container.displayTimeUnit);
217 this.stackFrameEvents_ = container.stackFrames; 218 this.storeTraceAnnotations_(container.traceAnnotations);
218 219 this.storeMetadata_(container);
219 // Some implementations specify displayTimeUnit 220 } else if (this.events_ instanceof tr.b.TraceStream) {
220 if (container.displayTimeUnit) { 221 const parser = oboe()
221 var unitName = container.displayTimeUnit; 222 .node('{cat ph}', function(e) { return oboe.drop; })
222 var unit = tr.b.TimeDisplayModes[unitName]; 223 .node('!.powerTraceAsString', this.storeSubtrace_.bind(this))
223 if (unit === undefined) { 224 .node('!.systemTraceEvents', this.storeSubtrace_.bind(this))
224 throw new Error('Unit ' + unitName + ' is not supported.'); 225 .node('!.samples', this.storeSamples_.bind(this))
225 } 226 .node('!.stackFrames', this.storeStackFrames_.bind(this))
226 this.model_.intrinsicTimeUnit = unit; 227 .node('!.displayTimeUnit', this.storeDisplayTimeUnit_.bind(this))
228 .node('!.traceAnnotations', this.storeTraceAnnotations_.bind(this))
229 .done(this.storeMetadata_.bind(this));
230 this.events_.rewind();
231 while (this.events_.hasData) {
232 parser.write(this.events_.readNumBytes());
227 } 233 }
228 234 parser.finish();
229 // Any other fields in the container should be treated as metadata.
230 for (var fieldName in container) {
231 if (NON_METADATA_FIELDS.has(fieldName)) continue;
232
233 this.model_.metadata.push(
234 { name: fieldName, value: container[fieldName] });
235
236 if (fieldName === 'metadata') {
237 var metadata = container[fieldName];
238 if (metadata['highres-ticks']) {
239 this.model_.isTimeHighResolution = metadata['highres-ticks'];
240 }
241 if (metadata['clock-domain']) {
242 this.clockDomainId_ = metadata['clock-domain'];
243 }
244 }
245 }
246 } 235 }
247 } 236 }
248 237
249 /** 238 /**
250 * @return {boolean} Whether obj is a TraceEvent array. 239 * @return {boolean} Whether obj is a TraceEvent array.
251 */ 240 */
252 TraceEventImporter.canImport = function(eventData) { 241 TraceEventImporter.canImport = function(eventData) {
253 // May be encoded JSON. But we dont want to parse it fully yet. 242 // May be encoded JSON. But we dont want to parse it fully yet.
254 // Use a simple heuristic: 243 // Use a simple heuristic:
255 // - eventData that starts with [ are probably trace_event 244 // - eventData that starts with [ are probably trace_event
256 // - eventData that starts with { are probably trace_event 245 // - eventData that starts with { are probably trace_event
257 // May be encoded JSON. Treat files that start with { as importable by us. 246 // May be encoded JSON. Treat files that start with { as importable by us.
247 if (eventData instanceof tr.b.TraceStream) {
248 if (eventData.isBinary) return false;
249 eventData = eventData.header;
250 }
251
258 if (typeof(eventData) === 'string' || eventData instanceof String) { 252 if (typeof(eventData) === 'string' || eventData instanceof String) {
259 eventData = eventData.trim(); 253 eventData = eventData.trim();
260 return eventData[0] === '{' || eventData[0] === '['; 254 return eventData[0] === '{' || eventData[0] === '[';
261 } 255 }
262 256
263 // Might just be an array of events 257 // Might just be an array of events
264 if (eventData instanceof Array && eventData.length && eventData[0].ph) { 258 if (eventData instanceof Array && eventData.length && eventData[0].ph) {
265 return true; 259 return true;
266 } 260 }
267 261
268 // Might be an object with a traceEvents field in it. 262 // Might be an object with a traceEvents field in it.
269 if (eventData.traceEvents) { 263 if (eventData.traceEvents) {
270 if (eventData.traceEvents instanceof Array) { 264 if (eventData.traceEvents instanceof Array) {
271 if (eventData.traceEvents.length && eventData.traceEvents[0].ph) { 265 if (eventData.traceEvents.length && eventData.traceEvents[0].ph) {
272 return true; 266 return true;
273 } 267 }
274 if (eventData.samples.length && eventData.stackFrames !== undefined) { 268 if (eventData.samples && eventData.samples.length &&
269 eventData.stackFrames !== undefined) {
275 return true; 270 return true;
276 } 271 }
277 } 272 }
278 } 273 }
279 274
280 return false; 275 return false;
281 }; 276 };
282 277
283 /** 278 /**
284 * Extracts a scoped ID from an event. 279 * Extracts a scoped ID from an event.
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 if (event.name.startsWith('Profile')) { 1067 if (event.name.startsWith('Profile')) {
1073 this.processSample(event); 1068 this.processSample(event);
1074 } else { 1069 } else {
1075 this.processLegacyV8Sample(event); 1070 this.processLegacyV8Sample(event);
1076 } 1071 }
1077 } 1072 }
1078 } 1073 }
1079 }, 1074 },
1080 1075
1081 importClockSyncMarkers: function() { 1076 importClockSyncMarkers: function() {
1082 for (var i = 0; i < this.events_.length; i++) { 1077 if (this.events_ instanceof tr.b.TraceStream) {
1083 var event = this.events_[i]; 1078 const parser = oboe().node(
1084 1079 '{cat ph}', this.importClockSyncMarker_.bind(this));
1085 var isLegacyChromeClockSync = isLegacyChromeClockSyncEvent(event); 1080 this.events_.rewind();
1086 if (event.ph !== 'c' && !isLegacyChromeClockSync) continue; 1081 while (this.events_.hasData) {
1087 1082 parser.write(this.events_.readNumBytes());
1088 var eventSizeInBytes = 1083 }
1089 this.model_.importOptions.trackDetailedModelStats ? 1084 parser.finish();
1090 JSON.stringify(event).length : undefined; 1085 } else {
1091 1086 for (let i = 0; i < this.events_.length; i++) {
1092 this.model_.stats.willProcessBasicTraceEvent( 1087 this.importClockSyncMarker_(this.events_[i]);
1093 'clock_sync', event.cat, event.name, event.ts, eventSizeInBytes);
1094
1095 if (isLegacyChromeClockSync) {
1096 this.processLegacyChromeClockSyncEvent(event);
1097 } else {
1098 this.processClockSyncEvent(event);
1099 } 1088 }
1100 } 1089 }
1101 }, 1090 },
1102 1091
1092 importClockSyncMarker_: function(event) {
1093 const isLegacyChromeClockSync = isLegacyChromeClockSyncEvent(event);
1094 if (event.ph !== 'c' && !isLegacyChromeClockSync) return;
1095
1096 const eventSizeInBytes =
1097 this.model_.importOptions.trackDetailedModelStats ?
1098 JSON.stringify(event).length : undefined;
1099
1100 this.model_.stats.willProcessBasicTraceEvent(
1101 'clock_sync', event.cat, event.name, event.ts, eventSizeInBytes);
1102
1103 if (isLegacyChromeClockSync) {
1104 this.processLegacyChromeClockSyncEvent(event);
1105 } else {
1106 this.processClockSyncEvent(event);
1107 }
1108 },
1109
1103 /** 1110 /**
1104 * Walks through the events_ list and outputs the structures discovered to 1111 * Walks through the events_ list and outputs the structures discovered to
1105 * model_. 1112 * model_.
1106 */ 1113 */
1107 importEvents: function() { 1114 importEvents: function() {
1115 this.hasEvents_ = false;
1108 if (this.stackFrameEvents_) { 1116 if (this.stackFrameEvents_) {
1109 this.importStackFrames_(this.stackFrameEvents_, 'g'); 1117 this.importStackFrames_(this.stackFrameEvents_, 'g');
1110 } 1118 }
1111 1119
1112 if (this.traceAnnotations_) { 1120 if (this.traceAnnotations_) this.importAnnotations_();
1113 this.importAnnotations_(); 1121
1122 if (this.events_ instanceof tr.b.TraceStream) {
1123 const parser = oboe().node('{cat ph}', this.processEvent_.bind(this));
1124 this.events_.rewind();
1125 while (this.events_.hasData) {
1126 parser.write(this.events_.readNumBytes());
1127 }
1128 parser.finish();
1129 } else {
1130 for (let eI = 0; eI < this.events_.length; eI++) {
1131 this.processEvent_(this.events_[eI]);
1132 }
1114 } 1133 }
1115 1134
1116 var importOptions = this.model_.importOptions; 1135 this.processV8Events();
1117 var trackDetailedModelStats = importOptions.trackDetailedModelStats;
1118 1136
1119 var modelStats = this.model_.stats; 1137 // Remove all the root stack frame children as they should
1138 // already be added.
1139 for (const frame of Object.values(this.v8ProcessRootStackFrame_)) {
1140 frame.removeAllChildren();
1141 }
1142 },
1120 1143
1121 var events = this.events_; 1144 // Some trace authors store subtraces as specific properties of the trace.
1122 for (var eI = 0; eI < events.length; eI++) { 1145 storeSubtrace_: function(subtrace) {
1123 var event = events[eI]; 1146 this.subtraces_.push(subtrace);
1147 return oboe.drop;
1148 },
1124 1149
1125 if (event.args === '__stripped__') { 1150 storeSamples_: function(samples) {
1126 event.argsStripped = true; 1151 this.sampleEvents_ = samples;
1127 event.args = undefined; 1152 return oboe.drop;
1153 },
1154
1155 storeStackFrames_: function(stackFrames) {
1156 this.stackFrameEvents_ = stackFrames;
1157 return oboe.drop;
1158 },
1159
1160 // Some implementations specify displayTimeUnit
1161 storeDisplayTimeUnit_: function(unitName) {
1162 if (!unitName) return;
1163 const unit = tr.b.TimeDisplayModes[unitName];
1164 if (unit === undefined) {
1165 throw new Error('Unit ' + unitName + ' is not supported.');
1166 }
1167 this.model_.intrinsicTimeUnit = unit;
1168 return oboe.drop;
1169 },
1170
1171 storeTraceAnnotations_: function(traceAnnotations) {
1172 this.traceAnnotations_ = traceAnnotations;
1173 return oboe.drop;
1174 },
1175
1176 // Any fields in the container that is not in NON_METADATA_FIELDS should be
1177 // treated as metadata.
1178 storeMetadata_: function(container) {
1179 for (const fieldName of Object.keys(container)) {
1180 if (NON_METADATA_FIELDS.has(fieldName)) continue;
1181 this.model_.metadata.push(
1182 { name: fieldName, value: container[fieldName] });
1183 if (fieldName !== 'metadata') continue;
1184 const metadata = container[fieldName];
1185 if (metadata['highres-ticks']) {
1186 this.model_.isTimeHighResolution = metadata['highres-ticks'];
1128 } 1187 }
1188 if (metadata['clock-domain']) {
1189 this.clockDomainId_ = metadata['clock-domain'];
1190 }
1191 }
1192 return oboe.drop;
1193 },
1129 1194
1130 var eventSizeInBytes; 1195 processEvent_: function(event) {
1131 if (trackDetailedModelStats) { 1196 this.hasEvents_ = true;
1132 eventSizeInBytes = JSON.stringify(event).length; 1197 const importOptions = this.model_.importOptions;
1133 } else { 1198 const trackDetailedModelStats = importOptions.trackDetailedModelStats;
1134 eventSizeInBytes = undefined; 1199 const modelStats = this.model_.stats;
1135 }
1136 1200
1137 if (event.ph === 'B' || event.ph === 'E') { 1201 if (event.args === '__stripped__') {
1202 event.argsStripped = true;
1203 event.args = undefined;
1204 }
1205
1206 let eventSizeInBytes = undefined;
1207 if (trackDetailedModelStats) {
1208 eventSizeInBytes = JSON.stringify(event).length;
1209 }
1210
1211 switch (event.ph) {
1212 case 'B':
1213 case 'E':
1138 modelStats.willProcessBasicTraceEvent( 1214 modelStats.willProcessBasicTraceEvent(
1139 'begin_end (non-compact)', event.cat, event.name, event.ts, 1215 'begin_end (non-compact)', event.cat, event.name, event.ts,
1140 eventSizeInBytes); 1216 eventSizeInBytes);
1141 this.processDurationEvent(event); 1217 this.processDurationEvent(event);
1142 } else if (event.ph === 'X') { 1218 break;
1219
1220 case 'X': {
1143 modelStats.willProcessBasicTraceEvent( 1221 modelStats.willProcessBasicTraceEvent(
1144 'begin_end (compact)', event.cat, event.name, event.ts, 1222 'begin_end (compact)', event.cat, event.name, event.ts,
1145 eventSizeInBytes); 1223 eventSizeInBytes);
1146 var slice = this.processCompleteEvent(event); 1224 const slice = this.processCompleteEvent(event);
1147 // TODO(yuhaoz): If Chrome supports creating other events with flow, 1225 // TODO(yuhaoz): If Chrome supports creating other events with flow,
1148 // we will need to call processFlowEvent for them also. 1226 // we will need to call processFlowEvent for them also.
1149 // https://github.com/catapult-project/catapult/issues/1259 1227 // https://github.com/catapult-project/catapult/issues/1259
1150 if (slice !== undefined && event.bind_id !== undefined) { 1228 if (slice !== undefined && event.bind_id !== undefined) {
1151 this.processFlowEvent(event, slice); 1229 this.processFlowEvent(event, slice);
1152 } 1230 }
1153 } else if (event.ph === 'b' || event.ph === 'e' || event.ph === 'n' || 1231 break;
1154 event.ph === 'S' || event.ph === 'F' || event.ph === 'T' || 1232 }
1155 event.ph === 'p') { 1233
1234 case 'b':
1235 case 'e':
1236 case 'n':
1237 case 'S':
1238 case 'F':
1239 case 'T':
1240 case 'p':
1156 modelStats.willProcessBasicTraceEvent( 1241 modelStats.willProcessBasicTraceEvent(
1157 'async', event.cat, event.name, event.ts, eventSizeInBytes); 1242 'async', event.cat, event.name, event.ts, eventSizeInBytes);
1158 this.processAsyncEvent(event); 1243 this.processAsyncEvent(event);
1244 break;
1159 1245
1160 // Note, I is historic. The instant event marker got changed, but we 1246 // Note, I is historic. The instant event marker got changed, but we
1161 // want to support loading old trace files so we have both I and i. 1247 // want to support loading old trace files so we have both I and i.
1162 } else if (event.ph === 'I' || event.ph === 'i' || event.ph === 'R') { 1248 case 'I':
1249 case 'i':
1250 case 'R':
1163 modelStats.willProcessBasicTraceEvent( 1251 modelStats.willProcessBasicTraceEvent(
1164 'instant', event.cat, event.name, event.ts, eventSizeInBytes); 1252 'instant', event.cat, event.name, event.ts, eventSizeInBytes);
1165 this.processInstantEvent(event); 1253 this.processInstantEvent(event);
1166 } else if (event.ph === 'P') { 1254 break;
1255
1256 case 'P':
1167 modelStats.willProcessBasicTraceEvent( 1257 modelStats.willProcessBasicTraceEvent(
1168 'samples', event.cat, event.name, event.ts, eventSizeInBytes); 1258 'samples', event.cat, event.name, event.ts, eventSizeInBytes);
1169 this.processTraceSampleEvent(event); 1259 this.processTraceSampleEvent(event);
1170 } else if (event.ph === 'C') { 1260 break;
1261
1262 case 'C':
1171 modelStats.willProcessBasicTraceEvent( 1263 modelStats.willProcessBasicTraceEvent(
1172 'counters', event.cat, event.name, event.ts, eventSizeInBytes); 1264 'counters', event.cat, event.name, event.ts, eventSizeInBytes);
1173 this.processCounterEvent(event); 1265 this.processCounterEvent(event);
1174 } else if (event.ph === 'M') { 1266 break;
1267
1268 case 'M':
1175 modelStats.willProcessBasicTraceEvent( 1269 modelStats.willProcessBasicTraceEvent(
1176 'metadata', event.cat, event.name, event.ts, eventSizeInBytes); 1270 'metadata', event.cat, event.name, event.ts, eventSizeInBytes);
1177 this.processMetadataEvent(event); 1271 this.processMetadataEvent(event);
1178 } else if (event.ph === 'N' || event.ph === 'D' || event.ph === 'O') { 1272 break;
1273
1274 case 'N':
1275 case 'D':
1276 case 'O':
1179 modelStats.willProcessBasicTraceEvent( 1277 modelStats.willProcessBasicTraceEvent(
1180 'objects', event.cat, event.name, event.ts, eventSizeInBytes); 1278 'objects', event.cat, event.name, event.ts, eventSizeInBytes);
1181 this.processObjectEvent(event); 1279 this.processObjectEvent(event);
1182 } else if (event.ph === 's' || event.ph === 't' || event.ph === 'f') { 1280 break;
1281
1282 case 's':
1283 case 't':
1284 case 'f':
1183 modelStats.willProcessBasicTraceEvent( 1285 modelStats.willProcessBasicTraceEvent(
1184 'flows', event.cat, event.name, event.ts, eventSizeInBytes); 1286 'flows', event.cat, event.name, event.ts, eventSizeInBytes);
1185 this.processFlowEvent(event); 1287 this.processFlowEvent(event);
1186 } else if (event.ph === 'v') { 1288 break;
1289
1290 case 'v':
1187 modelStats.willProcessBasicTraceEvent( 1291 modelStats.willProcessBasicTraceEvent(
1188 'memory_dumps', event.cat, event.name, event.ts, 1292 'memory_dumps', event.cat, event.name, event.ts,
1189 eventSizeInBytes); 1293 eventSizeInBytes);
1190 this.processMemoryDumpEvent(event); 1294 this.processMemoryDumpEvent(event);
1191 } else if (event.ph === '(' || event.ph === ')') { 1295 break;
1296
1297 case '(':
1298 case ')':
1192 this.processContextEvent(event); 1299 this.processContextEvent(event);
1193 } else if (event.ph === 'c') { 1300 break;
1194 // No-op. Clock sync events have already been processed in 1301
1195 // importClockSyncMarkers(). 1302 // No-op. Clock sync events have already been processed in
1196 } else { 1303 // importClockSyncMarkers().
1304 case 'c':
1305 break;
1306
1307 default:
1197 modelStats.willProcessBasicTraceEvent( 1308 modelStats.willProcessBasicTraceEvent(
1198 'unknown', event.cat, event.name, event.ts, eventSizeInBytes); 1309 'unknown', event.cat, event.name, event.ts, eventSizeInBytes);
1199 this.model_.importWarning({ 1310 this.model_.importWarning({
1200 type: 'parse_error', 1311 type: 'parse_error',
1201 message: 'Unrecognized event phase: ' + 1312 message: 'Unrecognized event phase: ' +
1202 event.ph + ' (' + event.name + ')' 1313 event.ph + ' (' + event.name + ')'
1203 }); 1314 });
1204 }
1205 } 1315 }
1206 this.processV8Events(); 1316 return oboe.drop;
1207
1208 // Remove all the root stack frame children as they should
1209 // already be added.
1210 for (var frame of Object.values(this.v8ProcessRootStackFrame_)) {
1211 frame.removeAllChildren();
1212 }
1213 }, 1317 },
1214 1318
1215 importStackFrames_: function(rawStackFrames, idPrefix) { 1319 importStackFrames_: function(rawStackFrames, idPrefix) {
1216 var model = this.model_; 1320 var model = this.model_;
1217 1321
1218 for (var id in rawStackFrames) { 1322 for (var id in rawStackFrames) {
1219 var rawStackFrame = rawStackFrames[id]; 1323 var rawStackFrame = rawStackFrames[id];
1220 var fullId = idPrefix + id; 1324 var fullId = idPrefix + id;
1221 var textForColor = rawStackFrame.category ? 1325 var textForColor = rawStackFrame.category ?
1222 rawStackFrame.category : rawStackFrame.name; 1326 rawStackFrame.category : rawStackFrame.name;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 // TODO(alph,fmeawad): Add codemap resolution code here. 1521 // TODO(alph,fmeawad): Add codemap resolution code here.
1418 return undefined; 1522 return undefined;
1419 }, 1523 },
1420 1524
1421 importSampleData: function() { 1525 importSampleData: function() {
1422 if (!this.sampleEvents_) return; 1526 if (!this.sampleEvents_) return;
1423 var m = this.model_; 1527 var m = this.model_;
1424 1528
1425 // If this is the only importer, then fake-create the threads. 1529 // If this is the only importer, then fake-create the threads.
1426 var events = this.sampleEvents_; 1530 var events = this.sampleEvents_;
1427 if (this.events_.length === 0) { 1531 if (this.hasEvents_ === undefined) {
1532 throw new Error('importEvents is not run before importSampleData');
1533 } else if (!this.hasEvents_) {
1428 for (var i = 0; i < events.length; i++) { 1534 for (var i = 0; i < events.length; i++) {
1429 var event = events[i]; 1535 var event = events[i];
1430 m.getOrCreateProcess(event.tid).getOrCreateThread(event.tid); 1536 m.getOrCreateProcess(event.tid).getOrCreateThread(event.tid);
1431 } 1537 }
1432 } 1538 }
1433 1539
1434 var threadsByTid = {}; 1540 var threadsByTid = {};
1435 m.getAllThreads().forEach(function(t) { 1541 m.getAllThreads().forEach(function(t) {
1436 threadsByTid[t.tid] = t; 1542 threadsByTid[t.tid] = t;
1437 }); 1543 });
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 } 3242 }
3137 }; 3243 };
3138 3244
3139 tr.importer.Importer.register(TraceEventImporter); 3245 tr.importer.Importer.register(TraceEventImporter);
3140 3246
3141 return { 3247 return {
3142 TraceEventImporter, 3248 TraceEventImporter,
3143 }; 3249 };
3144 }); 3250 });
3145 </script> 3251 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698