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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 info->Set(v8AtomicString(m_isolate, "columnNumber"), v8::Integer::New(script
Breakpoint.columnNumber, debuggerContext->GetIsolate())); | 95 info->Set(v8AtomicString(m_isolate, "columnNumber"), v8::Integer::New(script
Breakpoint.columnNumber, debuggerContext->GetIsolate())); |
96 info->Set(v8AtomicString(m_isolate, "interstatementLocation"), v8Boolean(int
erstatementLocation, debuggerContext->GetIsolate())); | 96 info->Set(v8AtomicString(m_isolate, "interstatementLocation"), v8Boolean(int
erstatementLocation, debuggerContext->GetIsolate())); |
97 info->Set(v8AtomicString(m_isolate, "condition"), v8String(debuggerContext->
GetIsolate(), scriptBreakpoint.condition)); | 97 info->Set(v8AtomicString(m_isolate, "condition"), v8String(debuggerContext->
GetIsolate(), scriptBreakpoint.condition)); |
98 | 98 |
99 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "setBreak
point"))); | 99 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "setBreak
point"))); |
100 v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction,
info); | 100 v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction,
info); |
101 if (!breakpointId->IsString()) | 101 if (!breakpointId->IsString()) |
102 return ""; | 102 return ""; |
103 *actualLineNumber = info->Get(v8AtomicString(m_isolate, "lineNumber"))->Int3
2Value(); | 103 *actualLineNumber = info->Get(v8AtomicString(m_isolate, "lineNumber"))->Int3
2Value(); |
104 *actualColumnNumber = info->Get(v8AtomicString(m_isolate, "columnNumber"))->
Int32Value(); | 104 *actualColumnNumber = info->Get(v8AtomicString(m_isolate, "columnNumber"))->
Int32Value(); |
105 return toWebCoreString(breakpointId.As<v8::String>()); | 105 return toCoreString(breakpointId.As<v8::String>()); |
106 } | 106 } |
107 | 107 |
108 void ScriptDebugServer::removeBreakpoint(const String& breakpointId) | 108 void ScriptDebugServer::removeBreakpoint(const String& breakpointId) |
109 { | 109 { |
110 v8::HandleScope scope(m_isolate); | 110 v8::HandleScope scope(m_isolate); |
111 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 111 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
112 v8::Context::Scope contextScope(debuggerContext); | 112 v8::Context::Scope contextScope(debuggerContext); |
113 | 113 |
114 v8::Local<v8::Object> info = v8::Object::New(); | 114 v8::Local<v8::Object> info = v8::Object::New(); |
115 info->Set(v8AtomicString(m_isolate, "breakpointId"), v8String(debuggerContex
t->GetIsolate(), breakpointId)); | 115 info->Set(v8AtomicString(m_isolate, "breakpointId"), v8String(debuggerContex
t->GetIsolate(), breakpointId)); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 v8::Local<v8::Value> v8result; | 269 v8::Local<v8::Value> v8result; |
270 { | 270 { |
271 EnableLiveEditScope enableLiveEditScope; | 271 EnableLiveEditScope enableLiveEditScope; |
272 v8::TryCatch tryCatch; | 272 v8::TryCatch tryCatch; |
273 tryCatch.SetVerbose(false); | 273 tryCatch.SetVerbose(false); |
274 v8result = callDebuggerMethod("liveEditScriptSource", 3, argv); | 274 v8result = callDebuggerMethod("liveEditScriptSource", 3, argv); |
275 if (tryCatch.HasCaught()) { | 275 if (tryCatch.HasCaught()) { |
276 v8::Local<v8::Message> message = tryCatch.Message(); | 276 v8::Local<v8::Message> message = tryCatch.Message(); |
277 if (!message.IsEmpty()) | 277 if (!message.IsEmpty()) |
278 *error = toWebCoreStringWithUndefinedOrNullCheck(message->Get())
; | 278 *error = toCoreStringWithUndefinedOrNullCheck(message->Get()); |
279 else | 279 else |
280 *error = "Unknown error."; | 280 *error = "Unknown error."; |
281 return false; | 281 return false; |
282 } | 282 } |
283 } | 283 } |
284 ASSERT(!v8result.IsEmpty()); | 284 ASSERT(!v8result.IsEmpty()); |
285 v8::Local<v8::Object> resultTuple = v8result->ToObject(); | 285 v8::Local<v8::Object> resultTuple = v8result->ToObject(); |
286 int code = static_cast<int>(resultTuple->Get(0)->ToInteger()->Value()); | 286 int code = static_cast<int>(resultTuple->Get(0)->ToInteger()->Value()); |
287 switch (code) { | 287 switch (code) { |
288 case 0: | 288 case 0: |
289 { | 289 { |
290 v8::Local<v8::Value> normalResult = resultTuple->Get(1); | 290 v8::Local<v8::Value> normalResult = resultTuple->Get(1); |
291 if (normalResult->IsObject()) | 291 if (normalResult->IsObject()) |
292 *result = ScriptObject(ScriptState::current(), normalResult->ToO
bject()); | 292 *result = ScriptObject(ScriptState::current(), normalResult->ToO
bject()); |
293 // Call stack may have changed after if the edited function was on t
he stack. | 293 // Call stack may have changed after if the edited function was on t
he stack. |
294 if (!preview && isPaused()) | 294 if (!preview && isPaused()) |
295 *newCallFrames = currentCallFrames(); | 295 *newCallFrames = currentCallFrames(); |
296 return true; | 296 return true; |
297 } | 297 } |
298 // Compile error. | 298 // Compile error. |
299 case 1: | 299 case 1: |
300 { | 300 { |
301 RefPtr<TypeBuilder::Debugger::SetScriptSourceError::CompileError> co
mpileError = | 301 RefPtr<TypeBuilder::Debugger::SetScriptSourceError::CompileError> co
mpileError = |
302 TypeBuilder::Debugger::SetScriptSourceError::CompileError::creat
e() | 302 TypeBuilder::Debugger::SetScriptSourceError::CompileError::creat
e() |
303 .setMessage(toWebCoreStringWithUndefinedOrNullCheck(resultTu
ple->Get(2))) | 303 .setMessage(toCoreStringWithUndefinedOrNullCheck(resultTuple
->Get(2))) |
304 .setLineNumber(resultTuple->Get(3)->ToInteger()->Value()) | 304 .setLineNumber(resultTuple->Get(3)->ToInteger()->Value()) |
305 .setColumnNumber(resultTuple->Get(4)->ToInteger()->Value()); | 305 .setColumnNumber(resultTuple->Get(4)->ToInteger()->Value()); |
306 | 306 |
307 *error = toWebCoreStringWithUndefinedOrNullCheck(resultTuple->Get(1)
); | 307 *error = toCoreStringWithUndefinedOrNullCheck(resultTuple->Get(1)); |
308 errorData = TypeBuilder::Debugger::SetScriptSourceError::create(); | 308 errorData = TypeBuilder::Debugger::SetScriptSourceError::create(); |
309 errorData->setCompileError(compileError); | 309 errorData->setCompileError(compileError); |
310 return false; | 310 return false; |
311 } | 311 } |
312 } | 312 } |
313 *error = "Unknown error."; | 313 *error = "Unknown error."; |
314 return false; | 314 return false; |
315 } | 315 } |
316 | 316 |
317 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::wrapCallFrames(v8::Handle<v8:
:Object> executionState, int maximumLimit) | 317 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::wrapCallFrames(v8::Handle<v8:
:Object> executionState, int maximumLimit) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 return; | 378 return; |
379 | 379 |
380 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); | 380 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); |
381 if (!listener) | 381 if (!listener) |
382 return; | 382 return; |
383 | 383 |
384 Vector<String> breakpointIds; | 384 Vector<String> breakpointIds; |
385 if (!hitBreakpointNumbers.IsEmpty()) { | 385 if (!hitBreakpointNumbers.IsEmpty()) { |
386 breakpointIds.resize(hitBreakpointNumbers->Length()); | 386 breakpointIds.resize(hitBreakpointNumbers->Length()); |
387 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) | 387 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) |
388 breakpointIds[i] = toWebCoreStringWithUndefinedOrNullCheck(hitBreakp
ointNumbers->Get(i)); | 388 breakpointIds[i] = toCoreStringWithUndefinedOrNullCheck(hitBreakpoin
tNumbers->Get(i)); |
389 } | 389 } |
390 | 390 |
391 m_executionState.set(m_isolate, executionState); | 391 m_executionState.set(m_isolate, executionState); |
392 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext
); | 392 ScriptState* currentCallFrameState = ScriptState::forContext(m_pausedContext
); |
393 listener->didPause(currentCallFrameState, currentCallFrames(), ScriptValue(e
xception, currentCallFrameState->isolate()), breakpointIds); | 393 listener->didPause(currentCallFrameState, currentCallFrames(), ScriptValue(e
xception, currentCallFrameState->isolate()), breakpointIds); |
394 | 394 |
395 m_runningNestedMessageLoop = true; | 395 m_runningNestedMessageLoop = true; |
396 runMessageLoopOnPause(m_pausedContext); | 396 runMessageLoopOnPause(m_pausedContext); |
397 m_runningNestedMessageLoop = false; | 397 m_runningNestedMessageLoop = false; |
398 } | 398 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 skipRequest = listener->shouldSkipStepPause(topFrame); | 482 skipRequest = listener->shouldSkipStepPause(topFrame); |
483 if (executeSkipPauseRequest(skipRequest, eventDetails.GetExecutionSt
ate())) | 483 if (executeSkipPauseRequest(skipRequest, eventDetails.GetExecutionSt
ate())) |
484 return; | 484 return; |
485 handleProgramBreak(eventDetails, v8::Handle<v8::Value>(), hitBreakpo
ints.As<v8::Array>()); | 485 handleProgramBreak(eventDetails, v8::Handle<v8::Value>(), hitBreakpo
ints.As<v8::Array>()); |
486 } | 486 } |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object) | 490 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object) |
491 { | 491 { |
492 String sourceID = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8Atom
icString(m_isolate, "id"))); | 492 String sourceID = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicS
tring(m_isolate, "id"))); |
493 | 493 |
494 ScriptDebugListener::Script script; | 494 ScriptDebugListener::Script script; |
495 script.url = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr
ing(m_isolate, "name"))); | 495 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); |
496 script.source = toWebCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic
String(m_isolate, "source"))); | 496 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr
ing(m_isolate, "source"))); |
497 script.sourceMappingURL = toWebCoreStringWithUndefinedOrNullCheck(object->Ge
t(v8AtomicString(m_isolate, "sourceMappingURL"))); | 497 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); |
498 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn
teger()->Value(); | 498 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn
teger()->Value(); |
499 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))->
ToInteger()->Value(); | 499 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))->
ToInteger()->Value(); |
500 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege
r()->Value(); | 500 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege
r()->Value(); |
501 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn
teger()->Value(); | 501 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn
teger()->Value(); |
502 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr
ipt"))->ToBoolean()->Value(); | 502 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr
ipt"))->ToBoolean()->Value(); |
503 | 503 |
504 listener->didParseSource(sourceID, script); | 504 listener->didParseSource(sourceID, script); |
505 } | 505 } |
506 | 506 |
507 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 507 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if (context.IsEmpty()) | 563 if (context.IsEmpty()) |
564 return; | 564 return; |
565 v8::Context::Scope contextScope(context); | 565 v8::Context::Scope contextScope(context); |
566 | 566 |
567 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 567 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
568 v8::TryCatch tryCatch; | 568 v8::TryCatch tryCatch; |
569 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); | 569 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); |
570 if (tryCatch.HasCaught()) { | 570 if (tryCatch.HasCaught()) { |
571 v8::Local<v8::Message> message = tryCatch.Message(); | 571 v8::Local<v8::Message> message = tryCatch.Message(); |
572 if (!message.IsEmpty()) | 572 if (!message.IsEmpty()) |
573 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); | 573 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); |
574 return; | 574 return; |
575 } | 575 } |
576 if (script.IsEmpty()) | 576 if (script.IsEmpty()) |
577 return; | 577 return; |
578 | 578 |
579 *scriptId = String::number(script->GetId()); | 579 *scriptId = String::number(script->GetId()); |
580 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); | 580 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); |
581 } | 581 } |
582 | 582 |
583 void ScriptDebugServer::clearCompiledScripts() | 583 void ScriptDebugServer::clearCompiledScripts() |
(...skipping 17 matching lines...) Expand all Loading... |
601 return; | 601 return; |
602 v8::Context::Scope contextScope(context); | 602 v8::Context::Scope contextScope(context); |
603 v8::TryCatch tryCatch; | 603 v8::TryCatch tryCatch; |
604 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, state
->executionContext(), m_isolate); | 604 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, state
->executionContext(), m_isolate); |
605 *wasThrown = false; | 605 *wasThrown = false; |
606 if (tryCatch.HasCaught()) { | 606 if (tryCatch.HasCaught()) { |
607 *wasThrown = true; | 607 *wasThrown = true; |
608 *result = ScriptValue(tryCatch.Exception(), m_isolate); | 608 *result = ScriptValue(tryCatch.Exception(), m_isolate); |
609 v8::Local<v8::Message> message = tryCatch.Message(); | 609 v8::Local<v8::Message> message = tryCatch.Message(); |
610 if (!message.IsEmpty()) | 610 if (!message.IsEmpty()) |
611 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); | 611 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); |
612 } else { | 612 } else { |
613 *result = ScriptValue(value, m_isolate); | 613 *result = ScriptValue(value, m_isolate); |
614 } | 614 } |
615 } | 615 } |
616 | 616 |
617 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(Frame*, const ScriptS
ourceCode&) | 617 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(Frame*, const ScriptS
ourceCode&) |
618 { | 618 { |
619 return PassOwnPtr<ScriptSourceCode>(); | 619 return PassOwnPtr<ScriptSourceCode>(); |
620 } | 620 } |
621 | 621 |
622 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source,
const String& url, const String& functionName) | 622 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source,
const String& url, const String& functionName) |
623 { | 623 { |
624 return source; | 624 return source; |
625 } | 625 } |
626 | 626 |
627 } // namespace WebCore | 627 } // namespace WebCore |
OLD | NEW |