Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/debug-debugger.js

Issue 16093040: Debug: support breakpoints set in the middle of statement (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: clean Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/debug.cc ('K') | « src/debug.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // the break point is triggered and supposed to break execution. 244 // the break point is triggered and supposed to break execution.
245 function IsBreakPointTriggered(break_id, break_point) { 245 function IsBreakPointTriggered(break_id, break_point) {
246 return break_point.isTriggered(MakeExecutionState(break_id)); 246 return break_point.isTriggered(MakeExecutionState(break_id));
247 } 247 }
248 248
249 249
250 // Object representing a script break point. The script is referenced by its 250 // 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 251 // script name or script id and the break point is represented as line and
252 // column. 252 // column.
253 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, 253 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
254 opt_groupId) { 254 opt_groupId, opt_statement_aligned) {
255 this.type_ = type; 255 this.type_ = type;
256 if (type == Debug.ScriptBreakPointType.ScriptId) { 256 if (type == Debug.ScriptBreakPointType.ScriptId) {
257 this.script_id_ = script_id_or_name; 257 this.script_id_ = script_id_or_name;
258 } else if (type == Debug.ScriptBreakPointType.ScriptName) { 258 } else if (type == Debug.ScriptBreakPointType.ScriptName) {
259 this.script_name_ = script_id_or_name; 259 this.script_name_ = script_id_or_name;
260 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) { 260 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) {
261 this.script_regexp_object_ = new RegExp(script_id_or_name); 261 this.script_regexp_object_ = new RegExp(script_id_or_name);
262 } else { 262 } else {
263 throw new Error("Unexpected breakpoint type " + type); 263 throw new Error("Unexpected breakpoint type " + type);
264 } 264 }
265 this.line_ = opt_line || 0; 265 this.line_ = opt_line || 0;
266 this.column_ = opt_column; 266 this.column_ = opt_column;
267 this.groupId_ = opt_groupId; 267 this.groupId_ = opt_groupId;
268 this.statement_aligned_ = opt_statement_aligned !== false;
268 this.hit_count_ = 0; 269 this.hit_count_ = 0;
269 this.active_ = true; 270 this.active_ = true;
270 this.condition_ = null; 271 this.condition_ = null;
271 this.ignoreCount_ = 0; 272 this.ignoreCount_ = 0;
272 this.break_points_ = []; 273 this.break_points_ = [];
273 } 274 }
274 275
275 276
276 //Creates a clone of script breakpoint that is linked to another script. 277 //Creates a clone of script breakpoint that is linked to another script.
277 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { 278 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) {
278 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, 279 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
279 other_script.id, this.line_, this.column_, this.groupId_); 280 other_script.id, this.line_, this.column_, this.groupId_, this.statement_a ligned_);
Yang 2013/06/25 11:32:00 80 char limit
Peter.Rybin 2013/06/27 14:07:29 Done.
280 copy.number_ = next_break_point_number++; 281 copy.number_ = next_break_point_number++;
281 script_break_points.push(copy); 282 script_break_points.push(copy);
282 283
283 copy.hit_count_ = this.hit_count_; 284 copy.hit_count_ = this.hit_count_;
284 copy.active_ = this.active_; 285 copy.active_ = this.active_;
285 copy.condition_ = this.condition_; 286 copy.condition_ = this.condition_;
286 copy.ignoreCount_ = this.ignoreCount_; 287 copy.ignoreCount_ = this.ignoreCount_;
287 return copy; 288 return copy;
288 }; 289 };
289 290
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // Convert the line and column into an absolute position within the script. 437 // Convert the line and column into an absolute position within the script.
437 var position = Debug.findScriptSourcePosition(script, this.line(), column); 438 var position = Debug.findScriptSourcePosition(script, this.line(), column);
438 439
439 // If the position is not found in the script (the script might be shorter 440 // If the position is not found in the script (the script might be shorter
440 // than it used to be) just ignore it. 441 // than it used to be) just ignore it.
441 if (position === null) return; 442 if (position === null) return;
442 443
443 // Create a break point object and set the break point. 444 // Create a break point object and set the break point.
444 break_point = MakeBreakPoint(position, this); 445 break_point = MakeBreakPoint(position, this);
445 break_point.setIgnoreCount(this.ignoreCount()); 446 break_point.setIgnoreCount(this.ignoreCount());
446 var actual_position = %SetScriptBreakPoint(script, position, break_point); 447 var actual_position = %SetScriptBreakPoint(script, position, this.statement_al igned_, break_point);
Yang 2013/06/25 11:32:00 80 char limit
Peter.Rybin 2013/06/27 14:07:29 Done.
447 if (IS_UNDEFINED(actual_position)) { 448 if (IS_UNDEFINED(actual_position)) {
448 actual_position = position; 449 actual_position = position;
449 } 450 }
450 var actual_location = script.locationFromPosition(actual_position, true); 451 var actual_location = script.locationFromPosition(actual_position, true);
451 break_point.actual_location = { line: actual_location.line, 452 break_point.actual_location = { line: actual_location.line,
452 column: actual_location.column, 453 column: actual_location.column,
453 script_id: script.id }; 454 script_id: script.id };
454 this.break_points_.push(break_point); 455 this.break_points_.push(break_point);
455 return break_point; 456 return break_point;
456 }; 457 };
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 { 679 {
679 break_point = MakeBreakPoint(position); 680 break_point = MakeBreakPoint(position);
680 break_point.setCondition(condition); 681 break_point.setCondition(condition);
681 if (!enabled) { 682 if (!enabled) {
682 break_point.disable(); 683 break_point.disable();
683 } 684 }
684 var scripts = this.scripts(); 685 var scripts = this.scripts();
685 for (var i = 0; i < scripts.length; i++) { 686 for (var i = 0; i < scripts.length; i++) {
686 if (script_id == scripts[i].id) { 687 if (script_id == scripts[i].id) {
687 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position, 688 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position,
688 break_point); 689 true, break_point);
689 break; 690 break;
690 } 691 }
691 } 692 }
692 return break_point; 693 return break_point;
693 }; 694 };
694 695
695 696
696 Debug.enableBreakPoint = function(break_point_number) { 697 Debug.enableBreakPoint = function(break_point_number) {
697 var break_point = this.findBreakPoint(break_point_number, false); 698 var break_point = this.findBreakPoint(break_point_number, false);
698 // Only enable if the breakpoint hasn't been deleted: 699 // Only enable if the breakpoint hasn't been deleted:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 } 774 }
774 } 775 }
775 return script_break_point; 776 return script_break_point;
776 }; 777 };
777 778
778 779
779 // Sets a breakpoint in a script identified through id or name at the 780 // Sets a breakpoint in a script identified through id or name at the
780 // specified source line and column within that line. 781 // specified source line and column within that line.
781 Debug.setScriptBreakPoint = function(type, script_id_or_name, 782 Debug.setScriptBreakPoint = function(type, script_id_or_name,
782 opt_line, opt_column, opt_condition, 783 opt_line, opt_column, opt_condition,
783 opt_groupId) { 784 opt_groupId, opt_statement_aligned) {
784 // Create script break point object. 785 // Create script break point object.
785 var script_break_point = 786 var script_break_point =
786 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, 787 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
787 opt_groupId); 788 opt_groupId, opt_statement_aligned);
788 789
789 // Assign number to the new script break point and add it. 790 // Assign number to the new script break point and add it.
790 script_break_point.number_ = next_break_point_number++; 791 script_break_point.number_ = next_break_point_number++;
791 script_break_point.setCondition(opt_condition); 792 script_break_point.setCondition(opt_condition);
792 script_break_points.push(script_break_point); 793 script_break_points.push(script_break_point);
793 794
794 // Run through all scripts to see if this script break point matches any 795 // Run through all scripts to see if this script break point matches any
795 // loaded scripts. 796 // loaded scripts.
796 var scripts = this.scripts(); 797 var scripts = this.scripts();
797 for (var i = 0; i < scripts.length; i++) { 798 for (var i = 0; i < scripts.length; i++) {
798 if (script_break_point.matchesScript(scripts[i])) { 799 if (script_break_point.matchesScript(scripts[i])) {
799 script_break_point.set(scripts[i]); 800 script_break_point.set(scripts[i]);
800 } 801 }
801 } 802 }
802 803
803 return script_break_point.number(); 804 return script_break_point.number();
804 }; 805 };
805 806
806 807
807 Debug.setScriptBreakPointById = function(script_id, 808 Debug.setScriptBreakPointById = function(script_id,
808 opt_line, opt_column, 809 opt_line, opt_column,
809 opt_condition, opt_groupId) { 810 opt_condition, opt_groupId, opt_stateme nt_aligned) {
Yang 2013/06/25 11:32:00 80 char limit
Peter.Rybin 2013/06/27 14:07:29 Done.
810 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, 811 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
811 script_id, opt_line, opt_column, 812 script_id, opt_line, opt_column,
812 opt_condition, opt_groupId); 813 opt_condition, opt_groupId, opt_statement_alig ned);
Yang 2013/06/25 11:32:00 80 char limit
Peter.Rybin 2013/06/27 14:07:29 Done.
813 }; 814 };
814 815
815 816
816 Debug.setScriptBreakPointByName = function(script_name, 817 Debug.setScriptBreakPointByName = function(script_name,
817 opt_line, opt_column, 818 opt_line, opt_column,
818 opt_condition, opt_groupId) { 819 opt_condition, opt_groupId) {
819 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, 820 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName,
820 script_name, opt_line, opt_column, 821 script_name, opt_line, opt_column,
821 opt_condition, opt_groupId); 822 opt_condition, opt_groupId);
822 }; 823 };
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 2625
2625 default: 2626 default:
2626 json = null; 2627 json = null;
2627 } 2628 }
2628 return json; 2629 return json;
2629 } 2630 }
2630 2631
2631 Debug.TestApi = { 2632 Debug.TestApi = {
2632 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ 2633 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_
2633 }; 2634 };
OLDNEW
« src/debug.cc ('K') | « src/debug.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698