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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 150 |
151 TickProcessor.prototype.processLogFile = function(fileName) { | 151 TickProcessor.prototype.processLogFile = function(fileName) { |
152 this.lastLogFileName_ = fileName; | 152 this.lastLogFileName_ = fileName; |
153 var contents = readFile(fileName); | 153 var contents = readFile(fileName); |
154 this.processLog(contents.split('\n')); | 154 this.processLog(contents.split('\n')); |
155 }; | 155 }; |
156 | 156 |
157 | 157 |
158 TickProcessor.prototype.processLog = function(lines) { | 158 TickProcessor.prototype.processLog = function(lines) { |
159 var csvParser = new devtools.profiler.CsvParser(); | 159 var csvParser = new devtools.profiler.CsvParser(); |
160 try { | 160 for (var i = 0, n = lines.length; i < n; ++i) { |
161 for (var i = 0, n = lines.length; i < n; ++i) { | 161 var line = lines[i]; |
162 var line = lines[i]; | 162 if (!line) { |
163 if (!line) { | 163 continue; |
164 continue; | |
165 } | |
166 var fields = csvParser.parseLine(line); | |
167 this.dispatchLogRow(fields); | |
168 } | 164 } |
169 } catch (e) { | 165 var fields = csvParser.parseLine(line); |
170 print('line ' + (i + 1) + ': ' + (e.message || e)); | 166 this.dispatchLogRow(fields); |
171 throw e; | |
mnaganov (inactive)
2009/06/16 13:32:00
Hmm... Does rethrowing an exception fails in your
Erik Corry
2009/06/16 13:44:56
No, it just means I can't see the original backtra
| |
172 } | 167 } |
173 }; | 168 }; |
174 | 169 |
175 | 170 |
176 TickProcessor.prototype.dispatchLogRow = function(fields) { | 171 TickProcessor.prototype.dispatchLogRow = function(fields) { |
177 // Obtain the dispatch. | 172 // Obtain the dispatch. |
178 var command = fields[0]; | 173 var command = fields[0]; |
179 if (!(command in TickProcessor.RecordsDispatch)) { | 174 if (!(command in TickProcessor.RecordsDispatch)) { |
180 throw new Error('unknown command: ' + command); | 175 throw new Error('unknown command: ' + command); |
181 } | 176 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 this.symbols = []; | 475 this.symbols = []; |
481 this.parsePos = 0; | 476 this.parsePos = 0; |
482 }; | 477 }; |
483 inherits(UnixCppEntriesProvider, CppEntriesProvider); | 478 inherits(UnixCppEntriesProvider, CppEntriesProvider); |
484 | 479 |
485 | 480 |
486 UnixCppEntriesProvider.FUNC_RE = /^([0-9a-fA-F]{8}) . (.*)$/; | 481 UnixCppEntriesProvider.FUNC_RE = /^([0-9a-fA-F]{8}) . (.*)$/; |
487 | 482 |
488 | 483 |
489 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { | 484 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { |
490 this.symbols = [ | 485 try { |
491 os.system('nm', ['-C', '-n', libName], -1, -1), | 486 this.symbols = [ |
492 os.system('nm', ['-C', '-n', '-D', libName], -1, -1) | 487 os.system('nm', ['-C', '-n', libName], -1, -1), |
493 ]; | 488 os.system('nm', ['-C', '-n', '-D', libName], -1, -1) |
494 this.parsePos = 0; | 489 ]; |
490 this.parsePos = 0; | |
mnaganov (inactive)
2009/06/16 13:32:00
You can move this assignment before the try block.
| |
491 } catch (e) { | |
492 // If the library cannot be found on this system let's not panic. | |
493 this.symbols = [ "", "" ]; | |
mnaganov (inactive)
2009/06/16 13:32:00
nit: Use single quotes.
| |
494 this.parsePos = 0; | |
495 } | |
495 }; | 496 }; |
496 | 497 |
497 | 498 |
498 UnixCppEntriesProvider.prototype.parseNextLine = function() { | 499 UnixCppEntriesProvider.prototype.parseNextLine = function() { |
499 if (this.symbols.length == 0) { | 500 if (this.symbols.length == 0) { |
500 return false; | 501 return false; |
501 } | 502 } |
502 var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos); | 503 var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos); |
503 if (lineEndPos == -1) { | 504 if (lineEndPos == -1) { |
504 this.symbols.shift(); | 505 this.symbols.shift(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 | 654 |
654 var params = processArguments(arguments); | 655 var params = processArguments(arguments); |
655 var tickProcessor = new TickProcessor( | 656 var tickProcessor = new TickProcessor( |
656 params.platform == 'unix' ? new UnixCppEntriesProvider() : | 657 params.platform == 'unix' ? new UnixCppEntriesProvider() : |
657 new WindowsCppEntriesProvider(), | 658 new WindowsCppEntriesProvider(), |
658 params.separateIc, | 659 params.separateIc, |
659 params.ignoreUnknown, | 660 params.ignoreUnknown, |
660 params.stateFilter); | 661 params.stateFilter); |
661 tickProcessor.processLogFile(params.logFileName); | 662 tickProcessor.processLogFile(params.logFileName); |
662 tickProcessor.printStatistics(); | 663 tickProcessor.printStatistics(); |
OLD | NEW |