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 a2a4ce1b6eb8dfae18cacff6a556b0a66754c9d3..9db6b47caf01c79944bb40412c1c9416a62e2a31 100644 |
--- a/src/inspector/v8-stack-trace-impl.cc |
+++ b/src/inspector/v8-stack-trace-impl.cc |
@@ -126,6 +126,12 @@ std::unique_ptr<protocol::Runtime::CallFrame> StackFrame::buildInspectorObject() |
.build(); |
} |
+bool StackFrame::isEqual(StackFrame* frame) const { |
+ return m_scriptId == frame->m_scriptId && |
+ m_lineNumber == frame->m_lineNumber && |
+ m_columnNumber == frame->m_columnNumber; |
+} |
+ |
// static |
void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions( |
v8::Isolate* isolate, bool capture) { |
@@ -241,6 +247,49 @@ std::unique_ptr<StringBuffer> V8StackTraceImpl::toString() const { |
return StringBufferImpl::adopt(string); |
} |
+bool V8StackTraceImpl::isEqualIgnoringTopFrame( |
+ V8StackTraceImpl* stackTrace) const { |
+ StackFrameIterator current(this); |
+ StackFrameIterator target(stackTrace); |
+ |
+ current.next(); |
+ target.next(); |
+ while (!current.done() && !target.done()) { |
+ if (!current.frame()->isEqual(target.frame())) { |
+ return false; |
+ } |
+ current.next(); |
+ target.next(); |
+ } |
+ return current.done() == target.done(); |
+} |
+ |
+V8StackTraceImpl::StackFrameIterator::StackFrameIterator( |
+ const V8StackTraceImpl* stackTrace) |
+ : m_currentIt(stackTrace->m_frames.begin()), |
+ m_currentEnd(stackTrace->m_frames.end()), |
+ m_parent(stackTrace->m_asyncParent.lock().get()) {} |
+ |
+void V8StackTraceImpl::StackFrameIterator::next() { |
+ if (m_currentIt == m_currentEnd) return; |
+ ++m_currentIt; |
+ while (m_currentIt == m_currentEnd && m_parent) { |
+ const std::vector<std::shared_ptr<StackFrame>>& frames = m_parent->frames(); |
+ m_currentIt = frames.begin(); |
+ if (m_parent->description() == "async function") ++m_currentIt; |
+ m_currentEnd = frames.end(); |
+ m_parent = m_parent->parent().lock().get(); |
+ } |
+} |
+ |
+bool V8StackTraceImpl::StackFrameIterator::done() { |
+ return m_currentIt == m_currentEnd; |
+} |
+ |
+StackFrame* V8StackTraceImpl::StackFrameIterator::frame() { |
+ return m_currentIt->get(); |
+} |
+ |
// static |
std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture( |
V8Debugger* debugger, int contextGroupId, const String16& description, |