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 5function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) { 6 LogReader.call(this, { 7 'shared-library': { parsers: [parseString, parseInt, parseInt, parseInt], 8 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( 40 name, startAddr, endAddr, aslrSlide) { 41 var self = this; 42 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( 43 name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) { 44 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}; 59