Web Inspector: hook up probe samples to TimelineAgent's records
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 05:53:51 +0000 (05:53 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 05:53:51 +0000 (05:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131127

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/ScriptDebugListener.h: Add a proper forward declaration for ScriptBreakpointAction.

Source/WebCore:

Hook up probe callbacks from ScriptDebugListener so that timeline records are
created for probe samples. The record includes the probe identifier and hit count.
The actual probe evaluation result is sent separately by DebuggerAgent, and
can be looked up in frontend models using the identifier and hit count.

* inspector/InspectorTimelineAgent.cpp: Only listen to the debug server when recording.
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::stop):
(WebCore::InspectorTimelineAgent::breakpointActionProbe):
(WebCore::toProtocol):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createProbeSampleData):
* inspector/TimelineRecordFactory.h:
* inspector/protocol/Timeline.json: Add new enum value.

Source/WebInspectorUI:

* UserInterface/Controllers/TimelineManager.js: Stub out a case for the ProbeSample record type.
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
(WebInspector.TimelineManager.prototype.eventRecorded):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166827 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/ScriptDebugListener.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebCore/inspector/protocol/Timeline.json
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

index 1ae282ef6a7cbf58fc007429ccd5da05543547f1..c2a9bb9aee5dd7043ff99ba37915ba1f355c2dc1 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-03  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Inspector: hook up probe samples to TimelineAgent's records
+        https://bugs.webkit.org/show_bug.cgi?id=131127
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/ScriptDebugListener.h: Add a proper forward declaration for ScriptBreakpointAction.
+
 2014-04-04  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r166820.
