Web Inspector: the max depth of the Timeline events' stack trace should be customizable.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 13:38:02 +0000 (13:38 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jul 2011 13:38:02 +0000 (13:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65023

Reviewed by Yury Semikhatsky.

* inspector/Inspector.json:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::startTimelineProfiler):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::pushGCEventRecords):
(WebCore::InspectorTimelineAgent::restore):
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::didInstallTimer):
(WebCore::InspectorTimelineAgent::didRemoveTimer):
(WebCore::InspectorTimelineAgent::didScheduleResourceRequest):
(WebCore::InspectorTimelineAgent::willSendResourceRequest):
(WebCore::InspectorTimelineAgent::didFinishLoadingResource):
(WebCore::InspectorTimelineAgent::didTimeStamp):
(WebCore::InspectorTimelineAgent::didMarkDOMContentEvent):
(WebCore::InspectorTimelineAgent::didMarkLoadEvent):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createGenericRecord):
* inspector/TimelineRecordFactory.h:
* inspector/front-end/TimelineManager.js:
(WebInspector.TimelineManager.prototype.start):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebCore/inspector/front-end/TimelineManager.js

index eecb29bcfe1bd049d7391af630998e5fe6befd3a..940f04c211232157c8db1501b00f6a43d67b50ed 100644 (file)
@@ -1,3 +1,34 @@
+2011-07-22  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: the max depth of the Timeline events' stack trace should be customizable.
+        https://bugs.webkit.org/show_bug.cgi?id=65023
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::startTimelineProfiler):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::pushGCEventRecords):
+        (WebCore::InspectorTimelineAgent::restore):
+        (WebCore::InspectorTimelineAgent::start):
+        (WebCore::InspectorTimelineAgent::didInstallTimer):
+        (WebCore::InspectorTimelineAgent::didRemoveTimer):
+        (WebCore::InspectorTimelineAgent::didScheduleResourceRequest):
+        (WebCore::InspectorTimelineAgent::willSendResourceRequest):
+        (WebCore::InspectorTimelineAgent::didFinishLoadingResource):
+        (WebCore::InspectorTimelineAgent::didTimeStamp):
+        (WebCore::InspectorTimelineAgent::didMarkDOMContentEvent):
+        (WebCore::InspectorTimelineAgent::didMarkLoadEvent):
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::pushCurrentRecord):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createGenericRecord):
+        * inspector/TimelineRecordFactory.h:
+        * inspector/front-end/TimelineManager.js:
+        (WebInspector.TimelineManager.prototype.start):
+
 2011-07-22  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r91024.
