Index: tracing/tracing/extras/importer/trace_event_importer.html |
diff --git a/tracing/tracing/extras/importer/trace_event_importer.html b/tracing/tracing/extras/importer/trace_event_importer.html |
index a0d543d731b7f4f6378d2ec7db67e20b5a82c8c9..fa8c0d134fa01578f8ba6c24e8fa77b4bcdeb091 100644 |
--- a/tracing/tracing/extras/importer/trace_event_importer.html |
+++ b/tracing/tracing/extras/importer/trace_event_importer.html |
@@ -12,6 +12,8 @@ found in the LICENSE file. |
<link rel="import" href="/tracing/base/unit.html"> |
<link rel="import" href="/tracing/base/utils.html"> |
<link rel="import" href="/tracing/extras/importer/heap_dump_trace_event_importer.html"> |
+<link rel="import" href="/tracing/extras/importer/legacy_heap_dump_trace_event_importer.html"> |
+<link rel="import" href="/tracing/extras/importer/streaming_event_expander.html"> |
<link rel="import" href="/tracing/extras/importer/trace_code_entry.html"> |
<link rel="import" href="/tracing/extras/importer/trace_code_map.html"> |
<link rel="import" href="/tracing/extras/importer/v8/codemap.html"> |
@@ -47,6 +49,9 @@ tr.exportTo('tr.e.importer', function() { |
var deepCopy = tr.b.deepCopy; |
var ColorScheme = tr.b.ColorScheme; |
var HeapDumpTraceEventImporter = tr.e.importer.HeapDumpTraceEventImporter; |
+ var LegacyHeapDumpTraceEventImporter = |
+ tr.e.importer.LegacyHeapDumpTraceEventImporter; |
+ var StreamingEventExpander = tr.e.importer.StreamingEventExpander; |
function getEventColor(event, opt_customName) { |
if (event.cname) |
@@ -166,6 +171,10 @@ tr.exportTo('tr.e.importer', function() { |
// Dump ID -> PID -> [process memory dump events]. |
this.allMemoryDumpEvents_ = {}; |
+ // Unpacks size, count, stackId and heapId from 'P' events. Also remembers |
+ // stack frame and type information. |
+ this.heapEventExpander = new StreamingEventExpander(); |
+ |
// PID -> Object type ID -> Object type name. |
this.objectTypeNameMap_ = {}; |
@@ -2634,9 +2643,33 @@ tr.exportTo('tr.e.importer', function() { |
}, |
parseMemoryDumpHeapDumps_: function(processMemoryDump, dumps, pid, dumpId) { |
- var rawHeapDumps = dumps.heaps; |
- if (rawHeapDumps === undefined) |
+ var idPrefix = 'p' + pid + ':'; |
+ var importer; |
+ if (dumps.heaps) { |
+ var processTypeMap = this.objectTypeNameMap_[pid]; |
fmeawad
2017/03/23 20:43:57
nit: let
hjd
2017/05/22 15:43:42
Done, thanks!
|
+ if (processTypeMap === undefined) { |
+ this.model_.importWarning({ |
+ type: 'memory_dump_parse_error', |
+ message: 'Missing mapping from object type IDs to names.' |
+ }); |
+ } |
+ var importer = new LegacyHeapDumpTraceEventImporter(this.model_, |
fmeawad
2017/03/23 20:43:57
nit: var not needed since the variable is already
hjd
2017/05/22 15:43:42
Done, Thanks!
|
+ processMemoryDump, processTypeMap, idPrefix, dumpId, dumps.heaps); |
+ } else if (dumps.heaps_v2) { |
+ let data = dumps.heaps_v2; |
+ this.heapEventExpander = this.heapEventExpander.expandData(data); |
+ // TODO(hjd): Unify how we are reading & inflating stack frame data. |
+ this.addNewStackFramesFromExpander_(this.heapEventExpander, idPrefix); |
+ importer = new HeapDumpTraceEventImporter(this.heapEventExpander, |
+ this.model_.stackFrames, processMemoryDump, idPrefix, this.model_); |
+ } else { |
+ return; |
+ } |
+ |
+ var heapDumps = importer.parse(); |
+ if (!heapDumps) { |
return; |
+ } |
if (processMemoryDump.heapDumps !== undefined) { |
this.model_.importWarning({ |
@@ -2648,33 +2681,24 @@ tr.exportTo('tr.e.importer', function() { |
return; |
} |
- var processTypeMap = this.objectTypeNameMap_[pid]; |
- if (processTypeMap === undefined) { |
- this.model_.importWarning({ |
- type: 'memory_dump_parse_error', |
- message: 'Missing mapping from object type IDs to names.' |
- }); |
+ if (Object.keys(heapDumps).length > 0) { |
+ processMemoryDump.heapDumps = heapDumps; |
} |
+ }, |
- var idPrefix = 'p' + pid + ':'; |
- var heapDumps = {}; |
- |
- var importer = new HeapDumpTraceEventImporter( |
- this.model_, processMemoryDump, processTypeMap, idPrefix, dumpId); |
- |
- for (var allocatorName in rawHeapDumps) { |
- var rawHeapDump = rawHeapDumps[allocatorName]; |
- var heapDump = importer.parseRawHeapDump(rawHeapDump, allocatorName); |
- |
- // Throw away heap dumps with no entries. This can happen if all raw |
- // entries in the trace are skipped for some reason (e.g. invalid leaf |
- // stack frame ID). |
- if (heapDump !== undefined && heapDump.entries.length > 0) |
- heapDumps[allocatorName] = heapDump; |
+ addNewStackFramesFromExpander_: function(expander, idPrefix) { |
+ const nodeMap = expander.getNewMap('nodes'); |
+ var newStackFrames = {}; |
+ for (var [id, stackFrame] of nodeMap.entries()) { |
+ if (!this.model_.stackFrames[idPrefix + id]) { |
+ newStackFrames[id] = { |
+ id, |
+ name: expander.getString(stackFrame.name_sid), |
+ }; |
+ if (stackFrame.parent) newStackFrames[id].parent = stackFrame.parent; |
+ } |
} |
- |
- if (Object.keys(heapDumps).length > 0) |
- processMemoryDump.heapDumps = heapDumps; |
+ this.importStackFrames_(newStackFrames, idPrefix); |
}, |
parseMemoryDumpLevelOfDetail_: function(levelsOfDetail, dumps, pid, |