Chromium Code Reviews| Index: src/inspector/v8-stack-trace-impl.cc |
| diff --git a/src/inspector/v8-stack-trace-impl.cc b/src/inspector/v8-stack-trace-impl.cc |
| index 962a00a773ded450312a8c5005601178c0773f76..6f7fe86db60877640d77d9bf0186eb038f72db5c 100644 |
| --- a/src/inspector/v8-stack-trace-impl.cc |
| +++ b/src/inspector/v8-stack-trace-impl.cc |
| @@ -117,7 +117,8 @@ void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions( |
| std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( |
| V8Debugger* debugger, int contextGroupId, |
| v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, |
| - const String16& description) { |
| + const String16& description, |
| + std::unique_ptr<V8StackTraceImpl> creationStackTrace) { |
| v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| v8::HandleScope scope(isolate); |
| std::vector<V8StackTraceImpl::Frame> frames; |
| @@ -127,6 +128,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( |
| int maxAsyncCallChainDepth = 1; |
| V8StackTraceImpl* asyncCallChain = nullptr; |
| + V8StackTraceImpl* creationCallChain = nullptr; |
|
dgozman
2017/01/24 01:02:41
Remove.
kozy
2017/01/24 21:43:39
Done.
|
| if (debugger && maxStackSize > 1) { |
| asyncCallChain = debugger->currentAsyncCallChain(); |
| maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); |
| @@ -143,14 +145,17 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( |
| // Only the top stack in the chain may be empty, so ensure that second stack |
|
dgozman
2017/01/24 01:02:41
Amend the comment.
kozy
2017/01/24 21:43:39
Done.
|
| // is non-empty (it's the top of appended chain). |
| - if (asyncCallChain && asyncCallChain->isEmpty()) |
| + if (asyncCallChain && asyncCallChain->isEmpty() && |
| + !asyncCallChain->m_creation) |
| asyncCallChain = asyncCallChain->m_parent.get(); |
| - if (stackTrace.IsEmpty() && !asyncCallChain) return nullptr; |
| + if (stackTrace.IsEmpty() && !asyncCallChain && !creationCallChain) |
| + return nullptr; |
| std::unique_ptr<V8StackTraceImpl> result(new V8StackTraceImpl( |
| contextGroupId, description, frames, |
| - asyncCallChain ? asyncCallChain->cloneImpl() : nullptr)); |
| + asyncCallChain ? asyncCallChain->cloneImpl() : nullptr, |
| + std::move(creationStackTrace))); |
| // Crop to not exceed maxAsyncCallChainDepth. |
| V8StackTraceImpl* deepest = result.get(); |
| @@ -166,7 +171,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( |
| // static |
| std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( |
| V8Debugger* debugger, int contextGroupId, size_t maxStackSize, |
| - const String16& description) { |
| + const String16& description, |
| + std::unique_ptr<V8StackTraceImpl> creationStackTrace) { |
| v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| v8::HandleScope handleScope(isolate); |
| v8::Local<v8::StackTrace> stackTrace; |
| @@ -175,31 +181,35 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( |
| isolate, static_cast<int>(maxStackSize), stackTraceOptions); |
| } |
| return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, |
| - maxStackSize, description); |
| + maxStackSize, description, |
| + std::move(creationStackTrace)); |
| } |
| std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { |
| std::vector<Frame> framesCopy(m_frames); |
| return std::unique_ptr<V8StackTraceImpl>( |
| new V8StackTraceImpl(m_contextGroupId, m_description, framesCopy, |
| - m_parent ? m_parent->cloneImpl() : nullptr)); |
| + m_parent ? m_parent->cloneImpl() : nullptr, |
| + m_creation ? m_creation->cloneImpl() : nullptr)); |
| } |
| std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone() { |
| std::vector<Frame> frames; |
| for (size_t i = 0; i < m_frames.size(); i++) |
| frames.push_back(m_frames.at(i).clone()); |
| - return std::unique_ptr<V8StackTraceImpl>( |
| - new V8StackTraceImpl(m_contextGroupId, m_description, frames, nullptr)); |
| + return std::unique_ptr<V8StackTraceImpl>(new V8StackTraceImpl( |
| + m_contextGroupId, m_description, frames, nullptr, nullptr)); |
| } |
| V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, |
| const String16& description, |
| std::vector<Frame>& frames, |
| - std::unique_ptr<V8StackTraceImpl> parent) |
| + std::unique_ptr<V8StackTraceImpl> parent, |
| + std::unique_ptr<V8StackTraceImpl> creation) |
| : m_contextGroupId(contextGroupId), |
| m_description(description), |
| - m_parent(std::move(parent)) { |
| + m_parent(std::move(parent)), |
| + m_creation(std::move(creation)) { |
| m_frames.swap(frames); |
| } |
| @@ -243,6 +253,10 @@ V8StackTraceImpl::buildInspectorObjectImpl() const { |
| .build(); |
| if (!m_description.isEmpty()) stackTrace->setDescription(m_description); |
| if (m_parent) stackTrace->setParent(m_parent->buildInspectorObjectImpl()); |
| + if (m_creation && m_creation->m_frames.size()) { |
| + stackTrace->setCreationFrame( |
| + m_creation->m_frames[0].buildInspectorObject()); |
| + } |
| return stackTrace; |
| } |