| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 403 |
| 404 CppEntriesProvider.prototype.loadSymbols = function(libName) { | 404 CppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 405 }; | 405 }; |
| 406 | 406 |
| 407 | 407 |
| 408 CppEntriesProvider.prototype.parseNextLine = function() { | 408 CppEntriesProvider.prototype.parseNextLine = function() { |
| 409 return false; | 409 return false; |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 | 412 |
| 413 function UnixCppEntriesProvider() { | 413 function UnixCppEntriesProvider(nmExec) { |
| 414 this.symbols = []; | 414 this.symbols = []; |
| 415 this.parsePos = 0; | 415 this.parsePos = 0; |
| 416 this.nmExec = nmExec; |
| 416 }; | 417 }; |
| 417 inherits(UnixCppEntriesProvider, CppEntriesProvider); | 418 inherits(UnixCppEntriesProvider, CppEntriesProvider); |
| 418 | 419 |
| 419 | 420 |
| 420 UnixCppEntriesProvider.FUNC_RE = /^([0-9a-fA-F]{8}) [tTwW] (.*)$/; | 421 UnixCppEntriesProvider.FUNC_RE = /^([0-9a-fA-F]{8}) [tTwW] (.*)$/; |
| 421 | 422 |
| 422 | 423 |
| 423 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { | 424 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 424 this.parsePos = 0; | 425 this.parsePos = 0; |
| 425 try { | 426 try { |
| 426 this.symbols = [ | 427 this.symbols = [ |
| 427 os.system('nm', ['-C', '-n', libName], -1, -1), | 428 os.system(this.nmExec, ['-C', '-n', libName], -1, -1), |
| 428 os.system('nm', ['-C', '-n', '-D', libName], -1, -1) | 429 os.system(this.nmExec, ['-C', '-n', '-D', libName], -1, -1) |
| 429 ]; | 430 ]; |
| 430 } catch (e) { | 431 } catch (e) { |
| 431 // If the library cannot be found on this system let's not panic. | 432 // If the library cannot be found on this system let's not panic. |
| 432 this.symbols = ['', '']; | 433 this.symbols = ['', '']; |
| 433 } | 434 } |
| 434 }; | 435 }; |
| 435 | 436 |
| 436 | 437 |
| 437 UnixCppEntriesProvider.prototype.parseNextLine = function() { | 438 UnixCppEntriesProvider.prototype.parseNextLine = function() { |
| 438 if (this.symbols.length == 0) { | 439 if (this.symbols.length == 0) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 return s; | 517 return s; |
| 517 }; | 518 }; |
| 518 | 519 |
| 519 | 520 |
| 520 function processArguments(args) { | 521 function processArguments(args) { |
| 521 var result = { | 522 var result = { |
| 522 logFileName: 'v8.log', | 523 logFileName: 'v8.log', |
| 523 platform: 'unix', | 524 platform: 'unix', |
| 524 stateFilter: null, | 525 stateFilter: null, |
| 525 ignoreUnknown: false, | 526 ignoreUnknown: false, |
| 526 separateIc: false | 527 separateIc: false, |
| 528 nm: 'nm' |
| 527 }; | 529 }; |
| 528 var argsDispatch = { | 530 var argsDispatch = { |
| 529 '-j': ['stateFilter', TickProcessor.VmStates.JS, | 531 '-j': ['stateFilter', TickProcessor.VmStates.JS, |
| 530 'Show only ticks from JS VM state'], | 532 'Show only ticks from JS VM state'], |
| 531 '-g': ['stateFilter', TickProcessor.VmStates.GC, | 533 '-g': ['stateFilter', TickProcessor.VmStates.GC, |
| 532 'Show only ticks from GC VM state'], | 534 'Show only ticks from GC VM state'], |
| 533 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER, | 535 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER, |
| 534 'Show only ticks from COMPILER VM state'], | 536 'Show only ticks from COMPILER VM state'], |
| 535 '-o': ['stateFilter', TickProcessor.VmStates.OTHER, | 537 '-o': ['stateFilter', TickProcessor.VmStates.OTHER, |
| 536 'Show only ticks from OTHER VM state'], | 538 'Show only ticks from OTHER VM state'], |
| 537 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, | 539 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, |
| 538 'Show only ticks from EXTERNAL VM state'], | 540 'Show only ticks from EXTERNAL VM state'], |
| 539 '--ignore-unknown': ['ignoreUnknown', true, | 541 '--ignore-unknown': ['ignoreUnknown', true, |
| 540 'Exclude ticks of unknown code entries from processing'], | 542 'Exclude ticks of unknown code entries from processing'], |
| 541 '--separate-ic': ['separateIc', true, | 543 '--separate-ic': ['separateIc', true, |
| 542 'Separate IC entries'], | 544 'Separate IC entries'], |
| 543 '--unix': ['platform', 'unix', | 545 '--unix': ['platform', 'unix', |
| 544 'Specify that we are running on *nix platform'], | 546 'Specify that we are running on *nix platform'], |
| 545 '--windows': ['platform', 'windows', | 547 '--windows': ['platform', 'windows', |
| 546 'Specify that we are running on Windows platform'] | 548 'Specify that we are running on Windows platform'], |
| 549 '--nm': ['nm', 'nm', |
| 550 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'] |
| 547 }; | 551 }; |
| 548 argsDispatch['--js'] = argsDispatch['-j']; | 552 argsDispatch['--js'] = argsDispatch['-j']; |
| 549 argsDispatch['--gc'] = argsDispatch['-g']; | 553 argsDispatch['--gc'] = argsDispatch['-g']; |
| 550 argsDispatch['--compiler'] = argsDispatch['-c']; | 554 argsDispatch['--compiler'] = argsDispatch['-c']; |
| 551 argsDispatch['--other'] = argsDispatch['-o']; | 555 argsDispatch['--other'] = argsDispatch['-o']; |
| 552 argsDispatch['--external'] = argsDispatch['-e']; | 556 argsDispatch['--external'] = argsDispatch['-e']; |
| 553 | 557 |
| 554 function printUsageAndExit() { | 558 function printUsageAndExit() { |
| 555 print('Cmdline args: [options] [log-file-name]\n' + | 559 print('Cmdline args: [options] [log-file-name]\n' + |
| 556 'Default log file name is "v8.log".\n'); | 560 'Default log file name is "v8.log".\n'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 568 } | 572 } |
| 569 quit(2); | 573 quit(2); |
| 570 } | 574 } |
| 571 | 575 |
| 572 while (args.length) { | 576 while (args.length) { |
| 573 var arg = args[0]; | 577 var arg = args[0]; |
| 574 if (arg.charAt(0) != '-') { | 578 if (arg.charAt(0) != '-') { |
| 575 break; | 579 break; |
| 576 } | 580 } |
| 577 args.shift(); | 581 args.shift(); |
| 582 var userValue = null; |
| 583 var eqPos = arg.indexOf('='); |
| 584 if (eqPos != -1) { |
| 585 userValue = arg.substr(eqPos + 1); |
| 586 arg = arg.substr(0, eqPos); |
| 587 } |
| 578 if (arg in argsDispatch) { | 588 if (arg in argsDispatch) { |
| 579 var dispatch = argsDispatch[arg]; | 589 var dispatch = argsDispatch[arg]; |
| 580 result[dispatch[0]] = dispatch[1]; | 590 result[dispatch[0]] = userValue == null ? dispatch[1] : userValue; |
| 581 } else { | 591 } else { |
| 582 printUsageAndExit(); | 592 printUsageAndExit(); |
| 583 } | 593 } |
| 584 } | 594 } |
| 585 | 595 |
| 586 if (args.length >= 1) { | 596 if (args.length >= 1) { |
| 587 result.logFileName = args.shift(); | 597 result.logFileName = args.shift(); |
| 588 } | 598 } |
| 589 return result; | 599 return result; |
| 590 }; | 600 }; |
| 591 | 601 |
| 592 | 602 |
| 593 var params = processArguments(arguments); | 603 var params = processArguments(arguments); |
| 594 var tickProcessor = new TickProcessor( | 604 var tickProcessor = new TickProcessor( |
| 595 params.platform == 'unix' ? new UnixCppEntriesProvider() : | 605 params.platform == 'unix' ? new UnixCppEntriesProvider(params.nm) : |
| 596 new WindowsCppEntriesProvider(), | 606 new WindowsCppEntriesProvider(), |
| 597 params.separateIc, | 607 params.separateIc, |
| 598 params.ignoreUnknown, | 608 params.ignoreUnknown, |
| 599 params.stateFilter); | 609 params.stateFilter); |
| 600 tickProcessor.processLogFile(params.logFileName); | 610 tickProcessor.processLogFile(params.logFileName); |
| 601 tickProcessor.printStatistics(); | 611 tickProcessor.printStatistics(); |
| OLD | NEW |