| 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 * @param {number} limit |
| 278 * @return {!Array<!JavaScriptCallFrame>} |
| 278 */ | 279 */ |
| 279 DebuggerScript.frameCount = function(execState) | 280 DebuggerScript.currentCallFrames = function(execState, limit) |
| 280 { | 281 { |
| 281 return execState.frameCount(); | 282 var frames = []; |
| 283 for (var i = 0; i < execState.frameCount() && (!limit || i < limit); ++i) |
| 284 frames.push(DebuggerScript._frameMirrorToJSCallFrame(execState.frame(i))
); |
| 285 return frames; |
| 282 } | 286 } |
| 283 | 287 |
| 284 /** | 288 /** |
| 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 | 289 * @param {!ExecutionState} execState |
| 316 */ | 290 */ |
| 317 DebuggerScript.stepIntoStatement = function(execState) | 291 DebuggerScript.stepIntoStatement = function(execState) |
| 318 { | 292 { |
| 319 execState.prepareStep(Debug.StepAction.StepIn); | 293 execState.prepareStep(Debug.StepAction.StepIn); |
| 320 } | 294 } |
| 321 | 295 |
| 322 /** | 296 /** |
| 323 * @param {!ExecutionState} execState | 297 * @param {!ExecutionState} execState |
| 324 */ | 298 */ |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); | 394 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); |
| 421 } | 395 } |
| 422 return numbers; | 396 return numbers; |
| 423 } | 397 } |
| 424 | 398 |
| 425 // NOTE: This function is performance critical, as it can be run on every | 399 // NOTE: This function is performance critical, as it can be run on every |
| 426 // statement that generates an async event (like addEventListener) to support | 400 // statement that generates an async event (like addEventListener) to support |
| 427 // asynchronous call stacks. Thus, when possible, initialize the data lazily. | 401 // asynchronous call stacks. Thus, when possible, initialize the data lazily. |
| 428 /** | 402 /** |
| 429 * @param {!FrameMirror} frameMirror | 403 * @param {!FrameMirror} frameMirror |
| 430 * @param {!JavaScriptCallFrame|undefined} callerFrame | |
| 431 * @return {!JavaScriptCallFrame} | 404 * @return {!JavaScriptCallFrame} |
| 432 */ | 405 */ |
| 433 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) | 406 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) |
| 434 { | 407 { |
| 435 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). | 408 // 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. | 409 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. |
| 437 var frameDetails = frameMirror.details(); | 410 var frameDetails = frameMirror.details(); |
| 438 | 411 |
| 439 var funcObject = frameDetails.func(); | 412 var funcObject = frameDetails.func(); |
| 440 var sourcePosition = frameDetails.sourcePosition(); | 413 var sourcePosition = frameDetails.sourcePosition(); |
| 441 var thisObject = frameDetails.receiver(); | 414 var thisObject = frameDetails.receiver(); |
| 442 | 415 |
| 443 var isAtReturn = !!frameDetails.isAtReturn(); | 416 var isAtReturn = !!frameDetails.isAtReturn(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 throw new Error("Incorrect scope index"); | 630 throw new Error("Incorrect scope index"); |
| 658 scopeMirror.setVariableValue(variableName, newValue); | 631 scopeMirror.setVariableValue(variableName, newValue); |
| 659 } | 632 } |
| 660 | 633 |
| 661 return { | 634 return { |
| 662 "sourceID": sourceID, | 635 "sourceID": sourceID, |
| 663 "line": line, | 636 "line": line, |
| 664 "column": column, | 637 "column": column, |
| 665 "thisObject": thisObject, | 638 "thisObject": thisObject, |
| 666 "evaluate": evaluate, | 639 "evaluate": evaluate, |
| 667 "caller": callerFrame, | |
| 668 "restart": restart, | 640 "restart": restart, |
| 669 "setVariableValue": setVariableValue, | 641 "setVariableValue": setVariableValue, |
| 670 "isAtReturn": isAtReturn, | 642 "isAtReturn": isAtReturn, |
| 671 "details": lazyDetails | 643 "details": lazyDetails |
| 672 }; | 644 }; |
| 673 } | 645 } |
| 674 | 646 |
| 675 /** | 647 /** |
| 676 * @param {number} scopeType | 648 * @param {number} scopeType |
| 677 * @param {!Object} scopeObject | 649 * @param {!Object} scopeObject |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 break; | 681 break; |
| 710 } | 682 } |
| 711 return result; | 683 return result; |
| 712 } | 684 } |
| 713 | 685 |
| 714 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 686 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 715 ToggleMirrorCache(false); | 687 ToggleMirrorCache(false); |
| 716 | 688 |
| 717 return DebuggerScript; | 689 return DebuggerScript; |
| 718 })(); | 690 })(); |
| OLD | NEW |