Commit ac3edd40 authored by lpy's avatar lpy Committed by Commit bot

[prof] Add slide offset in dumpcpp script

An additional slide offset is exported into `shared-library`, which is used to
symbolize C++ stack on systems with ASLR (OS X).

This patch adds slide offset support in dumpcpp script.

BUG=v8:5048

Review-Url: https://codereview.chromium.org/2006813002
Cr-Commit-Position: refs/heads/master@{#36574}
parent 5dc60052
......@@ -13,7 +13,8 @@
'../../tools/profile_view.js',
'../../tools/profviz/composer.js',
'../../tools/splaytree.js',
'../../tools/tickprocessor.js'
'../../tools/tickprocessor.js',
'../../tools/dumpcpp.js'
],
},
'includes': [
......
......@@ -214,6 +214,7 @@
# that, it doesn't make sense to run several variants of d8-os anyways.
'd8-os': [PASS, NO_VARIANTS, ['isolates or arch == android_arm or arch == android_arm64 or arch == android_ia32', SKIP]],
'tools/tickprocessor': [PASS, NO_VARIANTS, ['arch == android_arm or arch == android_arm64 or arch == android_ia32', SKIP]],
'tools/dumpcpp': [PASS, NO_VARIANTS, ['arch == android_arm or arch == android_arm64 or arch == android_ia32', SKIP]],
##############################################################################
# Long running test that reproduces memory leak and should be run manually.
......
// 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.
// Load implementations from <project root>/tools.
// Files: tools/splaytree.js tools/codemap.js tools/csvparser.js
// Files: tools/consarray.js tools/profile.js tools/profile_view.js
// Files: tools/logreader.js tools/tickprocessor.js
// Files: tools/dumpcpp.js
// Env: TEST_FILE_NAME
(function testProcessSharedLibrary() {
var oldLoadSymbols = UnixCppEntriesProvider.prototype.loadSymbols;
UnixCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.symbols = [[
'00000100 00000001 t v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
'00000110 00000001 T v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
'00000120 00000001 t v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
'00000130 00000001 W v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)'
].join('\n'), ''];
};
var testCppProcessor = new CppProcessor(new UnixCppEntriesProvider(),
false, false);
testCppProcessor.processSharedLibrary(
'/usr/local/google/home/lpy/v8/out/native/d8',
0x00000100, 0x00000400, 0);
var staticEntries = testCppProcessor.codeMap_.getAllStaticEntriesWithAddresses();
var total = staticEntries.length;
assertEquals(total, 3);
assertEquals(staticEntries[0],
[288,{size:1,
name:'v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
type:'CPP',
nameUpdated_:false}
]);
assertEquals(staticEntries[1],
[272,{size:1,
name:'v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
type:'CPP',
nameUpdated_:false}
]);
assertEquals(staticEntries[2],
[256,{size:1,
name:'v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
type:'CPP',
nameUpdated_:false}
]);
UnixCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
})();
......@@ -18,7 +18,7 @@ def is_file_executable(fPath):
if __name__ == '__main__':
JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js',
'profile.js', 'logreader.js', 'tickprocessor.js', 'SourceMap.js',
'dumpcpp.js']
'dumpcpp.js', 'dumpcpp-driver.js']
tools_path = os.path.dirname(os.path.realpath(__file__))
on_windows = platform.system() == 'Windows'
JS_FILES = [os.path.join(tools_path, f) for f in JS_FILES]
......
// 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.
// Dump C++ symbols of shared library if possible
function processArguments(args) {
var processor = new ArgumentsProcessor(args);
if (processor.parse()) {
return processor.result();
} else {
processor.printUsageAndExit();
}
}
function initSourceMapSupport() {
// Pull dev tools source maps into our name space.
SourceMap = WebInspector.SourceMap;
// Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject);
};
}
var entriesProviders = {
'unix': UnixCppEntriesProvider,
'windows': WindowsCppEntriesProvider,
'mac': MacCppEntriesProvider
};
var params = processArguments(arguments);
var sourceMap = null;
if (params.sourceMap) {
initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap);
}
var cppProcessor = new CppProcessor(
new (entriesProviders[params.platform])(params.nm, params.targetRootFS),
params.timedRange, params.pairwiseTimedRange);
cppProcessor.processLogFile(params.logFileName);
cppProcessor.dumpCppSymbols();
......@@ -2,45 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Dump C++ symbols of shared library if possible
function processArguments(args) {
var processor = new ArgumentsProcessor(args);
if (processor.parse()) {
return processor.result();
} else {
processor.printUsageAndExit();
}
}
function initSourceMapSupport() {
// Pull dev tools source maps into our name space.
SourceMap = WebInspector.SourceMap;
// Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject);
};
}
var entriesProviders = {
'unix': UnixCppEntriesProvider,
'windows': WindowsCppEntriesProvider,
'mac': MacCppEntriesProvider
};
var params = processArguments(arguments);
var sourceMap = null;
if (params.sourceMap) {
initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap);
}
function CppProcessor(cppEntriesProvider, timedRange, pairwiseTimedRange) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
'shared-library': { parsers: [null, parseInt, parseInt, parseInt],
processor: this.processSharedLibrary }
}, timedRange, pairwiseTimedRange);
......@@ -73,10 +37,10 @@ CppProcessor.prototype.processLogFileInTest = function(fileName) {
};
CppProcessor.prototype.processSharedLibrary = function(
name, startAddr, endAddr) {
name, startAddr, endAddr, aslrSlide) {
var self = this;
var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
name, startAddr, endAddr, function(fName, fStart, fEnd) {
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
var entry = new CodeMap.CodeEntry(fEnd - fStart, fName, 'CPP');
self.codeMap_.addStaticCode(fStart, entry);
});
......@@ -92,9 +56,3 @@ CppProcessor.prototype.dumpCppSymbols = function() {
print(printValues.join(','));
}
};
var cppProcessor = new CppProcessor(
new (entriesProviders[params.platform])(params.nm, params.targetRootFS),
params.timedRange, params.pairwiseTimedRange);
cppProcessor.processLogFile(params.logFileName);
cppProcessor.dumpCppSymbols();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment