Revision: 3382
Author: [email protected]
Date: Mon Nov 30 06:56:20 2009
Log: Add pause / resume profiling commands to debugger protocol.

This allows to profile "unresponsive" web pages in the same way
as it is possible to break into them with the debugger.

BUG=http://code.google.com/p/chromium/issues/detail?id=28689

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

Modified:
  /branches/bleeding_edge/src/debug-delay.js
  /branches/bleeding_edge/src/runtime.cc
  /branches/bleeding_edge/src/runtime.h

=======================================
--- /branches/bleeding_edge/src/debug-delay.js  Wed Oct 21 10:07:43 2009
+++ /branches/bleeding_edge/src/debug-delay.js  Mon Nov 30 06:56:20 2009
@@ -1245,6 +1245,8 @@
          this.suspendRequest_(request, response);
        } else if (request.command == 'version') {
          this.versionRequest_(request, response);
+      } else if (request.command == 'profile') {
+        this.profileRequest_(request, response);
        } else {
          throw new Error('Unknown command "' + request.command + '" in  
request');
        }
@@ -1924,6 +1926,25 @@
  };


+DebugCommandProcessor.prototype.profileRequest_ = function(request,  
response) {
+  if (!request.arguments) {
+    return response.failed('Missing arguments');
+  }
+  var modules = parseInt(request.arguments.modules);
+  if (isNaN(modules)) {
+    return response.failed('Modules is not an integer');
+  }
+  if (request.arguments.command == 'resume') {
+    %ProfilerResume(modules);
+  } else if (request.arguments.command == 'pause') {
+    %ProfilerPause(modules);
+  } else {
+    return response.failed('Unknown command');
+  }
+  response.body = {};
+};
+
+
  // Check whether the previously processed command caused the VM to become
  // running.
  DebugCommandProcessor.prototype.isRunning = function() {
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Nov 25 07:45:37 2009
+++ /branches/bleeding_edge/src/runtime.cc      Mon Nov 30 06:56:20 2009
@@ -7691,8 +7691,31 @@
    CONVERT_CHECKED(JSFunction, f, args[0]);
    return f->shared()->inferred_name();
  }
+
  #endif  // ENABLE_DEBUGGER_SUPPORT

+#ifdef ENABLE_LOGGING_AND_PROFILING
+
+static Object* Runtime_ProfilerResume(Arguments args) {
+  NoHandleAllocation ha;
+  ASSERT(args.length() == 1);
+
+  CONVERT_CHECKED(Smi, smi_modules, args[0]);
+  Logger::ResumeProfiler(smi_modules->value());
+  return Heap::undefined_value();
+}
+
+
+static Object* Runtime_ProfilerPause(Arguments args) {
+  NoHandleAllocation ha;
+  ASSERT(args.length() == 1);
+
+  CONVERT_CHECKED(Smi, smi_modules, args[0]);
+  Logger::PauseProfiler(smi_modules->value());
+  return Heap::undefined_value();
+}
+
+#endif  // ENABLE_LOGGING_AND_PROFILING

  // Finds the script object from the script data. NOTE: This operation uses
  // heap traversal to find the function generated for the source position
=======================================
--- /branches/bleeding_edge/src/runtime.h       Tue Nov 10 05:23:05 2009
+++ /branches/bleeding_edge/src/runtime.h       Mon Nov 30 06:56:20 2009
@@ -318,6 +318,14 @@
  #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
  #endif

+#ifdef ENABLE_LOGGING_AND_PROFILING
+#define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) \
+  F(ProfilerResume, 1, 1) \
+  F(ProfilerPause, 1, 1)
+#else
+#define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F)
+#endif
+
  #ifdef DEBUG
  #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
    /* Testing */ \
@@ -336,7 +344,8 @@
    RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
    RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
    RUNTIME_FUNCTION_LIST_DEBUG(F) \
-  RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
+  RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
+  RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F)

  //  
----------------------------------------------------------------------------
  // Runtime provides access to all C++ runtime functions.

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

Reply via email to