Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/inspector/v8-stack-trace-impl.h" | 5 #include "src/inspector/v8-stack-trace-impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/inspector/v8-debugger.h" | 9 #include "src/inspector/v8-debugger.h" |
| 10 #include "src/inspector/wasm-translation.h" | 10 #include "src/inspector/wasm-translation.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // stack, so ensure that second stack is non-empty (it's the top of appended | 56 // stack, so ensure that second stack is non-empty (it's the top of appended |
| 57 // chain). | 57 // chain). |
| 58 if (*asyncParent && !(*asyncCreation) && !(*asyncParent)->creation().lock() && | 58 if (*asyncParent && !(*asyncCreation) && !(*asyncParent)->creation().lock() && |
| 59 (*asyncParent)->isEmpty()) { | 59 (*asyncParent)->isEmpty()) { |
| 60 *asyncParent = (*asyncParent)->parent().lock(); | 60 *asyncParent = (*asyncParent)->parent().lock(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectCommon( | 64 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectCommon( |
| 65 const std::vector<std::shared_ptr<StackFrame>>& frames, | 65 const std::vector<std::shared_ptr<StackFrame>>& frames, |
| 66 const String16& description, | |
| 66 const std::shared_ptr<AsyncStackTrace>& asyncParent, | 67 const std::shared_ptr<AsyncStackTrace>& asyncParent, |
| 67 const std::shared_ptr<AsyncStackTrace>& asyncCreation, int maxAsyncDepth) { | 68 const std::shared_ptr<AsyncStackTrace>& asyncCreation, int maxAsyncDepth) { |
| 68 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> | 69 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> |
| 69 inspectorFrames = protocol::Array<protocol::Runtime::CallFrame>::create(); | 70 inspectorFrames = protocol::Array<protocol::Runtime::CallFrame>::create(); |
| 70 for (size_t i = 0; i < frames.size(); i++) { | 71 for (size_t i = 0; i < frames.size(); i++) { |
| 71 inspectorFrames->addItem(frames[i]->buildInspectorObject()); | 72 inspectorFrames->addItem(frames[i]->buildInspectorObject()); |
| 72 } | 73 } |
| 73 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = | 74 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = |
| 74 protocol::Runtime::StackTrace::create() | 75 protocol::Runtime::StackTrace::create() |
| 75 .setCallFrames(std::move(inspectorFrames)) | 76 .setCallFrames(std::move(inspectorFrames)) |
| 76 .build(); | 77 .build(); |
| 77 if (asyncParent && maxAsyncDepth > 0) { | 78 if (!description.isEmpty()) stackTrace->setDescription(description); |
| 79 if (asyncParent && maxAsyncDepth > 0 && | |
| 80 (asyncParent->description() != description || !asyncParent->isEmpty() || | |
|
dgozman
2017/04/27 22:37:22
We should not return here, but just skip the paren
kozy
2017/04/28 16:13:30
Done.
| |
| 81 asyncCreation.get())) { | |
| 78 stackTrace->setParent(asyncParent->buildInspectorObject(asyncCreation.get(), | 82 stackTrace->setParent(asyncParent->buildInspectorObject(asyncCreation.get(), |
| 79 maxAsyncDepth - 1)); | 83 maxAsyncDepth - 1)); |
| 80 } | 84 } |
| 81 return stackTrace; | 85 return stackTrace; |
| 82 } | 86 } |
| 83 | 87 |
| 84 } // namespace | 88 } // namespace |
| 85 | 89 |
| 86 StackFrame::StackFrame(v8::Local<v8::StackFrame> v8Frame) | 90 StackFrame::StackFrame(v8::Local<v8::StackFrame> v8Frame) |
| 87 : m_functionName(toProtocolString(v8Frame->GetFunctionName())), | 91 : m_functionName(toProtocolString(v8Frame->GetFunctionName())), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 StringView V8StackTraceImpl::topScriptId() const { | 203 StringView V8StackTraceImpl::topScriptId() const { |
| 200 return toStringView(m_frames[0]->scriptId()); | 204 return toStringView(m_frames[0]->scriptId()); |
| 201 } | 205 } |
| 202 | 206 |
| 203 StringView V8StackTraceImpl::topFunctionName() const { | 207 StringView V8StackTraceImpl::topFunctionName() const { |
| 204 return toStringView(m_frames[0]->functionName()); | 208 return toStringView(m_frames[0]->functionName()); |
| 205 } | 209 } |
| 206 | 210 |
| 207 std::unique_ptr<protocol::Runtime::StackTrace> | 211 std::unique_ptr<protocol::Runtime::StackTrace> |
| 208 V8StackTraceImpl::buildInspectorObjectImpl() const { | 212 V8StackTraceImpl::buildInspectorObjectImpl() const { |
| 209 return buildInspectorObjectCommon(m_frames, m_asyncParent.lock(), | 213 return buildInspectorObjectCommon(m_frames, String16(), m_asyncParent.lock(), |
| 210 m_asyncCreation.lock(), m_maxAsyncDepth); | 214 m_asyncCreation.lock(), m_maxAsyncDepth); |
| 211 } | 215 } |
| 212 | 216 |
| 213 std::unique_ptr<protocol::Runtime::API::StackTrace> | 217 std::unique_ptr<protocol::Runtime::API::StackTrace> |
| 214 V8StackTraceImpl::buildInspectorObject() const { | 218 V8StackTraceImpl::buildInspectorObject() const { |
| 215 return buildInspectorObjectImpl(); | 219 return buildInspectorObjectImpl(); |
| 216 } | 220 } |
| 217 | 221 |
| 218 std::unique_ptr<StringBuffer> V8StackTraceImpl::toString() const { | 222 std::unique_ptr<StringBuffer> V8StackTraceImpl::toString() const { |
| 219 String16Builder stackTrace; | 223 String16Builder stackTrace; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 m_frames(std::move(frames)), | 289 m_frames(std::move(frames)), |
| 286 m_asyncParent(asyncParent), | 290 m_asyncParent(asyncParent), |
| 287 m_asyncCreation(asyncCreation) { | 291 m_asyncCreation(asyncCreation) { |
| 288 DCHECK(m_contextGroupId); | 292 DCHECK(m_contextGroupId); |
| 289 } | 293 } |
| 290 | 294 |
| 291 std::unique_ptr<protocol::Runtime::StackTrace> | 295 std::unique_ptr<protocol::Runtime::StackTrace> |
| 292 AsyncStackTrace::buildInspectorObject(AsyncStackTrace* asyncCreation, | 296 AsyncStackTrace::buildInspectorObject(AsyncStackTrace* asyncCreation, |
| 293 int maxAsyncDepth) const { | 297 int maxAsyncDepth) const { |
| 294 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = | 298 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = |
| 295 buildInspectorObjectCommon(m_frames, m_asyncParent.lock(), | 299 buildInspectorObjectCommon(m_frames, m_description, m_asyncParent.lock(), |
| 296 m_asyncCreation.lock(), maxAsyncDepth); | 300 m_asyncCreation.lock(), maxAsyncDepth); |
| 297 if (!m_description.isEmpty()) stackTrace->setDescription(m_description); | |
| 298 if (asyncCreation && !asyncCreation->isEmpty()) { | 301 if (asyncCreation && !asyncCreation->isEmpty()) { |
| 299 stackTrace->setPromiseCreationFrame( | 302 stackTrace->setPromiseCreationFrame( |
| 300 asyncCreation->m_frames[0]->buildInspectorObject()); | 303 asyncCreation->m_frames[0]->buildInspectorObject()); |
| 301 } | 304 } |
| 302 return stackTrace; | 305 return stackTrace; |
| 303 } | 306 } |
| 304 | 307 |
| 305 int AsyncStackTrace::contextGroupId() const { return m_contextGroupId; } | 308 int AsyncStackTrace::contextGroupId() const { return m_contextGroupId; } |
| 306 | 309 |
| 310 const String16& AsyncStackTrace::description() const { return m_description; } | |
| 311 | |
| 307 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::parent() const { | 312 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::parent() const { |
| 308 return m_asyncParent; | 313 return m_asyncParent; |
| 309 } | 314 } |
| 310 | 315 |
| 311 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const { | 316 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const { |
| 312 return m_asyncCreation; | 317 return m_asyncCreation; |
| 313 } | 318 } |
| 314 | 319 |
| 315 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); } | 320 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); } |
| 316 | 321 |
| 317 } // namespace v8_inspector | 322 } // namespace v8_inspector |
| OLD | NEW |