Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index fa881eb203bc2a1e1d6693b403d6d433efcbf2a9..0b5698b180f243b2c1e6e68cc2ab4aa1ca1eed7f 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -9342,6 +9342,13 @@ static Object* Runtime_SetScriptBreakPoint(Arguments args) { |
} |
Debug::SetBreakPoint(shared, break_point_object_arg, &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 Heap::undefined_value(); |