Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 167 |
| 168 TickProcessor.prototype.processLogFile = function(fileName) { | 168 TickProcessor.prototype.processLogFile = function(fileName) { |
| 169 this.lastLogFileName_ = fileName; | 169 this.lastLogFileName_ = fileName; |
| 170 var contents = readFile(fileName); | 170 var contents = readFile(fileName); |
| 171 this.processLogChunk(contents); | 171 this.processLogChunk(contents); |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 | 174 |
| 175 TickProcessor.prototype.processSharedLibrary = function( | 175 TickProcessor.prototype.processSharedLibrary = function( |
| 176 name, startAddr, endAddr) { | 176 name, startAddr, endAddr) { |
| 177 var entry = this.profile_.addStaticCode(name, startAddr, endAddr); | 177 var entry = this.profile_.addLibrary(name, startAddr, endAddr); |
| 178 this.setCodeType(entry.getName(), 'SHARED_LIB'); | 178 this.setCodeType(entry.getName(), 'SHARED_LIB'); |
| 179 | 179 |
| 180 var self = this; | 180 var self = this; |
| 181 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( | 181 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( |
| 182 name, startAddr, endAddr, function(fName, fStart, fEnd) { | 182 name, startAddr, endAddr, function(fName, fStart, fEnd) { |
| 183 self.profile_.addStaticCode(fName, fStart, fEnd); | 183 self.profile_.addStaticCode(fName, fStart, fEnd); |
| 184 self.setCodeType(fName, 'CPP'); | 184 self.setCodeType(fName, 'CPP'); |
| 185 }); | 185 }); |
| 186 }; | 186 }; |
| 187 | 187 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 function CppEntriesProvider() { | 373 function CppEntriesProvider() { |
| 374 }; | 374 }; |
| 375 | 375 |
| 376 | 376 |
| 377 CppEntriesProvider.prototype.parseVmSymbols = function( | 377 CppEntriesProvider.prototype.parseVmSymbols = function( |
| 378 libName, libStart, libEnd, processorFunc) { | 378 libName, libStart, libEnd, processorFunc) { |
| 379 this.loadSymbols(libName); | 379 this.loadSymbols(libName); |
| 380 | 380 |
| 381 var prevEntry; | 381 var prevEntry; |
| 382 | 382 |
| 383 function addPrevEntry(end) { | 383 function addEntry(funcInfo) { |
| 384 // Several functions can be mapped onto the same address. To avoid | 384 // Several functions can be mapped onto the same address. To avoid |
| 385 // creating zero-sized entries, skip such duplicates. | 385 // creating zero-sized entries, skip such duplicates. |
| 386 // Also double-check that function belongs to the library address space. | 386 // Also double-check that function belongs to the library address space. |
| 387 if (prevEntry && prevEntry.start < end && | 387 if (prevEntry && !('end' in prevEntry) && |
|
Kasper Lund
2009/07/14 07:52:57
The 'end' in prevEntry stuff looks a bit weird to
Mikhail Naganov
2009/07/14 09:45:47
You're right, zero is a forbidden value here. Chan
| |
| 388 prevEntry.start >= libStart && end <= libEnd) { | 388 prevEntry.start < funcInfo.start && |
| 389 processorFunc(prevEntry.name, prevEntry.start, end); | 389 prevEntry.start >= libStart && funcInfo.start <= libEnd) { |
| 390 processorFunc(prevEntry.name, prevEntry.start, funcInfo.start); | |
| 390 } | 391 } |
| 392 if ('end' in funcInfo && | |
| 393 (!prevEntry || prevEntry.start != funcInfo.start) && | |
| 394 funcInfo.start >= libStart && funcInfo.end <= libEnd) { | |
| 395 processorFunc(funcInfo.name, funcInfo.start, funcInfo.end); | |
| 396 } | |
| 397 prevEntry = funcInfo; | |
| 391 } | 398 } |
| 392 | 399 |
| 393 while (true) { | 400 while (true) { |
| 394 var funcInfo = this.parseNextLine(); | 401 var funcInfo = this.parseNextLine(); |
| 395 if (funcInfo === null) { | 402 if (funcInfo === null) { |
| 396 continue; | 403 continue; |
| 397 } else if (funcInfo === false) { | 404 } else if (funcInfo === false) { |
| 398 break; | 405 break; |
| 399 } | 406 } |
| 400 if (funcInfo.start < libStart && funcInfo.start < libEnd - libStart) { | 407 if (funcInfo.start < libStart && funcInfo.start < libEnd - libStart) { |
| 401 funcInfo.start += libStart; | 408 funcInfo.start += libStart; |
| 402 } | 409 } |
| 403 addPrevEntry(funcInfo.start); | 410 if ('size' in funcInfo) { |
|
Kasper Lund
2009/07/14 07:52:57
Is this because you worry that size can be zero?
Mikhail Naganov
2009/07/14 09:45:47
Done.
| |
| 404 prevEntry = funcInfo; | 411 funcInfo.end = funcInfo.start + funcInfo.size; |
| 412 } | |
| 413 addEntry(funcInfo); | |
| 405 } | 414 } |
| 406 addPrevEntry(libEnd); | 415 addEntry({name: '', start: libEnd}); |
| 407 }; | 416 }; |
| 408 | 417 |
| 409 | 418 |
| 410 CppEntriesProvider.prototype.loadSymbols = function(libName) { | 419 CppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 411 }; | 420 }; |
| 412 | 421 |
| 413 | 422 |
| 414 CppEntriesProvider.prototype.parseNextLine = function() { | 423 CppEntriesProvider.prototype.parseNextLine = function() { |
| 415 return false; | 424 return false; |
| 416 }; | 425 }; |
| 417 | 426 |
| 418 | 427 |
| 419 function UnixCppEntriesProvider(nmExec) { | 428 function UnixCppEntriesProvider(nmExec) { |
| 420 this.symbols = []; | 429 this.symbols = []; |
| 421 this.parsePos = 0; | 430 this.parsePos = 0; |
| 422 this.nmExec = nmExec; | 431 this.nmExec = nmExec; |
| 423 }; | 432 }; |
| 424 inherits(UnixCppEntriesProvider, CppEntriesProvider); | 433 inherits(UnixCppEntriesProvider, CppEntriesProvider); |
| 425 | 434 |
| 426 | 435 |
| 427 UnixCppEntriesProvider.FUNC_RE = /^([0-9a-fA-F]{8}) [tTwW] (.*)$/; | 436 UnixCppEntriesProvider.FUNC_RE = |
| 437 /^([0-9a-fA-F]{8}) ([0-9a-fA-F]{8} )?[tTwW] (.*)$/; | |
| 428 | 438 |
| 429 | 439 |
| 430 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { | 440 UnixCppEntriesProvider.prototype.loadSymbols = function(libName) { |
| 431 this.parsePos = 0; | 441 this.parsePos = 0; |
| 432 try { | 442 try { |
| 433 this.symbols = [ | 443 this.symbols = [ |
| 434 os.system(this.nmExec, ['-C', '-n', libName], -1, -1), | 444 os.system(this.nmExec, ['-C', '-n', '-S', libName], -1, -1), |
| 435 os.system(this.nmExec, ['-C', '-n', '-D', libName], -1, -1) | 445 os.system(this.nmExec, ['-C', '-n', '-S', '-D', libName], -1, -1) |
| 436 ]; | 446 ]; |
| 437 } catch (e) { | 447 } catch (e) { |
| 438 // If the library cannot be found on this system let's not panic. | 448 // If the library cannot be found on this system let's not panic. |
| 439 this.symbols = ['', '']; | 449 this.symbols = ['', '']; |
| 440 } | 450 } |
| 441 }; | 451 }; |
| 442 | 452 |
| 443 | 453 |
| 444 UnixCppEntriesProvider.prototype.parseNextLine = function() { | 454 UnixCppEntriesProvider.prototype.parseNextLine = function() { |
| 445 if (this.symbols.length == 0) { | 455 if (this.symbols.length == 0) { |
| 446 return false; | 456 return false; |
| 447 } | 457 } |
| 448 var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos); | 458 var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos); |
| 449 if (lineEndPos == -1) { | 459 if (lineEndPos == -1) { |
| 450 this.symbols.shift(); | 460 this.symbols.shift(); |
| 451 this.parsePos = 0; | 461 this.parsePos = 0; |
| 452 return this.parseNextLine(); | 462 return this.parseNextLine(); |
| 453 } | 463 } |
| 454 | 464 |
| 455 var line = this.symbols[0].substring(this.parsePos, lineEndPos); | 465 var line = this.symbols[0].substring(this.parsePos, lineEndPos); |
| 456 this.parsePos = lineEndPos + 1; | 466 this.parsePos = lineEndPos + 1; |
| 457 var fields = line.match(UnixCppEntriesProvider.FUNC_RE); | 467 var fields = line.match(UnixCppEntriesProvider.FUNC_RE); |
| 458 return fields ? { name: fields[2], start: parseInt(fields[1], 16) } : null; | 468 var funcInfo = null; |
| 469 if (fields) { | |
| 470 funcInfo = { name: fields[3], start: parseInt(fields[1], 16) }; | |
| 471 if (fields[2]) { | |
| 472 funcInfo.size = parseInt(fields[2], 16); | |
| 473 } | |
| 474 } | |
| 475 return funcInfo; | |
| 459 }; | 476 }; |
| 460 | 477 |
| 461 | 478 |
| 462 function WindowsCppEntriesProvider() { | 479 function WindowsCppEntriesProvider() { |
| 463 this.symbols = ''; | 480 this.symbols = ''; |
| 464 this.parsePos = 0; | 481 this.parsePos = 0; |
| 465 }; | 482 }; |
| 466 inherits(WindowsCppEntriesProvider, CppEntriesProvider); | 483 inherits(WindowsCppEntriesProvider, CppEntriesProvider); |
| 467 | 484 |
| 468 | 485 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 630 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
| 614 synonims.push(synArg); | 631 synonims.push(synArg); |
| 615 delete this.argsDispatch_[synArg]; | 632 delete this.argsDispatch_[synArg]; |
| 616 } | 633 } |
| 617 } | 634 } |
| 618 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 635 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
| 619 } | 636 } |
| 620 quit(2); | 637 quit(2); |
| 621 }; | 638 }; |
| 622 | 639 |
| OLD | NEW |