OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/v8_inspector/V8StackTraceImpl.h" | 5 #include "platform/v8_inspector/V8StackTraceImpl.h" |
6 | 6 |
7 #include "platform/inspector_protocol/Platform.h" | 7 #include "platform/inspector_protocol/Platform.h" |
8 #include "platform/inspector_protocol/String16.h" | 8 #include "platform/inspector_protocol/String16.h" |
9 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 9 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
10 #include "platform/v8_inspector/V8DebuggerImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerImpl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 String16 functionName; | 29 String16 functionName; |
30 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); | 30 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); |
31 if (!functionNameValue.IsEmpty()) | 31 if (!functionNameValue.IsEmpty()) |
32 functionName = toProtocolString(functionNameValue); | 32 functionName = toProtocolString(functionNameValue); |
33 | 33 |
34 int sourceLineNumber = frame->GetLineNumber(); | 34 int sourceLineNumber = frame->GetLineNumber(); |
35 int sourceColumn = frame->GetColumn(); | 35 int sourceColumn = frame->GetColumn(); |
36 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLin
eNumber, sourceColumn); | 36 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLin
eNumber, sourceColumn); |
37 } | 37 } |
38 | 38 |
39 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, protocol::Vector<V8Sta
ckTraceImpl::Frame>& frames, size_t maxStackSize, v8::Isolate* isolate) | 39 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, std::vector<V8StackTra
ceImpl::Frame>& frames, size_t maxStackSize, v8::Isolate* isolate) |
40 { | 40 { |
41 DCHECK(isolate->InContext()); | 41 DCHECK(isolate->InContext()); |
42 int frameCount = stackTrace->GetFrameCount(); | 42 int frameCount = stackTrace->GetFrameCount(); |
43 if (frameCount > static_cast<int>(maxStackSize)) | 43 if (frameCount > static_cast<int>(maxStackSize)) |
44 frameCount = maxStackSize; | 44 frameCount = maxStackSize; |
45 for (int i = 0; i < frameCount; i++) { | 45 for (int i = 0; i < frameCount; i++) { |
46 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); | 46 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); |
47 frames.append(toFrame(stackFrame)); | 47 frames.push_back(toFrame(stackFrame)); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 V8StackTraceImpl::Frame::Frame() | 53 V8StackTraceImpl::Frame::Frame() |
54 : m_functionName("undefined") | 54 : m_functionName("undefined") |
55 , m_scriptId("") | 55 , m_scriptId("") |
56 , m_scriptName("undefined") | 56 , m_scriptName("undefined") |
57 , m_lineNumber(0) | 57 , m_lineNumber(0) |
(...skipping 29 matching lines...) Expand all Loading... |
87 | 87 |
88 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const | 88 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const |
89 { | 89 { |
90 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr
iptName.isolatedCopy(), m_lineNumber, m_columnNumber); | 90 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr
iptName.isolatedCopy(), m_lineNumber, m_columnNumber); |
91 } | 91 } |
92 | 92 |
93 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl*
agent, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, const String16
& description) | 93 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl*
agent, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, const String16
& description) |
94 { | 94 { |
95 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 95 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
96 v8::HandleScope scope(isolate); | 96 v8::HandleScope scope(isolate); |
97 protocol::Vector<V8StackTraceImpl::Frame> frames; | 97 std::vector<V8StackTraceImpl::Frame> frames; |
98 if (!stackTrace.IsEmpty()) | 98 if (!stackTrace.IsEmpty()) |
99 toFramesVector(stackTrace, frames, maxStackSize, isolate); | 99 toFramesVector(stackTrace, frames, maxStackSize, isolate); |
100 | 100 |
101 int maxAsyncCallChainDepth = 1; | 101 int maxAsyncCallChainDepth = 1; |
102 V8StackTraceImpl* asyncCallChain = nullptr; | 102 V8StackTraceImpl* asyncCallChain = nullptr; |
103 if (agent && maxStackSize > 1) { | 103 if (agent && maxStackSize > 1) { |
104 asyncCallChain = agent->currentAsyncCallChain(); | 104 asyncCallChain = agent->currentAsyncCallChain(); |
105 maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth(); | 105 maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth(); |
106 } | 106 } |
107 | 107 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description
); | 140 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description
); |
141 } | 141 } |
142 | 142 |
143 std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone() | 143 std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone() |
144 { | 144 { |
145 return cloneImpl(); | 145 return cloneImpl(); |
146 } | 146 } |
147 | 147 |
148 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() | 148 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() |
149 { | 149 { |
150 protocol::Vector<Frame> framesCopy(m_frames); | 150 std::vector<Frame> framesCopy(m_frames); |
151 return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ?
m_parent->cloneImpl() : nullptr)); | 151 return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ?
m_parent->cloneImpl() : nullptr)); |
152 } | 152 } |
153 | 153 |
154 std::unique_ptr<V8StackTrace> V8StackTraceImpl::isolatedCopy() | 154 std::unique_ptr<V8StackTrace> V8StackTraceImpl::isolatedCopy() |
155 { | 155 { |
156 return isolatedCopyImpl(); | 156 return isolatedCopyImpl(); |
157 } | 157 } |
158 | 158 |
159 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::isolatedCopyImpl() | 159 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::isolatedCopyImpl() |
160 { | 160 { |
161 protocol::Vector<Frame> frames; | 161 std::vector<Frame> frames; |
162 for (size_t i = 0; i < m_frames.size(); i++) | 162 for (size_t i = 0; i < m_frames.size(); i++) |
163 frames.append(m_frames.at(i).isolatedCopy()); | 163 frames.push_back(m_frames.at(i).isolatedCopy()); |
164 return wrapUnique(new V8StackTraceImpl(m_description.isolatedCopy(), frames,
m_parent ? m_parent->isolatedCopyImpl() : nullptr)); | 164 return wrapUnique(new V8StackTraceImpl(m_description.isolatedCopy(), frames,
m_parent ? m_parent->isolatedCopyImpl() : nullptr)); |
165 } | 165 } |
166 | 166 |
167 V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector
<Frame>& frames, std::unique_ptr<V8StackTraceImpl> parent) | 167 V8StackTraceImpl::V8StackTraceImpl(const String16& description, std::vector<Fram
e>& frames, std::unique_ptr<V8StackTraceImpl> parent) |
168 : m_description(description) | 168 : m_description(description) |
169 , m_parent(std::move(parent)) | 169 , m_parent(std::move(parent)) |
170 { | 170 { |
171 m_frames.swap(frames); | 171 m_frames.swap(frames); |
172 } | 172 } |
173 | 173 |
174 V8StackTraceImpl::~V8StackTraceImpl() | 174 V8StackTraceImpl::~V8StackTraceImpl() |
175 { | 175 { |
176 } | 176 } |
177 | 177 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 stackTrace.append(':'); | 241 stackTrace.append(':'); |
242 stackTrace.appendNumber(frame.lineNumber()); | 242 stackTrace.appendNumber(frame.lineNumber()); |
243 stackTrace.append(':'); | 243 stackTrace.append(':'); |
244 stackTrace.appendNumber(frame.columnNumber()); | 244 stackTrace.appendNumber(frame.columnNumber()); |
245 stackTrace.append(')'); | 245 stackTrace.append(')'); |
246 } | 246 } |
247 return stackTrace.toString(); | 247 return stackTrace.toString(); |
248 } | 248 } |
249 | 249 |
250 } // namespace blink | 250 } // namespace blink |
OLD | NEW |