Revision: 4656
Author: [email protected]
Date: Fri May 14 08:24:25 2010
Log: Add listbreakpoints command to protocol

Review URL: http://codereview.chromium.org/2050007
http://code.google.com/p/v8/source/detail?r=4656

Modified:
 /branches/bleeding_edge/src/d8.js
 /branches/bleeding_edge/src/debug-debugger.js

=======================================
--- /branches/bleeding_edge/src/d8.js   Fri Apr 16 05:19:47 2010
+++ /branches/bleeding_edge/src/d8.js   Fri May 14 08:24:25 2010
@@ -341,6 +341,11 @@
       this.request_ = this.breakCommandToJSONRequest_(args);
       break;

+    case 'breakpoints':
+    case 'bb':
+      this.request_ = this.breakpointsCommandToJSONRequest_(args);
+      break;
+
     case 'clear':
       this.request_ = this.clearCommandToJSONRequest_(args);
       break;
@@ -770,6 +775,15 @@
 };


+DebugRequest.prototype.breakpointsCommandToJSONRequest_ = function(args) {
+  if (args && args.length > 0) {
+    throw new Error('Unexpected arguments.');
+  }
+  var request = this.createRequest('listbreakpoints');
+  return request.toJSONProtocol();
+};
+
+
 // Create a JSON request for the clear command.
 DebugRequest.prototype.clearCommandToJSONRequest_ = function(args) {
   // Build a evaluate request from the text command.
@@ -947,6 +961,39 @@
         result += body.breakpoint;
         details.text = result;
         break;
+
+      case 'listbreakpoints':
+       result = 'breakpoints: (' + body.breakpoints.length + ')';
+       for (var i = 0; i < body.breakpoints.length; i++) {
+          var breakpoint = body.breakpoints[i];
+          result += '\n id=' + breakpoint.number;
+          result += ' type=' + breakpoint.type;
+          if (breakpoint.script_id) {
+              result += ' script_id=' + breakpoint.script_id;
+          }
+          if (breakpoint.script_name) {
+              result += ' script_name=' + breakpoint.script_name;
+          }
+          result += ' line=' + breakpoint.line;
+          if (breakpoint.column != null) {
+            result += ' column=' + breakpoint.column;
+          }
+          if (breakpoint.groupId) {
+            result += ' groupId=' + breakpoint.groupId;
+          }
+          if (breakpoint.ignoreCount) {
+              result += ' ignoreCount=' + breakpoint.ignoreCount;
+          }
+          if (breakpoint.active === false) {
+            result += ' inactive';
+          }
+          if (breakpoint.condition) {
+            result += ' condition=' + breakpoint.condition;
+          }
+          result += ' hit_count=' + breakpoint.hit_count;
+       }
+       details.text = result;
+       break;

       case 'backtrace':
         if (body.totalFrames == 0) {
@@ -1136,8 +1183,8 @@

       default:
         details.text =
-            'Response for unknown command \'' + response.command + '\'' +
-            ' (' + json_response + ')';
+            'Response for unknown command \'' + response.command() + '\'' +
+            ' (' + response.raw_json() + ')';
     }
   } catch (e) {
     details.text = 'Error: "' + e + '" formatting response';
@@ -1153,6 +1200,7 @@
  * @constructor
  */
 function ProtocolPackage(json) {
+  this.raw_json_ = json;
   this.packet_ = JSON.parse(json);
   this.refs_ = [];
   if (this.packet_.refs) {
@@ -1241,6 +1289,11 @@
     return new ProtocolReference(handle);
   }
 }
+
+
+ProtocolPackage.prototype.raw_json = function() {
+  return this.raw_json_;
+}


 function ProtocolValue(value, packet) {
=======================================
--- /branches/bleeding_edge/src/debug-debugger.js       Wed Apr 28 06:29:07 2010
+++ /branches/bleeding_edge/src/debug-debugger.js       Fri May 14 08:24:25 2010
@@ -1266,6 +1266,8 @@
         this.clearBreakPointRequest_(request, response);
       } else if (request.command == 'clearbreakpointgroup') {
         this.clearBreakPointGroupRequest_(request, response);
+      } else if (request.command == 'listbreakpoints') {
+        this.listBreakpointsRequest_(request, response);
       } else if (request.command == 'backtrace') {
         this.backtraceRequest_(request, response);
       } else if (request.command == 'frame') {
@@ -1580,6 +1582,35 @@
   // Add the cleared break point number to the response.
   response.body = { breakpoint: break_point }
 }
+
+DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, response) {
+  var array = [];
+  for (var i = 0; i < script_break_points.length; i++) {
+       var break_point = script_break_points[i];
+
+       var description = {
+         number: break_point.number(),
+         line: break_point.line(),
+         column: break_point.column(),
+         groupId: break_point.groupId(),
+         hit_count: break_point.hit_count(),
+         active: break_point.active(),
+         condition: break_point.condition(),
+         ignoreCount: break_point.ignoreCount()
+       }
+
+    if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
+      description.type = 'scriptId';
+         description.script_id = break_point.script_id();
+    } else {
+      description.type = 'scriptName';
+      description.script_name = break_point.script_name();
+    }
+       array.push(description);
+  }
+
+  response.body = { breakpoints: array }
+}


DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) {

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

Reply via email to