| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Function called from the runtime when a break point is hit. Returns true if | 216 // Function called from the runtime when a break point is hit. Returns true if |
| 217 // the break point is triggered and supposed to break execution. | 217 // the break point is triggered and supposed to break execution. |
| 218 function IsBreakPointTriggered(break_id, break_point) { | 218 function IsBreakPointTriggered(break_id, break_point) { |
| 219 return break_point.isTriggered(MakeExecutionState(break_id)); | 219 return break_point.isTriggered(MakeExecutionState(break_id)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 // Object representing a script break point. The script is referenced by its | 223 // Object representing a script break point. The script is referenced by its |
| 224 // script name or script id and the break point is represented as line and | 224 // script name or script id and the break point is represented as line and |
| 225 // column. | 225 // column. |
| 226 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column) { | 226 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, |
| 227 opt_groupId) { |
| 227 this.type_ = type; | 228 this.type_ = type; |
| 228 if (type == Debug.ScriptBreakPointType.ScriptId) { | 229 if (type == Debug.ScriptBreakPointType.ScriptId) { |
| 229 this.script_id_ = script_id_or_name; | 230 this.script_id_ = script_id_or_name; |
| 230 } else { // type == Debug.ScriptBreakPointType.ScriptName | 231 } else { // type == Debug.ScriptBreakPointType.ScriptName |
| 231 this.script_name_ = script_id_or_name; | 232 this.script_name_ = script_id_or_name; |
| 232 } | 233 } |
| 233 this.line_ = opt_line || 0; | 234 this.line_ = opt_line || 0; |
| 234 this.column_ = opt_column; | 235 this.column_ = opt_column; |
| 236 this.groupId_ = opt_groupId; |
| 235 this.hit_count_ = 0; | 237 this.hit_count_ = 0; |
| 236 this.active_ = true; | 238 this.active_ = true; |
| 237 this.condition_ = null; | 239 this.condition_ = null; |
| 238 this.ignoreCount_ = 0; | 240 this.ignoreCount_ = 0; |
| 239 } | 241 } |
| 240 | 242 |
| 241 | 243 |
| 242 ScriptBreakPoint.prototype.number = function() { | 244 ScriptBreakPoint.prototype.number = function() { |
| 243 return this.number_; | 245 return this.number_; |
| 244 }; | 246 }; |
| 245 | 247 |
| 246 | 248 |
| 249 ScriptBreakPoint.prototype.groupId = function() { |
| 250 return this.groupId_; |
| 251 }; |
| 252 |
| 253 |
| 247 ScriptBreakPoint.prototype.type = function() { | 254 ScriptBreakPoint.prototype.type = function() { |
| 248 return this.type_; | 255 return this.type_; |
| 249 }; | 256 }; |
| 250 | 257 |
| 251 | 258 |
| 252 ScriptBreakPoint.prototype.script_id = function() { | 259 ScriptBreakPoint.prototype.script_id = function() { |
| 253 return this.script_id_; | 260 return this.script_id_; |
| 254 }; | 261 }; |
| 255 | 262 |
| 256 | 263 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 break; | 611 break; |
| 605 } | 612 } |
| 606 } | 613 } |
| 607 return script_break_point; | 614 return script_break_point; |
| 608 } | 615 } |
| 609 | 616 |
| 610 | 617 |
| 611 // Sets a breakpoint in a script identified through id or name at the | 618 // Sets a breakpoint in a script identified through id or name at the |
| 612 // specified source line and column within that line. | 619 // specified source line and column within that line. |
| 613 Debug.setScriptBreakPoint = function(type, script_id_or_name, | 620 Debug.setScriptBreakPoint = function(type, script_id_or_name, |
| 614 opt_line, opt_column, opt_condition) { | 621 opt_line, opt_column, opt_condition, |
| 622 opt_groupId) { |
| 615 // Create script break point object. | 623 // Create script break point object. |
| 616 var script_break_point = | 624 var script_break_point = |
| 617 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column); | 625 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, |
| 626 opt_groupId); |
| 618 | 627 |
| 619 // Assign number to the new script break point and add it. | 628 // Assign number to the new script break point and add it. |
| 620 script_break_point.number_ = next_break_point_number++; | 629 script_break_point.number_ = next_break_point_number++; |
| 621 script_break_point.setCondition(opt_condition); | 630 script_break_point.setCondition(opt_condition); |
| 622 script_break_points.push(script_break_point); | 631 script_break_points.push(script_break_point); |
| 623 | 632 |
| 624 // Run through all scripts to see if this script break point matches any | 633 // Run through all scripts to see if this script break point matches any |
| 625 // loaded scripts. | 634 // loaded scripts. |
| 626 var scripts = this.scripts(); | 635 var scripts = this.scripts(); |
| 627 for (var i = 0; i < scripts.length; i++) { | 636 for (var i = 0; i < scripts.length; i++) { |
| 628 if (script_break_point.matchesScript(scripts[i])) { | 637 if (script_break_point.matchesScript(scripts[i])) { |
| 629 script_break_point.set(scripts[i]); | 638 script_break_point.set(scripts[i]); |
| 630 } | 639 } |
| 631 } | 640 } |
| 632 | 641 |
| 633 return script_break_point.number(); | 642 return script_break_point.number(); |
| 634 } | 643 } |
| 635 | 644 |
| 636 | 645 |
| 637 Debug.setScriptBreakPointById = function(script_id, | 646 Debug.setScriptBreakPointById = function(script_id, |
| 638 opt_line, opt_column, | 647 opt_line, opt_column, |
| 639 opt_condition) { | 648 opt_condition, opt_groupId) { |
| 640 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 649 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, |
| 641 script_id, opt_line, opt_column, | 650 script_id, opt_line, opt_column, |
| 642 opt_condition) | 651 opt_condition, opt_groupId); |
| 643 } | 652 } |
| 644 | 653 |
| 645 | 654 |
| 646 Debug.setScriptBreakPointByName = function(script_name, | 655 Debug.setScriptBreakPointByName = function(script_name, |
| 647 opt_line, opt_column, | 656 opt_line, opt_column, |
| 648 opt_condition) { | 657 opt_condition, opt_groupId) { |
| 649 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, | 658 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, |
| 650 script_name, opt_line, opt_column, | 659 script_name, opt_line, opt_column, |
| 651 opt_condition) | 660 opt_condition, opt_groupId); |
| 652 } | 661 } |
| 653 | 662 |
| 654 | 663 |
| 655 Debug.enableScriptBreakPoint = function(break_point_number) { | 664 Debug.enableScriptBreakPoint = function(break_point_number) { |
| 656 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 665 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 657 script_break_point.enable(); | 666 script_break_point.enable(); |
| 658 }; | 667 }; |
| 659 | 668 |
| 660 | 669 |
| 661 Debug.disableScriptBreakPoint = function(break_point_number) { | 670 Debug.disableScriptBreakPoint = function(break_point_number) { |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 if (request.command == 'continue') { | 1212 if (request.command == 'continue') { |
| 1204 this.continueRequest_(request, response); | 1213 this.continueRequest_(request, response); |
| 1205 } else if (request.command == 'break') { | 1214 } else if (request.command == 'break') { |
| 1206 this.breakRequest_(request, response); | 1215 this.breakRequest_(request, response); |
| 1207 } else if (request.command == 'setbreakpoint') { | 1216 } else if (request.command == 'setbreakpoint') { |
| 1208 this.setBreakPointRequest_(request, response); | 1217 this.setBreakPointRequest_(request, response); |
| 1209 } else if (request.command == 'changebreakpoint') { | 1218 } else if (request.command == 'changebreakpoint') { |
| 1210 this.changeBreakPointRequest_(request, response); | 1219 this.changeBreakPointRequest_(request, response); |
| 1211 } else if (request.command == 'clearbreakpoint') { | 1220 } else if (request.command == 'clearbreakpoint') { |
| 1212 this.clearBreakPointRequest_(request, response); | 1221 this.clearBreakPointRequest_(request, response); |
| 1222 } else if (request.command == 'clearbreakpointgroup') { |
| 1223 this.clearBreakPointGroupRequest_(request, response); |
| 1213 } else if (request.command == 'backtrace') { | 1224 } else if (request.command == 'backtrace') { |
| 1214 this.backtraceRequest_(request, response); | 1225 this.backtraceRequest_(request, response); |
| 1215 } else if (request.command == 'frame') { | 1226 } else if (request.command == 'frame') { |
| 1216 this.frameRequest_(request, response); | 1227 this.frameRequest_(request, response); |
| 1217 } else if (request.command == 'scopes') { | 1228 } else if (request.command == 'scopes') { |
| 1218 this.scopesRequest_(request, response); | 1229 this.scopesRequest_(request, response); |
| 1219 } else if (request.command == 'scope') { | 1230 } else if (request.command == 'scope') { |
| 1220 this.scopeRequest_(request, response); | 1231 this.scopeRequest_(request, response); |
| 1221 } else if (request.command == 'evaluate') { | 1232 } else if (request.command == 'evaluate') { |
| 1222 this.evaluateRequest_(request, response); | 1233 this.evaluateRequest_(request, response); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1329 |
| 1319 // Pull out arguments. | 1330 // Pull out arguments. |
| 1320 var type = request.arguments.type; | 1331 var type = request.arguments.type; |
| 1321 var target = request.arguments.target; | 1332 var target = request.arguments.target; |
| 1322 var line = request.arguments.line; | 1333 var line = request.arguments.line; |
| 1323 var column = request.arguments.column; | 1334 var column = request.arguments.column; |
| 1324 var enabled = IS_UNDEFINED(request.arguments.enabled) ? | 1335 var enabled = IS_UNDEFINED(request.arguments.enabled) ? |
| 1325 true : request.arguments.enabled; | 1336 true : request.arguments.enabled; |
| 1326 var condition = request.arguments.condition; | 1337 var condition = request.arguments.condition; |
| 1327 var ignoreCount = request.arguments.ignoreCount; | 1338 var ignoreCount = request.arguments.ignoreCount; |
| 1339 var groupId = request.arguments.groupId; |
| 1328 | 1340 |
| 1329 // Check for legal arguments. | 1341 // Check for legal arguments. |
| 1330 if (!type || IS_UNDEFINED(target)) { | 1342 if (!type || IS_UNDEFINED(target)) { |
| 1331 response.failed('Missing argument "type" or "target"'); | 1343 response.failed('Missing argument "type" or "target"'); |
| 1332 return; | 1344 return; |
| 1333 } | 1345 } |
| 1334 if (type != 'function' && type != 'handle' && | 1346 if (type != 'function' && type != 'handle' && |
| 1335 type != 'script' && type != 'scriptId') { | 1347 type != 'script' && type != 'scriptId') { |
| 1336 response.failed('Illegal type "' + type + '"'); | 1348 response.failed('Illegal type "' + type + '"'); |
| 1337 return; | 1349 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 if (!mirror.isFunction()) { | 1383 if (!mirror.isFunction()) { |
| 1372 return response.failed('Object #' + handle + '# is not a function'); | 1384 return response.failed('Object #' + handle + '# is not a function'); |
| 1373 } | 1385 } |
| 1374 | 1386 |
| 1375 // Set function break point. | 1387 // Set function break point. |
| 1376 break_point_number = Debug.setBreakPoint(mirror.value(), | 1388 break_point_number = Debug.setBreakPoint(mirror.value(), |
| 1377 line, column, condition); | 1389 line, column, condition); |
| 1378 } else if (type == 'script') { | 1390 } else if (type == 'script') { |
| 1379 // set script break point. | 1391 // set script break point. |
| 1380 break_point_number = | 1392 break_point_number = |
| 1381 Debug.setScriptBreakPointByName(target, line, column, condition); | 1393 Debug.setScriptBreakPointByName(target, line, column, condition, |
| 1394 groupId); |
| 1382 } else { // type == 'scriptId. | 1395 } else { // type == 'scriptId. |
| 1383 break_point_number = | 1396 break_point_number = |
| 1384 Debug.setScriptBreakPointById(target, line, column, condition); | 1397 Debug.setScriptBreakPointById(target, line, column, condition, groupId); |
| 1385 } | 1398 } |
| 1386 | 1399 |
| 1387 // Set additional break point properties. | 1400 // Set additional break point properties. |
| 1388 var break_point = Debug.findBreakPoint(break_point_number); | 1401 var break_point = Debug.findBreakPoint(break_point_number); |
| 1389 if (ignoreCount) { | 1402 if (ignoreCount) { |
| 1390 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); | 1403 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); |
| 1391 } | 1404 } |
| 1392 if (!enabled) { | 1405 if (!enabled) { |
| 1393 Debug.disableBreakPoint(break_point_number); | 1406 Debug.disableBreakPoint(break_point_number); |
| 1394 } | 1407 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 Debug.changeBreakPointCondition(break_point, condition); | 1460 Debug.changeBreakPointCondition(break_point, condition); |
| 1448 } | 1461 } |
| 1449 | 1462 |
| 1450 // Change ignore count if supplied | 1463 // Change ignore count if supplied |
| 1451 if (!IS_UNDEFINED(ignoreCount)) { | 1464 if (!IS_UNDEFINED(ignoreCount)) { |
| 1452 Debug.changeBreakPointIgnoreCount(break_point, ignoreCount); | 1465 Debug.changeBreakPointIgnoreCount(break_point, ignoreCount); |
| 1453 } | 1466 } |
| 1454 } | 1467 } |
| 1455 | 1468 |
| 1456 | 1469 |
| 1470 DebugCommandProcessor.prototype.clearBreakPointGroupRequest_ = function(request,
response) { |
| 1471 // Check for legal request. |
| 1472 if (!request.arguments) { |
| 1473 response.failed('Missing arguments'); |
| 1474 return; |
| 1475 } |
| 1476 |
| 1477 // Pull out arguments. |
| 1478 var group_id = request.arguments.groupId; |
| 1479 |
| 1480 // Check for legal arguments. |
| 1481 if (!group_id) { |
| 1482 response.failed('Missing argument "groupId"'); |
| 1483 return; |
| 1484 } |
| 1485 |
| 1486 var cleared_break_points = []; |
| 1487 var new_script_break_points = []; |
| 1488 for (var i = 0; i < script_break_points.length; i++) { |
| 1489 var next_break_point = script_break_points[i]; |
| 1490 if (next_break_point.groupId() == group_id) { |
| 1491 cleared_break_points.push(next_break_point.number()); |
| 1492 next_break_point.clear(); |
| 1493 } else { |
| 1494 new_script_break_points.push(next_break_point); |
| 1495 } |
| 1496 } |
| 1497 script_break_points = new_script_break_points; |
| 1498 |
| 1499 // Add the cleared break point numbers to the response. |
| 1500 response.body = { breakpoints: cleared_break_points }; |
| 1501 } |
| 1502 |
| 1503 |
| 1457 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, resp
onse) { | 1504 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, resp
onse) { |
| 1458 // Check for legal request. | 1505 // Check for legal request. |
| 1459 if (!request.arguments) { | 1506 if (!request.arguments) { |
| 1460 response.failed('Missing arguments'); | 1507 response.failed('Missing arguments'); |
| 1461 return; | 1508 return; |
| 1462 } | 1509 } |
| 1463 | 1510 |
| 1464 // Pull out arguments. | 1511 // Pull out arguments. |
| 1465 var break_point = %ToNumber(request.arguments.breakpoint); | 1512 var break_point = %ToNumber(request.arguments.breakpoint); |
| 1466 | 1513 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 case 'string': | 2023 case 'string': |
| 1977 case 'number': | 2024 case 'number': |
| 1978 json = value; | 2025 json = value; |
| 1979 break | 2026 break |
| 1980 | 2027 |
| 1981 default: | 2028 default: |
| 1982 json = null; | 2029 json = null; |
| 1983 } | 2030 } |
| 1984 return json; | 2031 return json; |
| 1985 } | 2032 } |
| OLD | NEW |