WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-40118-20120619112438.patch (text/plain), 9.52 KB, created by
sfa
on 2012-06-19 08:24:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
sfa
Created:
2012-06-19 08:24:38 PDT
Size:
9.52 KB
patch
obsolete
>Subversion Revision: 120143 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index acd29c54b67731f7637b212966a2a0a2bbf57ecd..c71e455a1fc572ac178b33df20a82dec26c83ea3 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,25 @@ >+2012-06-19 Anthony Scian <ascian@rim.com> >+ >+ Web Inspector [JSC]: Implement ScriptCallStack::stackTrace >+ https://bugs.webkit.org/show_bug.cgi?id=40118 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added member functions to expose function name, urlString, and line #. >+ Refactored toString to make use of these member functions to reduce >+ duplicated code for future maintenance. >+ >+ Manually tested refactoring of toString by tracing thrown exceptions. >+ >+ * interpreter/Interpreter.cpp: >+ (JSC::StackFrame::toString): >+ (JSC): >+ (JSC::StackFrame::friendlySourceURL): >+ (JSC::StackFrame::friendlyFunctionName): >+ * interpreter/Interpreter.h: >+ (StackFrame): >+ (JSC::StackFrame::friendlyLineNumber): >+ > 2012-05-14 Yong Li <yoli@rim.com> > > DFG JIT didn't work with ARM EABI. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf33a36f0942dd9f97c55a38b5f88a4094414f8d..dd89c83cc73a895ef1706832539c22ff36b5bdfc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2012-06-19 Anthony Scian <ascian@rim.com> >+ >+ Web Inspector [JSC]: Implement ScriptCallStack::stackTrace >+ https://bugs.webkit.org/show_bug.cgi?id=40118 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implemented stub for createScriptCallStack to call into >+ Interpreter and extract the current stack frames, iterate >+ through the frames and create the return result required. >+ >+ No new tests, manually tested thrown exception and inspector >+ tracebacks. >+ >+ * bindings/js/ScriptCallStackFactory.cpp: >+ (WebCore::createScriptCallStack): >+ > 2012-06-12 Sheriff Bot <webkit.review.bot@gmail.com> > > Unreviewed, rolling out r120036. >diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp >index a358b9ab04d461cbe26fd0d1d5efab920dc53d2d..2d2c3a3703539d6d3444e297a771c3ef703f1e69 100644 >--- a/Source/JavaScriptCore/interpreter/Interpreter.cpp >+++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. > * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> >+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -76,6 +77,67 @@ using namespace std; > > namespace JSC { > >+UString StackFrame::toString(CallFrame* callFrame) const >+{ >+ StringBuilder traceBuild; >+ String functionName = friendlyFunctionName(callFrame); >+ String sourceURL = friendlySourceURL(); >+ traceBuild.append(functionName); >+ if (!functionName.isEmpty() && !sourceURL.isEmpty()) >+ traceBuild.append('@'); >+ traceBuild.append(sourceURL); >+ if (line > -1) { >+ traceBuild.append(':'); >+ traceBuild.append(String::number(line)); >+ } >+ return traceBuild.toString().impl(); >+} >+ >+String StackFrame::friendlySourceURL() const >+{ >+ String traceLine; >+ >+ switch (codeType) { >+ case StackFrameEvalCode: >+ case StackFrameFunctionCode: >+ case StackFrameGlobalCode: >+ if (!sourceURL.isEmpty()) >+ traceLine = sourceURL.impl(); >+ break; >+ case StackFrameNativeCode: >+ traceLine = "[native code]"; >+ break; >+ } >+ if (traceLine.isEmpty()) >+ traceLine = ""; >+ return traceLine; >+} >+ >+String StackFrame::friendlyFunctionName(CallFrame* callFrame) const >+{ >+ String traceLine; >+ JSObject* stackFrameCallee = callee.get(); >+ >+ switch (codeType) { >+ case StackFrameEvalCode: >+ traceLine = "eval code"; >+ break; >+ case StackFrameNativeCode: >+ if (callee) >+ traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); >+ break; >+ case StackFrameFunctionCode: >+ traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); >+ break; >+ case StackFrameGlobalCode: >+ traceLine = "global code"; >+ break; >+ } >+ if (traceLine.isEmpty()) >+ traceLine = ""; >+ return traceLine; >+} >+ > // Returns the depth of the scope chain within a given call frame. > static int depth(CodeBlock* codeBlock, ScopeChainNode* sc) > { >diff --git a/Source/JavaScriptCore/interpreter/Interpreter.h b/Source/JavaScriptCore/interpreter/Interpreter.h >index adb23f2372384daf883b14eff8baf5dc5fe6df41..14865351b6735210860ac246c204db7f79bcc943 100644 >--- a/Source/JavaScriptCore/interpreter/Interpreter.h >+++ b/Source/JavaScriptCore/interpreter/Interpreter.h >@@ -78,47 +78,12 @@ namespace JSC { > Strong<ExecutableBase> executable; > int line; > UString sourceURL; >- UString toString(CallFrame* callFrame) const >+ UString toString(CallFrame*) const; >+ String friendlySourceURL() const; >+ String friendlyFunctionName(CallFrame*) const; >+ unsigned friendlyLineNumber() const > { >- bool hasSourceURLInfo = !sourceURL.isNull() && !sourceURL.isEmpty(); >- bool hasLineInfo = line > -1; >- String traceLine; >- JSObject* stackFrameCallee = callee.get(); >- >- switch (codeType) { >- case StackFrameEvalCode: >- if (hasSourceURLInfo) { >- traceLine = hasLineInfo ? String::format("eval code@%s:%d", sourceURL.ascii().data(), line) >- : String::format("eval code@%s", sourceURL.ascii().data()); >- } else >- traceLine = String::format("eval code"); >- break; >- case StackFrameNativeCode: { >- if (callee) { >- UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); >- traceLine = String::format("%s@[native code]", functionName.ascii().data()); >- } else >- traceLine = "[native code]"; >- break; >- } >- case StackFrameFunctionCode: { >- UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee); >- if (hasSourceURLInfo) { >- traceLine = hasLineInfo ? String::format("%s@%s:%d", functionName.ascii().data(), sourceURL.ascii().data(), line) >- : String::format("%s@%s", functionName.ascii().data(), sourceURL.ascii().data()); >- } else >- traceLine = String::format("%s\n", functionName.ascii().data()); >- break; >- } >- case StackFrameGlobalCode: >- if (hasSourceURLInfo) { >- traceLine = hasLineInfo ? String::format("global code@%s:%d", sourceURL.ascii().data(), line) >- : String::format("global code@%s", sourceURL.ascii().data()); >- } else >- traceLine = String::format("global code"); >- >- } >- return traceLine.impl(); >+ return line > -1 ? line : 0; > } > }; > >diff --git a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp >index ccf673fd41253ddbdcc0d794f11d68c9f4b6fa2d..62f64347a304d384038048f949ef8bd0f1036d06 100644 >--- a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp >+++ b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp >@@ -1,5 +1,6 @@ > /* > * Copyright (c) 2010 Google Inc. All rights reserved. >+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions are >@@ -33,6 +34,7 @@ > > #include "InspectorInstrumentation.h" > #include "JSDOMBinding.h" >+#include "JSMainThreadExecState.h" > #include "ScriptArguments.h" > #include "ScriptCallFrame.h" > #include "ScriptCallStack.h" >@@ -51,9 +53,26 @@ namespace WebCore { > > class ScriptExecutionContext; > >-PassRefPtr<ScriptCallStack> createScriptCallStack(size_t, bool) >+PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyIsAllowed) > { >- return 0; >+ Vector<ScriptCallFrame> frames; >+ if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) { >+ Vector<StackFrame> stackTrace; >+ Interpreter::getStackTrace(&exec->globalData(), stackTrace); >+ for (Vector<StackFrame>::const_iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) { >+ StackFrame level = *iter; >+ frames.append(ScriptCallFrame(level.friendlyFunctionName(exec), level.friendlySourceURL(), level.friendlyLineNumber())); >+ if (frames.size() >= maxStackSize) >+ break; >+ } >+ } >+ if (frames.isEmpty() && !emptyIsAllowed) { >+ // No frames found. It may happen in the case where >+ // a bound function is called from native code for example. >+ // Fallback to setting lineNumber to 0, and source and function name to "undefined". >+ frames.append(ScriptCallFrame("undefined", "undefined", 0)); >+ } >+ return ScriptCallStack::create(frames); > } > > PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 40118
:
100721
|
142716
|
142747
|
143824
|
143840
|
148334
|
148339
|
148347
|
148352
|
149291
|
150821
|
150830