| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 if (break_point) { | 467 if (break_point) { |
| 468 return break_point; | 468 return break_point; |
| 469 } else { | 469 } else { |
| 470 return this.findScriptBreakPoint(break_point_number, remove); | 470 return this.findScriptBreakPoint(break_point_number, remove); |
| 471 } | 471 } |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 | 474 |
| 475 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { | 475 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { |
| 476 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); | 476 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); |
| 477 // Break points in API functions are not supported. |
| 478 if (%FunctionIsAPIFunction(func)) { |
| 479 throw new Error('Cannot set break point in native code.'); |
| 480 } |
| 477 var source_position = this.findFunctionSourcePosition(func, opt_line, opt_colu
mn) - | 481 var source_position = this.findFunctionSourcePosition(func, opt_line, opt_colu
mn) - |
| 478 this.sourcePosition(func); | 482 this.sourcePosition(func); |
| 479 // Find the script for the function. | 483 // Find the script for the function. |
| 480 var script = %FunctionGetScript(func); | 484 var script = %FunctionGetScript(func); |
| 485 // Break in builtin JavaScript code is not supported. |
| 486 if (script.type == Debug.ScriptType.Native) { |
| 487 throw new Error('Cannot set break point in native code.'); |
| 488 } |
| 481 // If the script for the function has a name convert this to a script break | 489 // If the script for the function has a name convert this to a script break |
| 482 // point. | 490 // point. |
| 483 if (script && script.name) { | 491 if (script && script.name) { |
| 484 // Adjust the source position to be script relative. | 492 // Adjust the source position to be script relative. |
| 485 source_position += %FunctionGetScriptSourcePosition(func); | 493 source_position += %FunctionGetScriptSourcePosition(func); |
| 486 // Find line and column for the position in the script and set a script | 494 // Find line and column for the position in the script and set a script |
| 487 // break point from that. | 495 // break point from that. |
| 488 var location = script.locationFromPosition(source_position); | 496 var location = script.locationFromPosition(source_position); |
| 489 return this.setScriptBreakPoint(script.name, | 497 return this.setScriptBreakPoint(script.name, |
| 490 location.line, location.column, | 498 location.line, location.column, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 ExceptionEvent.prototype.executionState = function() { | 833 ExceptionEvent.prototype.executionState = function() { |
| 826 return this.exec_state_; | 834 return this.exec_state_; |
| 827 }; | 835 }; |
| 828 | 836 |
| 829 | 837 |
| 830 ExceptionEvent.prototype.eventType = function() { | 838 ExceptionEvent.prototype.eventType = function() { |
| 831 return Debug.DebugEvent.Exception; | 839 return Debug.DebugEvent.Exception; |
| 832 }; | 840 }; |
| 833 | 841 |
| 834 | 842 |
| 843 ExceptionEvent.prototype.exception = function() { |
| 844 return this.exception_; |
| 845 } |
| 846 |
| 847 |
| 835 ExceptionEvent.prototype.uncaught = function() { | 848 ExceptionEvent.prototype.uncaught = function() { |
| 836 return this.uncaught_; | 849 return this.uncaught_; |
| 837 } | 850 } |
| 838 | 851 |
| 852 |
| 839 ExceptionEvent.prototype.func = function() { | 853 ExceptionEvent.prototype.func = function() { |
| 840 return this.exec_state_.frame(0).func(); | 854 return this.exec_state_.frame(0).func(); |
| 841 }; | 855 }; |
| 842 | 856 |
| 843 | 857 |
| 844 ExceptionEvent.prototype.sourceLine = function() { | 858 ExceptionEvent.prototype.sourceLine = function() { |
| 845 return this.exec_state_.frame(0).sourceLine(); | 859 return this.exec_state_.frame(0).sourceLine(); |
| 846 }; | 860 }; |
| 847 | 861 |
| 848 | 862 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 | 1329 |
| 1316 // Clear break point. | 1330 // Clear break point. |
| 1317 Debug.clearBreakPoint(break_point); | 1331 Debug.clearBreakPoint(break_point); |
| 1318 } | 1332 } |
| 1319 | 1333 |
| 1320 | 1334 |
| 1321 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
{ | 1335 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
{ |
| 1322 // Get the number of frames. | 1336 // Get the number of frames. |
| 1323 var total_frames = this.exec_state_.frameCount(); | 1337 var total_frames = this.exec_state_.frameCount(); |
| 1324 | 1338 |
| 1339 // Create simple response if there are no frames. |
| 1340 if (total_frames == 0) { |
| 1341 response.body = { |
| 1342 totalFrames: total_frames |
| 1343 } |
| 1344 return; |
| 1345 } |
| 1346 |
| 1325 // Default frame range to include in backtrace. | 1347 // Default frame range to include in backtrace. |
| 1326 var from_index = 0 | 1348 var from_index = 0 |
| 1327 var to_index = kDefaultBacktraceLength; | 1349 var to_index = kDefaultBacktraceLength; |
| 1328 | 1350 |
| 1329 // Get the range from the arguments. | 1351 // Get the range from the arguments. |
| 1330 if (request.arguments) { | 1352 if (request.arguments) { |
| 1331 from_index = request.arguments.fromFrame; | 1353 from_index = request.arguments.fromFrame; |
| 1332 if (from_index < 0) { | 1354 if (from_index < 0) { |
| 1333 return response.failed('Invalid frame number'); | 1355 return response.failed('Invalid frame number'); |
| 1334 } | 1356 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 json += NumberToJSON_(elem); | 1662 json += NumberToJSON_(elem); |
| 1641 } else if (IS_STRING(elem)) { | 1663 } else if (IS_STRING(elem)) { |
| 1642 json += StringToJSON_(elem); | 1664 json += StringToJSON_(elem); |
| 1643 } else { | 1665 } else { |
| 1644 json += elem; | 1666 json += elem; |
| 1645 } | 1667 } |
| 1646 } | 1668 } |
| 1647 json += ']'; | 1669 json += ']'; |
| 1648 return json; | 1670 return json; |
| 1649 } | 1671 } |
| OLD | NEW |