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

Side by Side Diff: tools/dumpcpp.js

Issue 1884493003: Dump C++ symbols and merge into v8 log. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « tools/dump-cpp.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
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) {
42 LogReader.call(this, {
43 'shared-library': { parsers: [null, parseInt, parseInt],
44 processor: this.processSharedLibrary }
45 }, timedRange, pairwiseTimedRange);
46
47 this.cppEntriesProvider_ = cppEntriesProvider;
48 this.codeMap_ = new CodeMap();
49 this.lastLogFileName_ = null;
50 }
51 inherits(CppProcessor, LogReader);
52
53 /**
54 * @override
55 */
56 CppProcessor.prototype.printError = function(str) {
57 print(str);
58 };
59
60 CppProcessor.prototype.processLogFile = function(fileName) {
61 this.lastLogFileName_ = fileName;
62 var line;
63 while (line = readline()) {
64 this.processLogLine(line);
65 }
66 };
67
68 CppProcessor.prototype.processLogFileInTest = function(fileName) {
69 // Hack file name to avoid dealing with platform specifics.
70 this.lastLogFileName_ = 'v8.log';
71 var contents = readFile(fileName);
72 this.processLogChunk(contents);
73 };
74
75 CppProcessor.prototype.processSharedLibrary = function(
76 name, startAddr, endAddr) {
77 var self = this;
78 var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
79 name, startAddr, endAddr, function(fName, fStart, fEnd) {
80 var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP');
81 self.codeMap_.addStaticCode(fStart, entry);
82 });
83 };
84
85 CppProcessor.prototype.dumpCppSymbols = function() {
86 var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
87 var total = staticEntries.length;
88 for (var i = 0; i < total; ++i) {
89 var entry = staticEntries[i];
90 var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size,
91 '"' + entry[1].name + '"'];
92 print(printValues.join(','));
93 }
94 };
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
« no previous file with comments | « tools/dump-cpp.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698