| 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/V8DebuggerImpl.h" | 9 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 10 #include "platform/v8_inspector/V8StringUtil.h" | 10 #include "platform/v8_inspector/V8StringUtil.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 String16 functionName; | 28 String16 functionName; |
| 29 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); | 29 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); |
| 30 if (!functionNameValue.IsEmpty()) | 30 if (!functionNameValue.IsEmpty()) |
| 31 functionName = toProtocolString(functionNameValue); | 31 functionName = toProtocolString(functionNameValue); |
| 32 | 32 |
| 33 int sourceLineNumber = frame->GetLineNumber(); | 33 int sourceLineNumber = frame->GetLineNumber(); |
| 34 int sourceColumn = frame->GetColumn(); | 34 int sourceColumn = frame->GetColumn(); |
| 35 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLin
eNumber, sourceColumn); | 35 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLin
eNumber, sourceColumn); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, protocol::Vector<V8Sta
ckTraceImpl::Frame>& frames, size_t maxStackSize, v8::Isolate* isolate) | 38 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, std::vector<V8StackTra
ceImpl::Frame>& frames, size_t maxStackSize, v8::Isolate* isolate) |
| 39 { | 39 { |
| 40 DCHECK(isolate->InContext()); | 40 DCHECK(isolate->InContext()); |
| 41 int frameCount = stackTrace->GetFrameCount(); | 41 int frameCount = stackTrace->GetFrameCount(); |
| 42 if (frameCount > static_cast<int>(maxStackSize)) | 42 if (frameCount > static_cast<int>(maxStackSize)) |
| 43 frameCount = maxStackSize; | 43 frameCount = maxStackSize; |
| 44 for (int i = 0; i < frameCount; i++) { | 44 for (int i = 0; i < frameCount; i++) { |
| 45 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); | 45 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); |
| 46 frames.append(toFrame(stackFrame)); | 46 frames.push_back(toFrame(stackFrame)); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 V8StackTraceImpl::Frame::Frame() | 52 V8StackTraceImpl::Frame::Frame() |
| 53 : m_functionName("undefined") | 53 : m_functionName("undefined") |
| 54 , m_scriptId("") | 54 , m_scriptId("") |
| 55 , m_scriptName("undefined") | 55 , m_scriptName("undefined") |
| 56 , m_lineNumber(0) | 56 , m_lineNumber(0) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 | 86 |
| 87 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const | 87 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const |
| 88 { | 88 { |
| 89 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr
iptName.isolatedCopy(), m_lineNumber, m_columnNumber); | 89 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr
iptName.isolatedCopy(), m_lineNumber, m_columnNumber); |
| 90 } | 90 } |
| 91 | 91 |
| 92 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerImpl* debug
ger, int contextGroupId, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSi
ze, const String16& description) | 92 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerImpl* debug
ger, int contextGroupId, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSi
ze, const String16& description) |
| 93 { | 93 { |
| 94 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 94 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 95 v8::HandleScope scope(isolate); | 95 v8::HandleScope scope(isolate); |
| 96 protocol::Vector<V8StackTraceImpl::Frame> frames; | 96 std::vector<V8StackTraceImpl::Frame> frames; |
| 97 if (!stackTrace.IsEmpty()) | 97 if (!stackTrace.IsEmpty()) |
| 98 toFramesVector(stackTrace, frames, maxStackSize, isolate); | 98 toFramesVector(stackTrace, frames, maxStackSize, isolate); |
| 99 | 99 |
| 100 int maxAsyncCallChainDepth = 1; | 100 int maxAsyncCallChainDepth = 1; |
| 101 V8StackTraceImpl* asyncCallChain = nullptr; | 101 V8StackTraceImpl* asyncCallChain = nullptr; |
| 102 if (debugger && maxStackSize > 1) { | 102 if (debugger && maxStackSize > 1) { |
| 103 asyncCallChain = debugger->currentAsyncCallChain(); | 103 asyncCallChain = debugger->currentAsyncCallChain(); |
| 104 maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); | 104 maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); |
| 105 } | 105 } |
| 106 // Do not accidentally append async call chain from another group. This shou
ld not | 106 // Do not accidentally append async call chain from another group. This shou
ld not |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, maxSta
ckSize, description); | 145 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, maxSta
ckSize, description); |
| 146 } | 146 } |
| 147 | 147 |
| 148 std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone() | 148 std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone() |
| 149 { | 149 { |
| 150 return cloneImpl(); | 150 return cloneImpl(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() | 153 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() |
| 154 { | 154 { |
| 155 protocol::Vector<Frame> framesCopy(m_frames); | 155 std::vector<Frame> framesCopy(m_frames); |
| 156 return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description, fram
esCopy, m_parent ? m_parent->cloneImpl() : nullptr)); | 156 return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description, fram
esCopy, m_parent ? m_parent->cloneImpl() : nullptr)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 std::unique_ptr<V8StackTrace> V8StackTraceImpl::isolatedCopy() | 159 std::unique_ptr<V8StackTrace> V8StackTraceImpl::isolatedCopy() |
| 160 { | 160 { |
| 161 return isolatedCopyImpl(); | 161 return isolatedCopyImpl(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::isolatedCopyImpl() | 164 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::isolatedCopyImpl() |
| 165 { | 165 { |
| 166 protocol::Vector<Frame> frames; | 166 std::vector<Frame> frames; |
| 167 for (size_t i = 0; i < m_frames.size(); i++) | 167 for (size_t i = 0; i < m_frames.size(); i++) |
| 168 frames.append(m_frames.at(i).isolatedCopy()); | 168 frames.push_back(m_frames.at(i).isolatedCopy()); |
| 169 return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isola
tedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); | 169 return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isola
tedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, const String16& descripti
on, protocol::Vector<Frame>& frames, std::unique_ptr<V8StackTraceImpl> parent) | 172 V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, const String16& descripti
on, std::vector<Frame>& frames, std::unique_ptr<V8StackTraceImpl> parent) |
| 173 : m_contextGroupId(contextGroupId) | 173 : m_contextGroupId(contextGroupId) |
| 174 , m_description(description) | 174 , m_description(description) |
| 175 , m_parent(std::move(parent)) | 175 , m_parent(std::move(parent)) |
| 176 { | 176 { |
| 177 m_frames.swap(frames); | 177 m_frames.swap(frames); |
| 178 } | 178 } |
| 179 | 179 |
| 180 V8StackTraceImpl::~V8StackTraceImpl() | 180 V8StackTraceImpl::~V8StackTraceImpl() |
| 181 { | 181 { |
| 182 } | 182 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 stackTrace.append(':'); | 247 stackTrace.append(':'); |
| 248 stackTrace.appendNumber(frame.lineNumber()); | 248 stackTrace.appendNumber(frame.lineNumber()); |
| 249 stackTrace.append(':'); | 249 stackTrace.append(':'); |
| 250 stackTrace.appendNumber(frame.columnNumber()); | 250 stackTrace.appendNumber(frame.columnNumber()); |
| 251 stackTrace.append(')'); | 251 stackTrace.append(')'); |
| 252 } | 252 } |
| 253 return stackTrace.toString(); | 253 return stackTrace.toString(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |