|
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) |