Commit 488da005 authored by prybin@chromium.org's avatar prybin@chromium.org

Debug: support breakpoints set in the middle of statement (try #2 after rollback)

Review URL: https://codereview.chromium.org/18349004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15420 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a3bce198
...@@ -71,6 +71,13 @@ Debug.ScriptBreakPointType = { ScriptId: 0, ...@@ -71,6 +71,13 @@ Debug.ScriptBreakPointType = { ScriptId: 0,
ScriptName: 1, ScriptName: 1,
ScriptRegExp: 2 }; ScriptRegExp: 2 };
// The different types of breakpoint position alignments.
// Must match BreakPositionAlignment in debug.h.
Debug.BreakPositionAlignment = {
Statement: 0,
BreakPosition: 1
};
function ScriptTypeFlag(type) { function ScriptTypeFlag(type) {
return (1 << type); return (1 << type);
} }
...@@ -251,7 +258,7 @@ function IsBreakPointTriggered(break_id, break_point) { ...@@ -251,7 +258,7 @@ function IsBreakPointTriggered(break_id, break_point) {
// script name or script id and the break point is represented as line and // script name or script id and the break point is represented as line and
// column. // column.
function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
opt_groupId) { opt_groupId, opt_position_alignment) {
this.type_ = type; this.type_ = type;
if (type == Debug.ScriptBreakPointType.ScriptId) { if (type == Debug.ScriptBreakPointType.ScriptId) {
this.script_id_ = script_id_or_name; this.script_id_ = script_id_or_name;
...@@ -265,6 +272,8 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, ...@@ -265,6 +272,8 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
this.line_ = opt_line || 0; this.line_ = opt_line || 0;
this.column_ = opt_column; this.column_ = opt_column;
this.groupId_ = opt_groupId; this.groupId_ = opt_groupId;
this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
this.hit_count_ = 0; this.hit_count_ = 0;
this.active_ = true; this.active_ = true;
this.condition_ = null; this.condition_ = null;
...@@ -276,7 +285,8 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, ...@@ -276,7 +285,8 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
//Creates a clone of script breakpoint that is linked to another script. //Creates a clone of script breakpoint that is linked to another script.
ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) {
var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
other_script.id, this.line_, this.column_, this.groupId_); other_script.id, this.line_, this.column_, this.groupId_,
this.position_alignment_);
copy.number_ = next_break_point_number++; copy.number_ = next_break_point_number++;
script_break_points.push(copy); script_break_points.push(copy);
...@@ -443,7 +453,9 @@ ScriptBreakPoint.prototype.set = function (script) { ...@@ -443,7 +453,9 @@ ScriptBreakPoint.prototype.set = function (script) {
// Create a break point object and set the break point. // Create a break point object and set the break point.
break_point = MakeBreakPoint(position, this); break_point = MakeBreakPoint(position, this);
break_point.setIgnoreCount(this.ignoreCount()); break_point.setIgnoreCount(this.ignoreCount());
var actual_position = %SetScriptBreakPoint(script, position, break_point); var actual_position = %SetScriptBreakPoint(script, position,
this.position_alignment_,
break_point);
if (IS_UNDEFINED(actual_position)) { if (IS_UNDEFINED(actual_position)) {
actual_position = position; actual_position = position;
} }
...@@ -509,9 +521,11 @@ Debug.breakExecution = function(f) { ...@@ -509,9 +521,11 @@ Debug.breakExecution = function(f) {
%Break(); %Break();
}; };
Debug.breakLocations = function(f) { Debug.breakLocations = function(f, opt_position_aligment) {
if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.');
return %GetBreakLocations(f); var position_aligment = IS_UNDEFINED(opt_position_aligment)
? Debug.BreakPositionAlignment.Statement : opt_position_aligment;
return %GetBreakLocations(f, position_aligment);
}; };
// Returns a Script object. If the parameter is a function the return value // Returns a Script object. If the parameter is a function the return value
...@@ -674,7 +688,8 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { ...@@ -674,7 +688,8 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, Debug.setBreakPointByScriptIdAndPosition = function(script_id, position,
condition, enabled) condition, enabled,
opt_position_alignment)
{ {
break_point = MakeBreakPoint(position); break_point = MakeBreakPoint(position);
break_point.setCondition(condition); break_point.setCondition(condition);
...@@ -682,10 +697,12 @@ Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, ...@@ -682,10 +697,12 @@ Debug.setBreakPointByScriptIdAndPosition = function(script_id, position,
break_point.disable(); break_point.disable();
} }
var scripts = this.scripts(); var scripts = this.scripts();
var position_alignment = IS_UNDEFINED(opt_position_alignment)
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
for (var i = 0; i < scripts.length; i++) { for (var i = 0; i < scripts.length; i++) {
if (script_id == scripts[i].id) { if (script_id == scripts[i].id) {
break_point.actual_position = %SetScriptBreakPoint(scripts[i], position, break_point.actual_position = %SetScriptBreakPoint(scripts[i], position,
break_point); position_alignment, break_point);
break; break;
} }
} }
...@@ -780,11 +797,11 @@ Debug.findScriptBreakPoint = function(break_point_number, remove) { ...@@ -780,11 +797,11 @@ Debug.findScriptBreakPoint = function(break_point_number, remove) {
// specified source line and column within that line. // specified source line and column within that line.
Debug.setScriptBreakPoint = function(type, script_id_or_name, Debug.setScriptBreakPoint = function(type, script_id_or_name,
opt_line, opt_column, opt_condition, opt_line, opt_column, opt_condition,
opt_groupId) { opt_groupId, opt_position_alignment) {
// Create script break point object. // Create script break point object.
var script_break_point = var script_break_point =
new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
opt_groupId); opt_groupId, opt_position_alignment);
// Assign number to the new script break point and add it. // Assign number to the new script break point and add it.
script_break_point.number_ = next_break_point_number++; script_break_point.number_ = next_break_point_number++;
...@@ -806,10 +823,12 @@ Debug.setScriptBreakPoint = function(type, script_id_or_name, ...@@ -806,10 +823,12 @@ Debug.setScriptBreakPoint = function(type, script_id_or_name,
Debug.setScriptBreakPointById = function(script_id, Debug.setScriptBreakPointById = function(script_id,
opt_line, opt_column, opt_line, opt_column,
opt_condition, opt_groupId) { opt_condition, opt_groupId,
opt_position_alignment) {
return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
script_id, opt_line, opt_column, script_id, opt_line, opt_column,
opt_condition, opt_groupId); opt_condition, opt_groupId,
opt_position_alignment);
}; };
...@@ -893,11 +912,11 @@ Debug.isBreakOnUncaughtException = function() { ...@@ -893,11 +912,11 @@ Debug.isBreakOnUncaughtException = function() {
return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught); return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
}; };
Debug.showBreakPoints = function(f, full) { Debug.showBreakPoints = function(f, full, opt_position_alignment) {
if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.');
var source = full ? this.scriptSource(f) : this.source(f); var source = full ? this.scriptSource(f) : this.source(f);
var offset = full ? this.sourcePosition(f) : 0; var offset = full ? this.sourcePosition(f) : 0;
var locations = this.breakLocations(f); var locations = this.breakLocations(f, opt_position_alignment);
if (!locations) return source; if (!locations) return source;
locations.sort(function(x, y) { return x - y; }); locations.sort(function(x, y) { return x - y; });
var result = ""; var result = "";
......
...@@ -235,17 +235,30 @@ void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) { ...@@ -235,17 +235,30 @@ void BreakLocationIterator::FindBreakLocationFromAddress(Address pc) {
// Find the break point closest to the supplied source position. // Find the break point closest to the supplied source position.
void BreakLocationIterator::FindBreakLocationFromPosition(int position) { void BreakLocationIterator::FindBreakLocationFromPosition(int position,
BreakPositionAlignment alignment) {
// Run through all break points to locate the one closest to the source // Run through all break points to locate the one closest to the source
// position. // position.
int closest_break_point = 0; int closest_break_point = 0;
int distance = kMaxInt; int distance = kMaxInt;
while (!Done()) { while (!Done()) {
int next_position;
switch (alignment) {
case STATEMENT_ALIGNED:
next_position = this->statement_position();
break;
case BREAK_POSITION_ALIGNED:
next_position = this->position();
break;
default:
UNREACHABLE();
next_position = this->statement_position();
}
// Check if this break point is closer that what was previously found. // Check if this break point is closer that what was previously found.
if (position <= statement_position() && if (position <= next_position && next_position - position < distance) {
statement_position() - position < distance) {
closest_break_point = break_point(); closest_break_point = break_point();
distance = statement_position() - position; distance = next_position - position;
// Check whether we can't get any closer. // Check whether we can't get any closer.
if (distance == 0) break; if (distance == 0) break;
} }
...@@ -1190,7 +1203,7 @@ void Debug::SetBreakPoint(Handle<JSFunction> function, ...@@ -1190,7 +1203,7 @@ void Debug::SetBreakPoint(Handle<JSFunction> function,
// Find the break point and change it. // Find the break point and change it.
BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS);
it.FindBreakLocationFromPosition(*source_position); it.FindBreakLocationFromPosition(*source_position, STATEMENT_ALIGNED);
it.SetBreakPoint(break_point_object); it.SetBreakPoint(break_point_object);
*source_position = it.position(); *source_position = it.position();
...@@ -1202,7 +1215,8 @@ void Debug::SetBreakPoint(Handle<JSFunction> function, ...@@ -1202,7 +1215,8 @@ void Debug::SetBreakPoint(Handle<JSFunction> function,
bool Debug::SetBreakPointForScript(Handle<Script> script, bool Debug::SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object, Handle<Object> break_point_object,
int* source_position) { int* source_position,
BreakPositionAlignment alignment) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
PrepareForBreakPoints(); PrepareForBreakPoints();
...@@ -1233,7 +1247,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, ...@@ -1233,7 +1247,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
// Find the break point and change it. // Find the break point and change it.
BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS);
it.FindBreakLocationFromPosition(position); it.FindBreakLocationFromPosition(position, alignment);
it.SetBreakPoint(break_point_object); it.SetBreakPoint(break_point_object);
*source_position = it.position() + shared->start_position(); *source_position = it.position() + shared->start_position();
...@@ -1687,7 +1701,8 @@ Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { ...@@ -1687,7 +1701,8 @@ Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) {
// Simple function for returning the source positions for active break points. // Simple function for returning the source positions for active break points.
Handle<Object> Debug::GetSourceBreakLocations( Handle<Object> Debug::GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared) { Handle<SharedFunctionInfo> shared,
BreakPositionAlignment position_alignment) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
if (!HasDebugInfo(shared)) { if (!HasDebugInfo(shared)) {
...@@ -1705,7 +1720,20 @@ Handle<Object> Debug::GetSourceBreakLocations( ...@@ -1705,7 +1720,20 @@ Handle<Object> Debug::GetSourceBreakLocations(
BreakPointInfo* break_point_info = BreakPointInfo* break_point_info =
BreakPointInfo::cast(debug_info->break_points()->get(i)); BreakPointInfo::cast(debug_info->break_points()->get(i));
if (break_point_info->GetBreakPointCount() > 0) { if (break_point_info->GetBreakPointCount() > 0) {
locations->set(count++, break_point_info->statement_position()); Smi* position;
switch (position_alignment) {
case STATEMENT_ALIGNED:
position = break_point_info->statement_position();
break;
case BREAK_POSITION_ALIGNED:
position = break_point_info->source_position();
break;
default:
UNREACHABLE();
position = break_point_info->statement_position();
}
locations->set(count++, position);
} }
} }
} }
......
...@@ -79,6 +79,14 @@ enum BreakLocatorType { ...@@ -79,6 +79,14 @@ enum BreakLocatorType {
}; };
// The different types of breakpoint position alignments.
// Must match Debug.BreakPositionAlignment in debug-debugger.js
enum BreakPositionAlignment {
STATEMENT_ALIGNED = 0,
BREAK_POSITION_ALIGNED = 1
};
// Class for iterating through the break points in a function and changing // Class for iterating through the break points in a function and changing
// them. // them.
class BreakLocationIterator { class BreakLocationIterator {
...@@ -90,7 +98,8 @@ class BreakLocationIterator { ...@@ -90,7 +98,8 @@ class BreakLocationIterator {
void Next(); void Next();
void Next(int count); void Next(int count);
void FindBreakLocationFromAddress(Address pc); void FindBreakLocationFromAddress(Address pc);
void FindBreakLocationFromPosition(int position); void FindBreakLocationFromPosition(int position,
BreakPositionAlignment alignment);
void Reset(); void Reset();
bool Done() const; bool Done() const;
void SetBreakPoint(Handle<Object> break_point_object); void SetBreakPoint(Handle<Object> break_point_object);
...@@ -241,7 +250,8 @@ class Debug { ...@@ -241,7 +250,8 @@ class Debug {
int* source_position); int* source_position);
bool SetBreakPointForScript(Handle<Script> script, bool SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object, Handle<Object> break_point_object,
int* source_position); int* source_position,
BreakPositionAlignment alignment);
void ClearBreakPoint(Handle<Object> break_point_object); void ClearBreakPoint(Handle<Object> break_point_object);
void ClearAllBreakPoints(); void ClearAllBreakPoints();
void FloodWithOneShot(Handle<JSFunction> function); void FloodWithOneShot(Handle<JSFunction> function);
...@@ -284,7 +294,8 @@ class Debug { ...@@ -284,7 +294,8 @@ class Debug {
static Handle<Code> FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode); static Handle<Code> FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode);
static Handle<Object> GetSourceBreakLocations( static Handle<Object> GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared); Handle<SharedFunctionInfo> shared,
BreakPositionAlignment position_aligment);
// Getter for the debug_context. // Getter for the debug_context.
inline Handle<Context> debug_context() { return debug_context_; } inline Handle<Context> debug_context() { return debug_context_; }
......
...@@ -12103,14 +12103,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { ...@@ -12103,14 +12103,28 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) {
} }
static bool IsPositionAlignmentCodeCorrect(int alignment) {
return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() == 1); ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]);
if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
return isolate->ThrowIllegalOperation();
}
BreakPositionAlignment alignment =
static_cast<BreakPositionAlignment>(statement_aligned_code);
Handle<SharedFunctionInfo> shared(fun->shared()); Handle<SharedFunctionInfo> shared(fun->shared());
// Find the number of break points // Find the number of break points
Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); Handle<Object> break_locations =
Debug::GetSourceBreakLocations(shared, alignment);
if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
// Return array as JS array // Return array as JS array
return *isolate->factory()->NewJSArrayWithElements( return *isolate->factory()->NewJSArrayWithElements(
...@@ -12143,14 +12157,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { ...@@ -12143,14 +12157,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) {
// GetScriptFromScriptData. // GetScriptFromScriptData.
// args[0]: script to set break point in // args[0]: script to set break point in
// args[1]: number: break source position (within the script source) // args[1]: number: break source position (within the script source)
// args[2]: number: break point object // args[2]: number, breakpoint position alignment
// args[3]: number: break point object
RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() == 3); ASSERT(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
RUNTIME_ASSERT(source_position >= 0); RUNTIME_ASSERT(source_position >= 0);
Handle<Object> break_point_object_arg = args.at<Object>(2); CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]);
Handle<Object> break_point_object_arg = args.at<Object>(3);
if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
return isolate->ThrowIllegalOperation();
}
BreakPositionAlignment alignment =
static_cast<BreakPositionAlignment>(statement_aligned_code);
// Get the script from the script wrapper. // Get the script from the script wrapper.
RUNTIME_ASSERT(wrapper->value()->IsScript()); RUNTIME_ASSERT(wrapper->value()->IsScript());
...@@ -12158,7 +12180,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { ...@@ -12158,7 +12180,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
// Set break point. // Set break point.
if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
&source_position)) { &source_position,
alignment)) {
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
} }
......
...@@ -499,9 +499,9 @@ namespace internal { ...@@ -499,9 +499,9 @@ namespace internal {
F(GetThreadCount, 1, 1) \ F(GetThreadCount, 1, 1) \
F(GetThreadDetails, 2, 1) \ F(GetThreadDetails, 2, 1) \
F(SetDisableBreak, 1, 1) \ F(SetDisableBreak, 1, 1) \
F(GetBreakLocations, 1, 1) \ F(GetBreakLocations, 2, 1) \
F(SetFunctionBreakPoint, 3, 1) \ F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 3, 1) \ F(SetScriptBreakPoint, 4, 1) \
F(ClearBreakPoint, 1, 1) \ F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \ F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \ F(IsBreakOnException, 1, 1) \
......
...@@ -509,7 +509,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env, ...@@ -509,7 +509,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); Handle<v8::internal::SharedFunctionInfo> shared(fun->shared());
CHECK(Debug::HasDebugInfo(shared)); CHECK(Debug::HasDebugInfo(shared));
TestBreakLocationIterator it1(Debug::GetDebugInfo(shared)); TestBreakLocationIterator it1(Debug::GetDebugInfo(shared));
it1.FindBreakLocationFromPosition(position); it1.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode(); v8::internal::RelocInfo::Mode actual_mode = it1.it()->rinfo()->rmode();
if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
actual_mode = v8::internal::RelocInfo::CODE_TARGET; actual_mode = v8::internal::RelocInfo::CODE_TARGET;
...@@ -528,7 +528,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env, ...@@ -528,7 +528,7 @@ void CheckDebugBreakFunction(DebugLocalContext* env,
CHECK(!debug->HasDebugInfo(shared)); CHECK(!debug->HasDebugInfo(shared));
CHECK(debug->EnsureDebugInfo(shared, fun)); CHECK(debug->EnsureDebugInfo(shared, fun));
TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); TestBreakLocationIterator it2(Debug::GetDebugInfo(shared));
it2.FindBreakLocationFromPosition(position); it2.FindBreakLocationFromPosition(position, v8::internal::STATEMENT_ALIGNED);
actual_mode = it2.it()->rinfo()->rmode(); actual_mode = it2.it()->rinfo()->rmode();
if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) { if (actual_mode == v8::internal::RelocInfo::CODE_TARGET_WITH_ID) {
actual_mode = v8::internal::RelocInfo::CODE_TARGET; actual_mode = v8::internal::RelocInfo::CODE_TARGET;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// Get the Debug object exposed from the debug context global object. // Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
function f() {a=1;b=2}; function f() {a=1;b=2}
function g() { function g() {
a=1; a=1;
b=2; b=2;
...@@ -121,13 +121,13 @@ assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); ...@@ -121,13 +121,13 @@ assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0);
// Tests for setting break points by script id and position. // Tests for setting break points by script id and position.
function setBreakpointByPosition(f, position) function setBreakpointByPosition(f, position, opt_position_alignment)
{ {
var break_point = Debug.setBreakPointByScriptIdAndPosition( var break_point = Debug.setBreakPointByScriptIdAndPosition(
Debug.findScript(f).id, Debug.findScript(f).id,
position + Debug.sourcePosition(f), position + Debug.sourcePosition(f),
"", "",
true); true, opt_position_alignment);
return break_point.number(); return break_point.number();
} }
...@@ -204,3 +204,22 @@ Debug.clearBreakPoint(bp3); ...@@ -204,3 +204,22 @@ Debug.clearBreakPoint(bp3);
//b=2; //b=2;
//} //}
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0);
// Tests for setting break points without statement aligment.
// (This may be sensitive to compiler break position map generation).
function h() {a=f(f2(1,2),f3())+f3();b=f3();}
var scenario = [
[5, "{a[B0]=f"],
[6, "{a=[B0]f("],
[7, "{a=f([B0]f2("],
[16, "f2(1,2),[B0]f3()"],
[22, "+[B0]f3()"]
];
for(var i = 0; i < scenario.length; i++) {
bp1 = setBreakpointByPosition(h, scenario[i][0],
Debug.BreakPositionAlignment.BreakPosition);
assertTrue(Debug.showBreakPoints(h, undefined,
Debug.BreakPositionAlignment.BreakPosition).indexOf(scenario[i][1]) > 0);
Debug.clearBreakPoint(bp1);
}
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