index cb010aae3ad11417319ddf0c70f32ea8ae233594..3bdbcd823fb9148fa2b6f3ceb2527fae9a39e2aa 100644 (file)
@@ -40,6 +40,8 @@ class ScriptValue;
 
 namespace Inspector {
 
+struct ScriptBreakpointAction;
+
 class ScriptDebugListener {
 public:
     class Script {
index 81f6babcf951638deac6ccdb926ffaa56228185f..3b4d95a1815add22e7e1ae081571feab3795f8e3 100644 (file)
@@ -1,3 +1,26 @@
+2014-04-03  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Inspector: hook up probe samples to TimelineAgent's records
+        https://bugs.webkit.org/show_bug.cgi?id=131127
+
+        Reviewed by Timothy Hatcher.
+
+        Hook up probe callbacks from ScriptDebugListener so that timeline records are
+        created for probe samples. The record includes the probe identifier and hit count.
+        The actual probe evaluation result is sent separately by DebuggerAgent, and
+        can be looked up in frontend models using the identifier and hit count.
+
+        * inspector/InspectorTimelineAgent.cpp: Only listen to the debug server when recording.
+        (WebCore::InspectorTimelineAgent::start):
+        (WebCore::InspectorTimelineAgent::stop):
+        (WebCore::InspectorTimelineAgent::breakpointActionProbe):
+        (WebCore::toProtocol):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createProbeSampleData):
+        * inspector/TimelineRecordFactory.h:
+        * inspector/protocol/Timeline.json: Add new enum value.
+
 2014-04-04  Andreas Kling  <akling@apple.com>
 
         Streamline cached wrapper lookup for Nodes in the normal world.
index a188614afe8138c590e299b1c6175665c30fae49..68964918f3f530437818120968aefec76e8a0492 100644 (file)
@@ -1,5 +1,6 @@
 /*
 * Copyright (C) 2013 Google Inc. All rights reserved.
+* Copyright (C) 2014 University of Washington.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 #include "InstrumentingAgents.h"
 #include "IntRect.h"
 #include "JSDOMWindow.h"
+#include "PageScriptDebugServer.h"
 #include "RenderElement.h"
 #include "RenderView.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
 #include "ScriptProfiler.h"
+#include "ScriptState.h"
 #include "TimelineRecordFactory.h"
 #include <inspector/IdentifiersFactory.h>
+#include <inspector/ScriptBreakpoint.h>
 #include <wtf/CurrentTime.h>
 
 using namespace Inspector;
@@ -94,6 +98,7 @@ void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth)
     m_timeConverter.reset();
 
     m_instrumentingAgents->setInspectorTimelineAgent(this);
+    PageScriptDebugServer::shared().addListener(this, page());
     m_enabled = true;
 }
 
@@ -104,6 +109,7 @@ void InspectorTimelineAgent::stop(ErrorString*)
 
     m_weakFactory.revokeAll();
     m_instrumentingAgents->setInspectorTimelineAgent(nullptr);
+    PageScriptDebugServer::shared().removeListener(this, page(), true);
 
     clearRecordStack();
 
@@ -452,6 +458,18 @@ void InspectorTimelineAgent::didDestroyWebSocket(unsigned long identifier, Frame
 }
 #endif // ENABLE(WEB_SOCKETS)
 
+// ScriptDebugListener
+
+void InspectorTimelineAgent::breakpointActionProbe(JSC::ExecState* exec, const Inspector::ScriptBreakpointAction& action, int hitCount, const Deprecated::ScriptValue&)
+{
+    ASSERT(exec);
+
+    ScriptExecutionContext* context = scriptExecutionContextFromExecState(exec);
+    Document* document = (context && context->isDocument()) ? toDocument(context) : nullptr;
+    Frame* frame = document ? document->frame() : nullptr;
+    appendRecord(TimelineRecordFactory::createProbeSampleData(action, hitCount), TimelineRecordType::ProbeSample, false, frame);
+}
+
 void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<InspectorObject> record, TimelineRecordType type)
 {
     commitFrameRecord();
@@ -525,6 +543,8 @@ static Inspector::TypeBuilder::Timeline::EventType::Enum toProtocol(TimelineReco
 
     case TimelineRecordType::FunctionCall:
         return Inspector::TypeBuilder::Timeline::EventType::FunctionCall;
+    case TimelineRecordType::ProbeSample:
+        return Inspector::TypeBuilder::Timeline::EventType::ProbeSample;
 
     case TimelineRecordType::RequestAnimationFrame:
         return Inspector::TypeBuilder::Timeline::EventType::RequestAnimationFrame;
index f36c503338013395d5c5dd16388f528ad0a05e27..83176ce716137a5edbf18b25430f1debdf05b198 100644 (file)
@@ -1,5 +1,6 @@
 /*
 * Copyright (C) 2012 Google Inc. All rights reserved.
+* Copyright (C) 2014 University of Washington.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -38,6 +39,7 @@
 #include "InspectorWebFrontendDispatchers.h"
 #include "LayoutRect.h"
 #include <inspector/InspectorValues.h>
+#include <inspector/ScriptDebugListener.h>
 #include <wtf/Vector.h>
 #include <wtf/WeakPtr.h>
 
@@ -95,6 +97,7 @@ enum class TimelineRecordType {
     XHRLoad,
 
     FunctionCall,
+    ProbeSample,
 
     RequestAnimationFrame,
     CancelAnimationFrame,
@@ -121,7 +124,8 @@ private:
 
 class InspectorTimelineAgent
     : public InspectorAgentBase
-    , public Inspector::InspectorTimelineBackendDispatcherHandler {
+    , public Inspector::InspectorTimelineBackendDispatcherHandler
+    , public Inspector::ScriptDebugListener {
     WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
 public:
     enum InspectorType { PageInspector, WorkerInspector };
@@ -211,6 +215,17 @@ public:
     void didDestroyWebSocket(unsigned long identifier, Frame*);
 #endif
 
+protected:
+    // ScriptDebugListener. This is only used to create records for probe samples.
+    virtual void didParseSource(JSC::SourceID, const Script&) override { }
+    virtual void failedToParseSource(const String&, const String&, int, int, const String&) override { }
+    virtual void didPause(JSC::ExecState*, const Deprecated::ScriptValue&, const Deprecated::ScriptValue&) override { }
+    virtual void didContinue() override { }
+
+    virtual void breakpointActionLog(JSC::ExecState*, const String&) override { }
+    virtual void breakpointActionSound(int) override { }
+    virtual void breakpointActionProbe(JSC::ExecState*, const Inspector::ScriptBreakpointAction&, int hitCount, const Deprecated::ScriptValue& result) override;
+
 private:
     friend class TimelineRecordStack;
 
index 2d6227699f144b4d26aee950521ae3f67f302a04..c5600800b0d8a209eb6fc4cb68b720188e0ebc1d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 University of Washington.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -43,6 +44,7 @@
 #include "ResourceResponse.h"
 #include "ScriptProfile.h"
 #include <inspector/InspectorValues.h>
+#include <inspector/ScriptBreakpoint.h>
 #include <inspector/ScriptCallStack.h>
 #include <inspector/ScriptCallStackFactory.h>
 #include <wtf/CurrentTime.h>
@@ -87,6 +89,14 @@ PassRefPtr<InspectorObject> TimelineRecordFactory::createFunctionCallData(const
     return data.release();
 }
 
+PassRefPtr<InspectorObject> TimelineRecordFactory::createProbeSampleData(const ScriptBreakpointAction& action, int hitCount)
+{
+    RefPtr<InspectorObject> data = InspectorObject::create();
+    data->setNumber(ASCIILiteral("probeId"), action.identifier);
+    data->setNumber(ASCIILiteral("hitCount"), hitCount);
+    return data.release();
+}
+
 PassRefPtr<InspectorObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
 {
     RefPtr<InspectorObject> data = InspectorObject::create();
index ae37646ba93c99808f2b4c4f3145f0441208896b..2106d18f6583b21da9ece53c2704752e44892c2b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2014 University of Washington.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
 #include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
 
+namespace Inspector {
+struct ScriptBreakpointAction;
+}
+
 namespace WebCore {
 
     class Event;
@@ -53,6 +58,8 @@ namespace WebCore {
 
         static PassRefPtr<Inspector::InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine);
 
+        static PassRefPtr<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, int hitCount);
+
         static PassRefPtr<Inspector::InspectorObject> createEventDispatchData(const Event&);
 
         static PassRefPtr<Inspector::InspectorObject> createGenericTimerData(int timerId);
index 45c26c273ae7eb5ad55788599b536303aadacde4..213142137bc44aca4b6b9372a56843455b5a660f 100644 (file)
@@ -5,7 +5,7 @@
         {
             "id": "EventType",
             "type": "string",
-            "enum": ["EventDispatch", "BeginFrame", "ScheduleStyleRecalculation", "RecalculateStyles", "InvalidateLayout", "Layout", "Paint", "ScrollLayer", "ResizeImage", "CompositeLayers", "ParseHTML", "TimerInstall", "TimerRemove", "TimerFire", "EvaluateScript", "MarkLoad", "MarkDOMContent", "TimeStamp", "Time", "TimeEnd", "ScheduleResourceRequest", "ResourceSendRequest", "ResourceReceiveResponse", "ResourceReceivedData", "ResourceFinish", "XHRReadyStateChange", "XHRLoad", "FunctionCall", "GCEvent", "RequestAnimationFrame", "CancelAnimationFrame", "FireAnimationFrame", "WebSocketCreate", "WebSocketSendHandshakeRequest", "WebSocketReceiveHandshakeResponse", "WebSocketDestroy"],
+            "enum": ["EventDispatch", "BeginFrame", "ScheduleStyleRecalculation", "RecalculateStyles", "InvalidateLayout", "Layout", "Paint", "ScrollLayer", "ResizeImage", "CompositeLayers", "ParseHTML", "TimerInstall", "TimerRemove", "TimerFire", "EvaluateScript", "MarkLoad", "MarkDOMContent", "TimeStamp", "Time", "TimeEnd", "ScheduleResourceRequest", "ResourceSendRequest", "ResourceReceiveResponse", "ResourceReceivedData", "ResourceFinish", "XHRReadyStateChange", "XHRLoad", "FunctionCall", "ProbeSample", "GCEvent", "RequestAnimationFrame", "CancelAnimationFrame", "FireAnimationFrame", "WebSocketCreate", "WebSocketSendHandshakeRequest", "WebSocketReceiveHandshakeResponse", "WebSocketDestroy"],
             "description": "Timeline record type."
         },
         {
index 13de30aad26128171349f5c56eecbaeb0067ed10..2b73dd0d5e89bc7e215f94f1bde9d1916c1a4a75 100644 (file)
@@ -1,3 +1,14 @@
+2014-04-03  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Inspector: hook up probe samples to TimelineAgent's records
+        https://bugs.webkit.org/show_bug.cgi?id=131127
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/TimelineManager.js: Stub out a case for the ProbeSample record type.
+        (WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
+        (WebInspector.TimelineManager.prototype.eventRecorded):
+
 2014-04-04  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: JSContext inspection Resource search throws exception
index c8094457aa0ddc8c4fcd092eb2702f806d35c9b0..503d3795444f59bc0e983da195d352ffccf6a2b2 100644 (file)
@@ -271,6 +271,10 @@ WebInspector.TimelineManager.prototype = {
 
                 break;
 
+            case TimelineAgent.EventType.ProbeSample:
+                // FIXME: Create timeline records for probe samples <https://webkit.org/b/131173>
+                break;
+
             case TimelineAgent.EventType.TimerInstall:
                 console.assert(isNaN(endTime));