Breakpoint position should be inside function body.

Review URL: http://codereview.chromium.org/2883042

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5145 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3607a9e7
...@@ -224,7 +224,7 @@ void FullCodeGenerator::EmitReturnSequence() { ...@@ -224,7 +224,7 @@ void FullCodeGenerator::EmitReturnSequence() {
// Here we use masm_-> instead of the __ macro to avoid the code coverage // Here we use masm_-> instead of the __ macro to avoid the code coverage
// tool from instrumenting as we rely on the code size here. // tool from instrumenting as we rely on the code size here.
int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize;
CodeGenerator::RecordPositions(masm_, function()->end_position()); CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
__ RecordJSReturn(); __ RecordJSReturn();
masm_->mov(sp, fp); masm_->mov(sp, fp);
masm_->ldm(ia_w, sp, fp.bit() | lr.bit()); masm_->ldm(ia_w, sp, fp.bit() | lr.bit());
......
...@@ -433,7 +433,7 @@ void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) { ...@@ -433,7 +433,7 @@ void CodeGenerator::CodeForFunctionPosition(FunctionLiteral* fun) {
void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) { void CodeGenerator::CodeForReturnPosition(FunctionLiteral* fun) {
if (FLAG_debug_info) RecordPositions(masm(), fun->end_position(), false); if (FLAG_debug_info) RecordPositions(masm(), fun->end_position() - 1, false);
} }
......
...@@ -170,7 +170,7 @@ void BreakLocationIterator::Next() { ...@@ -170,7 +170,7 @@ void BreakLocationIterator::Next() {
// Set the positions to the end of the function. // Set the positions to the end of the function.
if (debug_info_->shared()->HasSourceCode()) { if (debug_info_->shared()->HasSourceCode()) {
position_ = debug_info_->shared()->end_position() - position_ = debug_info_->shared()->end_position() -
debug_info_->shared()->start_position(); debug_info_->shared()->start_position() - 1;
} else { } else {
position_ = 0; position_ = 0;
} }
......
...@@ -770,7 +770,7 @@ void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { ...@@ -770,7 +770,7 @@ void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) {
void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) {
if (FLAG_debug_info) { if (FLAG_debug_info) {
CodeGenerator::RecordPositions(masm_, fun->end_position()); CodeGenerator::RecordPositions(masm_, fun->end_position() - 1);
} }
} }
......
...@@ -207,7 +207,7 @@ void FullCodeGenerator::EmitReturnSequence() { ...@@ -207,7 +207,7 @@ void FullCodeGenerator::EmitReturnSequence() {
Label check_exit_codesize; Label check_exit_codesize;
masm_->bind(&check_exit_codesize); masm_->bind(&check_exit_codesize);
#endif #endif
CodeGenerator::RecordPositions(masm_, function()->end_position()); CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
__ RecordJSReturn(); __ RecordJSReturn();
// Do not use the leave instruction here because it is too short to // Do not use the leave instruction here because it is too short to
// patch with the code required by the debugger. // patch with the code required by the debugger.
......
...@@ -9387,13 +9387,6 @@ static Object* Runtime_SetScriptBreakPoint(Arguments args) { ...@@ -9387,13 +9387,6 @@ static Object* Runtime_SetScriptBreakPoint(Arguments args) {
} }
Debug::SetBreakPoint(shared, break_point_object_arg, &position); Debug::SetBreakPoint(shared, break_point_object_arg, &position);
position += shared->start_position(); position += shared->start_position();
// The result position may become beyond script source end.
// This is expected when the function is toplevel. This may become
// a problem later when actual position gets converted into line/column.
if (shared->is_toplevel() && position == shared->end_position()) {
position = shared->end_position() - 1;
}
return Smi::FromInt(position); return Smi::FromInt(position);
} }
return Heap::undefined_value(); return Heap::undefined_value();
......
...@@ -207,7 +207,7 @@ void FullCodeGenerator::EmitReturnSequence() { ...@@ -207,7 +207,7 @@ void FullCodeGenerator::EmitReturnSequence() {
Label check_exit_codesize; Label check_exit_codesize;
masm_->bind(&check_exit_codesize); masm_->bind(&check_exit_codesize);
#endif #endif
CodeGenerator::RecordPositions(masm_, function()->end_position()); CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
__ RecordJSReturn(); __ RecordJSReturn();
// Do not use the leave instruction here because it is too short to // Do not use the leave instruction here because it is too short to
// patch with the code required by the debugger. // patch with the code required by the debugger.
......
...@@ -1175,11 +1175,11 @@ TEST(BreakPointReturn) { ...@@ -1175,11 +1175,11 @@ TEST(BreakPointReturn) {
foo->Call(env->Global(), 0, NULL); foo->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count); CHECK_EQ(1, break_point_hit_count);
CHECK_EQ(0, last_source_line); CHECK_EQ(0, last_source_line);
CHECK_EQ(16, last_source_column); CHECK_EQ(15, last_source_column);
foo->Call(env->Global(), 0, NULL); foo->Call(env->Global(), 0, NULL);
CHECK_EQ(2, break_point_hit_count); CHECK_EQ(2, break_point_hit_count);
CHECK_EQ(0, last_source_line); CHECK_EQ(0, last_source_line);
CHECK_EQ(16, last_source_column); CHECK_EQ(15, last_source_column);
// Run without breakpoints. // Run without breakpoints.
ClearBreakPoint(bp); ClearBreakPoint(bp);
......
...@@ -43,12 +43,12 @@ bp1 = Debug.setBreakPoint(f, 0, 8); ...@@ -43,12 +43,12 @@ bp1 = Debug.setBreakPoint(f, 0, 8);
assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f));
bp2 = Debug.setBreakPoint(f, 0, 4); bp2 = Debug.setBreakPoint(f, 0, 4);
assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f)); assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f));
bp3 = Debug.setBreakPoint(f, 0, 12); bp3 = Debug.setBreakPoint(f, 0, 11);
assertEquals("() {[B0]a=1;[B1]b=2}[B2]", Debug.showBreakPoints(f)); assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp1); Debug.clearBreakPoint(bp1);
assertEquals("() {[B0]a=1;b=2}[B1]", Debug.showBreakPoints(f)); assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp2); Debug.clearBreakPoint(bp2);
assertEquals("() {a=1;b=2}[B0]", Debug.showBreakPoints(f)); assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f));
Debug.clearBreakPoint(bp3); Debug.clearBreakPoint(bp3);
assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f));
...@@ -96,21 +96,21 @@ bp3 = Debug.setBreakPoint(g, 3, 0); ...@@ -96,21 +96,21 @@ bp3 = Debug.setBreakPoint(g, 3, 0);
// }[B2] // }[B2]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("}[B2]") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B2]}") > 0);
Debug.clearBreakPoint(bp1); Debug.clearBreakPoint(bp1);
// function g() { // function g() {
// [B0]a=1; // [B0]a=1;
// b=2; // b=2;
// }[B1] // }[B1]
assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("}[B1]") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B1]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0);
Debug.clearBreakPoint(bp2); Debug.clearBreakPoint(bp2);
// function g() { // function g() {
// a=1; // a=1;
// b=2; // b=2;
// }[B0] // }[B0]
assertTrue(Debug.showBreakPoints(g).indexOf("}[B0]") > 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0);
Debug.clearBreakPoint(bp3); Debug.clearBreakPoint(bp3);
// function g() { // function g() {
......
...@@ -136,7 +136,7 @@ Debug.clearBreakPoint(bp); ...@@ -136,7 +136,7 @@ Debug.clearBreakPoint(bp);
// Conditional breakpoint which checks a local variable. // Conditional breakpoint which checks a local variable.
break_point_hit_count = 0; break_point_hit_count = 0;
bp = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0'); bp = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
g(); g();
} }
...@@ -146,8 +146,8 @@ Debug.clearBreakPoint(bp); ...@@ -146,8 +146,8 @@ Debug.clearBreakPoint(bp);
// Multiple conditional breakpoint which the same condition. // Multiple conditional breakpoint which the same condition.
break_point_hit_count = 0; break_point_hit_count = 0;
bp1 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0'); bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
bp2 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0'); bp2 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
g(); g();
} }
...@@ -159,8 +159,8 @@ Debug.clearBreakPoint(bp2); ...@@ -159,8 +159,8 @@ Debug.clearBreakPoint(bp2);
// Multiple conditional breakpoint which different conditions. // Multiple conditional breakpoint which different conditions.
break_point_hit_count = 0; break_point_hit_count = 0;
bp1 = Debug.setBreakPoint(h, 0, 23, 'a % 2 == 0'); bp1 = Debug.setBreakPoint(h, 0, 22, 'a % 2 == 0');
bp2 = Debug.setBreakPoint(h, 0, 23, '(a + 1) % 2 == 0'); bp2 = Debug.setBreakPoint(h, 0, 22, '(a + 1) % 2 == 0');
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
g(); g();
} }
......
...@@ -101,7 +101,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -101,7 +101,7 @@ function listener(event, exec_state, event_data, data) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1); exec_state.prepareStep(Debug.StepAction.StepIn, 1);
} else { } else {
// Position at the end of the function. // Position at the end of the function.
assertEquals(debugger_source_position + 51, assertEquals(debugger_source_position + 50,
exec_state.frame(0).sourcePosition()); exec_state.frame(0).sourcePosition());
// Just about to return from the function. // Just about to return from the function.
......
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