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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 Debug.assembler = function(f) { | 430 Debug.assembler = function(f) { |
431 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); | 431 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); |
432 return %FunctionGetAssemblerCode(f); | 432 return %FunctionGetAssemblerCode(f); |
433 }; | 433 }; |
434 | 434 |
435 Debug.sourcePosition = function(f) { | 435 Debug.sourcePosition = function(f) { |
436 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); | 436 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); |
437 return %FunctionGetScriptSourcePosition(f); | 437 return %FunctionGetScriptSourcePosition(f); |
438 }; | 438 }; |
439 | 439 |
440 Debug.findFunctionSourcePosition = function(func, opt_line, opt_column) { | 440 |
| 441 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) { |
441 var script = %FunctionGetScript(func); | 442 var script = %FunctionGetScript(func); |
442 var script_offset = %FunctionGetScriptSourcePosition(func); | 443 var script_offset = %FunctionGetScriptSourcePosition(func); |
443 return script.locationFromLine(opt_line, opt_column, script_offset).position; | 444 return script.locationFromLine(opt_line, opt_column, script_offset); |
444 } | 445 } |
445 | 446 |
446 | 447 |
447 // Returns the character position in a script based on a line number and an | 448 // Returns the character position in a script based on a line number and an |
448 // optional position within that line. | 449 // optional position within that line. |
449 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { | 450 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { |
450 var location = script.locationFromLine(opt_line, opt_column); | 451 var location = script.locationFromLine(opt_line, opt_column); |
451 return location ? location.position : null; | 452 return location ? location.position : null; |
452 } | 453 } |
453 | 454 |
(...skipping 17 matching lines...) Expand all Loading... |
471 } | 472 } |
472 }; | 473 }; |
473 | 474 |
474 | 475 |
475 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { | 476 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { |
476 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); | 477 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); |
477 // Break points in API functions are not supported. | 478 // Break points in API functions are not supported. |
478 if (%FunctionIsAPIFunction(func)) { | 479 if (%FunctionIsAPIFunction(func)) { |
479 throw new Error('Cannot set break point in native code.'); | 480 throw new Error('Cannot set break point in native code.'); |
480 } | 481 } |
481 var source_position = this.findFunctionSourcePosition(func, opt_line, opt_colu
mn) - | 482 // Find source position relative to start of the function |
482 this.sourcePosition(func); | 483 var break_position = |
| 484 this.findFunctionSourceLocation(func, opt_line, opt_column).position; |
| 485 var source_position = break_position - this.sourcePosition(func); |
483 // Find the script for the function. | 486 // Find the script for the function. |
484 var script = %FunctionGetScript(func); | 487 var script = %FunctionGetScript(func); |
485 // Break in builtin JavaScript code is not supported. | 488 // Break in builtin JavaScript code is not supported. |
486 if (script.type == Debug.ScriptType.Native) { | 489 if (script.type == Debug.ScriptType.Native) { |
487 throw new Error('Cannot set break point in native code.'); | 490 throw new Error('Cannot set break point in native code.'); |
488 } | 491 } |
489 // If the script for the function has a name convert this to a script break | 492 // If the script for the function has a name convert this to a script break |
490 // point. | 493 // point. |
491 if (script && script.name) { | 494 if (script && script.name) { |
492 // Adjust the source position to be script relative. | 495 // Adjust the source position to be script relative. |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 json += NumberToJSON_(elem); | 1753 json += NumberToJSON_(elem); |
1751 } else if (IS_STRING(elem)) { | 1754 } else if (IS_STRING(elem)) { |
1752 json += StringToJSON_(elem); | 1755 json += StringToJSON_(elem); |
1753 } else { | 1756 } else { |
1754 json += elem; | 1757 json += elem; |
1755 } | 1758 } |
1756 } | 1759 } |
1757 json += ']'; | 1760 json += ']'; |
1758 return json; | 1761 return json; |
1759 } | 1762 } |
OLD | NEW |