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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 }; | 492 }; |
493 | 493 |
494 | 494 |
495 function WindowsCppEntriesProvider() { | 495 function WindowsCppEntriesProvider() { |
496 this.symbols = ''; | 496 this.symbols = ''; |
497 this.parsePos = 0; | 497 this.parsePos = 0; |
498 }; | 498 }; |
499 inherits(WindowsCppEntriesProvider, CppEntriesProvider); | 499 inherits(WindowsCppEntriesProvider, CppEntriesProvider); |
500 | 500 |
501 | 501 |
502 WindowsCppEntriesProvider.FILENAME_RE = /^(.*)\.exe$/; | 502 WindowsCppEntriesProvider.FILENAME_RE = /^(.*)\.([^.]+)$/; |
503 | 503 |
504 | 504 |
505 WindowsCppEntriesProvider.FUNC_RE = | 505 WindowsCppEntriesProvider.FUNC_RE = |
506 /^ 0001:[0-9a-fA-F]{8}\s+([_\?@$0-9a-zA-Z]+)\s+([0-9a-fA-F]{8}).*$/; | 506 /^\s+0001:[0-9a-fA-F]{8}\s+([_\?@$0-9a-zA-Z]+)\s+([0-9a-fA-F]{8}).*$/; |
| 507 |
| 508 |
| 509 WindowsCppEntriesProvider.IMAGE_BASE_RE = |
| 510 /^\s+0000:00000000\s+___ImageBase\s+([0-9a-fA-F]{8}).*$/; |
| 511 |
| 512 |
| 513 // This is almost a constant on Windows. |
| 514 WindowsCppEntriesProvider.EXE_IMAGE_BASE = 0x00400000; |
507 | 515 |
508 | 516 |
509 WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) { | 517 WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) { |
510 var fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE); | 518 var fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE); |
511 // Only try to load symbols for the .exe file. | |
512 if (!fileNameFields) return; | 519 if (!fileNameFields) return; |
513 var mapFileName = fileNameFields[1] + '.map'; | 520 var mapFileName = fileNameFields[1] + '.map'; |
514 this.symbols = readFile(mapFileName); | 521 this.moduleType_ = fileNameFields[2].toLowerCase(); |
| 522 try { |
| 523 this.symbols = read(mapFileName); |
| 524 } catch (e) { |
| 525 // If .map file cannot be found let's not panic. |
| 526 this.symbols = ''; |
| 527 } |
515 }; | 528 }; |
516 | 529 |
517 | 530 |
518 WindowsCppEntriesProvider.prototype.parseNextLine = function() { | 531 WindowsCppEntriesProvider.prototype.parseNextLine = function() { |
519 var lineEndPos = this.symbols.indexOf('\r\n', this.parsePos); | 532 var lineEndPos = this.symbols.indexOf('\r\n', this.parsePos); |
520 if (lineEndPos == -1) { | 533 if (lineEndPos == -1) { |
521 return false; | 534 return false; |
522 } | 535 } |
523 | 536 |
524 var line = this.symbols.substring(this.parsePos, lineEndPos); | 537 var line = this.symbols.substring(this.parsePos, lineEndPos); |
525 this.parsePos = lineEndPos + 2; | 538 this.parsePos = lineEndPos + 2; |
| 539 |
| 540 // Image base entry is above all other symbols, so we can just |
| 541 // terminate parsing. |
| 542 var imageBaseFields = line.match(WindowsCppEntriesProvider.IMAGE_BASE_RE); |
| 543 if (imageBaseFields) { |
| 544 var imageBase = parseInt(imageBaseFields[1], 16); |
| 545 if ((this.moduleType_ == 'exe') != |
| 546 (imageBase == WindowsCppEntriesProvider.EXE_IMAGE_BASE)) { |
| 547 return false; |
| 548 } |
| 549 } |
| 550 |
526 var fields = line.match(WindowsCppEntriesProvider.FUNC_RE); | 551 var fields = line.match(WindowsCppEntriesProvider.FUNC_RE); |
527 return fields ? | 552 return fields ? |
528 { name: this.unmangleName(fields[1]), start: parseInt(fields[2], 16) } : | 553 { name: this.unmangleName(fields[1]), start: parseInt(fields[2], 16) } : |
529 null; | 554 null; |
530 }; | 555 }; |
531 | 556 |
532 | 557 |
533 /** | 558 /** |
534 * Performs very simple unmangling of C++ names. | 559 * Performs very simple unmangling of C++ names. |
535 * | 560 * |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 673 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
649 synonims.push(synArg); | 674 synonims.push(synArg); |
650 delete this.argsDispatch_[synArg]; | 675 delete this.argsDispatch_[synArg]; |
651 } | 676 } |
652 } | 677 } |
653 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 678 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
654 } | 679 } |
655 quit(2); | 680 quit(2); |
656 }; | 681 }; |
657 | 682 |
OLD | NEW |