| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 Debug.clearBreakOnException(); | 267 Debug.clearBreakOnException(); |
| 268 | 268 |
| 269 if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newS
tate) | 269 if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newS
tate) |
| 270 Debug.setBreakOnUncaughtException(); | 270 Debug.setBreakOnUncaughtException(); |
| 271 else | 271 else |
| 272 Debug.clearBreakOnUncaughtException(); | 272 Debug.clearBreakOnUncaughtException(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * @param {!ExecutionState} execState | 276 * @param {!ExecutionState} execState |
| 277 * @return {number} | 277 * @return {!Array<!JavaScriptCallFrame>} |
| 278 */ | 278 */ |
| 279 DebuggerScript.frameCount = function(execState) | 279 DebuggerScript.currentCallFrames = function(execState) |
| 280 { | 280 { |
| 281 return execState.frameCount(); | 281 var frames = []; |
| 282 for (var i = 0; i < execState.frameCount(); ++i) |
| 283 frames.push(DebuggerScript._frameMirrorToJSCallFrame(execState.frame(i))
); |
| 284 return frames; |
| 282 } | 285 } |
| 283 | 286 |
| 284 /** | 287 /** |
| 285 * @param {!ExecutionState} execState | |
| 286 * @return {!JavaScriptCallFrame|undefined} | |
| 287 */ | |
| 288 DebuggerScript.currentCallFrame = function(execState) | |
| 289 { | |
| 290 var frameCount = execState.frameCount(); | |
| 291 var topFrame = undefined; | |
| 292 for (var i = frameCount - 1; i >= 0; i--) { | |
| 293 var frameMirror = execState.frame(i); | |
| 294 topFrame = DebuggerScript._frameMirrorToJSCallFrame(frameMirror, topFram
e); | |
| 295 } | |
| 296 return topFrame; | |
| 297 } | |
| 298 | |
| 299 /** | |
| 300 * @param {!ExecutionState} execState | |
| 301 * @param {number} index | |
| 302 * @return {!JavaScriptCallFrame|undefined} | |
| 303 */ | |
| 304 DebuggerScript.currentCallFrameByIndex = function(execState, index) | |
| 305 { | |
| 306 if (index < 0) | |
| 307 return undefined; | |
| 308 var frameCount = execState.frameCount(); | |
| 309 if (index >= frameCount) | |
| 310 return undefined; | |
| 311 return DebuggerScript._frameMirrorToJSCallFrame(execState.frame(index), unde
fined); | |
| 312 } | |
| 313 | |
| 314 /** | |
| 315 * @param {!ExecutionState} execState | 288 * @param {!ExecutionState} execState |
| 316 */ | 289 */ |
| 317 DebuggerScript.stepIntoStatement = function(execState) | 290 DebuggerScript.stepIntoStatement = function(execState) |
| 318 { | 291 { |
| 319 execState.prepareStep(Debug.StepAction.StepIn); | 292 execState.prepareStep(Debug.StepAction.StepIn); |
| 320 } | 293 } |
| 321 | 294 |
| 322 /** | 295 /** |
| 323 * @param {!ExecutionState} execState | 296 * @param {!ExecutionState} execState |
| 324 */ | 297 */ |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); | 393 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); |
| 421 } | 394 } |
| 422 return numbers; | 395 return numbers; |
| 423 } | 396 } |
| 424 | 397 |
| 425 // NOTE: This function is performance critical, as it can be run on every | 398 // NOTE: This function is performance critical, as it can be run on every |
| 426 // statement that generates an async event (like addEventListener) to support | 399 // statement that generates an async event (like addEventListener) to support |
| 427 // asynchronous call stacks. Thus, when possible, initialize the data lazily. | 400 // asynchronous call stacks. Thus, when possible, initialize the data lazily. |
| 428 /** | 401 /** |
| 429 * @param {!FrameMirror} frameMirror | 402 * @param {!FrameMirror} frameMirror |
| 430 * @param {!JavaScriptCallFrame|undefined} callerFrame | |
| 431 * @return {!JavaScriptCallFrame} | 403 * @return {!JavaScriptCallFrame} |
| 432 */ | 404 */ |
| 433 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) | 405 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) |
| 434 { | 406 { |
| 435 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). | 407 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). |
| 436 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. | 408 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. |
| 437 var frameDetails = frameMirror.details(); | 409 var frameDetails = frameMirror.details(); |
| 438 | 410 |
| 439 var funcObject = frameDetails.func(); | 411 var funcObject = frameDetails.func(); |
| 440 var sourcePosition = frameDetails.sourcePosition(); | 412 var sourcePosition = frameDetails.sourcePosition(); |
| 441 var thisObject = frameDetails.receiver(); | 413 var thisObject = frameDetails.receiver(); |
| 442 | 414 |
| 443 var isAtReturn = !!frameDetails.isAtReturn(); | 415 var isAtReturn = !!frameDetails.isAtReturn(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 scopeMirror.setVariableValue(variableName, newValue); | 639 scopeMirror.setVariableValue(variableName, newValue); |
| 668 } | 640 } |
| 669 | 641 |
| 670 return { | 642 return { |
| 671 "sourceID": sourceID, | 643 "sourceID": sourceID, |
| 672 "line": line, | 644 "line": line, |
| 673 "column": column, | 645 "column": column, |
| 674 "contextId": contextId, | 646 "contextId": contextId, |
| 675 "thisObject": thisObject, | 647 "thisObject": thisObject, |
| 676 "evaluate": evaluate, | 648 "evaluate": evaluate, |
| 677 "caller": callerFrame, | |
| 678 "restart": restart, | 649 "restart": restart, |
| 679 "setVariableValue": setVariableValue, | 650 "setVariableValue": setVariableValue, |
| 680 "isAtReturn": isAtReturn, | 651 "isAtReturn": isAtReturn, |
| 681 "details": lazyDetails | 652 "details": lazyDetails |
| 682 }; | 653 }; |
| 683 } | 654 } |
| 684 | 655 |
| 685 /** | 656 /** |
| 686 * @param {number} scopeType | 657 * @param {number} scopeType |
| 687 * @param {!Object} scopeObject | 658 * @param {!Object} scopeObject |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 break; | 690 break; |
| 720 } | 691 } |
| 721 return result; | 692 return result; |
| 722 } | 693 } |
| 723 | 694 |
| 724 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 695 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 725 ToggleMirrorCache(false); | 696 ToggleMirrorCache(false); |
| 726 | 697 |
| 727 return DebuggerScript; | 698 return DebuggerScript; |
| 728 })(); | 699 })(); |
| OLD | NEW |