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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8StackTraceImpl.cpp

Issue 2035653006: [DevTools] Move Console to v8 inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all tests pass Created 4 years, 6 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 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/V8DebuggerAgentImpl.h" 9 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
10 #include "platform/v8_inspector/V8DebuggerImpl.h" 10 #include "platform/v8_inspector/V8DebuggerImpl.h"
11 #include "platform/v8_inspector/V8StringUtil.h" 11 #include "platform/v8_inspector/V8StringUtil.h"
12 12
13 #include <v8-debug.h> 13 #include <v8-debug.h>
14 #include <v8-profiler.h> 14 #include <v8-profiler.h>
15 #include <v8-version.h> 15 #include <v8-version.h>
16 16
17 namespace blink { 17 namespace blink {
18 18
19 namespace { 19 namespace {
20 20
21 static const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v 8::StackTrace::StackTraceOptions>(
22 v8::StackTrace::kLineNumber |
23 v8::StackTrace::kColumnOffset |
24 v8::StackTrace::kScriptId |
25 v8::StackTrace::kScriptNameOrSourceURL |
26 v8::StackTrace::kFunctionName);
27
21 V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame) 28 V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame)
22 { 29 {
23 String16 scriptId = String16::number(frame->GetScriptId()); 30 String16 scriptId = String16::number(frame->GetScriptId());
24 String16 sourceName; 31 String16 sourceName;
25 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL()); 32 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
26 if (!sourceNameValue.IsEmpty()) 33 if (!sourceNameValue.IsEmpty())
27 sourceName = toProtocolString(sourceNameValue); 34 sourceName = toProtocolString(sourceNameValue);
28 35
29 String16 functionName; 36 String16 functionName;
30 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); 37 v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 .setLineNumber(m_lineNumber) 90 .setLineNumber(m_lineNumber)
84 .setColumnNumber(m_columnNumber) 91 .setColumnNumber(m_columnNumber)
85 .build(); 92 .build();
86 } 93 }
87 94
88 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const 95 V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const
89 { 96 {
90 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr iptName.isolatedCopy(), m_lineNumber, m_columnNumber); 97 return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scr iptName.isolatedCopy(), m_lineNumber, m_columnNumber);
91 } 98 }
92 99
100 // static
101 void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(v8::Isolate* is olate, bool capture)
102 {
103 isolate->SetCaptureStackTraceForUncaughtExceptions(capture, V8StackTraceImpl ::maxCallStackSizeToCapture, stackTraceOptions);
104 }
105
93 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl* agent, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, const String16 & description) 106 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl* agent, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, const String16 & description)
94 { 107 {
95 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 108 v8::Isolate* isolate = v8::Isolate::GetCurrent();
96 v8::HandleScope scope(isolate); 109 v8::HandleScope scope(isolate);
97 protocol::Vector<V8StackTraceImpl::Frame> frames; 110 protocol::Vector<V8StackTraceImpl::Frame> frames;
98 if (!stackTrace.IsEmpty()) 111 if (!stackTrace.IsEmpty())
99 toFramesVector(stackTrace, frames, maxStackSize, isolate); 112 toFramesVector(stackTrace, frames, maxStackSize, isolate);
100 113
101 int maxAsyncCallChainDepth = 1; 114 int maxAsyncCallChainDepth = 1;
102 V8StackTraceImpl* asyncCallChain = nullptr; 115 V8StackTraceImpl* asyncCallChain = nullptr;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 stackTrace->setDescription(m_description); 230 stackTrace->setDescription(m_description);
218 if (m_parent) 231 if (m_parent)
219 stackTrace->setParent(m_parent->buildInspectorObject()); 232 stackTrace->setParent(m_parent->buildInspectorObject());
220 return stackTrace; 233 return stackTrace;
221 } 234 }
222 235
223 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectForTail(V8DebuggerAgentImpl* agent) const 236 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectForTail(V8DebuggerAgentImpl* agent) const
224 { 237 {
225 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); 238 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
226 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep th. 239 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep th.
227 std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(agent , v8::Local<v8::StackTrace>(), V8StackTrace::maxCallStackSizeToCapture); 240 std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(agent , v8::Local<v8::StackTrace>(), V8StackTraceImpl::maxCallStackSizeToCapture);
228 if (!fullChain || !fullChain->m_parent) 241 if (!fullChain || !fullChain->m_parent)
229 return nullptr; 242 return nullptr;
230 return fullChain->m_parent->buildInspectorObject(); 243 return fullChain->m_parent->buildInspectorObject();
231 } 244 }
232 245
233 String16 V8StackTraceImpl::toString() const 246 String16 V8StackTraceImpl::toString() const
234 { 247 {
235 String16Builder stackTrace; 248 String16Builder stackTrace;
236 for (size_t i = 0; i < m_frames.size(); ++i) { 249 for (size_t i = 0; i < m_frames.size(); ++i) {
237 const Frame& frame = m_frames[i]; 250 const Frame& frame = m_frames[i];
238 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 251 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
239 stackTrace.append(" ("); 252 stackTrace.append(" (");
240 stackTrace.append(frame.sourceURL()); 253 stackTrace.append(frame.sourceURL());
241 stackTrace.append(':'); 254 stackTrace.append(':');
242 stackTrace.appendNumber(frame.lineNumber()); 255 stackTrace.appendNumber(frame.lineNumber());
243 stackTrace.append(':'); 256 stackTrace.append(':');
244 stackTrace.appendNumber(frame.columnNumber()); 257 stackTrace.appendNumber(frame.columnNumber());
245 stackTrace.append(')'); 258 stackTrace.append(')');
246 } 259 }
247 return stackTrace.toString(); 260 return stackTrace.toString();
248 } 261 }
249 262
250 } // namespace blink 263 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698