Title: [194247] trunk/Source
Revision
194247
Author
[email protected]
Date
2015-12-17 16:20:18 -0800 (Thu, 17 Dec 2015)

Log Message

Web Inspector: Improve names in Debugger Call Stack section when paused
https://bugs.webkit.org/show_bug.cgi?id=152398

Reviewed by Brian Burg.

Source/_javascript_Core:

* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::functionName):
Provide a better name from the underlying CallFrame.

* inspector/InjectedScriptSource.js:
(InjectedScript.CallFrameProxy):
Just call functionName, it will provide a better
than nothing function name.

* runtime/JSFunction.cpp:
(JSC::getCalculatedDisplayName):
Use emptyString().

* interpreter/CallFrame.h:
* interpreter/CallFrame.cpp:
(JSC::CallFrame::friendlyFunctionName):
This is the third similiar implementation of this,
but all other cases use other "StackFrame" objects.
Use the expected names for program code.

Source/WebInspectorUI:

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype.debuggerDidPause):
Use a new fromPayload helper to construct the CallFrame and share code.

* UserInterface/Models/CallFrame.js:
(WebInspector.CallFrame.functionNameFromPayload):
(WebInspector.CallFrame.programCodeFromPayload):
(WebInspector.CallFrame.fromDebuggerPayload):
(WebInspector.CallFrame.fromPayload):
Add a new way to construct a call frame. There are two kinds of
CallFrame payloads in the protocol:
- Debugger.CallFrame, this new path
- Console.CallFrame, the pre-existing path

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (194246 => 194247)


--- trunk/Source/_javascript_Core/ChangeLog	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-12-18 00:20:18 UTC (rev 194247)
@@ -1,3 +1,30 @@
+2015-12-17  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Improve names in Debugger Call Stack section when paused
+        https://bugs.webkit.org/show_bug.cgi?id=152398
+
+        Reviewed by Brian Burg.
+
+        * debugger/DebuggerCallFrame.cpp:
+        (JSC::DebuggerCallFrame::functionName):
+        Provide a better name from the underlying CallFrame.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.CallFrameProxy):
+        Just call functionName, it will provide a better
+        than nothing function name.
+
+        * runtime/JSFunction.cpp:
+        (JSC::getCalculatedDisplayName):
+        Use emptyString().
+
+        * interpreter/CallFrame.h:
+        * interpreter/CallFrame.cpp:
+        (JSC::CallFrame::friendlyFunctionName):
+        This is the third similiar implementation of this,
+        but all other cases use other "StackFrame" objects.
+        Use the expected names for program code.
+
 2015-12-16  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Add JSContext Script Profiling

Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (194246 => 194247)


--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp	2015-12-18 00:20:18 UTC (rev 194247)
@@ -128,11 +128,7 @@
     ASSERT(isValid());
     if (!isValid())
         return String();
-    JSFunction* function = jsDynamicCast<JSFunction*>(m_callFrame->callee());
-    if (!function)
-        return String();
-
-    return getCalculatedDisplayName(m_callFrame, function);
+    return m_callFrame->friendlyFunctionName();
 }
 
 DebuggerScope* DebuggerCallFrame::scope()

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (194246 => 194247)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-12-18 00:20:18 UTC (rev 194247)
@@ -1344,7 +1344,7 @@
 InjectedScript.CallFrameProxy = function(ordinal, callFrame)
 {
     this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + injectedScriptId + "}";
-    this.functionName = (callFrame.type === "function" ? callFrame.functionName : "");
+    this.functionName = callFrame.functionName;
     this.location = {scriptId: String(callFrame.sourceID), lineNumber: callFrame.line, columnNumber: callFrame.column};
     this.scopeChain = this._wrapScopeChain(callFrame);
     this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace");

Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (194246 => 194247)


--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp	2015-12-18 00:20:18 UTC (rev 194247)
@@ -230,6 +230,26 @@
     registers()[activationRegister.offset()] = lexicalEnvironment;
 }
 
+String CallFrame::friendlyFunctionName()
+{
+    CodeBlock* codeBlock = this->codeBlock();
+    if (!codeBlock)
+        return emptyString();
+
+    switch (codeBlock->codeType()) {
+    case EvalCode:
+        return ASCIILiteral("eval code");
+    case ModuleCode:
+        return ASCIILiteral("module code");
+    case GlobalCode:
+        return ASCIILiteral("global code");
+    case FunctionCode:
+        if (callee())
+            return getCalculatedDisplayName(this, callee());
+        return emptyString();
+    }
+}
+
 void CallFrame::dump(PrintStream& out)
 {
     if (CodeBlock* codeBlock = this->codeBlock()) {

Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.h (194246 => 194247)


--- trunk/Source/_javascript_Core/interpreter/CallFrame.h	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.h	2015-12-18 00:20:18 UTC (rev 194247)
@@ -243,6 +243,8 @@
         void setCodeBlock(CodeBlock* codeBlock) { static_cast<Register*>(this)[JSStack::CodeBlock] = codeBlock; }
         void setReturnPC(void* value) { callerFrameAndPC().pc = reinterpret_cast<Instruction*>(value); }
 
+        String friendlyFunctionName();
+
         // CallFrame::iterate() expects a Functor that implements the following method:
         //     StackVisitor::Status operator()(StackVisitor&);
 

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (194246 => 194247)


--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2015-12-18 00:20:18 UTC (rev 194247)
@@ -566,7 +566,7 @@
         return function->calculatedDisplayName(callFrame);
     if (InternalFunction* function = jsDynamicCast<InternalFunction*>(object))
         return function->calculatedDisplayName(callFrame);
-    return "";
+    return emptyString();
 }
 
 } // namespace JSC

