| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +22 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2012-06-19  Anthony Scian  <ascian@rim.com>
2
3
        Web Inspector [JSC]: Implement ScriptCallStack::stackTrace
4
        https://bugs.webkit.org/show_bug.cgi?id=40118
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added member functions to expose function name, urlString, and line #.
9
        Refactored toString to make use of these member functions to reduce
10
        duplicated code for future maintenance.
11
12
        Manually tested refactoring of toString by tracing thrown exceptions.
13
14
        * interpreter/Interpreter.cpp:
15
        (JSC::StackFrame::toString):
16
        (JSC):
17
        (JSC::StackFrame::friendlySourceURL):
18
        (JSC::StackFrame::friendlyFunctionName):
19
        * interpreter/Interpreter.h:
20
        (StackFrame):
21
        (JSC::StackFrame::friendlyLineNumber):
22
1
2012-05-14  Yong Li  <yoli@rim.com>
23
2012-05-14  Yong Li  <yoli@rim.com>
2
24
3
        DFG JIT didn't work with ARM EABI.
25
        DFG JIT didn't work with ARM EABI.
- a/Source/WebCore/ChangeLog +17 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-06-19  Anthony Scian  <ascian@rim.com>
2
3
        Web Inspector [JSC]: Implement ScriptCallStack::stackTrace
4
        https://bugs.webkit.org/show_bug.cgi?id=40118
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Implemented stub for createScriptCallStack to call into
9
        Interpreter and extract the current stack frames, iterate
10
        through the frames and create the return result required.
11
12
        No new tests, manually tested thrown exception and inspector
13
        tracebacks.
14
15
        * bindings/js/ScriptCallStackFactory.cpp:
16
        (WebCore::createScriptCallStack):
17
1
2012-06-12  Sheriff Bot  <webkit.review.bot@gmail.com>
18
2012-06-12  Sheriff Bot  <webkit.review.bot@gmail.com>
2
19
3
        Unreviewed, rolling out r120036.
20
        Unreviewed, rolling out r120036.
- a/Source/JavaScriptCore/interpreter/Interpreter.cpp +62 lines
Lines 1-6 a/Source/JavaScriptCore/interpreter/Interpreter.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
2
 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
3
 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
3
 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
4
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4
 *
