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/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
8 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 8 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
9 #include "platform/v8_inspector/V8DebuggerImpl.h" | 9 #include "platform/v8_inspector/V8DebuggerImpl.h" |
10 #include "platform/v8_inspector/V8StringUtil.h" | 10 #include "platform/v8_inspector/V8StringUtil.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 // Crop to not exceed maxAsyncCallChainDepth. | 112 // Crop to not exceed maxAsyncCallChainDepth. |
113 V8StackTraceImpl* deepest = result.get(); | 113 V8StackTraceImpl* deepest = result.get(); |
114 while (deepest && maxAsyncCallChainDepth) { | 114 while (deepest && maxAsyncCallChainDepth) { |
115 deepest = deepest->m_parent.get(); | 115 deepest = deepest->m_parent.get(); |
116 maxAsyncCallChainDepth--; | 116 maxAsyncCallChainDepth--; |
117 } | 117 } |
118 if (deepest) | 118 if (deepest) |
119 deepest->m_parent.clear(); | 119 deepest->m_parent.clear(); |
120 | 120 |
121 return result.release(); | 121 return result; |
122 } | 122 } |
123 | 123 |
124 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::capture(V8DebuggerAgentImpl* agen
t, size_t maxStackSize, const String16& description) | 124 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::capture(V8DebuggerAgentImpl* agen
t, size_t maxStackSize, const String16& description) |
125 { | 125 { |
126 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 126 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
127 v8::HandleScope handleScope(isolate); | 127 v8::HandleScope handleScope(isolate); |
128 v8::Local<v8::StackTrace> stackTrace; | 128 v8::Local<v8::StackTrace> stackTrace; |
129 if (isolate->InContext()) { | 129 if (isolate->InContext()) { |
130 #if V8_MAJOR_VERSION >= 5 | 130 #if V8_MAJOR_VERSION >= 5 |
131 isolate->GetCpuProfiler()->CollectSample(); | 131 isolate->GetCpuProfiler()->CollectSample(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return m_frames[0].m_scriptId; | 182 return m_frames[0].m_scriptId; |
183 } | 183 } |
184 | 184 |
185 PassOwnPtr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorObject
() const | 185 PassOwnPtr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorObject
() const |
186 { | 186 { |
187 OwnPtr<protocol::Array<protocol::Runtime::CallFrame>> frames = protocol::Arr
ay<protocol::Runtime::CallFrame>::create(); | 187 OwnPtr<protocol::Array<protocol::Runtime::CallFrame>> frames = protocol::Arr
ay<protocol::Runtime::CallFrame>::create(); |
188 for (size_t i = 0; i < m_frames.size(); i++) | 188 for (size_t i = 0; i < m_frames.size(); i++) |
189 frames->addItem(m_frames.at(i).buildInspectorObject()); | 189 frames->addItem(m_frames.at(i).buildInspectorObject()); |
190 | 190 |
191 OwnPtr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtime::StackT
race::create() | 191 OwnPtr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtime::StackT
race::create() |
192 .setCallFrames(frames.release()).build(); | 192 .setCallFrames(std::move(frames)).build(); |
193 if (!m_description.isEmpty()) | 193 if (!m_description.isEmpty()) |
194 stackTrace->setDescription(m_description); | 194 stackTrace->setDescription(m_description); |
195 if (m_parent) | 195 if (m_parent) |
196 stackTrace->setParent(m_parent->buildInspectorObject()); | 196 stackTrace->setParent(m_parent->buildInspectorObject()); |
197 return stackTrace.release(); | 197 return stackTrace; |
198 } | 198 } |
199 | 199 |
200 PassOwnPtr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorObject
ForTail(V8DebuggerAgentImpl* agent) const | 200 PassOwnPtr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorObject
ForTail(V8DebuggerAgentImpl* agent) const |
201 { | 201 { |
202 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 202 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
203 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep
th. | 203 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep
th. |
204 OwnPtr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(agent, v8::Loc
al<v8::StackTrace>(), V8StackTrace::maxCallStackSizeToCapture); | 204 OwnPtr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(agent, v8::Loc
al<v8::StackTrace>(), V8StackTrace::maxCallStackSizeToCapture); |
205 if (!fullChain || !fullChain->m_parent) | 205 if (!fullChain || !fullChain->m_parent) |
206 return nullptr; | 206 return nullptr; |
207 return fullChain->m_parent->buildInspectorObject(); | 207 return fullChain->m_parent->buildInspectorObject(); |
(...skipping 10 matching lines...) Expand all Loading... |
218 stackTrace.append(':'); | 218 stackTrace.append(':'); |
219 stackTrace.appendNumber(frame.lineNumber()); | 219 stackTrace.appendNumber(frame.lineNumber()); |
220 stackTrace.append(':'); | 220 stackTrace.append(':'); |
221 stackTrace.appendNumber(frame.columnNumber()); | 221 stackTrace.appendNumber(frame.columnNumber()); |
222 stackTrace.append(')'); | 222 stackTrace.append(')'); |
223 } | 223 } |
224 return stackTrace.toString(); | 224 return stackTrace.toString(); |
225 } | 225 } |
226 | 226 |
227 } // namespace blink | 227 } // namespace blink |
OLD | NEW |