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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 }; | 938 }; |
939 | 939 |
940 | 940 |
941 NewFunctionEvent.prototype.setBreakPoint = function(p) { | 941 NewFunctionEvent.prototype.setBreakPoint = function(p) { |
942 Debug.setBreakPoint(this.func, p || 0); | 942 Debug.setBreakPoint(this.func, p || 0); |
943 }; | 943 }; |
944 | 944 |
945 | 945 |
946 function DebugCommandProcessor(exec_state) { | 946 function DebugCommandProcessor(exec_state) { |
947 this.exec_state_ = exec_state; | 947 this.exec_state_ = exec_state; |
| 948 this.running_ = false; |
948 }; | 949 }; |
949 | 950 |
950 | 951 |
951 DebugCommandProcessor.prototype.processDebugRequest = function (request) { | 952 DebugCommandProcessor.prototype.processDebugRequest = function (request) { |
952 return this.processDebugJSONRequest(request); | 953 return this.processDebugJSONRequest(request); |
953 } | 954 } |
954 | 955 |
955 | 956 |
956 DebugCommandProcessor.prototype.responseIsRunning = function (response) { | |
957 return this.isRunning(response); | |
958 } | |
959 | |
960 | |
961 function ResponsePacket(request) { | 957 function ResponsePacket(request) { |
962 // Build the initial response from the request. | 958 // Build the initial response from the request. |
963 this.seq = next_response_seq++; | 959 this.seq = next_response_seq++; |
964 this.type = 'response'; | 960 this.type = 'response'; |
965 if (request) this.request_seq = request.seq; | 961 if (request) this.request_seq = request.seq; |
966 if (request) this.command = request.command; | 962 if (request) this.command = request.command; |
967 this.success = true; | 963 this.success = true; |
968 this.running = false; | 964 this.running = false; |
969 } | 965 } |
970 | 966 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 json += '}'; | 1021 json += '}'; |
1026 return json; | 1022 return json; |
1027 } | 1023 } |
1028 | 1024 |
1029 | 1025 |
1030 DebugCommandProcessor.prototype.createResponse = function(request) { | 1026 DebugCommandProcessor.prototype.createResponse = function(request) { |
1031 return new ResponsePacket(request); | 1027 return new ResponsePacket(request); |
1032 }; | 1028 }; |
1033 | 1029 |
1034 | 1030 |
1035 DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request,
stopping) { | 1031 DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
{ |
1036 var request; // Current request. | 1032 var request; // Current request. |
1037 var response; // Generated response. | 1033 var response; // Generated response. |
1038 try { | 1034 try { |
1039 try { | 1035 try { |
1040 // Convert the JSON string to an object. | 1036 // Convert the JSON string to an object. |
1041 request = %CompileString('(' + json_request + ')', 0)(); | 1037 request = %CompileString('(' + json_request + ')', 0)(); |
1042 | 1038 |
1043 // Create an initial response. | 1039 // Create an initial response. |
1044 response = this.createResponse(request); | 1040 response = this.createResponse(request); |
1045 | 1041 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 // If there is no response object created one (without command). | 1080 // If there is no response object created one (without command). |
1085 if (!response) { | 1081 if (!response) { |
1086 response = this.createResponse(); | 1082 response = this.createResponse(); |
1087 } | 1083 } |
1088 response.success = false; | 1084 response.success = false; |
1089 response.message = %ToString(e); | 1085 response.message = %ToString(e); |
1090 } | 1086 } |
1091 | 1087 |
1092 // Return the response as a JSON encoded string. | 1088 // Return the response as a JSON encoded string. |
1093 try { | 1089 try { |
1094 // Set the running state to what indicated. | 1090 this.running_ = response.running; // Store the running state. |
1095 if (!IS_UNDEFINED(stopping)) { | |
1096 response.running = !stopping; | |
1097 } | |
1098 return response.toJSONProtocol(); | 1091 return response.toJSONProtocol(); |
1099 } catch (e) { | 1092 } catch (e) { |
1100 // Failed to generate response - return generic error. | 1093 // Failed to generate response - return generic error. |
1101 return '{"seq":' + response.seq + ',' + | 1094 return '{"seq":' + response.seq + ',' + |
1102 '"request_seq":' + request.seq + ',' + | 1095 '"request_seq":' + request.seq + ',' + |
1103 '"type":"response",' + | 1096 '"type":"response",' + |
1104 '"success":false,' + | 1097 '"success":false,' + |
1105 '"message":"Internal error: ' + %ToString(e) + '"}'; | 1098 '"message":"Internal error: ' + %ToString(e) + '"}'; |
1106 } | 1099 } |
1107 } catch (e) { | 1100 } catch (e) { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 script.lineCount = scripts[i].lineCount(); | 1524 script.lineCount = scripts[i].lineCount(); |
1532 script.sourceStart = scripts[i].source.substring(0, 80); | 1525 script.sourceStart = scripts[i].source.substring(0, 80); |
1533 script.sourceLength = scripts[i].source.length; | 1526 script.sourceLength = scripts[i].source.length; |
1534 script.type = scripts[i].type; | 1527 script.type = scripts[i].type; |
1535 response.body.push(script); | 1528 response.body.push(script); |
1536 } | 1529 } |
1537 } | 1530 } |
1538 }; | 1531 }; |
1539 | 1532 |
1540 | 1533 |
1541 // Check whether the JSON response indicate that the VM should be running. | 1534 // Check whether the previously processed command caused the VM to become |
1542 DebugCommandProcessor.prototype.isRunning = function(json_response) { | 1535 // running. |
1543 try { | 1536 DebugCommandProcessor.prototype.isRunning = function() { |
1544 // Convert the JSON string to an object. | 1537 return this.running_; |
1545 response = %CompileString('(' + json_response + ')', 0)(); | |
1546 | |
1547 // Return whether VM should be running after this request. | |
1548 return response.running; | |
1549 | |
1550 } catch (e) { | |
1551 return false; | |
1552 } | |
1553 } | 1538 } |
1554 | 1539 |
1555 | 1540 |
1556 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 1541 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
1557 return %SystemBreak(); | 1542 return %SystemBreak(); |
1558 }; | 1543 }; |
1559 | 1544 |
1560 | 1545 |
1561 function NumberToHex8Str(n) { | 1546 function NumberToHex8Str(n) { |
1562 var r = ""; | 1547 var r = ""; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 json += NumberToJSON_(elem); | 1663 json += NumberToJSON_(elem); |
1679 } else if (IS_STRING(elem)) { | 1664 } else if (IS_STRING(elem)) { |
1680 json += StringToJSON_(elem); | 1665 json += StringToJSON_(elem); |
1681 } else { | 1666 } else { |
1682 json += elem; | 1667 json += elem; |
1683 } | 1668 } |
1684 } | 1669 } |
1685 json += ']'; | 1670 json += ']'; |
1686 return json; | 1671 return json; |
1687 } | 1672 } |
OLD | NEW |