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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 } else if (request.command == 'setbreakpoint') { | 1201 } else if (request.command == 'setbreakpoint') { |
1202 this.setBreakPointRequest_(request, response); | 1202 this.setBreakPointRequest_(request, response); |
1203 } else if (request.command == 'changebreakpoint') { | 1203 } else if (request.command == 'changebreakpoint') { |
1204 this.changeBreakPointRequest_(request, response); | 1204 this.changeBreakPointRequest_(request, response); |
1205 } else if (request.command == 'clearbreakpoint') { | 1205 } else if (request.command == 'clearbreakpoint') { |
1206 this.clearBreakPointRequest_(request, response); | 1206 this.clearBreakPointRequest_(request, response); |
1207 } else if (request.command == 'backtrace') { | 1207 } else if (request.command == 'backtrace') { |
1208 this.backtraceRequest_(request, response); | 1208 this.backtraceRequest_(request, response); |
1209 } else if (request.command == 'frame') { | 1209 } else if (request.command == 'frame') { |
1210 this.frameRequest_(request, response); | 1210 this.frameRequest_(request, response); |
| 1211 } else if (request.command == 'scopes') { |
| 1212 this.scopesRequest_(request, response); |
| 1213 } else if (request.command == 'scope') { |
| 1214 this.scopeRequest_(request, response); |
1211 } else if (request.command == 'evaluate') { | 1215 } else if (request.command == 'evaluate') { |
1212 this.evaluateRequest_(request, response); | 1216 this.evaluateRequest_(request, response); |
1213 } else if (request.command == 'lookup') { | 1217 } else if (request.command == 'lookup') { |
1214 this.lookupRequest_(request, response); | 1218 this.lookupRequest_(request, response); |
1215 } else if (request.command == 'references') { | 1219 } else if (request.command == 'references') { |
1216 this.referencesRequest_(request, response); | 1220 this.referencesRequest_(request, response); |
1217 } else if (request.command == 'source') { | 1221 } else if (request.command == 'source') { |
1218 this.sourceRequest_(request, response); | 1222 this.sourceRequest_(request, response); |
1219 } else if (request.command == 'scripts') { | 1223 } else if (request.command == 'scripts') { |
1220 this.scriptsRequest_(request, response); | 1224 this.scriptsRequest_(request, response); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 | 1537 |
1534 | 1538 |
1535 DebugCommandProcessor.prototype.frameRequest_ = function(request, response) { | 1539 DebugCommandProcessor.prototype.frameRequest_ = function(request, response) { |
1536 // No frames no source. | 1540 // No frames no source. |
1537 if (this.exec_state_.frameCount() == 0) { | 1541 if (this.exec_state_.frameCount() == 0) { |
1538 return response.failed('No frames'); | 1542 return response.failed('No frames'); |
1539 } | 1543 } |
1540 | 1544 |
1541 // With no arguments just keep the selected frame. | 1545 // With no arguments just keep the selected frame. |
1542 if (request.arguments) { | 1546 if (request.arguments) { |
1543 index = request.arguments.number; | 1547 var index = request.arguments.number; |
1544 if (index < 0 || this.exec_state_.frameCount() <= index) { | 1548 if (index < 0 || this.exec_state_.frameCount() <= index) { |
1545 return response.failed('Invalid frame number'); | 1549 return response.failed('Invalid frame number'); |
1546 } | 1550 } |
1547 | 1551 |
1548 this.exec_state_.setSelectedFrame(request.arguments.number); | 1552 this.exec_state_.setSelectedFrame(request.arguments.number); |
1549 } | 1553 } |
1550 response.body = this.exec_state_.frame(); | 1554 response.body = this.exec_state_.frame(); |
1551 }; | 1555 }; |
1552 | 1556 |
1553 | 1557 |
| 1558 DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) { |
| 1559 // Get the frame for which the scope or scopes are requested. With no frameNum
ber |
| 1560 // argument use the currently selected frame. |
| 1561 if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) { |
| 1562 frame_index = request.arguments.frameNumber; |
| 1563 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { |
| 1564 return response.failed('Invalid frame number'); |
| 1565 } |
| 1566 return this.exec_state_.frame(frame_index); |
| 1567 } else { |
| 1568 return this.exec_state_.frame(); |
| 1569 } |
| 1570 } |
| 1571 |
| 1572 |
| 1573 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { |
| 1574 // No frames no scopes. |
| 1575 if (this.exec_state_.frameCount() == 0) { |
| 1576 return response.failed('No scopes'); |
| 1577 } |
| 1578 |
| 1579 // Get the frame for which the scopes are requested. |
| 1580 var frame = this.frameForScopeRequest_(request); |
| 1581 |
| 1582 // Fill all scopes for this frame. |
| 1583 var total_scopes = frame.scopeCount(); |
| 1584 var scopes = []; |
| 1585 for (var i = 0; i < total_scopes; i++) { |
| 1586 scopes.push(frame.scope(i)); |
| 1587 } |
| 1588 response.body = { |
| 1589 fromScope: 0, |
| 1590 toScope: total_scopes, |
| 1591 totalScopes: total_scopes, |
| 1592 scopes: scopes |
| 1593 } |
| 1594 }; |
| 1595 |
| 1596 |
| 1597 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { |
| 1598 // No frames no scopes. |
| 1599 if (this.exec_state_.frameCount() == 0) { |
| 1600 return response.failed('No scopes'); |
| 1601 } |
| 1602 |
| 1603 // Get the frame for which the scope is requested. |
| 1604 var frame = this.frameForScopeRequest_(request); |
| 1605 |
| 1606 // With no scope argument just return top scope. |
| 1607 var scope_index = 0; |
| 1608 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { |
| 1609 scope_index = %ToNumber(request.arguments.number); |
| 1610 if (scope_index < 0 || frame.scopeCount() <= scope_index) { |
| 1611 return response.failed('Invalid scope number'); |
| 1612 } |
| 1613 } |
| 1614 |
| 1615 response.body = frame.scope(scope_index); |
| 1616 }; |
| 1617 |
| 1618 |
1554 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { | 1619 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { |
1555 if (!request.arguments) { | 1620 if (!request.arguments) { |
1556 return response.failed('Missing arguments'); | 1621 return response.failed('Missing arguments'); |
1557 } | 1622 } |
1558 | 1623 |
1559 // Pull out arguments. | 1624 // Pull out arguments. |
1560 var expression = request.arguments.expression; | 1625 var expression = request.arguments.expression; |
1561 var frame = request.arguments.frame; | 1626 var frame = request.arguments.frame; |
1562 var global = request.arguments.global; | 1627 var global = request.arguments.global; |
1563 var disable_break = request.arguments.disable_break; | 1628 var disable_break = request.arguments.disable_break; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 case 'string': | 1977 case 'string': |
1913 case 'number': | 1978 case 'number': |
1914 json = value; | 1979 json = value; |
1915 break | 1980 break |
1916 | 1981 |
1917 default: | 1982 default: |
1918 json = null; | 1983 json = null; |
1919 } | 1984 } |
1920 return json; | 1985 return json; |
1921 } | 1986 } |
OLD | NEW |