Revert "Debug: support breakpoints set in the middle of statement"
authorprybin@chromium.org <prybin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 1 Jul 2013 13:05:21 +0000 (13:05 +0000)
committerprybin@chromium.org <prybin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 1 Jul 2013 13:05:21 +0000 (13:05 +0000)
Review URL: https://codereview.chromium.org/18326007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15418 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/debug-debugger.js
src/debug.cc
src/debug.h
src/runtime.cc
src/runtime.h
test/cctest/test-debug.cc
test/mjsunit/debug-breakpoints.js

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