| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119     const { | 119     const { | 
| 120   return protocol::Runtime::CallFrame::create() | 120   return protocol::Runtime::CallFrame::create() | 
| 121       .setFunctionName(m_functionName) | 121       .setFunctionName(m_functionName) | 
| 122       .setScriptId(m_scriptId) | 122       .setScriptId(m_scriptId) | 
| 123       .setUrl(m_sourceURL) | 123       .setUrl(m_sourceURL) | 
| 124       .setLineNumber(m_lineNumber) | 124       .setLineNumber(m_lineNumber) | 
| 125       .setColumnNumber(m_columnNumber) | 125       .setColumnNumber(m_columnNumber) | 
| 126       .build(); | 126       .build(); | 
| 127 } | 127 } | 
| 128 | 128 | 
|  | 129 bool StackFrame::isEqual(StackFrame* frame) const { | 
|  | 130   return m_scriptId == frame->m_scriptId && | 
|  | 131          m_lineNumber == frame->m_lineNumber && | 
|  | 132          m_columnNumber == frame->m_columnNumber; | 
|  | 133 } | 
|  | 134 | 
| 129 // static | 135 // static | 
| 130 void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions( | 136 void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions( | 
| 131     v8::Isolate* isolate, bool capture) { | 137     v8::Isolate* isolate, bool capture) { | 
| 132   isolate->SetCaptureStackTraceForUncaughtExceptions( | 138   isolate->SetCaptureStackTraceForUncaughtExceptions( | 
| 133       capture, V8StackTraceImpl::maxCallStackSizeToCapture); | 139       capture, V8StackTraceImpl::maxCallStackSizeToCapture); | 
| 134 } | 140 } | 
| 135 | 141 | 
| 136 // static | 142 // static | 
| 137 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( | 143 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( | 
| 138     V8Debugger* debugger, int contextGroupId, | 144     V8Debugger* debugger, int contextGroupId, | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 234     stackTrace.append(':'); | 240     stackTrace.append(':'); | 
| 235     stackTrace.append(String16::fromInteger(frame.lineNumber() + 1)); | 241     stackTrace.append(String16::fromInteger(frame.lineNumber() + 1)); | 
| 236     stackTrace.append(':'); | 242     stackTrace.append(':'); | 
| 237     stackTrace.append(String16::fromInteger(frame.columnNumber() + 1)); | 243     stackTrace.append(String16::fromInteger(frame.columnNumber() + 1)); | 
| 238     stackTrace.append(')'); | 244     stackTrace.append(')'); | 
| 239   } | 245   } | 
| 240   String16 string = stackTrace.toString(); | 246   String16 string = stackTrace.toString(); | 
| 241   return StringBufferImpl::adopt(string); | 247   return StringBufferImpl::adopt(string); | 
| 242 } | 248 } | 
| 243 | 249 | 
|  | 250 bool V8StackTraceImpl::isEqualIgnoringTopFrame( | 
|  | 251     V8StackTraceImpl* stackTrace) const { | 
|  | 252   StackFrameIterator current(this); | 
|  | 253   StackFrameIterator target(stackTrace); | 
|  | 254 | 
|  | 255   current.next(); | 
|  | 256   target.next(); | 
|  | 257   while (!current.done() && !target.done()) { | 
|  | 258     if (!current.frame()->isEqual(target.frame())) { | 
|  | 259       return false; | 
|  | 260     } | 
|  | 261     current.next(); | 
|  | 262     target.next(); | 
|  | 263   } | 
|  | 264   return current.done() == target.done(); | 
|  | 265 } | 
|  | 266 | 
|  | 267 V8StackTraceImpl::StackFrameIterator::StackFrameIterator( | 
|  | 268     const V8StackTraceImpl* stackTrace) | 
|  | 269     : m_currentIt(stackTrace->m_frames.begin()), | 
|  | 270       m_currentEnd(stackTrace->m_frames.end()), | 
|  | 271       m_parent(stackTrace->m_asyncParent.lock().get()) {} | 
|  | 272 | 
|  | 273 void V8StackTraceImpl::StackFrameIterator::next() { | 
|  | 274   if (m_currentIt == m_currentEnd) return; | 
|  | 275   ++m_currentIt; | 
|  | 276   while (m_currentIt == m_currentEnd && m_parent) { | 
|  | 277     const std::vector<std::shared_ptr<StackFrame>>& frames = m_parent->frames(); | 
|  | 278     m_currentIt = frames.begin(); | 
|  | 279     if (m_parent->description() == "async function") ++m_currentIt; | 
|  | 280     m_currentEnd = frames.end(); | 
|  | 281     m_parent = m_parent->parent().lock().get(); | 
|  | 282   } | 
|  | 283 } | 
|  | 284 | 
|  | 285 bool V8StackTraceImpl::StackFrameIterator::done() { | 
|  | 286   return m_currentIt == m_currentEnd; | 
|  | 287 } | 
|  | 288 | 
|  | 289 StackFrame* V8StackTraceImpl::StackFrameIterator::frame() { | 
|  | 290   return m_currentIt->get(); | 
|  | 291 } | 
|  | 292 | 
| 244 // static | 293 // static | 
| 245 std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture( | 294 std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture( | 
| 246     V8Debugger* debugger, int contextGroupId, const String16& description, | 295     V8Debugger* debugger, int contextGroupId, const String16& description, | 
| 247     int maxStackSize) { | 296     int maxStackSize) { | 
| 248   DCHECK(debugger); | 297   DCHECK(debugger); | 
| 249 | 298 | 
| 250   v8::Isolate* isolate = debugger->isolate(); | 299   v8::Isolate* isolate = debugger->isolate(); | 
| 251   v8::HandleScope handleScope(isolate); | 300   v8::HandleScope handleScope(isolate); | 
| 252 | 301 | 
| 253   std::vector<std::shared_ptr<StackFrame>> frames; | 302   std::vector<std::shared_ptr<StackFrame>> frames; | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 311   return m_asyncParent; | 360   return m_asyncParent; | 
| 312 } | 361 } | 
| 313 | 362 | 
| 314 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const { | 363 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const { | 
| 315   return m_asyncCreation; | 364   return m_asyncCreation; | 
| 316 } | 365 } | 
| 317 | 366 | 
| 318 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); } | 367 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); } | 
| 319 | 368 | 
| 320 }  // namespace v8_inspector | 369 }  // namespace v8_inspector | 
| OLD | NEW | 
|---|