| 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 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 } | 2205 } |
| 2206 | 2206 |
| 2207 // If auto continue don't make the event cause a break, but process messages | 2207 // If auto continue don't make the event cause a break, but process messages |
| 2208 // in the queue if any. For script collected events don't even process | 2208 // in the queue if any. For script collected events don't even process |
| 2209 // messages in the queue as the execution state might not be what is expected | 2209 // messages in the queue as the execution state might not be what is expected |
| 2210 // by the client. | 2210 // by the client. |
| 2211 if ((auto_continue && !HasCommands()) || event == v8::ScriptCollected) { | 2211 if ((auto_continue && !HasCommands()) || event == v8::ScriptCollected) { |
| 2212 return; | 2212 return; |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 // Get the DebugCommandProcessor. | |
| 2216 v8::Local<v8::Object> api_exec_state = | |
| 2217 v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)); | |
| 2218 v8::Local<v8::String> fun_name = | |
| 2219 v8::String::New("debugCommandProcessor"); | |
| 2220 v8::Local<v8::Function> fun = | |
| 2221 v8::Function::Cast(*api_exec_state->Get(fun_name)); | |
| 2222 v8::TryCatch try_catch; | 2215 v8::TryCatch try_catch; |
| 2223 v8::Local<v8::Object> cmd_processor = | 2216 |
| 2224 v8::Object::Cast(*fun->Call(api_exec_state, 0, NULL)); | 2217 // DebugCommandProcessor goes here. |
| 2225 if (try_catch.HasCaught()) { | 2218 v8::Local<v8::Object> cmd_processor; |
| 2226 PrintLn(try_catch.Exception()); | 2219 { |
| 2227 return; | 2220 v8::Local<v8::Object> api_exec_state = |
| 2221 v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state)); |
| 2222 v8::Local<v8::String> fun_name = |
| 2223 v8::String::New("debugCommandProcessor"); |
| 2224 v8::Local<v8::Function> fun = |
| 2225 v8::Function::Cast(*api_exec_state->Get(fun_name)); |
| 2226 |
| 2227 v8::Handle<v8::Boolean> running = |
| 2228 auto_continue ? v8::True() : v8::False(); |
| 2229 static const int kArgc = 1; |
| 2230 v8::Handle<Value> argv[kArgc] = { running }; |
| 2231 cmd_processor = v8::Object::Cast(*fun->Call(api_exec_state, kArgc, argv)); |
| 2232 if (try_catch.HasCaught()) { |
| 2233 PrintLn(try_catch.Exception()); |
| 2234 return; |
| 2235 } |
| 2228 } | 2236 } |
| 2229 | 2237 |
| 2238 bool running = auto_continue; |
| 2239 |
| 2230 // Process requests from the debugger. | 2240 // Process requests from the debugger. |
| 2231 while (true) { | 2241 while (true) { |
| 2232 // Wait for new command in the queue. | 2242 // Wait for new command in the queue. |
| 2233 if (Debugger::host_dispatch_handler_) { | 2243 if (Debugger::host_dispatch_handler_) { |
| 2234 // In case there is a host dispatch - do periodic dispatches. | 2244 // In case there is a host dispatch - do periodic dispatches. |
| 2235 if (!command_received_->Wait(host_dispatch_micros_)) { | 2245 if (!command_received_->Wait(host_dispatch_micros_)) { |
| 2236 // Timout expired, do the dispatch. | 2246 // Timout expired, do the dispatch. |
| 2237 Debugger::host_dispatch_handler_(); | 2247 Debugger::host_dispatch_handler_(); |
| 2238 continue; | 2248 continue; |
| 2239 } | 2249 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2260 fun = v8::Function::Cast(*cmd_processor->Get(fun_name)); | 2270 fun = v8::Function::Cast(*cmd_processor->Get(fun_name)); |
| 2261 | 2271 |
| 2262 request = v8::String::New(command.text().start(), | 2272 request = v8::String::New(command.text().start(), |
| 2263 command.text().length()); | 2273 command.text().length()); |
| 2264 static const int kArgc = 1; | 2274 static const int kArgc = 1; |
| 2265 v8::Handle<Value> argv[kArgc] = { request }; | 2275 v8::Handle<Value> argv[kArgc] = { request }; |
| 2266 v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv); | 2276 v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv); |
| 2267 | 2277 |
| 2268 // Get the response. | 2278 // Get the response. |
| 2269 v8::Local<v8::String> response; | 2279 v8::Local<v8::String> response; |
| 2270 bool running = false; | |
| 2271 if (!try_catch.HasCaught()) { | 2280 if (!try_catch.HasCaught()) { |
| 2272 // Get response string. | 2281 // Get response string. |
| 2273 if (!response_val->IsUndefined()) { | 2282 if (!response_val->IsUndefined()) { |
| 2274 response = v8::String::Cast(*response_val); | 2283 response = v8::String::Cast(*response_val); |
| 2275 } else { | 2284 } else { |
| 2276 response = v8::String::New(""); | 2285 response = v8::String::New(""); |
| 2277 } | 2286 } |
| 2278 | 2287 |
| 2279 // Log the JSON request/response. | 2288 // Log the JSON request/response. |
| 2280 if (FLAG_trace_debug_json) { | 2289 if (FLAG_trace_debug_json) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2303 Handle<JSObject>::cast(exec_state), | 2312 Handle<JSObject>::cast(exec_state), |
| 2304 Handle<JSObject>::cast(event_data), | 2313 Handle<JSObject>::cast(event_data), |
| 2305 Handle<String>(Utils::OpenHandle(*response)), | 2314 Handle<String>(Utils::OpenHandle(*response)), |
| 2306 command.client_data()); | 2315 command.client_data()); |
| 2307 InvokeMessageHandler(message); | 2316 InvokeMessageHandler(message); |
| 2308 command.Dispose(); | 2317 command.Dispose(); |
| 2309 | 2318 |
| 2310 // Return from debug event processing if either the VM is put into the | 2319 // Return from debug event processing if either the VM is put into the |
| 2311 // runnning state (through a continue command) or auto continue is active | 2320 // runnning state (through a continue command) or auto continue is active |
| 2312 // and there are no more commands queued. | 2321 // and there are no more commands queued. |
| 2313 if (running || (auto_continue && !HasCommands())) { | 2322 if (running && !HasCommands()) { |
| 2314 return; | 2323 return; |
| 2315 } | 2324 } |
| 2316 } | 2325 } |
| 2317 } | 2326 } |
| 2318 | 2327 |
| 2319 | 2328 |
| 2320 void Debugger::SetEventListener(Handle<Object> callback, | 2329 void Debugger::SetEventListener(Handle<Object> callback, |
| 2321 Handle<Object> data) { | 2330 Handle<Object> data) { |
| 2322 HandleScope scope; | 2331 HandleScope scope; |
| 2323 | 2332 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2703 | 2712 |
| 2704 | 2713 |
| 2705 void LockingCommandMessageQueue::Clear() { | 2714 void LockingCommandMessageQueue::Clear() { |
| 2706 ScopedLock sl(lock_); | 2715 ScopedLock sl(lock_); |
| 2707 queue_.Clear(); | 2716 queue_.Clear(); |
| 2708 } | 2717 } |
| 2709 | 2718 |
| 2710 #endif // ENABLE_DEBUGGER_SUPPORT | 2719 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2711 | 2720 |
| 2712 } } // namespace v8::internal | 2721 } } // namespace v8::internal |
| OLD | NEW |