OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 } else if (request.command == 'clearbreakpoint') { | 1071 } else if (request.command == 'clearbreakpoint') { |
1072 this.clearBreakPointRequest_(request, response); | 1072 this.clearBreakPointRequest_(request, response); |
1073 } else if (request.command == 'backtrace') { | 1073 } else if (request.command == 'backtrace') { |
1074 this.backtraceRequest_(request, response); | 1074 this.backtraceRequest_(request, response); |
1075 } else if (request.command == 'frame') { | 1075 } else if (request.command == 'frame') { |
1076 this.frameRequest_(request, response); | 1076 this.frameRequest_(request, response); |
1077 } else if (request.command == 'evaluate') { | 1077 } else if (request.command == 'evaluate') { |
1078 this.evaluateRequest_(request, response); | 1078 this.evaluateRequest_(request, response); |
1079 } else if (request.command == 'lookup') { | 1079 } else if (request.command == 'lookup') { |
1080 this.lookupRequest_(request, response); | 1080 this.lookupRequest_(request, response); |
| 1081 } else if (request.command == 'references') { |
| 1082 this.referencesRequest_(request, response); |
1081 } else if (request.command == 'source') { | 1083 } else if (request.command == 'source') { |
1082 this.sourceRequest_(request, response); | 1084 this.sourceRequest_(request, response); |
1083 } else if (request.command == 'scripts') { | 1085 } else if (request.command == 'scripts') { |
1084 this.scriptsRequest_(request, response); | 1086 this.scriptsRequest_(request, response); |
1085 } else { | 1087 } else { |
1086 throw new Error('Unknown command "' + request.command + '" in request'); | 1088 throw new Error('Unknown command "' + request.command + '" in request'); |
1087 } | 1089 } |
1088 } catch (e) { | 1090 } catch (e) { |
1089 // If there is no response object created one (without command). | 1091 // If there is no response object created one (without command). |
1090 if (!response) { | 1092 if (!response) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 // Lookup handle. | 1456 // Lookup handle. |
1455 var mirror = LookupMirror(handle); | 1457 var mirror = LookupMirror(handle); |
1456 if (mirror) { | 1458 if (mirror) { |
1457 response.body = mirror; | 1459 response.body = mirror; |
1458 } else { | 1460 } else { |
1459 return response.failed('Object #' + handle + '# not found'); | 1461 return response.failed('Object #' + handle + '# not found'); |
1460 } | 1462 } |
1461 }; | 1463 }; |
1462 | 1464 |
1463 | 1465 |
| 1466 DebugCommandProcessor.prototype.referencesRequest_ = |
| 1467 function(request, response) { |
| 1468 if (!request.arguments) { |
| 1469 return response.failed('Missing arguments'); |
| 1470 } |
| 1471 |
| 1472 // Pull out arguments. |
| 1473 var type = request.arguments.type; |
| 1474 var handle = request.arguments.handle; |
| 1475 |
| 1476 // Check for legal arguments. |
| 1477 if (IS_UNDEFINED(type)) { |
| 1478 return response.failed('Argument "type" missing'); |
| 1479 } |
| 1480 if (IS_UNDEFINED(handle)) { |
| 1481 return response.failed('Argument "handle" missing'); |
| 1482 } |
| 1483 if (type != 'referencedBy' && type != 'constructedBy') { |
| 1484 return response.failed('Invalid type "' + type + '"'); |
| 1485 } |
| 1486 |
| 1487 // Lookup handle and return objects with references the object. |
| 1488 var mirror = LookupMirror(handle); |
| 1489 if (mirror) { |
| 1490 if (type == 'referencedBy') { |
| 1491 response.body = mirror.referencedBy(); |
| 1492 } else { |
| 1493 response.body = mirror.constructedBy(); |
| 1494 } |
| 1495 } else { |
| 1496 return response.failed('Object #' + handle + '# not found'); |
| 1497 } |
| 1498 }; |
| 1499 |
| 1500 |
1464 DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) { | 1501 DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) { |
1465 // No frames no source. | 1502 // No frames no source. |
1466 if (this.exec_state_.frameCount() == 0) { | 1503 if (this.exec_state_.frameCount() == 0) { |
1467 return response.failed('No source'); | 1504 return response.failed('No source'); |
1468 } | 1505 } |
1469 | 1506 |
1470 var from_line; | 1507 var from_line; |
1471 var to_line; | 1508 var to_line; |
1472 var frame = this.exec_state_.frame(); | 1509 var frame = this.exec_state_.frame(); |
1473 if (request.arguments) { | 1510 if (request.arguments) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 json += NumberToJSON_(elem); | 1709 json += NumberToJSON_(elem); |
1673 } else if (IS_STRING(elem)) { | 1710 } else if (IS_STRING(elem)) { |
1674 json += StringToJSON_(elem); | 1711 json += StringToJSON_(elem); |
1675 } else { | 1712 } else { |
1676 json += elem; | 1713 json += elem; |
1677 } | 1714 } |
1678 } | 1715 } |
1679 json += ']'; | 1716 json += ']'; |
1680 return json; | 1717 return json; |
1681 } | 1718 } |
OLD | NEW |