Changeset 57231 in webkit
- Timestamp:
- Apr 7, 2010 2:20:50 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r57230 r57231 1 2010-04-07 Jaime Yap <jaimeyap@google.com> 2 3 Reviewed by Pavel Feldman. 4 Tests expectations changed due to the addition of the function symbol name for 5 the call location for records sent by the InspectorTimelineAgent. 6 https://bugs.webkit.org/show_bug.cgi?id=36839 7 8 No new tests. 9 10 * inspector/timeline-test.js: 11 * platform/chromium-win/inspector/timeline-event-dispatch-expected.txt: 12 * platform/chromium-win/inspector/timeline-mark-timeline-expected.txt: 13 * platform/chromium-win/inspector/timeline-network-resource-expected.txt: 14 * platform/chromium-win/inspector/timeline-paint-expected.txt: 15 * platform/chromium-win/inspector/timeline-parse-html-expected.txt: 16 1 17 2010-04-07 Jay Civelli <jcivelli@chromium.org> 2 18 -
trunk/LayoutTests/inspector/timeline-test.js
r57201 r57231 11 11 callerScriptName: 1, 12 12 callerScriptLine: 1, 13 callerFunctionName: 1, 13 14 url : 1, 14 15 usedHeapSize: 1, -
trunk/LayoutTests/platform/chromium-win/inspector/timeline-event-dispatch-expected.txt
r57150 r57231 6 6 + callerScriptName : * DEFINED * 7 7 + callerScriptLine : * DEFINED * 8 + callerFunctionName : * DEFINED * 8 9 + data : { 9 10 +- type : mousedown -
trunk/LayoutTests/platform/chromium-win/inspector/timeline-mark-timeline-expected.txt
r57150 r57231 5 5 + callerScriptName : * DEFINED * 6 6 + callerScriptLine : * DEFINED * 7 + callerFunctionName : * DEFINED * 7 8 + data : { 8 9 +- message : MARK TIMELINE -
trunk/LayoutTests/platform/chromium-win/inspector/timeline-network-resource-expected.txt
r57150 r57231 6 6 + callerScriptName : * DEFINED * 7 7 + callerScriptLine : * DEFINED * 8 + callerFunctionName : * DEFINED * 8 9 + data : { 9 10 +- identifier : * DEFINED * -
trunk/LayoutTests/platform/chromium-win/inspector/timeline-paint-expected.txt
r57150 r57231 5 5 + callerScriptName : * DEFINED * 6 6 + callerScriptLine : * DEFINED * 7 + callerFunctionName : * DEFINED * 7 8 + data : { 8 9 +- x : 0 -
trunk/LayoutTests/platform/chromium-win/inspector/timeline-parse-html-expected.txt
r57150 r57231 5 5 + callerScriptName : * DEFINED * 6 6 + callerScriptLine : * DEFINED * 7 + callerFunctionName : * DEFINED * 7 8 + data : { 8 9 +- length : 9 -
trunk/WebCore/ChangeLog
r57230 r57231 1 2010-04-07 Jaime Yap <jaimeyap@google.com> 2 3 Reviewed by Pavel Feldman. 4 5 Adds the ability to get the function symbol name when looking up the call location 6 for records sent by the InspectorTimelineAgent. 7 https://bugs.webkit.org/show_bug.cgi?id=36839 8 9 No new tests. 10 11 * bindings/js/ScriptCallStack.cpp: 12 (WebCore::ScriptCallStack::callLocation): 13 * bindings/js/ScriptCallStack.h: 14 * bindings/v8/ScriptCallStack.cpp: 15 (WebCore::ScriptCallStack::create): 16 (WebCore::ScriptCallStack::callLocation): 17 (WebCore::ScriptCallStack::ScriptCallStack): 18 * bindings/v8/ScriptCallStack.h: 19 * bindings/v8/ScriptDebugServer.cpp: 20 (WebCore::ScriptDebugServer::createUtilityContext): 21 (WebCore::ScriptDebugServer::topStackFrame): 22 * bindings/v8/ScriptDebugServer.h: 23 (WebCore::ScriptDebugServer::utilityContext): 24 * bindings/v8/V8Proxy.cpp: 25 * bindings/v8/V8Proxy.h: 26 * inspector/TimelineRecordFactory.cpp: 27 (WebCore::TimelineRecordFactory::createGenericRecord): 28 1 29 2010-04-07 Jay Civelli <jcivelli@chromium.org> 2 30 -
trunk/WebCore/bindings/js/ScriptCallStack.cpp
r57201 r57231 102 102 } 103 103 104 bool ScriptCallStack::callLocation(String*, int* )104 bool ScriptCallStack::callLocation(String*, int*, String*) 105 105 { 106 106 return false; -
trunk/WebCore/bindings/js/ScriptCallStack.h
r57201 r57231 54 54 const ScriptCallFrame &at(unsigned); 55 55 unsigned size(); 56 static bool callLocation(String*, int* );56 static bool callLocation(String*, int*, String*); 57 57 58 58 private: -
trunk/WebCore/bindings/v8/ScriptCallStack.cpp
r57201 r57231 33 33 34 34 #include "ScriptController.h" 35 #include "ScriptDebugServer.h" 35 36 36 37 #include <v8.h> 37 38 38 39 #include "V8Binding.h" 39 #include "V8Proxy.h"40 40 41 41 namespace WebCore { … … 44 44 String sourceName; 45 45 int sourceLineNumber; 46 if (!callLocation(&sourceName, &sourceLineNumber)) 46 String funcName; 47 if (!callLocation(&sourceName, &sourceLineNumber, &funcName)) 47 48 return 0; 48 return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber );49 return new ScriptCallStack(arguments, skipArgumentCount, sourceName, sourceLineNumber, funcName); 49 50 } 50 51 51 bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber )52 bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber, String* functionName) 52 53 { 53 if (! V8Proxy::sourceName(*sourceName) || !V8Proxy::sourceLineNumber(*sourceLineNumber))54 if (!ScriptDebugServer::topStackFrame(*sourceName, *sourceLineNumber, *functionName)) 54 55 return false; 55 56 *sourceLineNumber += 1; … … 57 58 } 58 59 59 ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber )60 : m_lastCaller( String(), sourceName, sourceLineNumber, arguments, skipArgumentCount)60 ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String functionName) 61 : m_lastCaller(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount) 61 62 , m_scriptState(ScriptState::current()) 62 63 { -
trunk/WebCore/bindings/v8/ScriptCallStack.h
r57201 r57231 48 48 ~ScriptCallStack(); 49 49 50 static bool callLocation(String* sourceName, int* sourceLineNumber );50 static bool callLocation(String* sourceName, int* sourceLineNumber, String* functionName); 51 51 52 52 const ScriptCallFrame& at(unsigned) const; … … 58 58 59 59 private: 60 ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber );60 ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String funcName); 61 61 62 62 ScriptCallFrame m_lastCaller; -
trunk/WebCore/bindings/v8/ScriptDebugServer.cpp
r57201 r57231 34 34 #if ENABLE(JAVASCRIPT_DEBUGGER) 35 35 36 #include "V8Binding.h" 37 #include <v8-debug.h> 38 36 39 #include <wtf/StdLibExtras.h> 37 40 38 41 namespace WebCore { 42 43 v8::Persistent<v8::Context> ScriptDebugServer::s_utilityContext; 39 44 40 45 ScriptDebugServer& ScriptDebugServer::shared() … … 44 49 } 45 50 51 // Create the utility context for holding JavaScript functions used internally 52 // which are not visible to JavaScript executing on the page. 53 void ScriptDebugServer::createUtilityContext() 54 { 55 ASSERT(s_utilityContext.IsEmpty()); 56 57 v8::HandleScope scope; 58 v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); 59 s_utilityContext = v8::Context::New(0, globalTemplate); 60 v8::Context::Scope contextScope(s_utilityContext); 61 62 // Compile JavaScript function for retrieving the source line, the source 63 // name and the symbol name for the top JavaScript stack frame. 64 DEFINE_STATIC_LOCAL(const char*, topStackFrame, 65 ("function topStackFrame(exec_state) {" 66 " if (!exec_state.frameCount())" 67 " return undefined;" 68 " var frame = exec_state.frame(0);" 69 " var func = frame.func();" 70 " var scriptName;" 71 " if (func.resolved() && func.script())" 72 " scriptName = func.script().name();" 73 " return [scriptName, frame.sourceLine(), (func.name() || func.inferredName())];" 74 "}")); 75 v8::Script::Compile(v8::String::New(topStackFrame))->Run(); 76 } 77 78 bool ScriptDebugServer::topStackFrame(String& sourceName, int& lineNumber, String& functionName) 79 { 80 v8::HandleScope scope; 81 v8::Handle<v8::Context> v8UtilityContext = utilityContext(); 82 if (v8UtilityContext.IsEmpty()) 83 return false; 84 v8::Context::Scope contextScope(v8UtilityContext); 85 v8::Handle<v8::Function> topStackFrame; 86 topStackFrame = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("topStackFrame"))); 87 if (topStackFrame.IsEmpty()) 88 return false; 89 v8::Handle<v8::Value> value = v8::Debug::Call(topStackFrame); 90 if (value.IsEmpty()) 91 return false; 92 // If there is no top stack frame, we still return success, but fill the input params with defaults. 93 if (value->IsUndefined()) { 94 // Fallback to setting lineNumber to 0, and source and function name to "undefined". 95 sourceName = toWebCoreString(value); 96 lineNumber = 0; 97 functionName = toWebCoreString(value); 98 return true; 99 } 100 if (!value->IsArray()) 101 return false; 102 v8::Local<v8::Object> jsArray = value->ToObject(); 103 v8::Local<v8::Value> sourceNameValue = jsArray->Get(0); 104 v8::Local<v8::Value> lineNumberValue = jsArray->Get(1); 105 v8::Local<v8::Value> functionNameValue = jsArray->Get(2); 106 if (sourceNameValue.IsEmpty() || lineNumberValue.IsEmpty() || functionNameValue.IsEmpty()) 107 return false; 108 sourceName = toWebCoreString(sourceNameValue); 109 lineNumber = lineNumberValue->Int32Value(); 110 functionName = toWebCoreString(functionNameValue); 111 return true; 112 } 113 46 114 } // namespace WebCore 47 115 -
trunk/WebCore/bindings/v8/ScriptDebugServer.h
r57201 r57231 48 48 public: 49 49 static ScriptDebugServer& shared(); 50 51 // Function for retrieving the source name, line number and function name for the top 52 // JavaScript stack frame. 53 // 54 // It will return true if the caller information was successfully retrieved and written 55 // into the function parameters, otherwise the function will return false. It may 56 // fail due to a stack overflow in the underlying JavaScript implementation, handling 57 // of such exception is up to the caller. 58 static bool topStackFrame(String& sourceName, int& lineNumber, String& functionName); 50 59 51 60 void addListener(ScriptDebugListener*, Page*) { } … … 81 90 ScriptDebugServer() { } 82 91 ~ScriptDebugServer() { } 92 93 static void createUtilityContext(); 94 95 // Returns a local handle of the utility context. 96 static v8::Local<v8::Context> utilityContext() 97 { 98 if (s_utilityContext.IsEmpty()) 99 createUtilityContext(); 100 return v8::Local<v8::Context>::New(s_utilityContext); 101 } 102 103 // Utility context holding JavaScript functions used internally. 104 static v8::Persistent<v8::Context> s_utilityContext; 83 105 }; 84 106 -
trunk/WebCore/bindings/v8/V8Proxy.cpp
r57201 r57231 69 69 #include <utility> 70 70 #include <v8.h> 71 #include <v8-debug.h>72 71 #include <wtf/Assertions.h> 73 72 #include <wtf/OwnArrayPtr.h> … … 77 76 78 77 namespace WebCore { 79 80 v8::Persistent<v8::Context> V8Proxy::m_utilityContext;81 78 82 79 // Static list of registered extensions … … 756 753 } 757 754 758 // Create the utility context for holding JavaScript functions used internally759 // which are not visible to JavaScript executing on the page.760 void V8Proxy::createUtilityContext()761 {762 ASSERT(m_utilityContext.IsEmpty());763 764 v8::HandleScope scope;765 v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New();766 m_utilityContext = v8::Context::New(0, globalTemplate);767 v8::Context::Scope contextScope(m_utilityContext);768 769 // Compile JavaScript function for retrieving the source line of the top770 // JavaScript stack frame.771 DEFINE_STATIC_LOCAL(const char*, frameSourceLineSource,772 ("function frameSourceLine(exec_state) {"773 " if (!exec_state.frameCount())"774 " return undefined;"775 " return exec_state.frame(0).sourceLine();"776 "}"));777 v8::Script::Compile(v8::String::New(frameSourceLineSource))->Run();778 779 // Compile JavaScript function for retrieving the source name of the top780 // JavaScript stack frame.781 DEFINE_STATIC_LOCAL(const char*, frameSourceNameSource,782 ("function frameSourceName(exec_state) {"783 " if (!exec_state.frameCount())"784 " return undefined;"785 " var frame = exec_state.frame(0);"786 " if (frame.func().resolved() && "787 " frame.func().script() && "788 " frame.func().script().name()) {"789 " return frame.func().script().name();"790 " }"791 "}"));792 v8::Script::Compile(v8::String::New(frameSourceNameSource))->Run();793 }794 795 bool V8Proxy::sourceLineNumber(int& result)796 {797 v8::HandleScope scope;798 v8::Handle<v8::Context> v8UtilityContext = V8Proxy::utilityContext();799 if (v8UtilityContext.IsEmpty())800 return false;801 v8::Context::Scope contextScope(v8UtilityContext);802 v8::Handle<v8::Function> frameSourceLine;803 frameSourceLine = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("frameSourceLine")));804 if (frameSourceLine.IsEmpty())805 return false;806 v8::Handle<v8::Value> value = v8::Debug::Call(frameSourceLine);807 if (value.IsEmpty())808 return false;809 result = value->Int32Value();810 return true;811 }812 813 bool V8Proxy::sourceName(String& result)814 {815 v8::HandleScope scope;816 v8::Handle<v8::Context> v8UtilityContext = utilityContext();817 if (v8UtilityContext.IsEmpty())818 return false;819 v8::Context::Scope contextScope(v8UtilityContext);820 v8::Handle<v8::Function> frameSourceName;821 frameSourceName = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("frameSourceName")));822 if (frameSourceName.IsEmpty())823 return false;824 v8::Handle<v8::Value> value = v8::Debug::Call(frameSourceName);825 if (value.IsEmpty())826 return false;827 result = toWebCoreString(value);828 return true;829 }830 831 755 void V8Proxy::registerExtensionWithV8(v8::Extension* extension) 832 756 { -
trunk/WebCore/bindings/v8/V8Proxy.h
r57201 r57231 297 297 static void processConsoleMessages(); 298 298 299 // Function for retrieving the line number and source name for the top300 // JavaScript stack frame.301 //302 // It will return true if the line number was successfully retrieved and written303 // into the |result| parameter, otherwise the function will return false. It may304 // fail due to a stck overflow in the underlying JavaScript implentation, handling305 // of such exception is up to the caller.306 static bool sourceLineNumber(int& result);307 static bool sourceName(String& result);308 309 299 v8::Local<v8::Context> context(); 310 300 v8::Local<v8::Context> mainWorldContext(); … … 357 347 #endif 358 348 359 static void createUtilityContext();360 361 // Returns a local handle of the utility context.362 static v8::Local<v8::Context> utilityContext()363 {364 if (m_utilityContext.IsEmpty())365 createUtilityContext();366 return v8::Local<v8::Context>::New(m_utilityContext);367 }368 369 349 Frame* m_frame; 370 350 371 351 // For the moment, we have one of these. Soon we will have one per DOMWrapperWorld. 372 352 RefPtr<V8DOMWindowShell> m_windowShell; 373 374 // Utility context holding JavaScript functions used internally.375 static v8::Persistent<v8::Context> m_utilityContext;376 353 377 354 int m_handlerLineNumber; -
trunk/WebCore/inspector/TimelineRecordFactory.cpp
r57201 r57231 52 52 String sourceName; 53 53 int sourceLineNumber; 54 if (ScriptCallStack::callLocation(&sourceName, &sourceLineNumber) && sourceName != "undefined") { 54 String functionName; 55 if (ScriptCallStack::callLocation(&sourceName, &sourceLineNumber, &functionName) && sourceName != "undefined") { 55 56 record.set("callerScriptName", sourceName); 56 57 record.set("callerScriptLine", sourceLineNumber); 58 record.set("callerFunctionName", functionName); 57 59 } 58 60 return record;
Note: See TracChangeset
for help on using the changeset viewer.