5
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * modification, are permitted provided that the following conditions
Lines 76-81 using namespace std; a/Source/JavaScriptCore/interpreter/Interpreter.cpp_sec2
76
77
77
namespace JSC {
78
namespace JSC {
78
79
80
UString StackFrame::toString(CallFrame* callFrame) const
81
{
82
    StringBuilder traceBuild;
83
    String functionName = friendlyFunctionName(callFrame);
84
    String sourceURL = friendlySourceURL();
85
    traceBuild.append(functionName);
86
    if (!functionName.isEmpty() && !sourceURL.isEmpty())
87
        traceBuild.append('@');
88
    traceBuild.append(sourceURL);
89
    if (line > -1) {
90
        traceBuild.append(':');
91
        traceBuild.append(String::number(line));
92
    }
93
    return traceBuild.toString().impl();
94
}
95
96
String StackFrame::friendlySourceURL() const
97
{
98
    String traceLine;
99
100
    switch (codeType) {
101
    case StackFrameEvalCode:
102
    case StackFrameFunctionCode:
103
    case StackFrameGlobalCode:
104
        if (!sourceURL.isEmpty())
105
            traceLine = sourceURL.impl();
106
        break;
107
    case StackFrameNativeCode:
108
        traceLine = "[native code]";
109
        break;
110
    }
111
    if (traceLine.isEmpty())
112
        traceLine = "";
113
    return traceLine;
114
}
115
116
String StackFrame::friendlyFunctionName(CallFrame* callFrame) const
117
{
118
    String traceLine;
119
    JSObject* stackFrameCallee = callee.get();
120
121
    switch (codeType) {
122
    case StackFrameEvalCode:
123
        traceLine = "eval code";
124
        break;
125
    case StackFrameNativeCode:
126
        if (callee)
127
            traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
128
        break;
129
    case StackFrameFunctionCode:
130
        traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
131
        break;
132
    case StackFrameGlobalCode:
133
        traceLine = "global code";
134
        break;
135
    }
136
    if (traceLine.isEmpty())
137
        traceLine = "";
138
    return traceLine;
139
}
140
79
// Returns the depth of the scope chain within a given call frame.
141
// Returns the depth of the scope chain within a given call frame.
80
static int depth(CodeBlock* codeBlock, ScopeChainNode* sc)
142
static int depth(CodeBlock* codeBlock, ScopeChainNode* sc)
81
{
143
{
- a/Source/JavaScriptCore/interpreter/Interpreter.h -40 / +5 lines
Lines 78-124 namespace JSC { a/Source/JavaScriptCore/interpreter/Interpreter.h_sec1
78
        Strong<ExecutableBase> executable;
78
        Strong<ExecutableBase> executable;
79
        int line;
79
        int line;
80
        UString sourceURL;
80
        UString sourceURL;
81
        UString toString(CallFrame* callFrame) const
81
        UString toString(CallFrame*) const;
82
        String friendlySourceURL() const;
83
        String friendlyFunctionName(CallFrame*) const;
84
        unsigned friendlyLineNumber() const
82
        {
85
        {
83
            bool hasSourceURLInfo = !sourceURL.isNull() && !sourceURL.isEmpty();
86
            return line > -1 ? line : 0;
84
            bool hasLineInfo = line > -1;
85
            String traceLine;
86
            JSObject* stackFrameCallee = callee.get();
87
88
            switch (codeType) {
89
            case StackFrameEvalCode:
90
                if (hasSourceURLInfo) {
91
                    traceLine = hasLineInfo ? String::format("eval code@%s:%d", sourceURL.ascii().data(), line) 
92
                                            : String::format("eval code@%s", sourceURL.ascii().data());
93
                } else
94
                    traceLine = String::format("eval code");
95
                break;
96
            case StackFrameNativeCode: {
97
                if (callee) {
98
                    UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee);
99
                    traceLine = String::format("%s@[native code]", functionName.ascii().data());
100
                } else
101
                    traceLine = "[native code]";
102
                break;
103
            }
104
            case StackFrameFunctionCode: {
105
                UString functionName = getCalculatedDisplayName(callFrame, stackFrameCallee);
106
                if (hasSourceURLInfo) {
107
                    traceLine = hasLineInfo ? String::format("%s@%s:%d", functionName.ascii().data(), sourceURL.ascii().data(), line)
108
                                            : String::format("%s@%s", functionName.ascii().data(), sourceURL.ascii().data());
109
                } else
110
                    traceLine = String::format("%s\n", functionName.ascii().data());
111
                break;
112
            }
113
            case StackFrameGlobalCode:
114
                if (hasSourceURLInfo) {
115
                    traceLine = hasLineInfo ? String::format("global code@%s:%d", sourceURL.ascii().data(), line)
116
                                            : String::format("global code@%s", sourceURL.ascii().data());
117
                } else
118
                    traceLine = String::format("global code");
119
                    
120
            }
121
            return traceLine.impl();
122
        }
87
        }
123
    };
88
    };
124
89
- a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp -2 / +21 lines
Lines 1-5 a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp_sec1
1
/*
1
/*
2
 * Copyright (c) 2010 Google Inc. All rights reserved.
2
 * Copyright (c) 2010 Google Inc. All rights reserved.
3
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
3
 * 
4
 * 
4
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * modification, are permitted provided that the following conditions are
Lines 33-38 a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp_sec2
33
34
34
#include "InspectorInstrumentation.h"
35
#include "InspectorInstrumentation.h"
35
#include "JSDOMBinding.h"
36
#include "JSDOMBinding.h"
37
#include "JSMainThreadExecState.h"
36
#include "ScriptArguments.h"
38
#include "ScriptArguments.h"
37
#include "ScriptCallFrame.h"
39
#include "ScriptCallFrame.h"
38
#include "ScriptCallStack.h"
40
#include "ScriptCallStack.h"
Lines 51-59 namespace WebCore { a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp_sec3
51
53
52
class ScriptExecutionContext;
54
class ScriptExecutionContext;
53
55
54
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t, bool)
56
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyIsAllowed)
55
{
57
{
56
    return 0;
58
    Vector<ScriptCallFrame> frames;
59
    if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) {
60
        Vector<StackFrame> stackTrace;
61
        Interpreter::getStackTrace(&exec->globalData(), stackTrace);
62
        for (Vector<StackFrame>::const_iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) {
63
            StackFrame level = *iter;
64
            frames.append(ScriptCallFrame(level.friendlyFunctionName(exec), level.friendlySourceURL(), level.friendlyLineNumber()));
65
            if (frames.size() >= maxStackSize)
66
                break;
67
        }
68
    }
69
    if (frames.isEmpty() && !emptyIsAllowed) {
70
        // No frames found. It may happen in the case where
71
        // a bound function is called from native code for example.
72
        // Fallback to setting lineNumber to 0, and source and function name to "undefined".
73
        frames.append(ScriptCallFrame("undefined", "undefined", 0));
74
    }
75
    return ScriptCallStack::create(frames);
57
}
76
}
58
77
59
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)
78
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize)

Return to Bug 40118