OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Provides communication interface to remote v8 debugger. See | 6 * @fileoverview Provides communication interface to remote v8 debugger. See |
7 * protocol decription at http://code.google.com/p/v8/wiki/DebuggerProtocol | 7 * protocol decription at http://code.google.com/p/v8/wiki/DebuggerProtocol |
8 */ | 8 */ |
9 goog.provide('devtools.DebuggerAgent'); | 9 goog.provide('devtools.DebuggerAgent'); |
10 | 10 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 */ | 297 */ |
298 devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) { | 298 devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) { |
299 var msg; | 299 var msg; |
300 try { | 300 try { |
301 msg = new devtools.DebuggerMessage(output); | 301 msg = new devtools.DebuggerMessage(output); |
302 } catch(e) { | 302 } catch(e) { |
303 debugPrint('Failed to handle debugger reponse:\n' + e); | 303 debugPrint('Failed to handle debugger reponse:\n' + e); |
304 throw e; | 304 throw e; |
305 } | 305 } |
306 | 306 |
| 307 |
307 if (msg.getType() == 'event') { | 308 if (msg.getType() == 'event') { |
308 if (msg.getEvent() == 'break') { | 309 if (msg.getEvent() == 'break') { |
309 this.handleBreakEvent_(msg); | 310 this.handleBreakEvent_(msg); |
310 } else if (msg.getEvent() == 'exception') { | 311 } else if (msg.getEvent() == 'exception') { |
311 this.handleExceptionEvent_(msg); | 312 this.handleExceptionEvent_(msg); |
| 313 } else if (msg.getEvent() == 'afterCompile') { |
| 314 this.handleAfterCompileEvent_(msg); |
312 } | 315 } |
313 } else if (msg.getType() == 'response') { | 316 } else if (msg.getType() == 'response') { |
314 if (msg.getCommand() == 'scripts') { | 317 if (msg.getCommand() == 'scripts') { |
315 this.handleScriptsResponse_(msg); | 318 this.handleScriptsResponse_(msg); |
316 } else if (msg.getCommand() == 'setbreakpoint') { | 319 } else if (msg.getCommand() == 'setbreakpoint') { |
317 this.handleSetBreakpointResponse_(msg); | 320 this.handleSetBreakpointResponse_(msg); |
318 } else if (msg.getCommand() == 'clearbreakpoint') { | 321 } else if (msg.getCommand() == 'clearbreakpoint') { |
319 this.handleClearBreakpointResponse_(msg); | 322 this.handleClearBreakpointResponse_(msg); |
320 } else if (msg.getCommand() == 'backtrace') { | 323 } else if (msg.getCommand() == 'backtrace') { |
321 this.handleBacktraceResponse_(msg); | 324 this.handleBacktraceResponse_(msg); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 362 |
360 | 363 |
361 /** | 364 /** |
362 * @param {devtools.DebuggerMessage} msg | 365 * @param {devtools.DebuggerMessage} msg |
363 */ | 366 */ |
364 devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) { | 367 devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) { |
365 var scripts = msg.getBody(); | 368 var scripts = msg.getBody(); |
366 for (var i = 0; i < scripts.length; i++) { | 369 for (var i = 0; i < scripts.length; i++) { |
367 var script = scripts[i]; | 370 var script = scripts[i]; |
368 | 371 |
369 this.parsedScripts_[script.id] = new devtools.ScriptInfo( | 372 // We may already have received the info in an afterCompile event. |
370 script.id, script.lineOffset); | 373 if (script.id in this.parsedScripts_) { |
371 | 374 continue; |
372 WebInspector.parsedScriptSource( | 375 } |
373 script.id, script.name, script.source, script.lineOffset); | 376 this.addScriptInfo_(script); |
374 } | 377 } |
375 }; | 378 }; |
376 | 379 |
377 | 380 |
378 /** | 381 /** |
379 * @param {devtools.DebuggerMessage} msg | 382 * @param {devtools.DebuggerMessage} msg |
380 */ | 383 */ |
381 devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) { | 384 devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) { |
382 var requestSeq = msg.getRequestSeq(); | 385 var requestSeq = msg.getRequestSeq(); |
383 var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq]; | 386 var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq]; |
(...skipping 11 matching lines...) Expand all Loading... |
395 | 398 |
396 if (breakpointInfo.isRemoved()) { | 399 if (breakpointInfo.isRemoved()) { |
397 this.requestClearBreakpoint_(idInV8); | 400 this.requestClearBreakpoint_(idInV8); |
398 } | 401 } |
399 }; | 402 }; |
400 | 403 |
401 | 404 |
402 /** | 405 /** |
403 * @param {devtools.DebuggerMessage} msg | 406 * @param {devtools.DebuggerMessage} msg |
404 */ | 407 */ |
| 408 devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) { |
| 409 var script = msg.getBody().script; |
| 410 this.addScriptInfo_(script); |
| 411 }; |
| 412 |
| 413 |
| 414 /** |
| 415 * Adds the script info to the local cache. This method assumes that the script |
| 416 * is not in the cache yet. |
| 417 * @param {Object} script Script json object from the debugger message. |
| 418 */ |
| 419 devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) { |
| 420 this.parsedScripts_[script.id] = new devtools.ScriptInfo( |
| 421 script.id, script.lineOffset); |
| 422 WebInspector.parsedScriptSource( |
| 423 script.id, script.name, script.source, script.lineOffset); |
| 424 }; |
| 425 |
| 426 |
| 427 /** |
| 428 * @param {devtools.DebuggerMessage} msg |
| 429 */ |
405 devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function( | 430 devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function( |
406 msg) { | 431 msg) { |
407 // Do nothing. | 432 // Do nothing. |
408 }; | 433 }; |
409 | 434 |
410 | 435 |
411 /** | 436 /** |
412 * Handles response to 'backtrace' command. | 437 * Handles response to 'backtrace' command. |
413 * @param {devtools.DebuggerMessage} msg | 438 * @param {devtools.DebuggerMessage} msg |
414 */ | 439 */ |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 | 977 |
953 | 978 |
954 /** | 979 /** |
955 * @param {number} handle Object handle. | 980 * @param {number} handle Object handle. |
956 * @return {?Object} Returns the object with the handle if it was sent in this | 981 * @return {?Object} Returns the object with the handle if it was sent in this |
957 * message(some objects referenced by handles may be missing in the message). | 982 * message(some objects referenced by handles may be missing in the message). |
958 */ | 983 */ |
959 devtools.DebuggerMessage.prototype.lookup = function(handle) { | 984 devtools.DebuggerMessage.prototype.lookup = function(handle) { |
960 return this.refs_[handle]; | 985 return this.refs_[handle]; |
961 }; | 986 }; |
OLD | NEW |