index 2f1a09ed8541191b95d8a6d177c841c806653496..8c8a2b4c4f409d16d4f328d7ec726b21a5982569 100644 (file)
         "commands": [
             {
                 "name": "start",
+                "parameters": [
+                    { "name": "maxCallStackDepth", "optional": true, "type": "integer", "description": "Samples JavaScript stack traces up to <code>maxCallStackDepth</code>, defaults to 5." },
+                ],
                 "description": "Starts capturing instrumentation events."
             },
             {
index 474963c4c50e613828d697c8f05e36f7ff45bc93..14d750635db99b0d5c0f9c01e4d173deeef4fc2b 100644 (file)
@@ -179,7 +179,7 @@ void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWo
 void InspectorController::startTimelineProfiler()
 {
     ErrorString error;
-    m_timelineAgent->start(&error);
+    m_timelineAgent->start(&error, 0);
 }
 
 void InspectorController::stopTimelineProfiler()
index db4d49860fa1c759e519467cee0c4a629a05df21..60b80d8736254b345d6ac3ffcf366d5c123d7632 100644 (file)
@@ -49,6 +49,7 @@ namespace WebCore {
 
 namespace TimelineAgentState {
 static const char timelineAgentEnabled[] = "timelineAgentEnabled";
+static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth";
 }
 
 namespace TimelineRecordType {
@@ -90,7 +91,7 @@ void InspectorTimelineAgent::pushGCEventRecords()
     GCEvents events = m_gcEvents;
     m_gcEvents.clear();
     for (GCEvents::iterator i = events.begin(); i != events.end(); ++i) {
-        RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(i->startTime);
+        RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(i->startTime, m_maxCallStackDepth);
         record->setObject("data", TimelineRecordFactory::createGCEventData(i->collectedBytes));
         record->setNumber("endTime", i->endTime);
         addRecordToTimeline(record.release(), TimelineRecordType::GCEvent);
@@ -122,15 +123,23 @@ void InspectorTimelineAgent::clearFrontend()
 void InspectorTimelineAgent::restore()
 {
     if (m_state->getBoolean(TimelineAgentState::timelineAgentEnabled)) {
+        m_maxCallStackDepth = m_state->getLong(TimelineAgentState::timelineMaxCallStackDepth);
         ErrorString error;
-        start(&error);
+        start(&error, &m_maxCallStackDepth);
     }
 }
 
-void InspectorTimelineAgent::start(ErrorString*)
+void InspectorTimelineAgent::start(ErrorString*, int* maxCallStackDepth)
 {
     if (!m_frontend)
         return;
+
+    if (maxCallStackDepth && *maxCallStackDepth > 0)
+        m_maxCallStackDepth = *maxCallStackDepth;
+    else
+        m_maxCallStackDepth = 5;
+    m_state->setLong(TimelineAgentState::timelineMaxCallStackDepth, m_maxCallStackDepth);
+
     m_instrumentingAgents->setInspectorTimelineAgent(this);
     ScriptGCEvent::addEventListener(this);
     m_frontend->started();
@@ -225,7 +234,7 @@ void InspectorTimelineAgent::didWriteHTML(unsigned int endLine)
 void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     record->setObject("data", TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot));
     addRecordToTimeline(record.release(), TimelineRecordType::TimerInstall);
 }
@@ -233,7 +242,7 @@ void InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool sing
 void InspectorTimelineAgent::didRemoveTimer(int timerId)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     record->setObject("data", TimelineRecordFactory::createGenericTimerData(timerId));
     addRecordToTimeline(record.release(), TimelineRecordType::TimerRemove);
 }
@@ -281,7 +290,7 @@ void InspectorTimelineAgent::didEvaluateScript()
 void InspectorTimelineAgent::didScheduleResourceRequest(const String& url)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     record->setObject("data", TimelineRecordFactory::createScheduleResourceRequestData(url));
     record->setString("type", TimelineRecordType::ScheduleResourceRequest);
     addRecordToTimeline(record.release(), TimelineRecordType::ScheduleResourceRequest);
@@ -290,7 +299,7 @@ void InspectorTimelineAgent::didScheduleResourceRequest(const String& url)
 void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     String resourceId = IdentifiersFactory::resourceId(identifier);
     record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(resourceId, request));
     record->setString("type", TimelineRecordType::ResourceSendRequest);
@@ -324,7 +333,7 @@ void InspectorTimelineAgent::didFinishLoadingResource(unsigned long identifier,
 {
     pushGCEventRecords();
     // Sometimes network stack can provide for us exact finish loading time. In the other case we will use currentTime.
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     String resourceId = IdentifiersFactory::resourceId(identifier);
     record->setObject("data", TimelineRecordFactory::createResourceFinishData(resourceId, didFail, finishTime * 1000));
     record->setString("type", TimelineRecordType::ResourceFinish);
@@ -335,7 +344,7 @@ void InspectorTimelineAgent::didFinishLoadingResource(unsigned long identifier,
 void InspectorTimelineAgent::didTimeStamp(const String& message)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     record->setObject("data", TimelineRecordFactory::createTimeStampData(message));
     addRecordToTimeline(record.release(), TimelineRecordType::TimeStamp);
 }
@@ -343,14 +352,14 @@ void InspectorTimelineAgent::didTimeStamp(const String& message)
 void InspectorTimelineAgent::didMarkDOMContentEvent()
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     addRecordToTimeline(record.release(), TimelineRecordType::MarkDOMContent);
 }
 
 void InspectorTimelineAgent::didMarkLoadEvent()
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     addRecordToTimeline(record.release(), TimelineRecordType::MarkLoad);
 }
 
@@ -403,13 +412,14 @@ InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentin
     , m_state(state)
     , m_frontend(0)
     , m_id(1)
+    , m_maxCallStackDepth(5)
 {
 }
 
 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, const String& type)
 {
     pushGCEventRecords();
-    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
+    RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS(), m_maxCallStackDepth);
     m_recordStack.append(TimelineRecordEntry(record.release(), data, InspectorArray::create(), type));
 }
 
index 816dce9a3cc58962d1061a8492b0aaa5cbe945ca..91f49420e63e2f46e6920cadfc2e95f4a604de9b 100644 (file)
@@ -65,8 +65,8 @@ public:
     void clearFrontend();
     void restore();
 
-    void start(ErrorString* error);
-    void stop(ErrorString* error);
+    void start(ErrorString*, int* maxCallStackDepth);
+    void stop(ErrorString*);
     bool started() const;
 
     int id() const { return m_id; }
@@ -163,6 +163,7 @@ private:
     };
     typedef Vector<GCEvent> GCEvents;
     GCEvents m_gcEvents;
+    int m_maxCallStackDepth;
 };
 
 } // namespace WebCore
index 42808a764cf64381b30e92e5b240d317a1856b3f..9aa70226dabd1fa472f12c4550449eab3997a273 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime)
+PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth)
 {
     RefPtr<InspectorObject> record = InspectorObject::create();
     record->setNumber("startTime", startTime);
 
-    RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(5, true);
+    RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(maxCallStackDepth, true);
     if (stackTrace && stackTrace->size())
         record->setArray("stackTrace", stackTrace->buildInspectorArray());
     return record.release();
index b98d9fe26c356f682582509e59b5493524146276..dad55f2e5cfda715ae25a40e7ef0b119c3e10e57 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
 
     class TimelineRecordFactory {
     public:
-        static PassRefPtr<InspectorObject> createGenericRecord(double startTime);
+        static PassRefPtr<InspectorObject> createGenericRecord(double startTime, int maxCallStackDepth);
 
         static PassRefPtr<InspectorObject> createGCEventData(const size_t usedHeapSizeDelta);
 
index a629ad6d431ab32c379631432de28522ad1ea942..192b557853a3a554e23d6e9796e9e557958b8708 100644 (file)
@@ -42,11 +42,11 @@ WebInspector.TimelineManager.EventTypes = {
 }
 
 WebInspector.TimelineManager.prototype = {
-    start: function()
+    start: function(maxCallStackDepth)
     {
         this._enablementCount++;
         if (this._enablementCount === 1)
-            TimelineAgent.start();
+            TimelineAgent.start(maxCallStackDepth);
     },
 
     stop: function()