Reviewers: pfeldman,

Description:
Maybe we should expose "break" command via DebuggerAgent.

This command ("break") is intentionally non-JSON, as it corresponds to
the fact that JavaScript VM is being busy right now so we can't parse
JSON.
This command has higher QoS that other commands, because it evades
normal command queue.

Please review this at http://codereview.chromium.org/160605

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/debug.cc


Index: src/debug.cc
===================================================================
--- src/debug.cc        (revision 2564)
+++ src/debug.cc        (working copy)
@@ -2264,12 +2264,35 @@
  }


+static bool CompareAsciiWithUtf16(const char* s1, Vector<const uint16_t>  
s2) {
+  const char* p = s1;
+  int i = 0;
+  while (*p != '\0' && i < s2.length()) {
+    if (static_cast<uint16_t>(*p) != s2[i]) {
+      return false;
+    }
+    ++p;
+    ++i;
+  }
+
+  return *p == '\0' && i == s2.length();
+}
+
+
  // Puts a command coming from the public API on the queue.  Creates
  // a copy of the command string managed by the debugger.  Up to this
  // point, the command data was managed by the API client.  Called
  // by the API client thread.
  void Debugger::ProcessCommand(Vector<const uint16_t> command,
                                v8::Debug::ClientData* client_data) {
+  // First check for non-JSON command break. VM is supposed to be busy,
+  // so we cannot use it to handle JSON.
+  if (CompareAsciiWithUtf16("break", command)) {
+    PrintF("v8::Debug::DebugBreak()\n");
+    v8::Debug::DebugBreak();
+    return;
+  }
+
    // Need to cast away const.
    CommandMessage message = CommandMessage::New(
        Vector<uint16_t>(const_cast<uint16_t*>(command.start()),



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

Reply via email to