| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 Debug.setBreakOnUncaughtException(); | 105 Debug.setBreakOnUncaughtException(); |
| 106 } else { | 106 } else { |
| 107 Debug.clearBreakOnUncaughtException(); | 107 Debug.clearBreakOnUncaughtException(); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 }, | 110 }, |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 | 113 |
| 114 // Create a new break point object and add it to the list of break points. | 114 // Create a new break point object and add it to the list of break points. |
| 115 function MakeBreakPoint(source_position, opt_line, opt_column, opt_script_break_
point) { | 115 function MakeBreakPoint(source_position, opt_script_break_point) { |
| 116 var break_point = new BreakPoint(source_position, opt_line, opt_column, opt_sc
ript_break_point); | 116 var break_point = new BreakPoint(source_position, opt_script_break_point); |
| 117 break_points.push(break_point); | 117 break_points.push(break_point); |
| 118 return break_point; | 118 return break_point; |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 // Object representing a break point. | 122 // Object representing a break point. |
| 123 // NOTE: This object does not have a reference to the function having break | 123 // NOTE: This object does not have a reference to the function having break |
| 124 // point as this would cause function not to be garbage collected when it is | 124 // point as this would cause function not to be garbage collected when it is |
| 125 // not used any more. We do not want break points to keep functions alive. | 125 // not used any more. We do not want break points to keep functions alive. |
| 126 function BreakPoint(source_position, opt_line, opt_column, opt_script_break_poin
t) { | 126 function BreakPoint(source_position, opt_script_break_point) { |
| 127 this.source_position_ = source_position; | 127 this.source_position_ = source_position; |
| 128 this.source_line_ = opt_line; | |
| 129 this.source_column_ = opt_column; | |
| 130 if (opt_script_break_point) { | 128 if (opt_script_break_point) { |
| 131 this.script_break_point_ = opt_script_break_point; | 129 this.script_break_point_ = opt_script_break_point; |
| 132 } else { | 130 } else { |
| 133 this.number_ = next_break_point_number++; | 131 this.number_ = next_break_point_number++; |
| 134 } | 132 } |
| 135 this.hit_count_ = 0; | 133 this.hit_count_ = 0; |
| 136 this.active_ = true; | 134 this.active_ = true; |
| 137 this.condition_ = null; | 135 this.condition_ = null; |
| 138 this.ignoreCount_ = 0; | 136 this.ignoreCount_ = 0; |
| 139 } | 137 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 415 } |
| 418 | 416 |
| 419 // Convert the line and column into an absolute position within the script. | 417 // Convert the line and column into an absolute position within the script. |
| 420 var position = Debug.findScriptSourcePosition(script, this.line(), column); | 418 var position = Debug.findScriptSourcePosition(script, this.line(), column); |
| 421 | 419 |
| 422 // If the position is not found in the script (the script might be shorter | 420 // If the position is not found in the script (the script might be shorter |
| 423 // than it used to be) just ignore it. | 421 // than it used to be) just ignore it. |
| 424 if (position === null) return; | 422 if (position === null) return; |
| 425 | 423 |
| 426 // Create a break point object and set the break point. | 424 // Create a break point object and set the break point. |
| 427 break_point = MakeBreakPoint(position, this.line(), this.column(), this); | 425 break_point = MakeBreakPoint(position, this); |
| 428 break_point.setIgnoreCount(this.ignoreCount()); | 426 break_point.setIgnoreCount(this.ignoreCount()); |
| 429 var actual_position = %SetScriptBreakPoint(script, position, break_point); | 427 var actual_position = %SetScriptBreakPoint(script, position, break_point); |
| 430 if (IS_UNDEFINED(actual_position)) { | 428 if (IS_UNDEFINED(actual_position)) { |
| 431 actual_position = position; | 429 actual_position = position; |
| 432 } | 430 } |
| 433 var actual_location = script.locationFromPosition(actual_position, true); | 431 var actual_location = script.locationFromPosition(actual_position, true); |
| 434 break_point.actual_location = { line: actual_location.line, | 432 break_point.actual_location = { line: actual_location.line, |
| 435 column: actual_location.column }; | 433 column: actual_location.column }; |
| 436 this.break_points_.push(break_point); | 434 this.break_points_.push(break_point); |
| 437 return break_point; | 435 return break_point; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // Adjust the source position to be script relative. | 630 // Adjust the source position to be script relative. |
| 633 source_position += %FunctionGetScriptSourcePosition(func); | 631 source_position += %FunctionGetScriptSourcePosition(func); |
| 634 // Find line and column for the position in the script and set a script | 632 // Find line and column for the position in the script and set a script |
| 635 // break point from that. | 633 // break point from that. |
| 636 var location = script.locationFromPosition(source_position, false); | 634 var location = script.locationFromPosition(source_position, false); |
| 637 return this.setScriptBreakPointById(script.id, | 635 return this.setScriptBreakPointById(script.id, |
| 638 location.line, location.column, | 636 location.line, location.column, |
| 639 opt_condition); | 637 opt_condition); |
| 640 } else { | 638 } else { |
| 641 // Set a break point directly on the function. | 639 // Set a break point directly on the function. |
| 642 var break_point = MakeBreakPoint(source_position, opt_line, opt_column); | 640 var break_point = MakeBreakPoint(source_position); |
| 643 var actual_position = | 641 var actual_position = |
| 644 %SetFunctionBreakPoint(func, source_position, break_point); | 642 %SetFunctionBreakPoint(func, source_position, break_point); |
| 645 actual_position += this.sourcePosition(func); | 643 actual_position += this.sourcePosition(func); |
| 646 var actual_location = script.locationFromPosition(actual_position, true); | 644 var actual_location = script.locationFromPosition(actual_position, true); |
| 647 break_point.actual_location = { line: actual_location.line, | 645 break_point.actual_location = { line: actual_location.line, |
| 648 column: actual_location.column }; | 646 column: actual_location.column }; |
| 649 break_point.setCondition(opt_condition); | 647 break_point.setCondition(opt_condition); |
| 650 return break_point.number(); | 648 return break_point.number(); |
| 651 } | 649 } |
| 652 }; | 650 }; |
| 653 | 651 |
| 654 | 652 |
| 653 Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, |
| 654 condition, enabled) |
| 655 { |
| 656 break_point = MakeBreakPoint(position); |
| 657 break_point.setCondition(condition); |
| 658 if (!enabled) |
| 659 break_point.disable(); |
| 660 var scripts = this.scripts(); |
| 661 for (var i = 0; i < scripts.length; i++) { |
| 662 if (script_id == scripts[i].id) { |
| 663 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position, |
| 664 break_point); |
| 665 break; |
| 666 } |
| 667 } |
| 668 return break_point; |
| 669 }; |
| 670 |
| 671 |
| 655 Debug.enableBreakPoint = function(break_point_number) { | 672 Debug.enableBreakPoint = function(break_point_number) { |
| 656 var break_point = this.findBreakPoint(break_point_number, false); | 673 var break_point = this.findBreakPoint(break_point_number, false); |
| 657 // Only enable if the breakpoint hasn't been deleted: | 674 // Only enable if the breakpoint hasn't been deleted: |
| 658 if (break_point) { | 675 if (break_point) { |
| 659 break_point.enable(); | 676 break_point.enable(); |
| 660 } | 677 } |
| 661 }; | 678 }; |
| 662 | 679 |
| 663 | 680 |
| 664 Debug.disableBreakPoint = function(break_point_number) { | 681 Debug.disableBreakPoint = function(break_point_number) { |
| (...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 case 'string': | 2439 case 'string': |
| 2423 case 'number': | 2440 case 'number': |
| 2424 json = value; | 2441 json = value; |
| 2425 break | 2442 break |
| 2426 | 2443 |
| 2427 default: | 2444 default: |
| 2428 json = null; | 2445 json = null; |
| 2429 } | 2446 } |
| 2430 return json; | 2447 return json; |
| 2431 } | 2448 } |
| OLD | NEW |