Modified: trunk/Source/WebInspectorUI/ChangeLog (194246 => 194247)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-12-18 00:20:18 UTC (rev 194247)
@@ -1,3 +1,24 @@
+2015-12-17  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Improve names in Debugger Call Stack section when paused
+        https://bugs.webkit.org/show_bug.cgi?id=152398
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WebInspector.DebuggerManager.prototype.debuggerDidPause):
+        Use a new fromPayload helper to construct the CallFrame and share code.
+
+        * UserInterface/Models/CallFrame.js:
+        (WebInspector.CallFrame.functionNameFromPayload):
+        (WebInspector.CallFrame.programCodeFromPayload):
+        (WebInspector.CallFrame.fromDebuggerPayload):
+        (WebInspector.CallFrame.fromPayload):
+        Add a new way to construct a call frame. There are two kinds of
+        CallFrame payloads in the protocol:
+        - Debugger.CallFrame, this new path
+        - Console.CallFrame, the pre-existing path
+
 2015-12-17  Brian Burg  <[email protected]>
 
         Web Inspector: control whether to collect and dump protocol messages using a WebInspector.Setting

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (194246 => 194247)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js	2015-12-18 00:20:18 UTC (rev 194247)
@@ -489,9 +489,9 @@
             // Exclude the case where the call frame is in the inspector code.
             if (sourceCodeLocation.sourceCode.url && sourceCodeLocation.sourceCode.url.startsWith("__WebInspector"))
                 continue;
-            var thisObject = WebInspector.RemoteObject.fromPayload(callFramePayload.this);
-            var scopeChain = this._scopeChainFromPayload(callFramePayload.scopeChain);
-            var callFrame = new WebInspector.CallFrame(callFramePayload.callFrameId, sourceCodeLocation, callFramePayload.functionName, thisObject, scopeChain);
+
+            let scopeChain = this._scopeChainFromPayload(callFramePayload.scopeChain);
+            let callFrame = WebInspector.CallFrame.fromDebuggerPayload(callFramePayload, scopeChain, sourceCodeLocation);
             this._callFrames.push(callFrame);
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js (194246 => 194247)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js	2015-12-18 00:05:04 UTC (rev 194246)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js	2015-12-18 00:20:18 UTC (rev 194247)
@@ -108,14 +108,43 @@
 
     // Static
 
+    static functionNameFromPayload(payload)
+    {
+        let functionName = payload.functionName;
+        if (functionName === "global code")
+            return WebInspector.UIString("Global Code");
+        if (functionName === "eval code")
+            return WebInspector.UIString("Eval Code");
+        if (functionName === "module code")
+            return WebInspector.UIString("Module Code");
+        return functionName;
+    }
+
+    static programCodeFromPayload(payload)
+    {
+        return payload.functionName.endsWith(" code");
+    }
+
+    static fromDebuggerPayload(payload, scopeChain, sourceCodeLocation)
+    {
+        let id = payload.callFrameId;
+        let thisObject = WebInspector.RemoteObject.fromPayload(payload.this);
+        let functionName = WebInspector.CallFrame.functionNameFromPayload(payload);
+        let nativeCode = false;
+        let programCode = WebInspector.CallFrame.programCodeFromPayload(payload);
+
+        return new WebInspector.CallFrame(id, sourceCodeLocation, functionName, thisObject, scopeChain, nativeCode, programCode);
+    }
+
     static fromPayload(payload)
     {
         console.assert(payload);
 
         let url = ""
         let nativeCode = false;
-        let programCode = false;
         let sourceCodeLocation = null;
+        let functionName = WebInspector.CallFrame.functionNameFromPayload(payload);
+        let programCode = WebInspector.CallFrame.programCodeFromPayload(payload);
 
         if (!url || url ="" "[native code]") {
             nativeCode = true;
@@ -132,18 +161,6 @@
             }
         }
 
-        let functionName = payload.functionName;
-        if (payload.functionName === "global code") {
-            functionName = WebInspector.UIString("Global Code");
-            programCode = true;
-        } else if (payload.functionName === "eval code") {
-            functionName = WebInspector.UIString("Eval Code");
-            programCode = true;
-        } else if (payload.functionName === "module code") {
-            functionName = WebInspector.UIString("Module Code");
-            programCode = true;
-        }
-
         return new WebInspector.CallFrame(null, sourceCodeLocation, functionName, null, null, nativeCode, programCode);
     }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to