Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: Source/bindings/v8/ScriptDebugServer.cpp

Issue 15096004: Passing hit breakpoint IDs to ScriptDebugServer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void* p = v8::Handle<v8::External>::Cast(data)->Value(); 399 void* p = v8::Handle<v8::External>::Cast(data)->Value();
400 return static_cast<ScriptDebugServer*>(p); 400 return static_cast<ScriptDebugServer*>(p);
401 } 401 }
402 402
403 v8::Handle<v8::Value> ScriptDebugServer::breakProgramCallback(const v8::Argument s& args) 403 v8::Handle<v8::Value> ScriptDebugServer::breakProgramCallback(const v8::Argument s& args)
404 { 404 {
405 ASSERT(2 == args.Length()); 405 ASSERT(2 == args.Length());
406 406
407 ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data()); 407 ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data());
408 v8::Handle<v8::Value> exception; 408 v8::Handle<v8::Value> exception;
409 thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception); 409 v8::Handle<v8::Array> hitBreakPoints;
410 thisPtr->breakProgram(v8::Handle<v8::Object>::Cast(args[0]), exception, hitB reakPoints);
410 return v8::Undefined(); 411 return v8::Undefined();
411 } 412 }
412 413
413 void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8:: Handle<v8::Value> exception) 414 void ScriptDebugServer::breakProgram(v8::Handle<v8::Object> executionState, v8:: Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers)
414 { 415 {
415 // Don't allow nested breaks. 416 // Don't allow nested breaks.
416 if (isPaused()) 417 if (isPaused())
417 return; 418 return;
418 419
419 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); 420 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext);
420 if (!listener) 421 if (!listener)
421 return; 422 return;
422 423
424 Vector<String> breakpointIDs;
425 if (!hitBreakpointNumbers.IsEmpty()) {
426 breakpointIDs.resize(hitBreakpointNumbers->Length());
427 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++)
428 breakpointIDs[i] = toWebCoreStringWithUndefinedOrNullCheck(hitBreakp ointNumbers->Get(i));
429 }
430
423 m_executionState.set(executionState); 431 m_executionState.set(executionState);
424 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext ); 432 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext );
425 listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(ex ception)); 433 listener->didPause(currentCallFrameState, currentCallFrame(), ScriptValue(ex ception), breakpointIDs);
426 434
427 m_runningNestedMessageLoop = true; 435 m_runningNestedMessageLoop = true;
428 runMessageLoopOnPause(m_pausedContext); 436 runMessageLoopOnPause(m_pausedContext);
429 m_runningNestedMessageLoop = false; 437 m_runningNestedMessageLoop = false;
430 } 438 }
431 439
432 void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even tDetails) 440 void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even tDetails)
433 { 441 {
434 ScriptDebugServer* thisPtr = toScriptDebugServer(eventDetails.GetCallbackDat a()); 442 ScriptDebugServer* thisPtr = toScriptDebugServer(eventDetails.GetCallbackDat a());
435 thisPtr->handleV8DebugEvent(eventDetails); 443 thisPtr->handleV8DebugEvent(eventDetails);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1); 479 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1);
472 480
473 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); 481 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource")));
474 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(s criptName)); 482 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(s criptName));
475 483
476 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) }; 484 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) };
477 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2); 485 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2);
478 m_scriptPreprocessor = preprocessor.release(); 486 m_scriptPreprocessor = preprocessor.release();
479 } else if (event == v8::AfterCompile) { 487 } else if (event == v8::AfterCompile) {
480 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 488 v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
481 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Func tion>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileSc ript"))); 489 v8::Handle<v8::Function> getAfterCompileFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileS cript")));
482 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; 490 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
483 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debugge rScript.get(), 1, argv); 491 v8::Handle<v8::Value> value = getAfterCompileFunction->Call(m_debugg erScript.get(), 1, argv);
484 ASSERT(value->IsObject()); 492 ASSERT(value->IsObject());
485 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); 493 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
486 dispatchDidParseSource(listener, object); 494 dispatchDidParseSource(listener, object);
487 } else if (event == v8::Break || event == v8::Exception) { 495 } else if (event == v8::Exception) {
496 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackT race(1);
497 // Stack trace is empty in case of syntax error. Silently continue e xecution in such cases.
498 if (!stackTrace->GetFrameCount())
499 return;
500 v8::Handle<v8::Object> eventData = eventDetails.GetEventData();
501 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8::Stri ng::NewSymbol("exception"));
502 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFu nction());
503 v8::Handle<v8::Value> argv[] = { v8Undefined() };
504 V8RecursionScope::MicrotaskSuppression scope;
505 v8::Handle<v8::Value> exception = v8::Handle<v8::Function>::Cast(exc eptionGetterValue)->Call(eventData, 0, argv);
506
507 v8::Handle<v8::Array> hitBreakpoints;
508 m_pausedContext = *eventContext;
509 breakProgram(eventDetails.GetExecutionState(), exception, hitBreakpo ints);
510 m_pausedContext.Clear();
511 } else if (event == v8::Break) {
512 // v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
513 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getBreakpoi ntNumbers")));
514 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
515 v8::Handle<v8::Value> hitBreakpoints = getBreakpointNumbersFunction- >Call(m_debuggerScript.get(), 1, argv);
516 ASSERT(hitBreakpoints.IsArray());
517
488 v8::Handle<v8::Value> exception; 518 v8::Handle<v8::Value> exception;
489 if (event == v8::Exception) {
490 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentSt ackTrace(1);
491 // Stack trace is empty in case of syntax error. Silently contin ue execution in such cases.
492 if (!stackTrace->GetFrameCount())
493 return;
494 v8::Handle<v8::Object> eventData = eventDetails.GetEventData();
495 v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8:: String::NewSymbol("exception"));
496 ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue-> IsFunction());
497 v8::Handle<v8::Value> argv[] = { v8Undefined() };
498 V8RecursionScope::MicrotaskSuppression scope;
499 exception = v8::Handle<v8::Function>::Cast(exceptionGetterValue) ->Call(eventData, 0, argv);
500 }
yurys 2013/05/16 19:52:53 Can you put breakpoint ids retrieval into else if
SeRya 2013/05/30 07:45:57 The code looks more clear for me without such an i
501
502 m_pausedContext = *eventContext; 519 m_pausedContext = *eventContext;
503 breakProgram(eventDetails.GetExecutionState(), exception); 520 breakProgram(eventDetails.GetExecutionState(), exception, hitBreakpo ints.As<v8::Array>());
504 m_pausedContext.Clear(); 521 m_pausedContext.Clear();
505 } 522 }
506 } 523 }
507 } 524 }
508 525
509 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object) 526 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object)
510 { 527 {
511 String sourceID = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::St ring::NewSymbol("id"))); 528 String sourceID = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8::St ring::NewSymbol("id")));
512 529
513 ScriptDebugListener::Script script; 530 ScriptDebugListener::Script script;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 *wasThrown = true; 650 *wasThrown = true;
634 *result = ScriptValue(tryCatch.Exception()); 651 *result = ScriptValue(tryCatch.Exception());
635 v8::Local<v8::Message> message = tryCatch.Message(); 652 v8::Local<v8::Message> message = tryCatch.Message();
636 if (!message.IsEmpty()) 653 if (!message.IsEmpty())
637 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get()); 654 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get());
638 } else 655 } else
639 *result = ScriptValue(value); 656 *result = ScriptValue(value);
640 } 657 }
641 658
642 } // namespace WebCore 659 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698