Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: src/inspector/v8-stack-trace-impl.cc

Issue 2879923003: [inspector] added targetCallFrames for continueToLocation (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (functionName() != frame->functionName()) return false;
131 if (scriptId() != frame->scriptId()) return false;
dgozman 2017/05/15 17:01:27 We always have scriptId, right? Then there is no n
kozy 2017/05/16 01:43:48 Done.
132 if (sourceURL() != frame->sourceURL()) return false;
133 if (lineNumber() != frame->lineNumber()) return false;
134 if (columnNumber() != frame->columnNumber()) return false;
135 return true;
136 }
137
129 // static 138 // static
130 void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions( 139 void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(
131 v8::Isolate* isolate, bool capture) { 140 v8::Isolate* isolate, bool capture) {
132 isolate->SetCaptureStackTraceForUncaughtExceptions( 141 isolate->SetCaptureStackTraceForUncaughtExceptions(
133 capture, V8StackTraceImpl::maxCallStackSizeToCapture); 142 capture, V8StackTraceImpl::maxCallStackSizeToCapture);
134 } 143 }
135 144
136 // static 145 // static
137 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( 146 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
138 V8Debugger* debugger, int contextGroupId, 147 V8Debugger* debugger, int contextGroupId,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 stackTrace.append(':'); 243 stackTrace.append(':');
235 stackTrace.append(String16::fromInteger(frame.lineNumber() + 1)); 244 stackTrace.append(String16::fromInteger(frame.lineNumber() + 1));
236 stackTrace.append(':'); 245 stackTrace.append(':');
237 stackTrace.append(String16::fromInteger(frame.columnNumber() + 1)); 246 stackTrace.append(String16::fromInteger(frame.columnNumber() + 1));
238 stackTrace.append(')'); 247 stackTrace.append(')');
239 } 248 }
240 String16 string = stackTrace.toString(); 249 String16 string = stackTrace.toString();
241 return StringBufferImpl::adopt(string); 250 return StringBufferImpl::adopt(string);
242 } 251 }
243 252
253 bool V8StackTraceImpl::isEqualIgnoringTopFrame(
254 V8StackTraceImpl* stackTrace) const {
255 StackFrameIterator current(this);
256 StackFrameIterator target(stackTrace);
257
258 current.next();
259 target.next();
260 while (!current.done() && !target.done()) {
261 if (!current.frame()->isEqual(target.frame())) {
262 return false;
263 }
264 current.next();
265 target.next();
266 }
267 return current.done() == target.done();
268 }
269
270 V8StackTraceImpl::StackFrameIterator::StackFrameIterator(
271 const V8StackTraceImpl* stackTrace)
272 : m_currentIt(stackTrace->m_frames.begin()),
273 m_currentEnd(stackTrace->m_frames.end()),
dgozman 2017/05/15 17:01:27 If top stack is empty, iterator will be immediatel
kozy 2017/05/16 01:43:48 currently it could not happen, removed DCHECK.
274 m_parent(stackTrace->m_asyncParent.lock().get()) {
275 DCHECK(m_currentIt != m_currentEnd);
276 }
277
278 void V8StackTraceImpl::StackFrameIterator::next() {
279 if (m_currentIt == m_currentEnd) return;
280 ++m_currentIt;
281 while (m_currentIt == m_currentEnd && m_parent) {
282 const std::vector<std::shared_ptr<StackFrame>>& frames = m_parent->frames();
283 m_currentIt = frames.begin();
284 if (m_parent->description() == "async function") ++m_currentIt;
285 m_currentEnd = frames.end();
286 m_parent = m_parent->parent().lock().get();
287 }
288 }
289
290 bool V8StackTraceImpl::StackFrameIterator::done() {
291 return m_currentIt == m_currentEnd;
292 }
293
294 StackFrame* V8StackTraceImpl::StackFrameIterator::frame() {
295 return m_currentIt != m_currentEnd ? m_currentIt->get() : nullptr;
dgozman 2017/05/15 17:01:27 Just m_currentIt->get(), since nobody should acces
kozy 2017/05/16 01:43:48 Done.
296 }
297
244 // static 298 // static
245 std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture( 299 std::shared_ptr<AsyncStackTrace> AsyncStackTrace::capture(
246 V8Debugger* debugger, int contextGroupId, const String16& description, 300 V8Debugger* debugger, int contextGroupId, const String16& description,
247 int maxStackSize) { 301 int maxStackSize) {
248 DCHECK(debugger); 302 DCHECK(debugger);
249 303
250 v8::Isolate* isolate = debugger->isolate(); 304 v8::Isolate* isolate = debugger->isolate();
251 v8::HandleScope handleScope(isolate); 305 v8::HandleScope handleScope(isolate);
252 306
253 std::vector<std::shared_ptr<StackFrame>> frames; 307 std::vector<std::shared_ptr<StackFrame>> frames;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return m_asyncParent; 365 return m_asyncParent;
312 } 366 }
313 367
314 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const { 368 std::weak_ptr<AsyncStackTrace> AsyncStackTrace::creation() const {
315 return m_asyncCreation; 369 return m_asyncCreation;
316 } 370 }
317 371
318 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); } 372 bool AsyncStackTrace::isEmpty() const { return m_frames.empty(); }
319 373
320 } // namespace v8_inspector 374 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698