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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 void* p = v8::Handle<v8::External>::Cast(data)->Value(); | 375 void* p = v8::Handle<v8::External>::Cast(data)->Value(); |
376 return static_cast<ScriptDebugServer*>(p); | 376 return static_cast<ScriptDebugServer*>(p); |
377 } | 377 } |
378 | 378 |
379 v8::Handle<v8::Value> ScriptDebugServer::breakProgramCallback(const v8::Argument s& args) | 379 v8::Handle<v8::Value> ScriptDebugServer::breakProgramCallback(const v8::Argument s& args) |
380 { | 380 { |
381 ASSERT(2 == args.Length()); | 381 ASSERT(2 == args.Length()); |
382 | 382 |
383 ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data()); | 383 ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data()); |
384 v8::Handle<v8::Value> exception; | 384 v8::Handle<v8::Value> exception; |
385 thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception); | 385 v8::Handle<v8::Array> hitBreakPoints; |
yurys
2013/06/05 08:07:36
hitBreakpoints
SeRya
2013/06/05 11:34:57
Done.
| |
386 thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception, hitB reakPoints); | |
386 return v8::Undefined(); | 387 return v8::Undefined(); |
387 } | 388 } |
388 | 389 |
389 void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8:: Handle<v8::Value> exception) | 390 void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8:: Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) |
390 { | 391 { |
391 // Don't allow nested breaks. | 392 // Don't allow nested breaks. |
392 if (isPaused()) | 393 if (isPaused()) |
393 return; | 394 return; |
394 | 395 |
395 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); | 396 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); |
396 if (!listener) | 397 if (!listener) |
397 return; | 398 return; |
398 | 399 |
400 Vector<String> breakpointIDs; | |
yurys
2013/06/05 08:07:36
breakpointIds
SeRya
2013/06/05 11:34:57
Done.
| |
401 if (!hitBreakpointNumbers.IsEmpty()) { | |
402 breakpointIDs.resize(hitBreakpointNumbers->Length()); | |
403 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) | |
404 breakpointIDs[i] = toWebCoreStringWithUndefinedOrNullCheck(hitBreakp ointNumbers->Get(i)); | |
405 } | |
406 | |
399 m_executionState.set(m_isolate, executionState); | 407 m_executionState.set(m_isolate, executionState); |
400 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext ); | 408 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext ); |
401 listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(ex ception)); | 409 listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(ex ception), breakpointIDs); |
402 | 410 |
403 m_runningNestedMessageLoop = true; | 411 m_runningNestedMessageLoop = true; |
404 runMessageLoopOnPause(m_pausedContext); | 412 runMessageLoopOnPause(m_pausedContext); |
405 m_runningNestedMessageLoop = false; | 413 m_runningNestedMessageLoop = false; |
406 } | 414 } |
407 | 415 |
416 void ScriptDebugServer::breakProgram(const v8::Debug::EventDetails& eventDetails , v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) | |
417 { | |
418 m_pausedContext = *eventDetails.GetEventContext(); | |
419 breakProgram(eventDetails.GetExecutionState(), exception, hitBreakpointNumbe rs); | |
420 m_pausedContext.Clear(); | |
421 } | |
422 | |
408 void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even tDetails) | 423 void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even tDetails) |
409 { | 424 { |
410 ScriptDebugServer* thisPtr = toScriptDebugServer(eventDetails.GetCallbackDat a()); | 425 ScriptDebugServer* thisPtr = toScriptDebugServer(eventDetails.GetCallbackDat a()); |
411 thisPtr->handleV8DebugEvent(eventDetails); | 426 thisPtr->handleV8DebugEvent(eventDetails); |
412 } | 427 } |
413 | 428 |
414 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) | 429 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) |
415 { | 430 { |
416 v8::DebugEvent event = eventDetails.GetEvent(); | 431 v8::DebugEvent event = eventDetails.GetEvent(); |
417 | 432 |
(...skipping 29 matching lines...) Expand all Loading... | |
447 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1); | 462 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1); |
448 | 463 |
449 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); | 464 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); |
450 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(s criptName)); | 465 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(s criptName)); |
451 | 466 |
452 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) }; | 467 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) }; |
453 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2); | 468 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2); |
454 m_scriptPreprocessor = preprocessor.release(); | 469 m_scriptPreprocessor = preprocessor.release(); |
455 } else if (event == v8::AfterCompile) { | 470 } else if (event == v8::AfterCompile) { |
456 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 471 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
457 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Func tion>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileSc ript"))); | 472 v8::Handle<v8::Function> getAfterCompileFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileS cript"))); |
yurys
2013/06/05 08:07:36
the new name doesn't seem better, maybe getAfterCo
SeRya
2013/06/05 11:34:57
Done.
| |
458 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 473 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
459 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debugge rScript.get(), 1, argv); | 474 v8::Handle<v8::Value> value = getAfterCompileFunction->Call(m_debugg erScript.get(), 1, argv); |
460 ASSERT(value->IsObject()); | 475 ASSERT(value->IsObject()); |
461 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 476 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
462 dispatchDidParseSource(listener, object); | 477 dispatchDidParseSource(listener, object); |
463 } else if (event == v8::Break || event == v8::Exception) { | 478 } else if (event == v8::Exception) { |
464 v8::Handle<v8::Value> exception; | 479 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT race(1); |
465 if (event == v8::Exception) { | 480 // Stack trace is empty in case of syntax error. Silently continue e xecution in such cases. |
466 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentSt ackTrace(1); | 481 if (!stackTrace->GetFrameCount()) |
467 // Stack trace is empty in case of syntax error. Silently contin ue execution in such cases. | 482 return; |
468 if (!stackTrace->GetFrameCount()) | 483 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); |
469 return; | 484 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8::Stri ng::NewSymbol("exception")); |
470 v8::Handle<v8::Object> eventData = eventDetails.GetEventData(); | 485 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFu nction()); |
471 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8:: String::NewSymbol("exception")); | 486 v8::Handle<v8::Value> argv[] = { v8Undefined() }; |
472 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue-> IsFunction()); | 487 V8RecursionScope::MicrotaskSuppression scope; |
473 v8::Handle<v8::Value> argv[] = { v8Undefined() }; | 488 v8::Handle<v8::Value> exception = v8::Handle<v8::Function>::Cast(exc eptionGetterValue)->Call(eventData, 0, argv); |
474 V8RecursionScope::MicrotaskSuppression scope; | |
475 exception = v8::Handle<v8::Function>::Cast(exceptionGetterValue) ->Call(eventData, 0, argv); | |
476 } | |
477 | 489 |
478 m_pausedContext = *eventContext; | 490 breakProgram(eventDetails, exception, v8::Handle<v8::Array>()); |
479 breakProgram(eventDetails.GetExecutionState(), exception); | 491 } else if (event == v8::Break) { |
480 m_pausedContext.Clear(); | 492 // v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
yurys
2013/06/05 08:07:36
delete this line.
SeRya
2013/06/05 11:34:57
Done.
| |
493 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getBreakpoi ntNumbers"))); | |
494 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | |
495 v8::Handle<v8::Value> hitBreakpoints = getBreakpointNumbersFunction- >Call(m_debuggerScript.get(), 1, argv); | |
yurys
2013/06/05 08:07:36
1 -> ARRAY_SIZE(argv)
SeRya
2013/06/05 11:34:57
Done.
| |
496 ASSERT(hitBreakpoints.IsArray()); | |
497 | |
498 breakProgram(eventDetails, v8::Handle<v8::Value>(), hitBreakpoints.A s<v8::Array>()); | |
481 } | 499 } |
482 } | 500 } |
483 } | 501 } |
484 | 502 |
485 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object) | 503 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object) |
486 { | 504 { |
487 String sourceID = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::St ring::NewSymbol("id"))); | 505 String sourceID = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::St ring::NewSymbol("id"))); |
488 | 506 |
489 ScriptDebugListener::Script script; | 507 ScriptDebugListener::Script script; |
490 script.url = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::String: :NewSymbol("name"))); | 508 script.url = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::String: :NewSymbol("name"))); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 *wasThrown = true; | 620 *wasThrown = true; |
603 *result = ScriptValue(tryCatch.Exception()); | 621 *result = ScriptValue(tryCatch.Exception()); |
604 v8::Local<v8::Message> message = tryCatch.Message(); | 622 v8::Local<v8::Message> message = tryCatch.Message(); |
605 if (!message.IsEmpty()) | 623 if (!message.IsEmpty()) |
606 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get()); | 624 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get()); |
607 } else | 625 } else |
608 *result = ScriptValue(value); | 626 *result = ScriptValue(value); |
609 } | 627 } |
610 | 628 |
611 } // namespace WebCore | 629 } // namespace WebCore |
OLD | NEW |