Commit 0d421991 authored by yangguo's avatar yangguo Committed by Commit bot

[debug] do not retroactively apply script break points.

R=jgruber@chromium.org, kozyatinskiy@chromium.org
BUG=v8:5510

Review-Url: https://codereview.chromium.org/2530093002
Cr-Commit-Position: refs/heads/master@{#41549}
parent 36807f8a
......@@ -1875,16 +1875,6 @@ void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
if (event == v8::AfterCompile) {
// If debugging there might be script break points registered for this
// script. Make sure that these break points are set.
Handle<Object> argv[] = {Script::GetWrapper(script)};
if (CallFunction("UpdateScriptBreakPoints", arraysize(argv), argv)
.is_null()) {
return;
}
}
// Create the compile state object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
......
......@@ -254,20 +254,6 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
}
// Creates a clone of script breakpoint that is linked to another script.
ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) {
var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
other_script.id, this.line_, this.column_, this.groupId_,
this.position_alignment_);
copy.number_ = next_break_point_number++;
script_break_points.push(copy);
copy.active_ = this.active_;
copy.condition_ = this.condition_;
return copy;
};
ScriptBreakPoint.prototype.number = function() {
return this.number_;
};
......@@ -433,31 +419,6 @@ ScriptBreakPoint.prototype.clear = function () {
};
// Function called from runtime when a new script is compiled to set any script
// break points set in this script.
function UpdateScriptBreakPoints(script) {
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
if ((break_point.type() == Debug.ScriptBreakPointType.ScriptName ||
break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) &&
break_point.matchesScript(script)) {
break_point.set(script);
}
}
}
function GetScriptBreakPoints(script) {
var result = [];
for (var i = 0; i < script_break_points.length; i++) {
if (script_break_points[i].matchesScript(script)) {
result.push(script_break_points[i]);
}
}
return result;
}
Debug.setListener = function(listener, opt_data) {
if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) {
throw %make_type_error(kDebuggerType);
......@@ -2462,12 +2423,6 @@ utils.InstallFunctions(utils, DONT_ENUM, [
"MakeCompileEvent", MakeCompileEvent,
"MakeAsyncTaskEvent", MakeAsyncTaskEvent,
"IsBreakPointTriggered", IsBreakPointTriggered,
"UpdateScriptBreakPoints", UpdateScriptBreakPoints,
]);
// Export to liveedit.js
utils.Export(function(to) {
to.GetScriptBreakPoints = GetScriptBreakPoints;
});
})
......@@ -27,15 +27,10 @@
// Imports
var FindScriptSourcePosition = global.Debug.findScriptSourcePosition;
var GetScriptBreakPoints;
var GlobalArray = global.Array;
var MathFloor = global.Math.floor;
var SyntaxError = global.SyntaxError;
utils.Import(function(from) {
GetScriptBreakPoints = from.GetScriptBreakPoints;
});
// -------------------------------------------------------------------
// Forward declaration for minifier.
......@@ -170,10 +165,6 @@
// command for correct stack state if the stack was modified.
preview_description.stack_modified = dropped_functions_number != 0;
// Start with breakpoints. Convert their line/column positions and
// temporary remove.
var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log);
var old_script;
// Create an old script only if there are function that should be linked
......@@ -228,8 +219,6 @@
}
}
break_points_restorer(pos_translator, old_script);
preview_description.updated = true;
return preview_description;
}
......@@ -368,79 +357,6 @@
}
}
// Returns function that restores breakpoints.
function TemporaryRemoveBreakPoints(original_script, change_log) {
var script_break_points = GetScriptBreakPoints(original_script);
var break_points_update_report = [];
change_log.push( { break_points_update: break_points_update_report } );
var break_point_old_positions = [];
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
break_point.clear();
// TODO(LiveEdit): be careful with resource offset here.
var break_point_position = FindScriptSourcePosition(original_script,
break_point.line(), break_point.column());
var old_position_description = {
position: break_point_position,
line: break_point.line(),
column: break_point.column()
};
break_point_old_positions.push(old_position_description);
}
// Restores breakpoints and creates their copies in the "old" copy of
// the script.
return function (pos_translator, old_script_copy_opt) {
// Update breakpoints (change positions and restore them in old version
// of script.
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
if (old_script_copy_opt) {
var clone = break_point.cloneForOtherScript(old_script_copy_opt);
clone.set(old_script_copy_opt);
break_points_update_report.push( {
type: "copied_to_old",
id: break_point.number(),
new_id: clone.number(),
positions: break_point_old_positions[i]
} );
}
var updated_position = pos_translator.Translate(
break_point_old_positions[i].position,
PosTranslator.ShiftWithTopInsideChunkHandler);
var new_location =
original_script.locationFromPosition(updated_position, false);
break_point.update_positions(new_location.line, new_location.column);
var new_position_description = {
position: updated_position,
line: new_location.line,
column: new_location.column
};
break_point.set(original_script);
break_points_update_report.push( { type: "position_changed",
id: break_point.number(),
old_positions: break_point_old_positions[i],
new_positions: new_position_description
} );
}
};
}
function Assert(condition, message) {
if (!condition) {
if (message) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment