Author: [email protected]
Date: Wed Apr 22 06:59:48 2009
New Revision: 1770

Modified:
    branches/bleeding_edge/src/d8.js
    branches/bleeding_edge/src/debug-delay.js
    branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js

Log:
Add setting break points by using handles.

Extend the D8 break command to handle script names with :line[:column]  
position specification and handles using #<id>#.
Review URL: http://codereview.chromium.org/92011

Modified: branches/bleeding_edge/src/d8.js
==============================================================================
--- branches/bleeding_edge/src/d8.js    (original)
+++ branches/bleeding_edge/src/d8.js    Wed Apr 22 06:59:48 2009
@@ -653,17 +653,47 @@
    // Process arguments if any.
    if (args && args.length > 0) {
      var target = args;
+    var type = 'function';
+    var line;
+    var column;
      var condition;
+    var pos;

-    var pos = args.indexOf(' ');
+    // Check for breakpoint condition.
+    pos = args.indexOf(' ');
      if (pos > 0) {
        target = args.substring(0, pos);
        condition = args.substring(pos + 1, args.length);
      }

+    // Check for script breakpoint (name:line[:column]). If no ':' in break
+    // specification it is considered a function break point.
+    pos = target.indexOf(':');
+    if (pos > 0) {
+      type = 'script';
+      var tmp = target.substring(pos + 1, target.length);
+      target = target.substring(0, pos);
+
+      // Check for both line and column.
+      pos = tmp.indexOf(':');
+      if (pos > 0) {
+        column = parseInt(tmp.substring(pos + 1, tmp.length)) - 1;
+        line = parseInt(tmp.substring(0, pos)) - 1;
+      } else {
+        line = parseInt(tmp) - 1;
+      }
+    } else if (target[0] == '#' && target[target.length - 1] == '#') {
+      type = 'handle';
+      target = target.substring(1, target.length - 1);
+    } else {
+      type = 'function';
+    }
+
      request.arguments = {};
-    request.arguments.type = 'function';
+    request.arguments.type = type;
      request.arguments.target = target;
+    request.arguments.line = line;
+    request.arguments.column = column;
      request.arguments.condition = condition;
    } else {
      throw new Error('Invalid break arguments.');
@@ -721,6 +751,9 @@
    }

    print('break location [condition]');
+  print('  break on named function: location is a function name');
+  print('  break on function: location is #<id>#');
+  print('  break on script position: location is name:line[:column]');
    print('clear <breakpoint #>');
    print('backtrace [from frame #] [to frame #]]');
    print('frame <frame #>');

Modified: branches/bleeding_edge/src/debug-delay.js
==============================================================================
--- branches/bleeding_edge/src/debug-delay.js   (original)
+++ branches/bleeding_edge/src/debug-delay.js   Wed Apr 22 06:59:48 2009
@@ -1273,11 +1273,12 @@
    var ignoreCount = request.arguments.ignoreCount;

    // Check for legal arguments.
-  if (!type || !target) {
+  if (!type || IS_UNDEFINED(target)) {
      response.failed('Missing argument "type" or "target"');
      return;
    }
-  if (type != 'function' && type != 'script' && type != 'scriptId') {
+  if (type != 'function' && type != 'handle' &&
+      type != 'script' && type != 'scriptId') {
      response.failed('Illegal type "' + type + '"');
      return;
    }
@@ -1306,6 +1307,20 @@

      // Set function break point.
      break_point_number = Debug.setBreakPoint(f, line, column, condition);
+  } else if (type == 'handle') {
+    // Find the object pointed by the specified handle.
+    var handle = parseInt(target, 10);
+    var mirror = LookupMirror(handle);
+    if (!mirror) {
+      return response.failed('Object #' + handle + '# not found');
+    }
+    if (!mirror.isFunction()) {
+      return response.failed('Object #' + handle + '# is not a function');
+    }
+
+    // Set function break point.
+    break_point_number = Debug.setBreakPoint(mirror.value(),
+                                             line, column, condition);
    } else if (type == 'script') {
      // set script break point.
      break_point_number =

Modified: branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js  (original)
+++ branches/bleeding_edge/test/mjsunit/debug-setbreakpoint.js  Wed Apr 22  
06:59:48 2009
@@ -54,14 +54,14 @@
    var json_response = dcp.processDebugJSONRequest(request);
    var response = safeEval(json_response);
    if (success) {
-    assertTrue(response.success, json_response);
+    assertTrue(response.success, request + ' -> ' + json_response);
      if (is_script) {
-      assertEquals('scriptName', response.body.type, json_response);
+      assertEquals('scriptName', response.body.type, request + ' -> ' +  
json_response);
      } else {
-      assertEquals('scriptId', response.body.type, json_response);
+      assertEquals('scriptId', response.body.type, request + ' -> ' +  
json_response);
      }
    } else {
-    assertFalse(response.success, json_response);
+    assertFalse(response.success, request + ' -> ' + json_response);
    }
  }

@@ -75,6 +75,8 @@
      var request = '{' + base_request + '}'
      var response = safeEval(dcp.processDebugJSONRequest(request));
      assertFalse(response.success);
+
+    var mirror;

      testArguments(dcp, '{}', false);
      testArguments(dcp, '{"type":"xx"}', false);
@@ -86,6 +88,9 @@
      testArguments(dcp, '{"type":"function","target":"f","line":-1}',  
false);
      testArguments(dcp, '{"type":"function","target":"f","column":-1}',  
false);
       
testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}',  
false);
+    testArguments(dcp, '{"type":"handle","target":"-1"}', false);
+    mirror = debug.MakeMirror(o);
+    testArguments(dcp, '{"type":"handle","target":' + mirror.handle()  
+ '}', false);

      // Test some legal setbreakpoint requests.
      testArguments(dcp, '{"type":"function","target":"f"}', true, false);
@@ -106,6 +111,11 @@
      testArguments(dcp, '{"type":"scriptId","target":' + g_script_id  
+ ',"line":' + g_line + '}', true, false);
      testArguments(dcp, '{"type":"scriptId","target":' + h_script_id  
+ ',"line":' + h_line + '}', true, false);

+    mirror = debug.MakeMirror(f);
+    testArguments(dcp, '{"type":"handle","target":' + mirror.handle()  
+ '}', true, false);
+    mirror = debug.MakeMirror(o.a);
+    testArguments(dcp, '{"type":"handle","target":' + mirror.handle()  
+ '}', true, false);
+
      // Indicate that all was processed.
      listenerComplete = true;
    }
@@ -126,6 +136,8 @@
  };

  eval('function h(){}');
+
+o = {a:function(){},b:function(){}}

  // Check the script ids for the test functions.
  f_script_id = Debug.findScript(f).id;

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to