blob: ca5ff675f325c5610db8f85ce795c2c5e6343929 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// 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
Ben Murdochc5610432016-08-08 18:44:38 +01005function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) {
6 LogReader.call(this, {
Ben Murdoch61f157c2016-09-16 13:49:30 +01007 'shared-library': { parsers: [null, parseInt, parseInt, parseInt],
Ben Murdochc5610432016-08-08 18:44:38 +01008 processor: this.processSharedLibrary }
9 }, timedRange, pairwiseTimedRange);
10
11 this.cppEntriesProvider_ = cppEntriesProvider;
12 this.codeMap_ = new CodeMap();
13 this.lastLogFileName_ = null;
14}
15inherits(CppProcessor, LogReader);
16
17/**
18 * @override
19 */
20CppProcessor.prototype.printError = function(str) {
21 print(str);
22};
23
24CppProcessor.prototype.processLogFile = function(fileName) {
25 this.lastLogFileName_ = fileName;
26 var line;
27 while (line = readline()) {
28 this.processLogLine(line);
29 }
30};
31
32CppProcessor.prototype.processLogFileInTest = function(fileName) {
33 // Hack file name to avoid dealing with platform specifics.
34 this.lastLogFileName_ = 'v8.log';
35 var contents = readFile(fileName);
36 this.processLogChunk(contents);
37};
38
39CppProcessor.prototype.processSharedLibrary = function(
Ben Murdoch61f157c2016-09-16 13:49:30 +010040 name, startAddr, endAddr, aslrSlide) {
Ben Murdochc5610432016-08-08 18:44:38 +010041 var self = this;
42 var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
Ben Murdoch61f157c2016-09-16 13:49:30 +010043 name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
Ben Murdochc5610432016-08-08 18:44:38 +010044 var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP');
45 self.codeMap_.addStaticCode(fStart, entry);
46 });
47};
48
49CppProcessor.prototype.dumpCppSymbols = function() {
50 var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
51 var total = staticEntries.length;
52 for (var i = 0; i < total; ++i) {
53 var entry = staticEntries[i];
54 var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size,
55 '"' + entry[1].name + '"'];
56 print(printValues.join(','));
57 }
58};