| 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 20 matching lines...) Expand all Loading... |
| 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, protocol::Vector<V8Sta
ckTraceImpl::Frame>& frames, size_t maxStackSize, v8::Isolate* isolate) |
| 40 { | 40 { |
| 41 ASSERT(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.append(toFrame(stackFrame)); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 { | 147 { |
| 148 m_frames.swap(frames); | 148 m_frames.swap(frames); |
| 149 } | 149 } |
| 150 | 150 |
| 151 V8StackTraceImpl::~V8StackTraceImpl() | 151 V8StackTraceImpl::~V8StackTraceImpl() |
| 152 { | 152 { |
| 153 } | 153 } |
| 154 | 154 |
| 155 String16 V8StackTraceImpl::topSourceURL() const | 155 String16 V8StackTraceImpl::topSourceURL() const |
| 156 { | 156 { |
| 157 ASSERT(m_frames.size()); | 157 DCHECK(m_frames.size()); |
| 158 return m_frames[0].m_scriptName; | 158 return m_frames[0].m_scriptName; |
| 159 } | 159 } |
| 160 | 160 |
| 161 int V8StackTraceImpl::topLineNumber() const | 161 int V8StackTraceImpl::topLineNumber() const |
| 162 { | 162 { |
| 163 ASSERT(m_frames.size()); | 163 DCHECK(m_frames.size()); |
| 164 return m_frames[0].m_lineNumber; | 164 return m_frames[0].m_lineNumber; |
| 165 } | 165 } |
| 166 | 166 |
| 167 int V8StackTraceImpl::topColumnNumber() const | 167 int V8StackTraceImpl::topColumnNumber() const |
| 168 { | 168 { |
| 169 ASSERT(m_frames.size()); | 169 DCHECK(m_frames.size()); |
| 170 return m_frames[0].m_columnNumber; | 170 return m_frames[0].m_columnNumber; |
| 171 } | 171 } |
| 172 | 172 |
| 173 String16 V8StackTraceImpl::topFunctionName() const | 173 String16 V8StackTraceImpl::topFunctionName() const |
| 174 { | 174 { |
| 175 ASSERT(m_frames.size()); | 175 DCHECK(m_frames.size()); |
| 176 return m_frames[0].m_functionName; | 176 return m_frames[0].m_functionName; |
| 177 } | 177 } |
| 178 | 178 |
| 179 String16 V8StackTraceImpl::topScriptId() const | 179 String16 V8StackTraceImpl::topScriptId() const |
| 180 { | 180 { |
| 181 ASSERT(m_frames.size()); | 181 DCHECK(m_frames.size()); |
| 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() |
| (...skipping 26 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 |