Changeset 58402 in webkit
- Timestamp:
- Apr 28, 2010 4:39:03 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r58400 r58402 1 2010-04-28 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Support pause on exceptions in v8 implementation of ScriptDebugServer. 6 7 https://bugs.webkit.org/show_bug.cgi?id=38205 8 9 * bindings/v8/ScriptDebugServer.cpp: 10 (WebCore::ScriptDebugServer::addListener): 11 (WebCore::ScriptDebugServer::pauseOnExceptionsState): 12 (WebCore::ScriptDebugServer::setPauseOnExceptionsState): 13 (WebCore::ScriptDebugServer::currentCallFrame): 14 (WebCore::ScriptDebugServer::handleV8DebugMessage): 15 (WebCore::ScriptDebugServer::dispatchDidParseSource): 16 * bindings/v8/ScriptDebugServer.h: 17 1 18 2010-04-28 Sheriff Bot <webkit.review.bot@gmail.com> 2 19 -
trunk/WebCore/bindings/v8/ScriptDebugServer.cpp
r57812 r58402 82 82 V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame()); 83 83 v8::Local<v8::Context> context = proxy->mainWorldContext(); 84 String contextData = toWebCoreStringWithNullCheck(context->GetData());85 m_contextDataMap.set(listener, contextData);86 84 87 85 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts"))); 88 v8::Handle<v8::Value> value = v8::Debug::Call(getScriptsFunction); 86 v8::Handle<v8::Value> argv[] = { context->GetData() }; 87 v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv); 89 88 if (value.IsEmpty()) 90 89 return; … … 176 175 } 177 176 177 ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState() 178 { 179 #if ENABLE(V8_SCRIPT_DEBUG_SERVER) 180 ensureDebuggerScriptCompiled(); 181 v8::HandleScope scope; 182 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 183 184 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("pauseOnExceptionsState"))); 185 v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() }; 186 v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 0, argv); 187 return static_cast<ScriptDebugServer::PauseOnExceptionsState>(result->Int32Value()); 188 #else 189 return DontPauseOnExceptions; 190 #endif 191 } 192 193 void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) 194 { 195 #if ENABLE(V8_SCRIPT_DEBUG_SERVER) 196 ensureDebuggerScriptCompiled(); 197 v8::HandleScope scope; 198 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 199 200 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setPauseOnExceptionsState"))); 201 v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) }; 202 currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); 203 #endif 204 } 205 178 206 void ScriptDebugServer::continueProgram() 179 207 { … … 217 245 } 218 246 219 v8::Handle<v8::Value> ScriptDebugServer::currentCallFrameV8()220 {221 #if ENABLE(V8_SCRIPT_DEBUG_SERVER)222 if (!m_currentCallFrame.get().IsEmpty())223 return m_currentCallFrame.get();224 225 // Check on a bp.226 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));227 v8::Handle<v8::Value> argv[] = { m_executionState.get() };228 v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);229 m_currentCallFrame.set(result);230 return result;231 #else232 return v8::Handle<v8::Value>();233 #endif234 }235 236 247 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame() 237 248 { 238 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8())); 249 if (!m_currentCallFrame) { 250 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); 251 v8::Handle<v8::Value> argv[] = { m_executionState.get() }; 252 v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); 253 m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8)); 254 } 255 return m_currentCallFrame; 239 256 } 240 257 … … 269 286 270 287 // Ignore unsupported event types. 271 if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break )288 if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception) 272 289 return; 273 290 … … 287 304 return; 288 305 306 bool handled = false; 289 307 Frame* frame = V8Proxy::retrieveFrame(context); 290 308 if (frame) { … … 292 310 if (listener) { 293 311 if (message.GetEvent() == v8::AfterCompile) { 312 handled = true; 294 313 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 295 314 v8::Local<v8::Object> args = v8::Object::New(); … … 301 320 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); 302 321 dispatchDidParseSource(listener, object); 303 } else if (message.GetEvent() == v8::Break) { 322 } else if (message.GetEvent() == v8::Break || message.GetEvent() == v8::Exception) { 323 handled = true; 304 324 m_executionState.set(message.GetExecutionState()); 305 325 m_currentCallFrameState = mainWorldScriptState(frame); … … 309 329 } 310 330 } 331 332 if (!handled && !message.WillStartRunning()) 333 continueProgram(); 311 334 } 312 335 313 336 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object) 314 337 { 315 String contextData = toWebCoreStringWithNullCheck(object->Get(v8::String::New("contextData")));316 if (contextData != m_contextDataMap.get(listener))317 return;318 319 338 listener->didParseSource( 320 339 toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))), -
trunk/WebCore/bindings/v8/ScriptDebugServer.h
r57812 r58402 34 34 #if ENABLE(JAVASCRIPT_DEBUGGER) 35 35 36 #include " OwnHandle.h"36 #include "JavaScriptCallFrame.h" 37 37 #include "PlatformString.h" 38 38 #include "ScriptBreakpoint.h" … … 46 46 namespace WebCore { 47 47 48 class JavaScriptCallFrame;49 48 class Page; 50 49 class ScriptDebugListener; … … 76 75 PauseOnUncaughtExceptions 77 76 }; 78 PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; }79 void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) { m_pauseOnExceptionsState = pauseOnExceptionsState; }77 PauseOnExceptionsState pauseOnExceptionsState(); 78 void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState); 80 79 81 80 void pauseProgram() { } … … 98 97 static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler messageLoopDispatchHandler) { s_messageLoopDispatchHandler = messageLoopDispatchHandler; } 99 98 100 v8::Handle<v8::Value> currentCallFrameV8();101 99 PassRefPtr<JavaScriptCallFrame> currentCallFrame(); 102 100 … … 131 129 typedef HashMap<Page*, ScriptDebugListener*> ListenersMap; 132 130 ListenersMap m_listenersMap; 133 typedef HashMap<ScriptDebugListener*, String> ContextDataMap;134 ContextDataMap m_contextDataMap;135 131 String m_debuggerScriptSource; 136 132 PauseOnExceptionsState m_pauseOnExceptionsState; 137 133 OwnHandle<v8::Object> m_debuggerScript; 138 134 ScriptState* m_currentCallFrameState; 139 OwnHandle<v8::Value> m_currentCallFrame;135 RefPtr<JavaScriptCallFrame> m_currentCallFrame; 140 136 OwnHandle<v8::Object> m_executionState; 141 137 -
trunk/WebKit/chromium/ChangeLog
r58382 r58402 1 2010-04-28 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Support pause on exceptions in v8 implementation of ScriptDebugServer. 6 7 https://bugs.webkit.org/show_bug.cgi?id=38205 8 9 * src/js/DebuggerScript.js: 10 (debuggerScriptConstructor.DebuggerScript.getScripts): 11 (debuggerScriptConstructor.DebuggerScript.pauseOnExceptionsState): 12 (debuggerScriptConstructor.DebuggerScript.setPauseOnExceptionsState): 13 (debuggerScriptConstructor.DebuggerScript._v8ToWebkitLineNumber): 14 (debuggerScriptConstructor): 15 1 16 2010-04-27 Jens Alfke <snej@chromium.org> 2 17 -
trunk/WebKit/chromium/src/js/DebuggerScript.js
r57812 r58402 34 34 DebuggerScript._breakpoints = {}; 35 35 36 DebuggerScript.PauseOnExceptionsState = { 37 DontPauseOnExceptions : 0, 38 PauseOnAllExceptions : 1, 39 PauseOnUncaughtExceptions: 2 40 }; 41 42 DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions; 43 Debug.clearBreakOnException(); 44 Debug.clearBreakOnUncaughtException(); 36 45 37 46 DebuggerScript.getAfterCompileScript = function(execState, args) … … 40 49 } 41 50 42 DebuggerScript.getScripts = function( execState, args)51 DebuggerScript.getScripts = function(contextData) 43 52 { 44 53 var scripts = Debug.scripts(); 45 54 var result = []; 46 55 for (var i = 0; i < scripts.length; ++i) { 47 result.push(DebuggerScript._formatScript(scripts[i])); 56 var script = scripts[i]; 57 if (contextData === script.context_data) 58 result.push(DebuggerScript._formatScript(script)); 48 59 } 49 60 return result; … … 93 104 } 94 105 106 DebuggerScript.pauseOnExceptionsState = function() 107 { 108 return DebuggerScript._pauseOnExceptionsState; 109 } 110 111 DebuggerScript.setPauseOnExceptionsState = function(newState) 112 { 113 DebuggerScript._pauseOnExceptionsState = newState; 114 115 if (DebuggerScript.PauseOnExceptionsState.PauseOnAllExceptions === newState) 116 Debug.setBreakOnException(); 117 else 118 Debug.clearBreakOnException(); 119 120 if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newState) 121 Debug.setBreakOnUncaughtException(); 122 else 123 Debug.clearBreakOnUncaughtException(); 124 } 125 95 126 DebuggerScript.currentCallFrame = function(execState, args) 96 127 { … … 161 192 162 193 // Get line number. 163 var line = DebuggerScript._v8ToW webkitLineNumber(frameMirror.sourceLine());194 var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine()); 164 195 165 196 // Get this object. … … 202 233 }; 203 234 204 DebuggerScript._v8ToW webkitLineNumber = function(line)235 DebuggerScript._v8ToWebkitLineNumber = function(line) 205 236 { 206 237 return line + 1;
Note: See TracChangeset
for help on using the changeset viewer.