| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 ScriptDebugServer::~ScriptDebugServer() | 82 ScriptDebugServer::~ScriptDebugServer() |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
kpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool i
nterstatementLocation) | 86 String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
kpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool i
nterstatementLocation) |
| 87 { | 87 { |
| 88 v8::HandleScope scope(m_isolate); | 88 v8::HandleScope scope(m_isolate); |
| 89 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 89 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 90 v8::Context::Scope contextScope(debuggerContext); | 90 v8::Context::Scope contextScope(debuggerContext); |
| 91 | 91 |
| 92 v8::Local<v8::Object> args = v8::Object::New(); | 92 v8::Local<v8::Object> info = v8::Object::New(); |
| 93 args->Set(v8::String::NewSymbol("sourceID"), v8String(sourceID, debuggerCont
ext->GetIsolate())); | 93 info->Set(v8::String::NewSymbol("sourceID"), v8String(sourceID, debuggerCont
ext->GetIsolate())); |
| 94 args->Set(v8::String::NewSymbol("lineNumber"), v8::Integer::New(scriptBreakp
oint.lineNumber, debuggerContext->GetIsolate())); | 94 info->Set(v8::String::NewSymbol("lineNumber"), v8::Integer::New(scriptBreakp
oint.lineNumber, debuggerContext->GetIsolate())); |
| 95 args->Set(v8::String::NewSymbol("columnNumber"), v8::Integer::New(scriptBrea
kpoint.columnNumber, debuggerContext->GetIsolate())); | 95 info->Set(v8::String::NewSymbol("columnNumber"), v8::Integer::New(scriptBrea
kpoint.columnNumber, debuggerContext->GetIsolate())); |
| 96 args->Set(v8::String::NewSymbol("interstatementLocation"), v8Boolean(interst
atementLocation, debuggerContext->GetIsolate())); | 96 info->Set(v8::String::NewSymbol("interstatementLocation"), v8Boolean(interst
atementLocation, debuggerContext->GetIsolate())); |
| 97 args->Set(v8::String::NewSymbol("condition"), v8String(scriptBreakpoint.cond
ition, debuggerContext->GetIsolate())); | 97 info->Set(v8::String::NewSymbol("condition"), v8String(scriptBreakpoint.cond
ition, debuggerContext->GetIsolate())); |
| 98 | 98 |
| 99 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpoin
t"))); | 99 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpoin
t"))); |
| 100 v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction,
args); | 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 = args->Get(v8::String::NewSymbol("lineNumber"))->Int32Val
ue(); | 103 *actualLineNumber = info->Get(v8::String::NewSymbol("lineNumber"))->Int32Val
ue(); |
| 104 *actualColumnNumber = args->Get(v8::String::NewSymbol("columnNumber"))->Int3
2Value(); | 104 *actualColumnNumber = info->Get(v8::String::NewSymbol("columnNumber"))->Int3
2Value(); |
| 105 return toWebCoreString(breakpointId.As<v8::String>()); | 105 return toWebCoreString(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> args = v8::Object::New(); | 114 v8::Local<v8::Object> info = v8::Object::New(); |
| 115 args->Set(v8::String::NewSymbol("breakpointId"), v8String(breakpointId, debu
ggerContext->GetIsolate())); | 115 info->Set(v8::String::NewSymbol("breakpointId"), v8String(breakpointId, debu
ggerContext->GetIsolate())); |
| 116 | 116 |
| 117 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>:
:Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("removeBre
akpoint"))); | 117 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>:
:Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("removeBre
akpoint"))); |
| 118 v8::Debug::Call(removeBreakpointFunction, args); | 118 v8::Debug::Call(removeBreakpointFunction, info); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ScriptDebugServer::clearBreakpoints() | 121 void ScriptDebugServer::clearBreakpoints() |
| 122 { | 122 { |
| 123 ensureDebuggerScriptCompiled(); | 123 ensureDebuggerScriptCompiled(); |
| 124 v8::HandleScope scope(m_isolate); | 124 v8::HandleScope scope(m_isolate); |
| 125 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 125 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 126 v8::Context::Scope contextScope(debuggerContext); | 126 v8::Context::Scope contextScope(debuggerContext); |
| 127 | 127 |
| 128 v8::Handle<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_
debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("clearBreakpoints"
))); | 128 v8::Handle<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_
debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("clearBreakpoints"
))); |
| 129 v8::Debug::Call(clearBreakpoints); | 129 v8::Debug::Call(clearBreakpoints); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ScriptDebugServer::setBreakpointsActivated(bool activated) | 132 void ScriptDebugServer::setBreakpointsActivated(bool activated) |
| 133 { | 133 { |
| 134 ensureDebuggerScriptCompiled(); | 134 ensureDebuggerScriptCompiled(); |
| 135 v8::HandleScope scope(m_isolate); | 135 v8::HandleScope scope(m_isolate); |
| 136 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 136 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 137 v8::Context::Scope contextScope(debuggerContext); | 137 v8::Context::Scope contextScope(debuggerContext); |
| 138 | 138 |
| 139 v8::Local<v8::Object> args = v8::Object::New(); | 139 v8::Local<v8::Object> info = v8::Object::New(); |
| 140 args->Set(v8::String::NewSymbol("enabled"), v8::Boolean::New(activated)); | 140 info->Set(v8::String::NewSymbol("enabled"), v8::Boolean::New(activated)); |
| 141 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::
Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpo
intsActivated"))); | 141 v8::Handle<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::
Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8::String::NewSymbol("setBreakpo
intsActivated"))); |
| 142 v8::Debug::Call(setBreakpointsActivated, args); | 142 v8::Debug::Call(setBreakpointsActivated, info); |
| 143 | 143 |
| 144 m_breakpointsActivated = activated; | 144 m_breakpointsActivated = activated; |
| 145 } | 145 } |
| 146 | 146 |
| 147 ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsSt
ate() | 147 ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsSt
ate() |
| 148 { | 148 { |
| 149 ensureDebuggerScriptCompiled(); | 149 ensureDebuggerScriptCompiled(); |
| 150 v8::HandleScope scope(m_isolate); | 150 v8::HandleScope scope(m_isolate); |
| 151 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); | 151 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); |
| 152 | 152 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 { | 357 { |
| 358 v8::Debug::ProcessDebugMessages(); | 358 v8::Debug::ProcessDebugMessages(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 static ScriptDebugServer* toScriptDebugServer(v8::Handle<v8::Value> data) | 361 static ScriptDebugServer* toScriptDebugServer(v8::Handle<v8::Value> data) |
| 362 { | 362 { |
| 363 void* p = v8::Handle<v8::External>::Cast(data)->Value(); | 363 void* p = v8::Handle<v8::External>::Cast(data)->Value(); |
| 364 return static_cast<ScriptDebugServer*>(p); | 364 return static_cast<ScriptDebugServer*>(p); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8::
Value>& args) | 367 void ScriptDebugServer::breakProgramCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 368 { | 368 { |
| 369 ASSERT(2 == args.Length()); | 369 ASSERT(2 == info.Length()); |
| 370 | 370 |
| 371 ScriptDebugServer* thisPtr = toScriptDebugServer(args.Data()); | 371 ScriptDebugServer* thisPtr = toScriptDebugServer(info.Data()); |
| 372 v8::Handle<v8::Value> exception; | 372 v8::Handle<v8::Value> exception; |
| 373 v8::Handle<v8::Array> hitBreakpoints; | 373 v8::Handle<v8::Array> hitBreakpoints; |
| 374 thisPtr->handleProgramBreak(v8::Handle<v8::Object>::Cast(args[0]), exception
, hitBreakpoints); | 374 thisPtr->handleProgramBreak(v8::Handle<v8::Object>::Cast(info[0]), exception
, hitBreakpoints); |
| 375 } | 375 } |
| 376 | 376 |
| 377 void ScriptDebugServer::handleProgramBreak(v8::Handle<v8::Object> executionState
, v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) | 377 void ScriptDebugServer::handleProgramBreak(v8::Handle<v8::Object> executionState
, v8::Handle<v8::Value> exception, v8::Handle<v8::Array> hitBreakpointNumbers) |
| 378 { | 378 { |
| 379 // Don't allow nested breaks. | 379 // Don't allow nested breaks. |
| 380 if (isPaused()) | 380 if (isPaused()) |
| 381 return; | 381 return; |
| 382 | 382 |
| 383 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); | 383 ScriptDebugListener* listener = getDebugListenerForContext(m_pausedContext); |
| 384 if (!listener) | 384 if (!listener) |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 { | 626 { |
| 627 return PassOwnPtr<ScriptSourceCode>(); | 627 return PassOwnPtr<ScriptSourceCode>(); |
| 628 } | 628 } |
| 629 | 629 |
| 630 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source,
const String& url, const String& functionName) | 630 String ScriptDebugServer::preprocessEventListener(Frame*, const String& source,
const String& url, const String& functionName) |
| 631 { | 631 { |
| 632 return source; | 632 return source; |
| 633 } | 633 } |
| 634 | 634 |
| 635 } // namespace WebCore | 635 } // namespace WebCore |
| OLD | NEW |