OLD | NEW |
---|---|
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/range.html"> | 10 <link rel="import" href="/tracing/base/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/unit.html"> | 12 <link rel="import" href="/tracing/base/unit.html"> |
13 <link rel="import" href="/tracing/base/utils.html"> | 13 <link rel="import" href="/tracing/base/utils.html"> |
14 <link rel="import" href="/tracing/extras/importer/heap_dump_trace_event_importer .html"> | 14 <link rel="import" href="/tracing/extras/importer/heap_dump_trace_event_importer .html"> |
15 <link rel="import" href="/tracing/extras/importer/legacy_heap_dump_trace_event_i mporter.html"> | |
16 <link rel="import" href="/tracing/extras/importer/streaming_event_expander.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 15 matching lines...) Expand all Loading... | |
40 | 42 |
41 /** | 43 /** |
42 * @fileoverview TraceEventImporter imports TraceEvent-formatted data | 44 * @fileoverview TraceEventImporter imports TraceEvent-formatted data |
43 * into the provided model. | 45 * into the provided model. |
44 */ | 46 */ |
45 tr.exportTo('tr.e.importer', function() { | 47 tr.exportTo('tr.e.importer', function() { |
46 var Base64 = tr.b.Base64; | 48 var Base64 = tr.b.Base64; |
47 var deepCopy = tr.b.deepCopy; | 49 var deepCopy = tr.b.deepCopy; |
48 var ColorScheme = tr.b.ColorScheme; | 50 var ColorScheme = tr.b.ColorScheme; |
49 var HeapDumpTraceEventImporter = tr.e.importer.HeapDumpTraceEventImporter; | 51 var HeapDumpTraceEventImporter = tr.e.importer.HeapDumpTraceEventImporter; |
52 var LegacyHeapDumpTraceEventImporter = | |
53 tr.e.importer.LegacyHeapDumpTraceEventImporter; | |
54 var StreamingEventExpander = tr.e.importer.StreamingEventExpander; | |
50 | 55 |
51 function getEventColor(event, opt_customName) { | 56 function getEventColor(event, opt_customName) { |
52 if (event.cname) | 57 if (event.cname) |
53 return ColorScheme.getColorIdForReservedName(event.cname); | 58 return ColorScheme.getColorIdForReservedName(event.cname); |
54 else if (opt_customName || event.name) { | 59 else if (opt_customName || event.name) { |
55 return ColorScheme.getColorIdForGeneralPurposeString( | 60 return ColorScheme.getColorIdForGeneralPurposeString( |
56 opt_customName || event.name); | 61 opt_customName || event.name); |
57 } | 62 } |
58 } | 63 } |
59 | 64 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 this.profileInfo_ = new Map(); | 164 this.profileInfo_ = new Map(); |
160 | 165 |
161 // For tracking async events that is used to create back-compat clock sync | 166 // For tracking async events that is used to create back-compat clock sync |
162 // event. | 167 // event. |
163 this.legacyChromeClockSyncStartEvent_ = undefined; | 168 this.legacyChromeClockSyncStartEvent_ = undefined; |
164 this.legacyChromeClockSyncFinishEvent_ = undefined; | 169 this.legacyChromeClockSyncFinishEvent_ = undefined; |
165 | 170 |
166 // Dump ID -> PID -> [process memory dump events]. | 171 // Dump ID -> PID -> [process memory dump events]. |
167 this.allMemoryDumpEvents_ = {}; | 172 this.allMemoryDumpEvents_ = {}; |
168 | 173 |
174 // Unpacks size, count, stackId and heapId from 'P' events. Also remembers | |
175 // stack frame and type information. | |
176 this.heapEventExpander = new StreamingEventExpander(); | |
177 | |
169 // PID -> Object type ID -> Object type name. | 178 // PID -> Object type ID -> Object type name. |
170 this.objectTypeNameMap_ = {}; | 179 this.objectTypeNameMap_ = {}; |
171 | 180 |
172 // For old Chrome traces with no clock domain metadata, just use a | 181 // For old Chrome traces with no clock domain metadata, just use a |
173 // placeholder clock domain. | 182 // placeholder clock domain. |
174 this.clockDomainId_ = tr.model.ClockDomainId.UNKNOWN_CHROME_LEGACY; | 183 this.clockDomainId_ = tr.model.ClockDomainId.UNKNOWN_CHROME_LEGACY; |
175 // A function able to transform timestamps in |clockDomainId| to timestamps | 184 // A function able to transform timestamps in |clockDomainId| to timestamps |
176 // in the model clock domain. | 185 // in the model clock domain. |
177 this.toModelTime_ = undefined; | 186 this.toModelTime_ = undefined; |
178 | 187 |
(...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2627 rawVmRegion.pf, // protectionFlags | 2636 rawVmRegion.pf, // protectionFlags |
2628 rawVmRegion.mf, // mappedFile | 2637 rawVmRegion.mf, // mappedFile |
2629 byteStats); | 2638 byteStats); |
2630 } | 2639 } |
2631 | 2640 |
2632 processMemoryDump.vmRegions = | 2641 processMemoryDump.vmRegions = |
2633 tr.model.VMRegionClassificationNode.fromRegions(vmRegions); | 2642 tr.model.VMRegionClassificationNode.fromRegions(vmRegions); |
2634 }, | 2643 }, |
2635 | 2644 |
2636 parseMemoryDumpHeapDumps_: function(processMemoryDump, dumps, pid, dumpId) { | 2645 parseMemoryDumpHeapDumps_: function(processMemoryDump, dumps, pid, dumpId) { |
2637 var rawHeapDumps = dumps.heaps; | 2646 var idPrefix = 'p' + pid + ':'; |
2638 if (rawHeapDumps === undefined) | 2647 var importer; |
2648 if (dumps.heaps) { | |
2649 var processTypeMap = this.objectTypeNameMap_[pid]; | |
fmeawad
2017/03/23 20:43:57
nit: let
hjd
2017/05/22 15:43:42
Done, thanks!
| |
2650 if (processTypeMap === undefined) { | |
2651 this.model_.importWarning({ | |
2652 type: 'memory_dump_parse_error', | |
2653 message: 'Missing mapping from object type IDs to names.' | |
2654 }); | |
2655 } | |
2656 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!
| |
2657 processMemoryDump, processTypeMap, idPrefix, dumpId, dumps.heaps); | |
2658 } else if (dumps.heaps_v2) { | |
2659 let data = dumps.heaps_v2; | |
2660 this.heapEventExpander = this.heapEventExpander.expandData(data); | |
2661 // TODO(hjd): Unify how we are reading & inflating stack frame data. | |
2662 this.addNewStackFramesFromExpander_(this.heapEventExpander, idPrefix); | |
2663 importer = new HeapDumpTraceEventImporter(this.heapEventExpander, | |
2664 this.model_.stackFrames, processMemoryDump, idPrefix, this.model_); | |
2665 } else { | |
2639 return; | 2666 return; |
2667 } | |
2668 | |
2669 var heapDumps = importer.parse(); | |
2670 if (!heapDumps) { | |
2671 return; | |
2672 } | |
2640 | 2673 |
2641 if (processMemoryDump.heapDumps !== undefined) { | 2674 if (processMemoryDump.heapDumps !== undefined) { |
2642 this.model_.importWarning({ | 2675 this.model_.importWarning({ |
2643 type: 'memory_dump_parse_error', | 2676 type: 'memory_dump_parse_error', |
2644 message: 'Heap dumps provided multiple times for' + | 2677 message: 'Heap dumps provided multiple times for' + |
2645 ' process memory dump for PID=' + pid + | 2678 ' process memory dump for PID=' + pid + |
2646 ' and dump ID=' + dumpId + '.' | 2679 ' and dump ID=' + dumpId + '.' |
2647 }); | 2680 }); |
2648 return; | 2681 return; |
2649 } | 2682 } |
2650 | 2683 |
2651 var processTypeMap = this.objectTypeNameMap_[pid]; | 2684 if (Object.keys(heapDumps).length > 0) { |
2652 if (processTypeMap === undefined) { | 2685 processMemoryDump.heapDumps = heapDumps; |
2653 this.model_.importWarning({ | |
2654 type: 'memory_dump_parse_error', | |
2655 message: 'Missing mapping from object type IDs to names.' | |
2656 }); | |
2657 } | 2686 } |
2687 }, | |
2658 | 2688 |
2659 var idPrefix = 'p' + pid + ':'; | 2689 addNewStackFramesFromExpander_: function(expander, idPrefix) { |
2660 var heapDumps = {}; | 2690 const nodeMap = expander.getNewMap('nodes'); |
2661 | 2691 var newStackFrames = {}; |
2662 var importer = new HeapDumpTraceEventImporter( | 2692 for (var [id, stackFrame] of nodeMap.entries()) { |
2663 this.model_, processMemoryDump, processTypeMap, idPrefix, dumpId); | 2693 if (!this.model_.stackFrames[idPrefix + id]) { |
2664 | 2694 newStackFrames[id] = { |
2665 for (var allocatorName in rawHeapDumps) { | 2695 id, |
2666 var rawHeapDump = rawHeapDumps[allocatorName]; | 2696 name: expander.getString(stackFrame.name_sid), |
2667 var heapDump = importer.parseRawHeapDump(rawHeapDump, allocatorName); | 2697 }; |
2668 | 2698 if (stackFrame.parent) newStackFrames[id].parent = stackFrame.parent; |
2669 // Throw away heap dumps with no entries. This can happen if all raw | 2699 } |
2670 // entries in the trace are skipped for some reason (e.g. invalid leaf | |
2671 // stack frame ID). | |
2672 if (heapDump !== undefined && heapDump.entries.length > 0) | |
2673 heapDumps[allocatorName] = heapDump; | |
2674 } | 2700 } |
2675 | 2701 this.importStackFrames_(newStackFrames, idPrefix); |
2676 if (Object.keys(heapDumps).length > 0) | |
2677 processMemoryDump.heapDumps = heapDumps; | |
2678 }, | 2702 }, |
2679 | 2703 |
2680 parseMemoryDumpLevelOfDetail_: function(levelsOfDetail, dumps, pid, | 2704 parseMemoryDumpLevelOfDetail_: function(levelsOfDetail, dumps, pid, |
2681 dumpId) { | 2705 dumpId) { |
2682 var rawLevelOfDetail = dumps.level_of_detail; | 2706 var rawLevelOfDetail = dumps.level_of_detail; |
2683 var level; | 2707 var level; |
2684 switch (rawLevelOfDetail) { | 2708 switch (rawLevelOfDetail) { |
2685 case 'background': | 2709 case 'background': |
2686 level = BACKGROUND; | 2710 level = BACKGROUND; |
2687 break; | 2711 break; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3103 } | 3127 } |
3104 }; | 3128 }; |
3105 | 3129 |
3106 tr.importer.Importer.register(TraceEventImporter); | 3130 tr.importer.Importer.register(TraceEventImporter); |
3107 | 3131 |
3108 return { | 3132 return { |
3109 TraceEventImporter, | 3133 TraceEventImporter, |
3110 }; | 3134 }; |
3111 }); | 3135 }); |
3112 </script> | 3136 </script> |
OLD | NEW |