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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 } else { // type == Debug.ScriptBreakPointType.ScriptName | 229 } else { // type == Debug.ScriptBreakPointType.ScriptName |
230 this.script_name_ = script_id_or_name; | 230 this.script_name_ = script_id_or_name; |
231 } | 231 } |
232 this.line_ = opt_line || 0; | 232 this.line_ = opt_line || 0; |
233 this.column_ = opt_column; | 233 this.column_ = opt_column; |
234 this.groupId_ = opt_groupId; | 234 this.groupId_ = opt_groupId; |
235 this.hit_count_ = 0; | 235 this.hit_count_ = 0; |
236 this.active_ = true; | 236 this.active_ = true; |
237 this.condition_ = null; | 237 this.condition_ = null; |
238 this.ignoreCount_ = 0; | 238 this.ignoreCount_ = 0; |
239 this.break_points_ = []; | |
239 } | 240 } |
240 | 241 |
241 | 242 |
242 //Creates a clone of script breakpoint that is linked to another script. | 243 //Creates a clone of script breakpoint that is linked to another script. |
243 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { | 244 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { |
244 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 245 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, |
245 other_script.id, this.line_, this.column_, this.groupId_); | 246 other_script.id, this.line_, this.column_, this.groupId_); |
246 copy.number_ = next_break_point_number++; | 247 copy.number_ = next_break_point_number++; |
247 script_break_points.push(copy); | 248 script_break_points.push(copy); |
248 | 249 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 ScriptBreakPoint.prototype.line = function() { | 283 ScriptBreakPoint.prototype.line = function() { |
283 return this.line_; | 284 return this.line_; |
284 }; | 285 }; |
285 | 286 |
286 | 287 |
287 ScriptBreakPoint.prototype.column = function() { | 288 ScriptBreakPoint.prototype.column = function() { |
288 return this.column_; | 289 return this.column_; |
289 }; | 290 }; |
290 | 291 |
291 | 292 |
293 ScriptBreakPoint.prototype.actual_locations = function() { | |
294 var locations = []; | |
295 for (var i = 0; i < this.break_points_.length; i++) { | |
296 locations.push(this.break_points_[i].actual_location); | |
297 } | |
298 return locations; | |
299 } | |
300 | |
301 | |
292 ScriptBreakPoint.prototype.update_positions = function(line, column) { | 302 ScriptBreakPoint.prototype.update_positions = function(line, column) { |
293 this.line_ = line; | 303 this.line_ = line; |
294 this.column_ = column; | 304 this.column_ = column; |
295 } | 305 } |
296 | 306 |
297 | 307 |
298 ScriptBreakPoint.prototype.hit_count = function() { | 308 ScriptBreakPoint.prototype.hit_count = function() { |
299 return this.hit_count_; | 309 return this.hit_count_; |
300 }; | 310 }; |
301 | 311 |
(...skipping 25 matching lines...) Expand all Loading... | |
327 | 337 |
328 ScriptBreakPoint.prototype.setCondition = function(condition) { | 338 ScriptBreakPoint.prototype.setCondition = function(condition) { |
329 this.condition_ = condition; | 339 this.condition_ = condition; |
330 }; | 340 }; |
331 | 341 |
332 | 342 |
333 ScriptBreakPoint.prototype.setIgnoreCount = function(ignoreCount) { | 343 ScriptBreakPoint.prototype.setIgnoreCount = function(ignoreCount) { |
334 this.ignoreCount_ = ignoreCount; | 344 this.ignoreCount_ = ignoreCount; |
335 | 345 |
336 // Set ignore count on all break points created from this script break point. | 346 // Set ignore count on all break points created from this script break point. |
337 for (var i = 0; i < break_points.length; i++) { | 347 for (var i = 0; i < this.break_points_.length; i++) { |
338 if (break_points[i].script_break_point() === this) { | 348 this.break_points_[i].setIgnoreCount(ignoreCount); |
339 break_points[i].setIgnoreCount(ignoreCount); | |
340 } | |
341 } | 349 } |
342 }; | 350 }; |
343 | 351 |
344 | 352 |
345 // Check whether a script matches this script break point. Currently this is | 353 // Check whether a script matches this script break point. Currently this is |
346 // only based on script name. | 354 // only based on script name. |
347 ScriptBreakPoint.prototype.matchesScript = function(script) { | 355 ScriptBreakPoint.prototype.matchesScript = function(script) { |
348 if (this.type_ == Debug.ScriptBreakPointType.ScriptId) { | 356 if (this.type_ == Debug.ScriptBreakPointType.ScriptId) { |
349 return this.script_id_ == script.id; | 357 return this.script_id_ == script.id; |
350 } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName | 358 } else { // this.type_ == Debug.ScriptBreakPointType.ScriptName |
(...skipping 21 matching lines...) Expand all Loading... | |
372 | 380 |
373 // Fill cache if needed and get column where the actual source starts. | 381 // Fill cache if needed and get column where the actual source starts. |
374 if (IS_UNDEFINED(script.sourceColumnStart_[line])) { | 382 if (IS_UNDEFINED(script.sourceColumnStart_[line])) { |
375 script.sourceColumnStart_[line] = | 383 script.sourceColumnStart_[line] = |
376 source_line.match(sourceLineBeginningSkip)[0].length; | 384 source_line.match(sourceLineBeginningSkip)[0].length; |
377 } | 385 } |
378 column = script.sourceColumnStart_[line]; | 386 column = script.sourceColumnStart_[line]; |
379 } | 387 } |
380 | 388 |
381 // Convert the line and column into an absolute position within the script. | 389 // Convert the line and column into an absolute position within the script. |
382 var pos = Debug.findScriptSourcePosition(script, this.line(), column); | 390 var position = Debug.findScriptSourcePosition(script, this.line(), column); |
383 | 391 |
384 // If the position is not found in the script (the script might be shorter | 392 // If the position is not found in the script (the script might be shorter |
385 // than it used to be) just ignore it. | 393 // than it used to be) just ignore it. |
386 if (pos === null) return; | 394 if (position === null) return; |
387 | 395 |
388 // Create a break point object and set the break point. | 396 // Create a break point object and set the break point. |
389 break_point = MakeBreakPoint(pos, this.line(), this.column(), this); | 397 break_point = MakeBreakPoint(position, this.line(), this.column(), this); |
390 break_point.setIgnoreCount(this.ignoreCount()); | 398 break_point.setIgnoreCount(this.ignoreCount()); |
391 pos = %SetScriptBreakPoint(script, pos, break_point); | 399 var actual_position = %SetScriptBreakPoint(script, position, break_point); |
392 if (!IS_UNDEFINED(pos)) { | 400 if (IS_UNDEFINED(actual_position)) { |
Søren Thygesen Gjesse
2010/06/28 06:50:30
Is this undefined check still needed after the cha
podivilov
2010/06/28 12:10:06
Yes, because Runtime_SetScriptBreakPoint returns u
| |
393 this.actual_location = script.locationFromPosition(pos); | 401 actual_position = position; |
394 } | 402 } |
395 | 403 var actual_location = script.locationFromPosition(actual_position, true); |
404 break_point.actual_location = { line: actual_location.line, | |
405 column: actual_location.column }; | |
406 this.break_points_.push(break_point); | |
396 return break_point; | 407 return break_point; |
397 }; | 408 }; |
398 | 409 |
399 | 410 |
400 // Clear all the break points created from this script break point | 411 // Clear all the break points created from this script break point |
401 ScriptBreakPoint.prototype.clear = function () { | 412 ScriptBreakPoint.prototype.clear = function () { |
402 var remaining_break_points = []; | 413 var remaining_break_points = []; |
403 for (var i = 0; i < break_points.length; i++) { | 414 for (var i = 0; i < break_points.length; i++) { |
404 if (break_points[i].script_break_point() && | 415 if (break_points[i].script_break_point() && |
405 break_points[i].script_break_point() === this) { | 416 break_points[i].script_break_point() === this) { |
406 %ClearBreakPoint(break_points[i]); | 417 %ClearBreakPoint(break_points[i]); |
407 } else { | 418 } else { |
408 remaining_break_points.push(break_points[i]); | 419 remaining_break_points.push(break_points[i]); |
409 } | 420 } |
410 } | 421 } |
411 break_points = remaining_break_points; | 422 break_points = remaining_break_points; |
423 this.break_points_ = []; | |
412 }; | 424 }; |
413 | 425 |
414 | 426 |
415 // Function called from runtime when a new script is compiled to set any script | 427 // Function called from runtime when a new script is compiled to set any script |
416 // break points set in this script. | 428 // break points set in this script. |
417 function UpdateScriptBreakPoints(script) { | 429 function UpdateScriptBreakPoints(script) { |
418 for (var i = 0; i < script_break_points.length; i++) { | 430 for (var i = 0; i < script_break_points.length; i++) { |
419 if (script_break_points[i].type() == Debug.ScriptBreakPointType.ScriptName & & | 431 if (script_break_points[i].type() == Debug.ScriptBreakPointType.ScriptName & & |
420 script_break_points[i].matchesScript(script)) { | 432 script_break_points[i].matchesScript(script)) { |
421 script_break_points[i].set(script); | 433 script_break_points[i].set(script); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 break; | 559 break; |
548 } | 560 } |
549 } | 561 } |
550 if (break_point) { | 562 if (break_point) { |
551 return break_point; | 563 return break_point; |
552 } else { | 564 } else { |
553 return this.findScriptBreakPoint(break_point_number, remove); | 565 return this.findScriptBreakPoint(break_point_number, remove); |
554 } | 566 } |
555 }; | 567 }; |
556 | 568 |
569 Debug.findBreakPointActualLocations = function(break_point_number) { | |
570 for (var i = 0; i < script_break_points.length; i++) { | |
571 if (script_break_points[i].number() == break_point_number) { | |
572 return script_break_points[i].actual_locations(); | |
573 } | |
574 } | |
575 for (var i = 0; i < break_points.length; i++) { | |
576 if (break_points[i].number() == break_point_number) { | |
577 return [break_points[i].actual_location]; | |
578 } | |
579 } | |
580 return []; | |
581 } | |
557 | 582 |
558 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { | 583 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { |
559 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); | 584 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); |
560 // Break points in API functions are not supported. | 585 // Break points in API functions are not supported. |
561 if (%FunctionIsAPIFunction(func)) { | 586 if (%FunctionIsAPIFunction(func)) { |
562 throw new Error('Cannot set break point in native code.'); | 587 throw new Error('Cannot set break point in native code.'); |
563 } | 588 } |
564 // Find source position relative to start of the function | 589 // Find source position relative to start of the function |
565 var break_position = | 590 var break_position = |
566 this.findFunctionSourceLocation(func, opt_line, opt_column).position; | 591 this.findFunctionSourceLocation(func, opt_line, opt_column).position; |
(...skipping 11 matching lines...) Expand all Loading... | |
578 source_position += %FunctionGetScriptSourcePosition(func); | 603 source_position += %FunctionGetScriptSourcePosition(func); |
579 // Find line and column for the position in the script and set a script | 604 // Find line and column for the position in the script and set a script |
580 // break point from that. | 605 // break point from that. |
581 var location = script.locationFromPosition(source_position, false); | 606 var location = script.locationFromPosition(source_position, false); |
582 return this.setScriptBreakPointById(script.id, | 607 return this.setScriptBreakPointById(script.id, |
583 location.line, location.column, | 608 location.line, location.column, |
584 opt_condition); | 609 opt_condition); |
585 } else { | 610 } else { |
586 // Set a break point directly on the function. | 611 // Set a break point directly on the function. |
587 var break_point = MakeBreakPoint(source_position, opt_line, opt_column); | 612 var break_point = MakeBreakPoint(source_position, opt_line, opt_column); |
588 %SetFunctionBreakPoint(func, source_position, break_point); | 613 var pos = %SetFunctionBreakPoint(func, source_position, break_point); |
Søren Thygesen Gjesse
2010/06/28 06:50:30
Maybe pos -> actual_position as above
podivilov
2010/06/28 12:10:06
Done.
| |
614 pos += this.sourcePosition(func); | |
615 var actual_location = script.locationFromPosition(pos, true); | |
616 break_point.actual_location = { line: actual_location.line, | |
617 column: actual_location.column }; | |
589 break_point.setCondition(opt_condition); | 618 break_point.setCondition(opt_condition); |
590 return break_point.number(); | 619 return break_point.number(); |
591 } | 620 } |
592 }; | 621 }; |
593 | 622 |
594 | 623 |
595 Debug.enableBreakPoint = function(break_point_number) { | 624 Debug.enableBreakPoint = function(break_point_number) { |
596 var break_point = this.findBreakPoint(break_point_number, false); | 625 var break_point = this.findBreakPoint(break_point_number, false); |
597 break_point.enable(); | 626 break_point.enable(); |
598 }; | 627 }; |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 if (break_point instanceof ScriptBreakPoint) { | 1504 if (break_point instanceof ScriptBreakPoint) { |
1476 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1505 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
1477 response.body.type = 'scriptId'; | 1506 response.body.type = 'scriptId'; |
1478 response.body.script_id = break_point.script_id(); | 1507 response.body.script_id = break_point.script_id(); |
1479 } else { | 1508 } else { |
1480 response.body.type = 'scriptName'; | 1509 response.body.type = 'scriptName'; |
1481 response.body.script_name = break_point.script_name(); | 1510 response.body.script_name = break_point.script_name(); |
1482 } | 1511 } |
1483 response.body.line = break_point.line(); | 1512 response.body.line = break_point.line(); |
1484 response.body.column = break_point.column(); | 1513 response.body.column = break_point.column(); |
1514 response.body.actual_locations = break_point.actual_locations(); | |
1485 } else { | 1515 } else { |
1486 response.body.type = 'function'; | 1516 response.body.type = 'function'; |
1517 response.body.actual_locations = [break_point.actual_location]; | |
1487 } | 1518 } |
1488 }; | 1519 }; |
1489 | 1520 |
1490 | 1521 |
1491 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(request, res ponse) { | 1522 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(request, res ponse) { |
1492 // Check for legal request. | 1523 // Check for legal request. |
1493 if (!request.arguments) { | 1524 if (!request.arguments) { |
1494 response.failed('Missing arguments'); | 1525 response.failed('Missing arguments'); |
1495 return; | 1526 return; |
1496 } | 1527 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 var break_point = script_break_points[i]; | 1622 var break_point = script_break_points[i]; |
1592 | 1623 |
1593 var description = { | 1624 var description = { |
1594 number: break_point.number(), | 1625 number: break_point.number(), |
1595 line: break_point.line(), | 1626 line: break_point.line(), |
1596 column: break_point.column(), | 1627 column: break_point.column(), |
1597 groupId: break_point.groupId(), | 1628 groupId: break_point.groupId(), |
1598 hit_count: break_point.hit_count(), | 1629 hit_count: break_point.hit_count(), |
1599 active: break_point.active(), | 1630 active: break_point.active(), |
1600 condition: break_point.condition(), | 1631 condition: break_point.condition(), |
1601 ignoreCount: break_point.ignoreCount() | 1632 ignoreCount: break_point.ignoreCount(), |
1633 actual_locations: break_point.actual_locations() | |
1602 } | 1634 } |
1603 | 1635 |
1604 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1636 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
1605 description.type = 'scriptId'; | 1637 description.type = 'scriptId'; |
1606 description.script_id = break_point.script_id(); | 1638 description.script_id = break_point.script_id(); |
1607 } else { | 1639 } else { |
1608 description.type = 'scriptName'; | 1640 description.type = 'scriptName'; |
1609 description.script_name = break_point.script_name(); | 1641 description.script_name = break_point.script_name(); |
1610 } | 1642 } |
1611 array.push(description); | 1643 array.push(description); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2193 case 'string': | 2225 case 'string': |
2194 case 'number': | 2226 case 'number': |
2195 json = value; | 2227 json = value; |
2196 break | 2228 break |
2197 | 2229 |
2198 default: | 2230 default: |
2199 json = null; | 2231 json = null; |
2200 } | 2232 } |
2201 return json; | 2233 return json; |
2202 } | 2234 } |
OLD | NEW |