OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 templ->SetCallHandler(&ScriptDebugServer::breakProgramCallback, v8::Exte rnal::New(m_isolate, this)); | 194 templ->SetCallHandler(&ScriptDebugServer::breakProgramCallback, v8::Exte rnal::New(m_isolate, this)); |
195 m_breakProgramCallbackTemplate.set(m_isolate, templ); | 195 m_breakProgramCallbackTemplate.set(m_isolate, templ); |
196 } | 196 } |
197 | 197 |
198 m_pausedContext = m_isolate->GetCurrentContext(); | 198 m_pausedContext = m_isolate->GetCurrentContext(); |
199 v8::Handle<v8::Function> breakProgramFunction = m_breakProgramCallbackTempla te.newLocal(m_isolate)->GetFunction(); | 199 v8::Handle<v8::Function> breakProgramFunction = m_breakProgramCallbackTempla te.newLocal(m_isolate)->GetFunction(); |
200 v8::Debug::Call(breakProgramFunction); | 200 v8::Debug::Call(breakProgramFunction); |
201 m_pausedContext.Clear(); | 201 m_pausedContext.Clear(); |
202 } | 202 } |
203 | 203 |
204 bool ScriptDebugServer::requestAsyncCallFrames() | |
205 { | |
206 if (isPaused()) { | |
207 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedConte xt); | |
208 ASSERT(listener); | |
209 if (!listener) | |
210 return false; | |
211 listener->didRequestAsyncCallFrames(currentCallFrame()); | |
yurys
2013/12/03 13:41:08
I believe we can implement this synchronously by p
aandrey
2013/12/04 12:45:47
Done.
| |
212 return true; | |
213 } | |
214 | |
215 v8::HandleScope scope(m_isolate); | |
216 if (m_asyncCallFramesCallbackTemplate.isEmpty()) { | |
217 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | |
218 templ->SetCallHandler(&ScriptDebugServer::asyncCallFramesCallback, v8::E xternal::New(this)); | |
219 m_asyncCallFramesCallbackTemplate.set(m_isolate, templ); | |
220 } | |
221 | |
222 v8::Handle<v8::Function> asyncCallFramesFunction = m_asyncCallFramesCallback Template.newLocal(m_isolate)->GetFunction(); | |
223 v8::Debug::Call(asyncCallFramesFunction); | |
224 return true; | |
225 } | |
226 | |
204 void ScriptDebugServer::continueProgram() | 227 void ScriptDebugServer::continueProgram() |
205 { | 228 { |
206 if (isPaused()) | 229 if (isPaused()) |
207 quitMessageLoopOnPause(); | 230 quitMessageLoopOnPause(); |
208 m_executionState.clear(); | 231 m_executionState.clear(); |
209 } | 232 } |
210 | 233 |
211 void ScriptDebugServer::stepIntoStatement() | 234 void ScriptDebugServer::stepIntoStatement() |
212 { | 235 { |
213 ASSERT(isPaused()); | 236 ASSERT(isPaused()); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 | 351 |
329 ASSERT(!currentCallFrameV8.IsEmpty()); | 352 ASSERT(!currentCallFrameV8.IsEmpty()); |
330 if (!currentCallFrameV8->IsObject()) | 353 if (!currentCallFrameV8->IsObject()) |
331 return PassRefPtr<JavaScriptCallFrame>(); | 354 return PassRefPtr<JavaScriptCallFrame>(); |
332 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle< v8::Object>::Cast(currentCallFrameV8)); | 355 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle< v8::Object>::Cast(currentCallFrameV8)); |
333 } | 356 } |
334 | 357 |
335 ScriptValue ScriptDebugServer::currentCallFrame() | 358 ScriptValue ScriptDebugServer::currentCallFrame() |
336 { | 359 { |
337 ASSERT(isPaused()); | 360 ASSERT(isPaused()); |
361 return currentCallFrame(m_executionState.newLocal(m_isolate), m_pausedContex t); | |
362 } | |
363 | |
364 ScriptValue ScriptDebugServer::currentCallFrame(v8::Handle<v8::Object> execution State, v8::Handle<v8::Context> pausedContext) | |
365 { | |
338 v8::HandleScope handleScope(m_isolate); | 366 v8::HandleScope handleScope(m_isolate); |
339 RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(m_executionSta te.newLocal(m_isolate), -1); | 367 RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(executionState , -1); |
340 if (!currentCallFrame) | 368 if (!currentCallFrame) |
341 return ScriptValue(v8::Null(m_isolate), m_isolate); | 369 return ScriptValue(v8::Null(m_isolate), m_isolate); |
342 v8::Context::Scope contextScope(m_pausedContext); | 370 v8::Context::Scope contextScope(pausedContext); |
343 return ScriptValue(toV8(currentCallFrame.release(), v8::Handle<v8::Object>() , m_pausedContext->GetIsolate()), m_pausedContext->GetIsolate()); | 371 return ScriptValue(toV8(currentCallFrame.release(), v8::Handle<v8::Object>() , pausedContext->GetIsolate()), pausedContext->GetIsolate()); |
344 } | 372 } |
345 | 373 |
346 void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task, v8::Isolate* isol ate) | 374 void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task, v8::Isolate* isol ate) |
347 { | 375 { |
348 v8::Debug::DebugBreakForCommand(new ClientDataImpl(task), isolate); | 376 v8::Debug::DebugBreakForCommand(new ClientDataImpl(task), isolate); |
349 } | 377 } |
350 | 378 |
351 void ScriptDebugServer::runPendingTasks() | 379 void ScriptDebugServer::runPendingTasks() |
352 { | 380 { |
353 v8::Debug::ProcessDebugMessages(); | 381 v8::Debug::ProcessDebugMessages(); |
354 } | 382 } |
355 | 383 |
356 static ScriptDebugServer* toScriptDebugServer(v8::Handle<v8::Value> data) | 384 static ScriptDebugServer* toScriptDebugServer(v8::Handle<v8::Value> data) |
357 { | 385 { |
358 void* p = v8::Handle<v8::External>::Cast(data)->Value(); | 386 void* p = v8::Handle<v8::External>::Cast(data)->Value(); |
359 return static_cast<ScriptDebugServer*>(p); | 387 return static_cast<ScriptDebugServer*>(p); |
360 } | 388 } |
361 | 389 |
390 void ScriptDebugServer::asyncCallFramesCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) | |
391 { | |
392 ASSERT(2 == info.Length()); | |
393 ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); | |
394 thisPtr->handleAsyncCallFrames(v8::Handle<v8::Object>::Cast(info[0])); | |
395 } | |
396 | |
397 void ScriptDebugServer::handleAsyncCallFrames(v8::Handle<v8::Object> executionSt ate) | |
398 { | |
399 if (m_isolate->GetCurrentContext().IsEmpty()) | |
400 return; | |
401 ScriptDebugListener* listener = getDebugListenerForContext(m_isolate->GetCur rentContext()); | |
402 if (!listener) | |
403 return; | |
404 if (isPaused()) | |
yurys
2013/12/03 13:41:08
How can we get here not being paused?
| |
405 listener->didRequestAsyncCallFrames(currentCallFrame()); | |
406 else | |
407 listener->didRequestAsyncCallFrames(currentCallFrame(executionState, m_i solate->GetCurrentContext())); | |
408 } | |
409 | |
362 void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8:: Value>& info) | 410 void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8:: Value>& info) |
363 { | 411 { |
364 ASSERT(2 == info.Length()); | 412 ASSERT(2 == info.Length()); |
365 | |
366 ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); | 413 ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); |
367 v8::Handle<v8::Value> exception; | 414 v8::Handle<v8::Value> exception; |
368 v8::Handle<v8::Array> hitBreakpoints; | 415 v8::Handle<v8::Array> hitBreakpoints; |
369 thisPtr->handleProgramBreak(v8::Handle<v8::Object>::Cast(info[0]), exception , hitBreakpoints); | 416 thisPtr->handleProgramBreak(v8::Handle<v8::Object>::Cast(info[0]), exception , hitBreakpoints); |
370 } | 417 } |
371 | 418 |
372 void ScriptDebugServer::handleProgramBreak(v8::Handle<v8::Object> executionState , v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) | 419 void ScriptDebugServer::handleProgramBreak(v8::Handle<v8::Object> executionState , v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) |
373 { | 420 { |
374 // Don't allow nested breaks. | 421 // Don't allow nested breaks. |
375 if (isPaused()) | 422 if (isPaused()) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 { | 663 { |
617 return PassOwnPtr<ScriptSourceCode>(); | 664 return PassOwnPtr<ScriptSourceCode>(); |
618 } | 665 } |
619 | 666 |
620 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source, const String& url, const String& functionName) | 667 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source, const String& url, const String& functionName) |
621 { | 668 { |
622 return source; | 669 return source; |
623 } | 670 } |
624 | 671 |
625 } // namespace WebCore | 672 } // namespace WebCore |
OLD | NEW |