Diff
Modified: trunk/LayoutTests/ChangeLog (100112 => 100113)
--- trunk/LayoutTests/ChangeLog 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/LayoutTests/ChangeLog 2011-11-14 09:27:25 UTC (rev 100113)
@@ -1,3 +1,16 @@
+2011-11-10 Yury Semikhatsky <[email protected]>
+
+ Web Inspector: function remote objetct should provide access to function position in the script
+ https://bugs.webkit.org/show_bug.cgi?id=71808
+
+ Added test for Debugger.getFunctionLocation command.
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/function-location-expected.txt: Added.
+ * inspector/debugger/function-location.html: Added.
+ * platform/chromium/inspector/debugger/function-location-expected.txt: Added.
+
2011-11-14 Kristóf Kosztyó <[email protected]>
[Qt] Unreviewed gardening after r100050
Added: trunk/LayoutTests/inspector/debugger/function-location-expected.txt (0 => 100113)
--- trunk/LayoutTests/inspector/debugger/function-location-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/debugger/function-location-expected.txt 2011-11-14 09:27:25 UTC (rev 100113)
@@ -0,0 +1,19 @@
+Tests that Debugger.getFunctionLocation command returns location. Bug 71808
+
+Debugger was enabled.
+
+Running: testGetFirstLineFunctionLocation
+firstLineFunction type = function
+didGetLocation:
+lineNumber: 7
+columnNumber: undefined
+scriptId is valid: true
+
+Running: testGetNonFirstLineFunctionLocation
+nonFirstLineFunctiontype = function
+didGetLocation:
+lineNumber: 12
+columnNumber: undefined
+scriptId is valid: true
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/function-location-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/function-location.html (0 => 100113)
--- trunk/LayoutTests/inspector/debugger/function-location.html (rev 0)
+++ trunk/LayoutTests/inspector/debugger/function-location.html 2011-11-14 09:27:25 UTC (rev 100113)
@@ -0,0 +1,68 @@
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script> function firstLineFunction()
+
+{
+}
+
+ function notFirstLineFunction()
+
+{
+}
+
+function test()
+{
+ InspectorTest.runDebuggerTestSuite([
+ function testGetFirstLineFunctionLocation(next)
+ {
+ InspectorTest.evaluateInPage("firstLineFunction", didEvaluate);
+
+ function didEvaluate(remote)
+ {
+ InspectorTest.addResult("firstLineFunction type = " + remote.type);
+ DebuggerAgent.getFunctionLocation(remote.objectId, didGetLocation);
+ }
+ function didGetLocation(error, response)
+ {
+ InspectorTest.addResult("didGetLocation: ");
+ InspectorTest.addResult("lineNumber: " + response.lineNumber);
+ InspectorTest.addResult("columnNumber: " + response.columnNumber);
+ InspectorTest.addResult("scriptId is valid: " + !!response.scriptId);
+ next();
+ }
+ },
+ function testGetNonFirstLineFunctionLocation(next)
+ {
+ InspectorTest.evaluateInPage("notFirstLineFunction", didEvaluate);
+
+ function didEvaluate(remote)
+ {
+ InspectorTest.addResult("nonFirstLineFunctiontype = " + remote.type);
+ DebuggerAgent.getFunctionLocation(remote.objectId, didGetLocation);
+ }
+ function didGetLocation(error, response)
+ {
+ InspectorTest.addResult("didGetLocation: ");
+ InspectorTest.addResult("lineNumber: " + response.lineNumber);
+ InspectorTest.addResult("columnNumber: " + response.columnNumber);
+ InspectorTest.addResult("scriptId is valid: " + !!response.scriptId);
+ next();
+ }
+ }
+ ]);
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests that Debugger.getFunctionLocation command returns location.
+<a href="" 71808</a>
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/function-location.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/platform/chromium/inspector/debugger/function-location-expected.txt (0 => 100113)
--- trunk/LayoutTests/platform/chromium/inspector/debugger/function-location-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/inspector/debugger/function-location-expected.txt 2011-11-14 09:27:25 UTC (rev 100113)
@@ -0,0 +1,19 @@
+Tests that Debugger.getFunctionLocation command returns location. Bug 71808
+
+Debugger was enabled.
+
+Running: testGetFirstLineFunctionLocation
+firstLineFunction type = function
+didGetLocation:
+lineNumber: 5
+columnNumber: 36
+scriptId is valid: true
+
+Running: testGetNonFirstLineFunctionLocation
+nonFirstLineFunctiontype = function
+didGetLocation:
+lineNumber: 10
+columnNumber: 32
+scriptId is valid: true
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/platform/chromium/inspector/debugger/function-location-expected.txt
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/_javascript_Core/ChangeLog (100112 => 100113)
--- trunk/Source/_javascript_Core/ChangeLog 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-11-14 09:27:25 UTC (rev 100113)
@@ -1,3 +1,18 @@
+2011-11-11 Yury Semikhatsky <[email protected]>
+
+ Web Inspector: function remote objetct should provide access to function position in the script
+ https://bugs.webkit.org/show_bug.cgi?id=71808
+
+ Exposed accessor for function source code.
+
+ Reviewed by Pavel Feldman.
+
+ * _javascript_Core.exp:
+ * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::sourceCode):
+ * runtime/JSFunction.h:
+
2011-11-13 Yuqiang Xian <[email protected]>
Fix silent spilling/filling GPRs in DFG 32_64
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (100112 => 100113)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -533,6 +533,7 @@
__ZN3WTF9emptyAtomE
__ZN3WTF9xmlnsAtomE
__ZN3WTFeqERKNS_7CStringES2_
+__ZNK3JSC10JSFunction10sourceCodeEv
__ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_10JSFunctionE
__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (100112 => 100113)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-14 09:27:25 UTC (rev 100113)
@@ -308,6 +308,7 @@
?slowAppend@MarkedArgumentBuffer@JSC@@AAEXVJSValue@2@@Z
?slowValidateCell@JSC@@YAXPAVJSCell@1@@Z
?slowValidateCell@JSC@@YAXPAVJSGlobalObject@1@@Z
+ ?sourceCode@JSFunction@JSC@@QBEPBVSourceCode@2@XZ
?startProfiling@Profiler@JSC@@QAEXPAVExecState@2@ABVUString@2@@Z
?startSampling@JSGlobalData@JSC@@QAEXXZ
?stopProfiling@Profiler@JSC@@QAE?AV?$PassRefPtr@VProfile@JSC@@@WTF@@PAVExecState@2@ABVUString@2@@Z
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (100112 => 100113)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -149,6 +149,13 @@
return name(exec);
}
+const SourceCode* JSFunction::sourceCode() const
+{
+ if (isHostFunction())
+ return 0;
+ return &jsExecutable()->source();
+}
+
void JSFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSFunction* thisObject = jsCast<JSFunction*>(cell);
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.h (100112 => 100113)
--- trunk/Source/_javascript_Core/runtime/JSFunction.h 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.h 2011-11-14 09:27:25 UTC (rev 100113)
@@ -34,6 +34,7 @@
class JSActivation;
class JSGlobalObject;
class NativeExecutable;
+ class SourceCode;
class VPtrHackExecutable;
namespace DFG {
class JITCodeGenerator;
@@ -96,6 +97,8 @@
inline bool isHostFunction() const;
FunctionExecutable* jsExecutable() const;
+ const SourceCode* sourceCode() const;
+
static JS_EXPORTDATA const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
Modified: trunk/Source/WebCore/ChangeLog (100112 => 100113)
--- trunk/Source/WebCore/ChangeLog 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/ChangeLog 2011-11-14 09:27:25 UTC (rev 100113)
@@ -1,3 +1,30 @@
+2011-11-10 Yury Semikhatsky <[email protected]>
+
+ Web Inspector: function remote objetct should provide access to function position in the script
+ https://bugs.webkit.org/show_bug.cgi?id=71808
+
+ Added Debugger.getFunctionLocation command for resolving function location including
+ start line, column and script id.
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector/debugger/function-location.html
+
+ * bindings/js/JSInjectedScriptHostCustom.cpp:
+ (WebCore::JSInjectedScriptHost::functionLocation):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::V8InjectedScriptHost::functionLocationCallback):
+ * inspector/InjectedScript.cpp:
+ (WebCore::InjectedScript::getFunctionLocation):
+ * inspector/InjectedScript.h:
+ * inspector/InjectedScriptHost.idl:
+ * inspector/InjectedScriptSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorDebuggerAgent.cpp:
+ (WebCore::InspectorDebuggerAgent::getFunctionLocation):
+ * inspector/InspectorDebuggerAgent.h:
+
2011-11-14 Rakesh KN <[email protected]>
Cannot select multiple options by mouse dragging in <select multiple="multiple" size="7"> list
Modified: trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp (100112 => 100113)
--- trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -51,6 +51,7 @@
#include "JSStorage.h"
#include "ScriptValue.h"
#include "Storage.h"
+#include <parser/SourceCode.h>
#include <runtime/DateInstance.h>
#include <runtime/Error.h>
#include <runtime/JSArray.h>
@@ -156,6 +157,29 @@
return jsUndefined();
}
+JSValue JSInjectedScriptHost::functionLocation(ExecState* exec)
+{
+ if (exec->argumentCount() < 1)
+ return jsUndefined();
+ JSValue value = exec->argument(0);
+ if (!value.asCell()->inherits(&JSFunction::s_info))
+ return jsUndefined();
+ JSFunction* function = asFunction(value);
+
+ const SourceCode* sourceCode = function->sourceCode();
+ if (!sourceCode)
+ return jsUndefined();
+ int lineNumber = sourceCode->firstLine();
+ if (lineNumber)
+ lineNumber -= 1; // In the inspector protocol all positions are 0-based while in SourceCode they are 1-based
+ UString scriptId = UString::number(sourceCode->provider()->asID());
+
+ JSObject* result = constructEmptyObject(exec);
+ result->putDirect(exec->globalData(), Identifier(exec, "lineNumber"), jsNumber(lineNumber));
+ result->putDirect(exec->globalData(), Identifier(exec, "scriptId"), jsString(exec, scriptId));
+ return result;
+}
+
JSValue JSInjectedScriptHost::inspect(ExecState* exec)
{
if (exec->argumentCount() >= 2) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp (100112 => 100113)
--- trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -150,6 +150,27 @@
return v8::Undefined();
}
+v8::Handle<v8::Value> V8InjectedScriptHost::functionLocationCallback(const v8::Arguments& args)
+{
+ INC_STATS("InjectedScriptHost.typeCallback()");
+ if (args.Length() < 1)
+ return v8::Undefined();
+
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Value> value = args[0];
+ if (!value->IsFunction())
+ return v8::Undefined();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value);
+ int lineNumber = function->GetScriptLineNumber();
+ int columnNumber = function->GetScriptColumnNumber();
+ v8::Local<v8::Object> result = v8::Object::New();
+ result->Set(v8::String::New("lineNumber"), v8::Integer::New(lineNumber));
+ result->Set(v8::String::New("columnNumber"), v8::Integer::New(columnNumber));
+ result->Set(v8::String::New("scriptId"), function->GetScriptId());
+ return result;
+}
+
v8::Handle<v8::Value> V8InjectedScriptHost::inspectCallback(const v8::Arguments& args)
{
INC_STATS("InjectedScriptHost.inspect()");
Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (100112 => 100113)
--- trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -88,6 +88,20 @@
makeEvalCall(errorString, function, result, wasThrown);
}
+void InjectedScript::getFunctionLocation(ErrorString* errorString, const String& functionId, RefPtr<InspectorObject>* result)
+{
+ ScriptFunctionCall function(m_injectedScriptObject, "getFunctionLocation");
+ function.appendArgument(functionId);
+ RefPtr<InspectorValue> resultValue;
+ makeCall(function, &resultValue);
+ if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
+ if (!resultValue->asString(errorString))
+ *errorString = "Internal error";
+ return;
+ }
+ *result = resultValue->asObject();
+}
+
void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* properties)
{
ScriptFunctionCall function(m_injectedScriptObject, "getProperties");
Modified: trunk/Source/WebCore/inspector/InjectedScript.h (100112 => 100113)
--- trunk/Source/WebCore/inspector/InjectedScript.h 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InjectedScript.h 2011-11-14 09:27:25 UTC (rev 100113)
@@ -78,6 +78,7 @@
bool returnByValue,
RefPtr<InspectorObject>* result,
bool* wasThrown);
+ void getFunctionLocation(ErrorString*, const String& functionId, RefPtr<InspectorObject>* result);
void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr<InspectorArray>* result);
Node* nodeForObjectId(const String& objectId);
void releaseObject(const String& objectId);
Modified: trunk/Source/WebCore/inspector/InjectedScriptHost.idl (100112 => 100113)
--- trunk/Source/WebCore/inspector/InjectedScriptHost.idl 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InjectedScriptHost.idl 2011-11-14 09:27:25 UTC (rev 100113)
@@ -44,6 +44,7 @@
[Custom] DOMObject internalConstructorName(in DOMObject object);
[Custom] boolean isHTMLAllCollection(in DOMObject object);
[Custom] DOMString type(in DOMObject object);
+ [Custom] DOMObject functionLocation(in DOMObject object);
[Custom] int databaseId(in DOMObject database);
[Custom] int storageId(in DOMObject storage);
Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (100112 => 100113)
--- trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-11-14 09:27:25 UTC (rev 100113)
@@ -194,6 +194,15 @@
return descriptors;
},
+ getFunctionLocation: function(functionId)
+ {
+ var parsedFunctionId = this._parseObjectId(functionId);
+ var func = this._objectForId(parsedFunctionId);
+ if (typeof func !== "function")
+ return "Cannot resolve function by id.";
+ return InjectedScriptHost.functionLocation(func);
+ },
+
releaseObject: function(objectId)
{
var parsedObjectId = this._parseObjectId(objectId);
Modified: trunk/Source/WebCore/inspector/Inspector.json (100112 => 100113)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-11-14 09:27:25 UTC (rev 100113)
@@ -310,7 +310,8 @@
{ "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
{ "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values or JSON values if it was requested)." },
{ "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
- { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." }
+ { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." },
+ { "name": "functionLocation", "$ref": "Debugger.Location", "optional": true, "description": "Function location within owning script." }
]
},
{
@@ -1902,6 +1903,16 @@
"description": "Returns source for the script with given id."
},
{
+ "name": "getFunctionLocation",
+ "parameters": [
+ { "name": "functionId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the function to get location for." }
+ ],
+ "returns": [
+ { "name": "location", "$ref": "Location", "description": "Function location." }
+ ],
+ "description": "Returns location of given function."
+ },
+ {
"name": "setPauseOnExceptions",
"parameters": [
{ "name": "state", "type": "string", "enum": ["none", "uncaught", "all"], "description": "Pause on exceptions mode." }
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (100112 => 100113)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2011-11-14 09:27:25 UTC (rev 100113)
@@ -354,6 +354,16 @@
*error = "No script for id: " + scriptId;
}
+void InspectorDebuggerAgent::getFunctionLocation(ErrorString* errorString, const String& functionId, RefPtr<InspectorObject>* location)
+{
+ InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(functionId);
+ if (injectedScript.hasNoValue()) {
+ *errorString = "Inspected frame has gone";
+ return;
+ }
+ injectedScript.getFunctionLocation(errorString, functionId, location);
+}
+
void InspectorDebuggerAgent::schedulePauseOnNextStatement(const String& breakReason, PassRefPtr<InspectorObject> data)
{
if (m_javaScriptPauseScheduled)
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h (100112 => 100113)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h 2011-11-14 09:25:37 UTC (rev 100112)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h 2011-11-14 09:27:25 UTC (rev 100113)
@@ -84,6 +84,7 @@
void searchInContent(ErrorString*, const String& scriptId, const String& query, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>*);
void setScriptSource(ErrorString*, const String& scriptId, const String& newContent, const bool* const preview, RefPtr<InspectorArray>* newCallFrames, RefPtr<InspectorObject>* result);
void getScriptSource(ErrorString*, const String& scriptId, String* scriptSource);
+ void getFunctionLocation(ErrorString*, const String& functionId, RefPtr<InspectorObject>* location);
void schedulePauseOnNextStatement(const String& breakReason, PassRefPtr<InspectorObject> data);
void cancelPauseOnNextStatement();
void breakProgram(const String& breakReason, PassRefPtr<InspectorObject> data);