| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Load implementations from <project root>/tools. | 28 // Load implementations from <project root>/tools. |
| 29 // Files: tools/splaytree.js tools/codemap.js tools/csvparser.js | 29 // Files: tools/splaytree.js tools/codemap.js tools/csvparser.js |
| 30 // Files: tools/consarray.js tools/profile.js tools/profile_view.js | 30 // Files: tools/consarray.js tools/profile.js tools/profile_view.js |
| 31 // Files: tools/logreader.js tools/tickprocessor.js | 31 // Files: tools/logreader.js tools/tickprocessor.js |
| 32 // Env: TEST_FILE_NAME | 32 // Env: TEST_FILE_NAME |
| 33 | 33 |
| 34 |
| 34 (function testArgumentsProcessor() { | 35 (function testArgumentsProcessor() { |
| 35 var p_default = new ArgumentsProcessor([]); | 36 var p_default = new ArgumentsProcessor([]); |
| 36 assertTrue(p_default.parse()); | 37 assertTrue(p_default.parse()); |
| 37 assertEquals(ArgumentsProcessor.DEFAULTS, p_default.result()); | 38 assertEquals(ArgumentsProcessor.DEFAULTS, p_default.result()); |
| 38 | 39 |
| 39 var p_logFile = new ArgumentsProcessor(['logfile.log']); | 40 var p_logFile = new ArgumentsProcessor(['logfile.log']); |
| 40 assertTrue(p_logFile.parse()); | 41 assertTrue(p_logFile.parse()); |
| 41 assertEquals('logfile.log', p_logFile.result().logFileName); | 42 assertEquals('logfile.log', p_logFile.result().logFileName); |
| 42 | 43 |
| 43 var p_platformAndLog = new ArgumentsProcessor(['--windows', 'winlog.log']); | 44 var p_platformAndLog = new ArgumentsProcessor(['--windows', 'winlog.log']); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 | 63 |
| 63 (function testUnixCppEntriesProvider() { | 64 (function testUnixCppEntriesProvider() { |
| 64 var oldLoadSymbols = UnixCppEntriesProvider.prototype.loadSymbols; | 65 var oldLoadSymbols = UnixCppEntriesProvider.prototype.loadSymbols; |
| 65 | 66 |
| 66 // shell executable | 67 // shell executable |
| 67 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { | 68 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 68 this.symbols = [[ | 69 this.symbols = [[ |
| 69 ' U operator delete[](void*)@@GLIBCXX_3.4', | 70 ' U operator delete[](void*)@@GLIBCXX_3.4', |
| 70 '08049790 T _init', | 71 '08049790 T _init', |
| 71 '08049f50 T _start', | 72 '08049f50 T _start', |
| 72 '08139150 t v8::internal::Runtime_StringReplaceRegExpWithString(v8::intern
al::Arguments)', | 73 '08139150 00000b4b t v8::internal::Runtime_StringReplaceRegExpWithString(v
8::internal::Arguments)', |
| 73 '08139ca0 T v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle
<v8::internal::Object>, unsigned int)', | 74 '08139ca0 000003f1 T v8::internal::Runtime::GetElementOrCharAt(v8::interna
l::Handle<v8::internal::Object>, unsigned int)', |
| 74 '0813a0b0 t v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Ar
guments)', | 75 '0813a0b0 00000855 t v8::internal::Runtime_DebugGetPropertyDetails(v8::int
ernal::Arguments)', |
| 75 '08181d30 W v8::internal::RegExpMacroAssemblerIrregexp::stack_limit_slack(
)', | 76 '0818b220 00000036 W v8::internal::RegExpMacroAssembler::CheckPosition(int
, v8::internal::Label*)', |
| 76 ' w __gmon_start__', | 77 ' w __gmon_start__', |
| 77 '081f08a0 B stdout' | 78 '081f08a0 00000004 B stdout' |
| 78 ].join('\n'), '']; | 79 ].join('\n'), '']; |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 var shell_prov = new UnixCppEntriesProvider(); | 82 var shell_prov = new UnixCppEntriesProvider(); |
| 82 var shell_syms = []; | 83 var shell_syms = []; |
| 83 shell_prov.parseVmSymbols('shell', 0x08048000, 0x081ee000, | 84 shell_prov.parseVmSymbols('shell', 0x08048000, 0x081ee000, |
| 84 function (name, start, end) { | 85 function (name, start, end) { |
| 85 shell_syms.push(Array.prototype.slice.apply(arguments, [0])); | 86 shell_syms.push(Array.prototype.slice.apply(arguments, [0])); |
| 86 }); | 87 }); |
| 87 assertEquals( | 88 assertEquals( |
| 88 [['_init', 0x08049790, 0x08049f50], | 89 [['_init', 0x08049790, 0x08049f50], |
| 89 ['_start', 0x08049f50, 0x08139150], | 90 ['_start', 0x08049f50, 0x08139150], |
| 90 ['v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Argum
ents)', 0x08139150, 0x08139ca0], | 91 ['v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Argum
ents)', 0x08139150, 0x08139150 + 0xb4b], |
| 91 ['v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::inte
rnal::Object>, unsigned int)', 0x08139ca0, 0x0813a0b0], | 92 ['v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::inte
rnal::Object>, unsigned int)', 0x08139ca0, 0x08139ca0 + 0x3f1], |
| 92 ['v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)'
, 0x0813a0b0, 0x08181d30], | 93 ['v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)'
, 0x0813a0b0, 0x0813a0b0 + 0x855], |
| 93 ['v8::internal::RegExpMacroAssemblerIrregexp::stack_limit_slack()', 0x081
81d30, 0x081ee000]], | 94 ['v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::La
bel*)', 0x0818b220, 0x0818b220 + 0x36]], |
| 94 shell_syms); | 95 shell_syms); |
| 95 | 96 |
| 96 // libc library | 97 // libc library |
| 97 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { | 98 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 98 this.symbols = [[ | 99 this.symbols = [[ |
| 99 '000162a0 T __libc_init_first', | 100 '000162a0 00000005 T __libc_init_first', |
| 100 '0002a5f0 T __isnan', | 101 '0002a5f0 0000002d T __isnan', |
| 101 '0002a5f0 W isnan', | 102 '0002a5f0 0000002d W isnan', |
| 102 '0002aaa0 W scalblnf', | 103 '0002aaa0 0000000d W scalblnf', |
| 103 '0002aaa0 W scalbnf', | 104 '0002aaa0 0000000d W scalbnf', |
| 104 '0011a340 T __libc_thread_freeres', | 105 '0011a340 00000048 T __libc_thread_freeres', |
| 105 '00128860 R _itoa_lower_digits'].join('\n'), '']; | 106 '00128860 00000024 R _itoa_lower_digits'].join('\n'), '']; |
| 106 }; | 107 }; |
| 107 var libc_prov = new UnixCppEntriesProvider(); | 108 var libc_prov = new UnixCppEntriesProvider(); |
| 108 var libc_syms = []; | 109 var libc_syms = []; |
| 109 libc_prov.parseVmSymbols('libc', 0xf7c5c000, 0xf7da5000, | 110 libc_prov.parseVmSymbols('libc', 0xf7c5c000, 0xf7da5000, |
| 110 function (name, start, end) { | 111 function (name, start, end) { |
| 111 libc_syms.push(Array.prototype.slice.apply(arguments, [0])); | 112 libc_syms.push(Array.prototype.slice.apply(arguments, [0])); |
| 112 }); | 113 }); |
| 113 assertEquals( | 114 var libc_ref_syms = [['__libc_init_first', 0x000162a0, 0x000162a0 + 0x5], |
| 114 [['__libc_init_first', 0xf7c5c000 + 0x000162a0, 0xf7c5c000 + 0x0002a5f0], | 115 ['__isnan', 0x0002a5f0, 0x0002a5f0 + 0x2d], |
| 115 ['isnan', 0xf7c5c000 + 0x0002a5f0, 0xf7c5c000 + 0x0002aaa0], | 116 ['scalblnf', 0x0002aaa0, 0x0002aaa0 + 0xd], |
| 116 ['scalbnf', 0xf7c5c000 + 0x0002aaa0, 0xf7c5c000 + 0x0011a340], | 117 ['__libc_thread_freeres', 0x0011a340, 0x0011a340 + 0x48]]; |
| 117 ['__libc_thread_freeres', 0xf7c5c000 + 0x0011a340, 0xf7da5000]], | 118 for (var i = 0; i < libc_ref_syms.length; ++i) { |
| 118 libc_syms); | 119 libc_ref_syms[i][1] += 0xf7c5c000; |
| 120 libc_ref_syms[i][2] += 0xf7c5c000; |
| 121 } |
| 122 assertEquals(libc_ref_syms, libc_syms); |
| 119 | 123 |
| 120 UnixCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols; | 124 UnixCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols; |
| 121 })(); | 125 })(); |
| 122 | 126 |
| 123 | 127 |
| 124 (function testWindowsCppEntriesProvider() { | 128 (function testWindowsCppEntriesProvider() { |
| 125 var oldLoadSymbols = WindowsCppEntriesProvider.prototype.loadSymbols; | 129 var oldLoadSymbols = WindowsCppEntriesProvider.prototype.loadSymbols; |
| 126 | 130 |
| 127 WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) { | 131 WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 128 this.symbols = [ | 132 this.symbols = [ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 171 |
| 168 | 172 |
| 169 CppEntriesProviderMock.prototype.parseVmSymbols = function( | 173 CppEntriesProviderMock.prototype.parseVmSymbols = function( |
| 170 name, startAddr, endAddr, symbolAdder) { | 174 name, startAddr, endAddr, symbolAdder) { |
| 171 var symbols = { | 175 var symbols = { |
| 172 'shell': | 176 'shell': |
| 173 [['v8::internal::JSObject::LocalLookupRealNamedProperty(v8::internal::St
ring*, v8::internal::LookupResult*)', 0x080f8800, 0x080f8d90], | 177 [['v8::internal::JSObject::LocalLookupRealNamedProperty(v8::internal::St
ring*, v8::internal::LookupResult*)', 0x080f8800, 0x080f8d90], |
| 174 ['v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::inte
rnal::String*>::FindEntry(v8::internal::String*)', 0x080f8210, 0x080f8800], | 178 ['v8::internal::HashTable<v8::internal::StringDictionaryShape, v8::inte
rnal::String*>::FindEntry(v8::internal::String*)', 0x080f8210, 0x080f8800], |
| 175 ['v8::internal::Runtime_Math_exp(v8::internal::Arguments)', 0x08123b20,
0x08123b80]], | 179 ['v8::internal::Runtime_Math_exp(v8::internal::Arguments)', 0x08123b20,
0x08123b80]], |
| 176 '/lib32/libm-2.7.so': | 180 '/lib32/libm-2.7.so': |
| 177 [['exp', startAddr + 0x00009e80, startAddr + 0x00009f30], | 181 [['exp', startAddr + 0x00009e80, startAddr + 0x00009e80 + 0xa3], |
| 178 ['fegetexcept', startAddr + 0x000061e0, startAddr + 0x00008b10]], | 182 ['fegetexcept', startAddr + 0x000061e0, startAddr + 0x000061e0 + 0x15]]
, |
| 179 'ffffe000-fffff000': []}; | 183 'ffffe000-fffff000': []}; |
| 180 assertTrue(name in symbols); | 184 assertTrue(name in symbols); |
| 181 var syms = symbols[name]; | 185 var syms = symbols[name]; |
| 182 for (var i = 0; i < syms.length; ++i) { | 186 for (var i = 0; i < syms.length; ++i) { |
| 183 symbolAdder.apply(null, syms[i]); | 187 symbolAdder.apply(null, syms[i]); |
| 184 } | 188 } |
| 185 }; | 189 }; |
| 186 | 190 |
| 187 | 191 |
| 188 function PrintMonitor(outputOrFileName) { | 192 function PrintMonitor(outputOrFileName) { |
| 189 var expectedOut = typeof outputOrFileName == 'string' ? | 193 var expectedOut = typeof outputOrFileName == 'string' ? |
| 190 this.loadExpectedOutput(outputOrFileName) : outputOrFileName; | 194 this.loadExpectedOutput(outputOrFileName) : outputOrFileName; |
| 191 var outputPos = 0; | 195 var outputPos = 0; |
| 192 var diffs = this.diffs = []; | 196 var diffs = this.diffs = []; |
| 193 var realOut = this.realOut = []; | 197 var realOut = this.realOut = []; |
| 198 var unexpectedOut = this.unexpectedOut = null; |
| 194 | 199 |
| 195 this.oldPrint = print; | 200 this.oldPrint = print; |
| 196 print = function(str) { | 201 print = function(str) { |
| 197 var strSplit = str.split('\n'); | 202 var strSplit = str.split('\n'); |
| 198 for (var i = 0; i < strSplit.length; ++i) { | 203 for (var i = 0; i < strSplit.length; ++i) { |
| 199 s = strSplit[i]; | 204 s = strSplit[i]; |
| 200 realOut.push(s); | 205 realOut.push(s); |
| 201 assertTrue(outputPos < expectedOut.length, | 206 if (outputPos < expectedOut.length) { |
| 202 'unexpected output: "' + s + '"'); | 207 if (expectedOut[outputPos] != s) { |
| 203 if (expectedOut[outputPos] != s) { | 208 diffs.push('line ' + outputPos + ': expected <' + |
| 204 diffs.push('line ' + outputPos + ': expected <' + | 209 expectedOut[outputPos] + '> found <' + s + '>\n'); |
| 205 expectedOut[outputPos] + '> found <' + s + '>\n'); | 210 } |
| 211 outputPos++; |
| 212 } else { |
| 213 unexpectedOut = true; |
| 206 } | 214 } |
| 207 outputPos++; | |
| 208 } | 215 } |
| 209 }; | 216 }; |
| 210 }; | 217 }; |
| 211 | 218 |
| 212 | 219 |
| 213 PrintMonitor.prototype.loadExpectedOutput = function(fileName) { | 220 PrintMonitor.prototype.loadExpectedOutput = function(fileName) { |
| 214 var output = readFile(fileName); | 221 var output = readFile(fileName); |
| 215 return output.split('\n'); | 222 return output.split('\n'); |
| 216 }; | 223 }; |
| 217 | 224 |
| 218 | 225 |
| 219 PrintMonitor.prototype.finish = function() { | 226 PrintMonitor.prototype.finish = function() { |
| 220 print = this.oldPrint; | 227 print = this.oldPrint; |
| 221 if (this.diffs.length > 0) { | 228 if (this.diffs.length > 0 || this.unexpectedOut != null) { |
| 222 print(this.realOut.join('\n')); | 229 print(this.realOut.join('\n')); |
| 223 assertEquals([], this.diffs); | 230 assertEquals([], this.diffs); |
| 231 assertNull(this.unexpectedOut); |
| 224 } | 232 } |
| 225 }; | 233 }; |
| 226 | 234 |
| 227 | 235 |
| 228 function driveTickProcessorTest( | 236 function driveTickProcessorTest( |
| 229 separateIc, ignoreUnknown, stateFilter, logInput, refOutput) { | 237 separateIc, ignoreUnknown, stateFilter, logInput, refOutput) { |
| 230 // TEST_FILE_NAME must be provided by test runner. | 238 // TEST_FILE_NAME must be provided by test runner. |
| 231 assertEquals('string', typeof TEST_FILE_NAME); | 239 assertEquals('string', typeof TEST_FILE_NAME); |
| 232 var pathLen = TEST_FILE_NAME.lastIndexOf('/'); | 240 var pathLen = TEST_FILE_NAME.lastIndexOf('/'); |
| 233 if (pathLen == -1) { | 241 if (pathLen == -1) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 259 'tickprocessor-test.log', 'tickprocessor-test.ignore-unknown'], | 267 'tickprocessor-test.log', 'tickprocessor-test.ignore-unknown'], |
| 260 'GcState': [ | 268 'GcState': [ |
| 261 false, false, TickProcessor.VmStates.GC, | 269 false, false, TickProcessor.VmStates.GC, |
| 262 'tickprocessor-test.log', 'tickprocessor-test.gc-state'] | 270 'tickprocessor-test.log', 'tickprocessor-test.gc-state'] |
| 263 }; | 271 }; |
| 264 for (var testName in testData) { | 272 for (var testName in testData) { |
| 265 print('=== testProcessing-' + testName + ' ==='); | 273 print('=== testProcessing-' + testName + ' ==='); |
| 266 driveTickProcessorTest.apply(null, testData[testName]); | 274 driveTickProcessorTest.apply(null, testData[testName]); |
| 267 } | 275 } |
| 268 })(); | 276 })(); |
| OLD | NEW |