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

Side by Side Diff: tools/dumpcpp.js

Issue 2006813002: [prof] Add slide offset in dumpcpp script (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add unit test for dumpcpp script Created 4 years, 6 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 // 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 // Dump C++ symbols of shared library if possible
6
7 function processArguments(args) {
8 var processor = new ArgumentsProcessor(args);
9 if (processor.parse()) {
10 return processor.result();
11 } else {
12 processor.printUsageAndExit();
13 }
14 }
15
16 function initSourceMapSupport() {
17 // Pull dev tools source maps into our name space.
18 SourceMap = WebInspector.SourceMap;
19
20 // Overwrite the load function to load scripts synchronously.
21 SourceMap.load = function(sourceMapURL) {
22 var content = readFile(sourceMapURL);
23 var sourceMapObject = (JSON.parse(content));
24 return new SourceMap(sourceMapURL, sourceMapObject);
25 };
26 }
27
28 var entriesProviders = {
29 'unix': UnixCppEntriesProvider,
30 'windows': WindowsCppEntriesProvider,
31 'mac': MacCppEntriesProvider
32 };
33
34 var params = processArguments(arguments);
35 var sourceMap = null;
36 if (params.sourceMap) {
37 initSourceMapSupport();
38 sourceMap = SourceMap.load(params.sourceMap);
39 }
40
41 function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) { 5 function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) {
42 LogReader.call(this, { 6 LogReader.call(this, {
43 'shared-library': { parsers: [null, parseInt, parseInt], 7 'shared-library': { parsers: [null, parseInt, parseInt, parseInt],
44 processor: this.processSharedLibrary } 8 processor: this.processSharedLibrary }
45 }, timedRange, pairwiseTimedRange); 9 }, timedRange, pairwiseTimedRange);
46 10
47 this.cppEntriesProvider_ = cppEntriesProvider; 11 this.cppEntriesProvider_ = cppEntriesProvider;
48 this.codeMap_ = new CodeMap(); 12 this.codeMap_ = new CodeMap();
49 this.lastLogFileName_ = null; 13 this.lastLogFileName_ = null;
50 } 14 }
51 inherits(CppProcessor, LogReader); 15 inherits(CppProcessor, LogReader);
52 16
53 /** 17 /**
(...skipping 12 matching lines...) Expand all
66 }; 30 };
67 31
68 CppProcessor.prototype.processLogFileInTest = function(fileName) { 32 CppProcessor.prototype.processLogFileInTest = function(fileName) {
69 // Hack file name to avoid dealing with platform specifics. 33 // Hack file name to avoid dealing with platform specifics.
70 this.lastLogFileName_ = 'v8.log'; 34 this.lastLogFileName_ = 'v8.log';
71 var contents = readFile(fileName); 35 var contents = readFile(fileName);
72 this.processLogChunk(contents); 36 this.processLogChunk(contents);
73 }; 37 };
74 38
75 CppProcessor.prototype.processSharedLibrary = function( 39 CppProcessor.prototype.processSharedLibrary = function(
76 name, startAddr, endAddr) { 40 name, startAddr, endAddr, aslrSlide) {
77 var self = this; 41 var self = this;
78 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( 42 var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
79 name, startAddr, endAddr, function(fName, fStart, fEnd) { 43 name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
80 var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP'); 44 var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP');
81 self.codeMap_.addStaticCode(fStart, entry); 45 self.codeMap_.addStaticCode(fStart, entry);
82 }); 46 });
83 }; 47 };
84 48
85 CppProcessor.prototype.dumpCppSymbols = function() { 49 CppProcessor.prototype.dumpCppSymbols = function() {
86 var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses(); 50 var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
87 var total = staticEntries.length; 51 var total = staticEntries.length;
88 for (var i = 0; i < total; ++i) { 52 for (var i = 0; i < total; ++i) {
89 var entry = staticEntries[i]; 53 var entry = staticEntries[i];
90 var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size, 54 var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size,
91 '"' + entry[1].name + '"']; 55 '"' + entry[1].name + '"'];
92 print(printValues.join(',')); 56 print(printValues.join(','));
93 } 57 }
94 }; 58 };
95
96 var cppProcessor = new CppProcessor(
97 new (entriesProviders[params.platform])(params.nm, params.targetRootFS),
98 params.timedRange, params.pairwiseTimedRange);
99 cppProcessor.processLogFile(params.logFileName);
100 cppProcessor.dumpCppSymbols();
OLDNEW
« test/mjsunit/mjsunit.isolate ('K') | « tools/dump-cpp.py ('k') | tools/dumpcpp-driver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698