Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 5 | function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) { |
| 6 | LogReader.call(this, { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 7 | 'shared-library': { parsers: [null, parseInt, parseInt, parseInt], |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 8 | processor: this.processSharedLibrary } |
| 9 | }, timedRange, pairwiseTimedRange); |
| 10 | |
| 11 | this.cppEntriesProvider_ = cppEntriesProvider; |
| 12 | this.codeMap_ = new CodeMap(); |
| 13 | this.lastLogFileName_ = null; |
| 14 | } |
| 15 | inherits(CppProcessor, LogReader); |
| 16 | |
| 17 | /** |
| 18 | * @override |
| 19 | */ |
| 20 | CppProcessor.prototype.printError = function(str) { |
| 21 | print(str); |
| 22 | }; |
| 23 | |
| 24 | CppProcessor.prototype.processLogFile = function(fileName) { |
| 25 | this.lastLogFileName_ = fileName; |
| 26 | var line; |
| 27 | while (line = readline()) { |
| 28 | this.processLogLine(line); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | CppProcessor.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 | |
| 39 | CppProcessor.prototype.processSharedLibrary = function( |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 40 | name, startAddr, endAddr, aslrSlide) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 41 | var self = this; |
| 42 | var libFuncs = this.cppEntriesProvider_.parseVmSymbols( |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 43 | name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 44 | var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP'); |
| 45 | self.codeMap_.addStaticCode(fStart, entry); |
| 46 | }); |
| 47 | }; |
| 48 | |
| 49 | CppProcessor.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 | }; |