2016-04-28 06:56:35 +00:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-09-28 13:50:56 +00:00
|
|
|
import { LogReader, parseString } from "./logreader.mjs";
|
2020-11-03 09:17:12 +00:00
|
|
|
import { CodeMap, CodeEntry } from "./codemap.mjs";
|
2020-09-28 13:50:56 +00:00
|
|
|
export {
|
2021-06-01 18:13:48 +00:00
|
|
|
ArgumentsProcessor, LinuxCppEntriesProvider,
|
|
|
|
WindowsCppEntriesProvider, MacOSCppEntriesProvider,
|
2020-09-28 13:50:56 +00:00
|
|
|
} from "./tickprocessor.mjs";
|
|
|
|
|
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
export class CppProcessor extends LogReader {
|
|
|
|
constructor(cppEntriesProvider, timedRange, pairwiseTimedRange) {
|
|
|
|
super({}, timedRange, pairwiseTimedRange);
|
|
|
|
this.dispatchTable_ = {
|
|
|
|
'shared-library': {
|
|
|
|
parsers: [parseString, parseInt, parseInt, parseInt],
|
2016-04-28 06:56:35 +00:00
|
|
|
processor: this.processSharedLibrary }
|
2020-11-03 09:17:12 +00:00
|
|
|
};
|
|
|
|
this.cppEntriesProvider_ = cppEntriesProvider;
|
|
|
|
this.codeMap_ = new CodeMap();
|
|
|
|
this.lastLogFileName_ = null;
|
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
printError(str) {
|
2021-03-24 12:12:45 +00:00
|
|
|
console.log(str);
|
2021-01-11 14:16:54 +00:00
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
processLogFile(fileName) {
|
|
|
|
this.lastLogFileName_ = fileName;
|
2020-11-10 11:47:40 +00:00
|
|
|
let line;
|
2020-11-03 09:17:12 +00:00
|
|
|
while (line = readline()) {
|
|
|
|
this.processLogLine(line);
|
|
|
|
}
|
2021-01-11 14:16:54 +00:00
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
processLogFileInTest(fileName) {
|
|
|
|
// Hack file name to avoid dealing with platform specifics.
|
|
|
|
this.lastLogFileName_ = 'v8.log';
|
2021-06-01 12:46:36 +00:00
|
|
|
const contents = d8.file.read(fileName);
|
2020-11-03 09:17:12 +00:00
|
|
|
this.processLogChunk(contents);
|
2021-01-11 14:16:54 +00:00
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
processSharedLibrary(name, startAddr, endAddr, aslrSlide) {
|
2020-11-10 11:47:40 +00:00
|
|
|
const self = this;
|
|
|
|
const libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
2020-11-03 09:17:12 +00:00
|
|
|
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
|
2020-11-10 11:47:40 +00:00
|
|
|
const entry = new CodeEntry(fEnd - fStart, fName, 'CPP');
|
2020-11-03 09:17:12 +00:00
|
|
|
self.codeMap_.addStaticCode(fStart, entry);
|
|
|
|
});
|
2021-01-11 14:16:54 +00:00
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
|
2020-11-03 09:17:12 +00:00
|
|
|
dumpCppSymbols() {
|
2020-11-10 11:47:40 +00:00
|
|
|
const staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
|
|
|
|
const total = staticEntries.length;
|
|
|
|
for (let i = 0; i < total; ++i) {
|
|
|
|
const entry = staticEntries[i];
|
|
|
|
const printValues = ['cpp', `0x${entry[0].toString(16)}`, entry[1].size,
|
|
|
|
`"${entry[1].name}"`];
|
2021-03-24 12:12:45 +00:00
|
|
|
console.log(printValues.join(','));
|
2020-11-03 09:17:12 +00:00
|
|
|
}
|
2016-04-28 06:56:35 +00:00
|
|
|
}
|
2020-11-03 09:17:12 +00:00
|
|
|
}
|