Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 Normal: 2 }; | 61 Normal: 2 }; |
| 62 | 62 |
| 63 // The different types of script compilations matching enum | 63 // The different types of script compilations matching enum |
| 64 // Script::CompilationType in objects.h. | 64 // Script::CompilationType in objects.h. |
| 65 Debug.ScriptCompilationType = { Host: 0, | 65 Debug.ScriptCompilationType = { Host: 0, |
| 66 Eval: 1, | 66 Eval: 1, |
| 67 JSON: 2 }; | 67 JSON: 2 }; |
| 68 | 68 |
| 69 // The different script break point types. | 69 // The different script break point types. |
| 70 Debug.ScriptBreakPointType = { ScriptId: 0, | 70 Debug.ScriptBreakPointType = { ScriptId: 0, |
| 71 ScriptName: 1 }; | 71 ScriptName: 1, |
| 72 ScriptRegexp: 2 }; | |
|
Søren Thygesen Gjesse
2011/06/06 09:03:43
I guess that we do need an additional type here ev
Peter Rybin
2011/06/16 11:02:20
(I take it as "we do NOT need")
Actually on the c
| |
| 72 | 73 |
| 73 function ScriptTypeFlag(type) { | 74 function ScriptTypeFlag(type) { |
| 74 return (1 << type); | 75 return (1 << type); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Globals. | 78 // Globals. |
| 78 var next_response_seq = 0; | 79 var next_response_seq = 0; |
| 79 var next_break_point_number = 1; | 80 var next_break_point_number = 1; |
| 80 var break_points = []; | 81 var break_points = []; |
| 81 var script_break_points = []; | 82 var script_break_points = []; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 249 |
| 249 | 250 |
| 250 // Object representing a script break point. The script is referenced by its | 251 // Object representing a script break point. The script is referenced by its |
| 251 // script name or script id and the break point is represented as line and | 252 // script name or script id and the break point is represented as line and |
| 252 // column. | 253 // column. |
| 253 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, | 254 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, |
| 254 opt_groupId) { | 255 opt_groupId) { |
| 255 this.type_ = type; | 256 this.type_ = type; |
| 256 if (type == Debug.ScriptBreakPointType.ScriptId) { | 257 if (type == Debug.ScriptBreakPointType.ScriptId) { |
| 257 this.script_id_ = script_id_or_name; | 258 this.script_id_ = script_id_or_name; |
| 259 } else if (type == Debug.ScriptBreakPointType.ScriptRegexp) { | |
| 260 this.script_regexp_ = new RegExp(script_id_or_name); | |
| 258 } else { // type == Debug.ScriptBreakPointType.ScriptName | 261 } else { // type == Debug.ScriptBreakPointType.ScriptName |
| 259 this.script_name_ = script_id_or_name; | 262 this.script_name_ = script_id_or_name; |
| 260 } | 263 } |
| 261 this.line_ = opt_line || 0; | 264 this.line_ = opt_line || 0; |
| 262 this.column_ = opt_column; | 265 this.column_ = opt_column; |
| 263 this.groupId_ = opt_groupId; | 266 this.groupId_ = opt_groupId; |
| 264 this.hit_count_ = 0; | 267 this.hit_count_ = 0; |
| 265 this.active_ = true; | 268 this.active_ = true; |
| 266 this.condition_ = null; | 269 this.condition_ = null; |
| 267 this.ignoreCount_ = 0; | 270 this.ignoreCount_ = 0; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 ScriptBreakPoint.prototype.script_id = function() { | 305 ScriptBreakPoint.prototype.script_id = function() { |
| 303 return this.script_id_; | 306 return this.script_id_; |
| 304 }; | 307 }; |
| 305 | 308 |
| 306 | 309 |
| 307 ScriptBreakPoint.prototype.script_name = function() { | 310 ScriptBreakPoint.prototype.script_name = function() { |
| 308 return this.script_name_; | 311 return this.script_name_; |
| 309 }; | 312 }; |
| 310 | 313 |
| 311 | 314 |
| 315 ScriptBreakPoint.prototype.script_regexp = function() { | |
| 316 return this.script_regexp_; | |
| 317 }; | |
| 318 | |
| 319 | |
| 312 ScriptBreakPoint.prototype.line = function() { | 320 ScriptBreakPoint.prototype.line = function() { |
| 313 return this.line_; | 321 return this.line_; |
| 314 }; | 322 }; |
| 315 | 323 |
| 316 | 324 |
| 317 ScriptBreakPoint.prototype.column = function() { | 325 ScriptBreakPoint.prototype.column = function() { |
| 318 return this.column_; | 326 return this.column_; |
| 319 }; | 327 }; |
| 320 | 328 |
| 321 | 329 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 this.break_points_[i].setIgnoreCount(ignoreCount); | 385 this.break_points_[i].setIgnoreCount(ignoreCount); |
| 378 } | 386 } |
| 379 }; | 387 }; |
| 380 | 388 |
| 381 | 389 |
| 382 // Check whether a script matches this script break point. Currently this is | 390 // Check whether a script matches this script break point. Currently this is |
| 383 // only based on script name. | 391 // only based on script name. |
| 384 ScriptBreakPoint.prototype.matchesScript = function(script) { | 392 ScriptBreakPoint.prototype.matchesScript = function(script) { |
| 385 if (this.type_ == Debug.ScriptBreakPointType.ScriptId) { | 393 if (this.type_ == Debug.ScriptBreakPointType.ScriptId) { |
| 386 return this.script_id_ == script.id; | 394 return this.script_id_ == script.id; |
| 387 } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName | 395 } else { |
| 388 return this.script_name_ == script.nameOrSourceURL() && | 396 if (!(script.line_offset <= this.line_ && |
| 389 script.line_offset <= this.line_ && | 397 this.line_ < script.line_offset + script.lineCount())) { |
| 390 this.line_ < script.line_offset + script.lineCount(); | 398 return false; |
| 399 } | |
| 400 if (this.type_ == Debug.ScriptBreakPointType.ScriptRegexp) { | |
| 401 return this.script_regexp_.test(script.nameOrSourceURL()); | |
| 402 } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName | |
| 403 return this.script_name_ == script.nameOrSourceURL(); | |
| 404 } | |
| 391 } | 405 } |
| 392 }; | 406 }; |
| 393 | 407 |
| 394 | 408 |
| 395 // Set the script break point in a script. | 409 // Set the script break point in a script. |
| 396 ScriptBreakPoint.prototype.set = function (script) { | 410 ScriptBreakPoint.prototype.set = function (script) { |
| 397 var column = this.column(); | 411 var column = this.column(); |
| 398 var line = this.line(); | 412 var line = this.line(); |
| 399 // If the column is undefined the break is on the line. To help locate the | 413 // If the column is undefined the break is on the line. To help locate the |
| 400 // first piece of breakable code on the line try to find the column on the | 414 // first piece of breakable code on the line try to find the column on the |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 | 806 |
| 793 Debug.setScriptBreakPointByName = function(script_name, | 807 Debug.setScriptBreakPointByName = function(script_name, |
| 794 opt_line, opt_column, | 808 opt_line, opt_column, |
| 795 opt_condition, opt_groupId) { | 809 opt_condition, opt_groupId) { |
| 796 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, | 810 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, |
| 797 script_name, opt_line, opt_column, | 811 script_name, opt_line, opt_column, |
| 798 opt_condition, opt_groupId); | 812 opt_condition, opt_groupId); |
| 799 } | 813 } |
| 800 | 814 |
| 801 | 815 |
| 816 Debug.setScriptBreakPointByRegexp = function(script_regexp, | |
| 817 opt_line, opt_column, | |
| 818 opt_condition, opt_groupId) { | |
| 819 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegexp, | |
| 820 script_regexp, opt_line, opt_column, | |
| 821 opt_condition, opt_groupId); | |
| 822 } | |
| 823 | |
| 824 | |
| 802 Debug.enableScriptBreakPoint = function(break_point_number) { | 825 Debug.enableScriptBreakPoint = function(break_point_number) { |
| 803 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 826 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 804 script_break_point.enable(); | 827 script_break_point.enable(); |
| 805 }; | 828 }; |
| 806 | 829 |
| 807 | 830 |
| 808 Debug.disableScriptBreakPoint = function(break_point_number) { | 831 Debug.disableScriptBreakPoint = function(break_point_number) { |
| 809 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 832 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 810 script_break_point.disable(); | 833 script_break_point.disable(); |
| 811 }; | 834 }; |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1543 var condition = request.arguments.condition; | 1566 var condition = request.arguments.condition; |
| 1544 var ignoreCount = request.arguments.ignoreCount; | 1567 var ignoreCount = request.arguments.ignoreCount; |
| 1545 var groupId = request.arguments.groupId; | 1568 var groupId = request.arguments.groupId; |
| 1546 | 1569 |
| 1547 // Check for legal arguments. | 1570 // Check for legal arguments. |
| 1548 if (!type || IS_UNDEFINED(target)) { | 1571 if (!type || IS_UNDEFINED(target)) { |
| 1549 response.failed('Missing argument "type" or "target"'); | 1572 response.failed('Missing argument "type" or "target"'); |
| 1550 return; | 1573 return; |
| 1551 } | 1574 } |
| 1552 if (type != 'function' && type != 'handle' && | 1575 if (type != 'function' && type != 'handle' && |
| 1553 type != 'script' && type != 'scriptId') { | 1576 type != 'script' && type != 'scriptId' && type != 'scriptRegexp') { |
| 1554 response.failed('Illegal type "' + type + '"'); | 1577 response.failed('Illegal type "' + type + '"'); |
| 1555 return; | 1578 return; |
| 1556 } | 1579 } |
| 1557 | 1580 |
| 1558 // Either function or script break point. | 1581 // Either function or script break point. |
| 1559 var break_point_number; | 1582 var break_point_number; |
| 1560 if (type == 'function') { | 1583 if (type == 'function') { |
| 1561 // Handle function break point. | 1584 // Handle function break point. |
| 1562 if (!IS_STRING(target)) { | 1585 if (!IS_STRING(target)) { |
| 1563 response.failed('Argument "target" is not a string value'); | 1586 response.failed('Argument "target" is not a string value'); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1591 } | 1614 } |
| 1592 | 1615 |
| 1593 // Set function break point. | 1616 // Set function break point. |
| 1594 break_point_number = Debug.setBreakPoint(mirror.value(), | 1617 break_point_number = Debug.setBreakPoint(mirror.value(), |
| 1595 line, column, condition); | 1618 line, column, condition); |
| 1596 } else if (type == 'script') { | 1619 } else if (type == 'script') { |
| 1597 // set script break point. | 1620 // set script break point. |
| 1598 break_point_number = | 1621 break_point_number = |
| 1599 Debug.setScriptBreakPointByName(target, line, column, condition, | 1622 Debug.setScriptBreakPointByName(target, line, column, condition, |
| 1600 groupId); | 1623 groupId); |
| 1624 } else if (type == 'scriptRegexp') { | |
|
Søren Thygesen Gjesse
2011/06/06 09:03:43
Can't we combine 'script' and 'scriptRegexp' here,
Peter Rybin
2011/06/16 11:02:20
I'd like to keep exact name and regexp separate. I
| |
| 1625 break_point_number = | |
| 1626 Debug.setScriptBreakPointByRegexp(target, line, column, condition, | |
| 1627 groupId); | |
| 1601 } else { // type == 'scriptId. | 1628 } else { // type == 'scriptId. |
| 1602 break_point_number = | 1629 break_point_number = |
| 1603 Debug.setScriptBreakPointById(target, line, column, condition, groupId); | 1630 Debug.setScriptBreakPointById(target, line, column, condition, groupId); |
| 1604 } | 1631 } |
| 1605 | 1632 |
| 1606 // Set additional break point properties. | 1633 // Set additional break point properties. |
| 1607 var break_point = Debug.findBreakPoint(break_point_number); | 1634 var break_point = Debug.findBreakPoint(break_point_number); |
| 1608 if (ignoreCount) { | 1635 if (ignoreCount) { |
| 1609 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); | 1636 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); |
| 1610 } | 1637 } |
| 1611 if (!enabled) { | 1638 if (!enabled) { |
| 1612 Debug.disableBreakPoint(break_point_number); | 1639 Debug.disableBreakPoint(break_point_number); |
| 1613 } | 1640 } |
| 1614 | 1641 |
| 1615 // Add the break point number to the response. | 1642 // Add the break point number to the response. |
| 1616 response.body = { type: type, | 1643 response.body = { type: type, |
| 1617 breakpoint: break_point_number } | 1644 breakpoint: break_point_number } |
| 1618 | 1645 |
| 1619 // Add break point information to the response. | 1646 // Add break point information to the response. |
| 1620 if (break_point instanceof ScriptBreakPoint) { | 1647 if (break_point instanceof ScriptBreakPoint) { |
| 1621 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1648 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| 1622 response.body.type = 'scriptId'; | 1649 response.body.type = 'scriptId'; |
| 1623 response.body.script_id = break_point.script_id(); | 1650 response.body.script_id = break_point.script_id(); |
| 1651 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegexp) { | |
| 1652 response.body.type = 'scriptRegexp'; | |
| 1653 response.body.script_regexp = break_point.script_regexp().source(); | |
| 1624 } else { | 1654 } else { |
| 1625 response.body.type = 'scriptName'; | 1655 response.body.type = 'scriptName'; |
| 1626 response.body.script_name = break_point.script_name(); | 1656 response.body.script_name = break_point.script_name(); |
| 1627 } | 1657 } |
| 1628 response.body.line = break_point.line(); | 1658 response.body.line = break_point.line(); |
| 1629 response.body.column = break_point.column(); | 1659 response.body.column = break_point.column(); |
| 1630 response.body.actual_locations = break_point.actual_locations(); | 1660 response.body.actual_locations = break_point.actual_locations(); |
| 1631 } else { | 1661 } else { |
| 1632 response.body.type = 'function'; | 1662 response.body.type = 'function'; |
| 1633 response.body.actual_locations = [break_point.actual_location]; | 1663 response.body.actual_locations = [break_point.actual_location]; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1746 hit_count: break_point.hit_count(), | 1776 hit_count: break_point.hit_count(), |
| 1747 active: break_point.active(), | 1777 active: break_point.active(), |
| 1748 condition: break_point.condition(), | 1778 condition: break_point.condition(), |
| 1749 ignoreCount: break_point.ignoreCount(), | 1779 ignoreCount: break_point.ignoreCount(), |
| 1750 actual_locations: break_point.actual_locations() | 1780 actual_locations: break_point.actual_locations() |
| 1751 } | 1781 } |
| 1752 | 1782 |
| 1753 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1783 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| 1754 description.type = 'scriptId'; | 1784 description.type = 'scriptId'; |
| 1755 description.script_id = break_point.script_id(); | 1785 description.script_id = break_point.script_id(); |
| 1786 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegexp) { | |
| 1787 description.type = 'scriptRegexp'; | |
| 1788 description.script_name = break_point.script_regexp().source(); | |
| 1756 } else { | 1789 } else { |
| 1757 description.type = 'scriptName'; | 1790 description.type = 'scriptName'; |
| 1758 description.script_name = break_point.script_name(); | 1791 description.script_name = break_point.script_name(); |
| 1759 } | 1792 } |
| 1760 array.push(description); | 1793 array.push(description); |
| 1761 } | 1794 } |
| 1762 | 1795 |
| 1763 response.body = { | 1796 response.body = { |
| 1764 breakpoints: array, | 1797 breakpoints: array, |
| 1765 breakOnExceptions: Debug.isBreakOnException(), | 1798 breakOnExceptions: Debug.isBreakOnException(), |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2560 case 'string': | 2593 case 'string': |
| 2561 case 'number': | 2594 case 'number': |
| 2562 json = value; | 2595 json = value; |
| 2563 break | 2596 break |
| 2564 | 2597 |
| 2565 default: | 2598 default: |
| 2566 json = null; | 2599 json = null; |
| 2567 } | 2600 } |
| 2568 return json; | 2601 return json; |
| 2569 } | 2602 } |
| OLD | NEW |