| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Default number of frames to include in the response to backtrace request. | 5 // Default number of frames to include in the response to backtrace request. |
| 6 var kDefaultBacktraceLength = 10; | 6 var kDefaultBacktraceLength = 10; |
| 7 | 7 |
| 8 var Debug = {}; | 8 var Debug = {}; |
| 9 | 9 |
| 10 // Regular expression to skip "crud" at the beginning of a source line which is | 10 // Regular expression to skip "crud" at the beginning of a source line which is |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 | 979 |
| 980 ExecutionState.prototype.selectedFrame = function() { | 980 ExecutionState.prototype.selectedFrame = function() { |
| 981 return this.selected_frame; | 981 return this.selected_frame; |
| 982 }; | 982 }; |
| 983 | 983 |
| 984 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { | 984 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { |
| 985 return new DebugCommandProcessor(this, opt_is_running); | 985 return new DebugCommandProcessor(this, opt_is_running); |
| 986 }; | 986 }; |
| 987 | 987 |
| 988 | 988 |
| 989 function MakeBreakEvent(exec_state, break_points_hit) { | 989 function MakeBreakEvent(break_id, break_points_hit) { |
| 990 return new BreakEvent(exec_state, break_points_hit); | 990 return new BreakEvent(break_id, break_points_hit); |
| 991 } | 991 } |
| 992 | 992 |
| 993 | 993 |
| 994 function BreakEvent(exec_state, break_points_hit) { | 994 function BreakEvent(break_id, break_points_hit) { |
| 995 this.exec_state_ = exec_state; | 995 this.frame_ = new FrameMirror(break_id, 0); |
| 996 this.break_points_hit_ = break_points_hit; | 996 this.break_points_hit_ = break_points_hit; |
| 997 } | 997 } |
| 998 | 998 |
| 999 | 999 |
| 1000 BreakEvent.prototype.executionState = function() { | |
| 1001 return this.exec_state_; | |
| 1002 }; | |
| 1003 | |
| 1004 | |
| 1005 BreakEvent.prototype.eventType = function() { | 1000 BreakEvent.prototype.eventType = function() { |
| 1006 return Debug.DebugEvent.Break; | 1001 return Debug.DebugEvent.Break; |
| 1007 }; | 1002 }; |
| 1008 | 1003 |
| 1009 | 1004 |
| 1010 BreakEvent.prototype.func = function() { | 1005 BreakEvent.prototype.func = function() { |
| 1011 return this.exec_state_.frame(0).func(); | 1006 return this.frame_.func(); |
| 1012 }; | 1007 }; |
| 1013 | 1008 |
| 1014 | 1009 |
| 1015 BreakEvent.prototype.sourceLine = function() { | 1010 BreakEvent.prototype.sourceLine = function() { |
| 1016 return this.exec_state_.frame(0).sourceLine(); | 1011 return this.frame_.sourceLine(); |
| 1017 }; | 1012 }; |
| 1018 | 1013 |
| 1019 | 1014 |
| 1020 BreakEvent.prototype.sourceColumn = function() { | 1015 BreakEvent.prototype.sourceColumn = function() { |
| 1021 return this.exec_state_.frame(0).sourceColumn(); | 1016 return this.frame_.sourceColumn(); |
| 1022 }; | 1017 }; |
| 1023 | 1018 |
| 1024 | 1019 |
| 1025 BreakEvent.prototype.sourceLineText = function() { | 1020 BreakEvent.prototype.sourceLineText = function() { |
| 1026 return this.exec_state_.frame(0).sourceLineText(); | 1021 return this.frame_.sourceLineText(); |
| 1027 }; | 1022 }; |
| 1028 | 1023 |
| 1029 | 1024 |
| 1030 BreakEvent.prototype.breakPointsHit = function() { | 1025 BreakEvent.prototype.breakPointsHit = function() { |
| 1031 return this.break_points_hit_; | 1026 return this.break_points_hit_; |
| 1032 }; | 1027 }; |
| 1033 | 1028 |
| 1034 | 1029 |
| 1035 BreakEvent.prototype.toJSONProtocol = function() { | 1030 BreakEvent.prototype.toJSONProtocol = function() { |
| 1036 var o = { seq: next_response_seq++, | 1031 var o = { seq: next_response_seq++, |
| 1037 type: "event", | 1032 type: "event", |
| 1038 event: "break", | 1033 event: "break", |
| 1039 body: { invocationText: this.exec_state_.frame(0).invocationText(), | 1034 body: { invocationText: this.frame_.invocationText() } |
| 1040 } | |
| 1041 }; | 1035 }; |
| 1042 | 1036 |
| 1043 // Add script related information to the event if available. | 1037 // Add script related information to the event if available. |
| 1044 var script = this.func().script(); | 1038 var script = this.func().script(); |
| 1045 if (script) { | 1039 if (script) { |
| 1046 o.body.sourceLine = this.sourceLine(), | 1040 o.body.sourceLine = this.sourceLine(), |
| 1047 o.body.sourceColumn = this.sourceColumn(), | 1041 o.body.sourceColumn = this.sourceColumn(), |
| 1048 o.body.sourceLineText = this.sourceLineText(), | 1042 o.body.sourceLineText = this.sourceLineText(), |
| 1049 o.body.script = MakeScriptObject_(script, false); | 1043 o.body.script = MakeScriptObject_(script, false); |
| 1050 } | 1044 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1063 } else { | 1057 } else { |
| 1064 number = breakpoint.number(); | 1058 number = breakpoint.number(); |
| 1065 } | 1059 } |
| 1066 o.body.breakpoints.push(number); | 1060 o.body.breakpoints.push(number); |
| 1067 } | 1061 } |
| 1068 } | 1062 } |
| 1069 return JSON.stringify(ObjectToProtocolObject_(o)); | 1063 return JSON.stringify(ObjectToProtocolObject_(o)); |
| 1070 }; | 1064 }; |
| 1071 | 1065 |
| 1072 | 1066 |
| 1073 function MakeExceptionEvent(exec_state, exception, uncaught, promise) { | 1067 function MakeExceptionEvent(break_id, exception, uncaught, promise) { |
| 1074 return new ExceptionEvent(exec_state, exception, uncaught, promise); | 1068 return new ExceptionEvent(break_id, exception, uncaught, promise); |
| 1075 } | 1069 } |
| 1076 | 1070 |
| 1077 | 1071 |
| 1078 function ExceptionEvent(exec_state, exception, uncaught, promise) { | 1072 function ExceptionEvent(break_id, exception, uncaught, promise) { |
| 1079 this.exec_state_ = exec_state; | 1073 this.exec_state_ = new ExecutionState(break_id); |
| 1080 this.exception_ = exception; | 1074 this.exception_ = exception; |
| 1081 this.uncaught_ = uncaught; | 1075 this.uncaught_ = uncaught; |
| 1082 this.promise_ = promise; | 1076 this.promise_ = promise; |
| 1083 } | 1077 } |
| 1084 | 1078 |
| 1085 | 1079 |
| 1086 ExceptionEvent.prototype.executionState = function() { | |
| 1087 return this.exec_state_; | |
| 1088 }; | |
| 1089 | |
| 1090 | |
| 1091 ExceptionEvent.prototype.eventType = function() { | 1080 ExceptionEvent.prototype.eventType = function() { |
| 1092 return Debug.DebugEvent.Exception; | 1081 return Debug.DebugEvent.Exception; |
| 1093 }; | 1082 }; |
| 1094 | 1083 |
| 1095 | 1084 |
| 1096 ExceptionEvent.prototype.exception = function() { | 1085 ExceptionEvent.prototype.exception = function() { |
| 1097 return this.exception_; | 1086 return this.exception_; |
| 1098 }; | 1087 }; |
| 1099 | 1088 |
| 1100 | 1089 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 o.body.script = MakeScriptObject_(script, false); | 1136 o.body.script = MakeScriptObject_(script, false); |
| 1148 } | 1137 } |
| 1149 } else { | 1138 } else { |
| 1150 o.body.sourceLine = -1; | 1139 o.body.sourceLine = -1; |
| 1151 } | 1140 } |
| 1152 | 1141 |
| 1153 return o.toJSONProtocol(); | 1142 return o.toJSONProtocol(); |
| 1154 }; | 1143 }; |
| 1155 | 1144 |
| 1156 | 1145 |
| 1157 function MakeCompileEvent(exec_state, script, before) { | 1146 function MakeCompileEvent(script, before) { |
| 1158 return new CompileEvent(exec_state, script, before); | 1147 return new CompileEvent(script, before); |
| 1159 } | 1148 } |
| 1160 | 1149 |
| 1161 | 1150 |
| 1162 function CompileEvent(exec_state, script, before) { | 1151 function CompileEvent(script, before) { |
| 1163 this.exec_state_ = exec_state; | |
| 1164 this.script_ = MakeMirror(script); | 1152 this.script_ = MakeMirror(script); |
| 1165 this.before_ = before; | 1153 this.before_ = before; |
| 1166 } | 1154 } |
| 1167 | 1155 |
| 1168 | 1156 |
| 1169 CompileEvent.prototype.executionState = function() { | |
| 1170 return this.exec_state_; | |
| 1171 }; | |
| 1172 | |
| 1173 | |
| 1174 CompileEvent.prototype.eventType = function() { | 1157 CompileEvent.prototype.eventType = function() { |
| 1175 if (this.before_) { | 1158 if (this.before_) { |
| 1176 return Debug.DebugEvent.BeforeCompile; | 1159 return Debug.DebugEvent.BeforeCompile; |
| 1177 } else { | 1160 } else { |
| 1178 return Debug.DebugEvent.AfterCompile; | 1161 return Debug.DebugEvent.AfterCompile; |
| 1179 } | 1162 } |
| 1180 }; | 1163 }; |
| 1181 | 1164 |
| 1182 | 1165 |
| 1183 CompileEvent.prototype.script = function() { | 1166 CompileEvent.prototype.script = function() { |
| 1184 return this.script_; | 1167 return this.script_; |
| 1185 }; | 1168 }; |
| 1186 | 1169 |
| 1187 | 1170 |
| 1188 CompileEvent.prototype.toJSONProtocol = function() { | 1171 CompileEvent.prototype.toJSONProtocol = function() { |
| 1189 var o = new ProtocolMessage(); | 1172 var o = new ProtocolMessage(); |
| 1190 o.running = true; | 1173 o.running = true; |
| 1191 if (this.before_) { | 1174 if (this.before_) { |
| 1192 o.event = "beforeCompile"; | 1175 o.event = "beforeCompile"; |
| 1193 } else { | 1176 } else { |
| 1194 o.event = "afterCompile"; | 1177 o.event = "afterCompile"; |
| 1195 } | 1178 } |
| 1196 o.body = {}; | 1179 o.body = {}; |
| 1197 o.body.script = this.script_; | 1180 o.body.script = this.script_; |
| 1198 | 1181 |
| 1199 return o.toJSONProtocol(); | 1182 return o.toJSONProtocol(); |
| 1200 }; | 1183 }; |
| 1201 | 1184 |
| 1202 | 1185 |
| 1203 function MakeScriptCollectedEvent(exec_state, id) { | 1186 function MakeScriptCollectedEvent(id) { |
| 1204 return new ScriptCollectedEvent(exec_state, id); | 1187 return new ScriptCollectedEvent(id); |
| 1205 } | 1188 } |
| 1206 | 1189 |
| 1207 | 1190 |
| 1208 function ScriptCollectedEvent(exec_state, id) { | 1191 function ScriptCollectedEvent(id) { |
| 1209 this.exec_state_ = exec_state; | |
| 1210 this.id_ = id; | 1192 this.id_ = id; |
| 1211 } | 1193 } |
| 1212 | 1194 |
| 1213 | 1195 |
| 1214 ScriptCollectedEvent.prototype.id = function() { | 1196 ScriptCollectedEvent.prototype.id = function() { |
| 1215 return this.id_; | 1197 return this.id_; |
| 1216 }; | 1198 }; |
| 1217 | 1199 |
| 1218 | 1200 |
| 1219 ScriptCollectedEvent.prototype.executionState = function() { | |
| 1220 return this.exec_state_; | |
| 1221 }; | |
| 1222 | |
| 1223 | |
| 1224 ScriptCollectedEvent.prototype.toJSONProtocol = function() { | 1201 ScriptCollectedEvent.prototype.toJSONProtocol = function() { |
| 1225 var o = new ProtocolMessage(); | 1202 var o = new ProtocolMessage(); |
| 1226 o.running = true; | 1203 o.running = true; |
| 1227 o.event = "scriptCollected"; | 1204 o.event = "scriptCollected"; |
| 1228 o.body = {}; | 1205 o.body = {}; |
| 1229 o.body.script = { id: this.id() }; | 1206 o.body.script = { id: this.id() }; |
| 1230 return o.toJSONProtocol(); | 1207 return o.toJSONProtocol(); |
| 1231 }; | 1208 }; |
| 1232 | 1209 |
| 1233 | 1210 |
| (...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 | 2539 |
| 2563 default: | 2540 default: |
| 2564 json = null; | 2541 json = null; |
| 2565 } | 2542 } |
| 2566 return json; | 2543 return json; |
| 2567 } | 2544 } |
| 2568 | 2545 |
| 2569 Debug.TestApi = { | 2546 Debug.TestApi = { |
| 2570 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ | 2547 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ |
| 2571 }; | 2548 }; |
| OLD | NEW |