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

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

Issue 1997293002: Introduce SourceLocation to be used for console messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 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 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth(); 100 maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth();
101 } 101 }
102 102
103 // Only the top stack in the chain may be empty, so ensure that second stack is non-empty (it's the top of appended chain). 103 // Only the top stack in the chain may be empty, so ensure that second stack is non-empty (it's the top of appended chain).
104 if (asyncCallChain && asyncCallChain->isEmpty()) 104 if (asyncCallChain && asyncCallChain->isEmpty())
105 asyncCallChain = asyncCallChain->m_parent.get(); 105 asyncCallChain = asyncCallChain->m_parent.get();
106 106
107 if (stackTrace.IsEmpty() && !asyncCallChain) 107 if (stackTrace.IsEmpty() && !asyncCallChain)
108 return nullptr; 108 return nullptr;
109 109
110 OwnPtr<V8StackTraceImpl> result = adoptPtr(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->clone() : nullptr)); 110 OwnPtr<V8StackTraceImpl> result = adoptPtr(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr));
111 111
112 // Crop to not exceed maxAsyncCallChainDepth. 112 // Crop to not exceed maxAsyncCallChainDepth.
113 V8StackTraceImpl* deepest = result.get(); 113 V8StackTraceImpl* deepest = result.get();
114 while (deepest && maxAsyncCallChainDepth) { 114 while (deepest && maxAsyncCallChainDepth) {
115 deepest = deepest->m_parent.get(); 115 deepest = deepest->m_parent.get();
116 maxAsyncCallChainDepth--; 116 maxAsyncCallChainDepth--;
117 } 117 }
118 if (deepest) 118 if (deepest)
119 deepest->m_parent.clear(); 119 deepest->m_parent.clear();
120 120
121 return result; 121 return result;
122 } 122 }
123 123
124 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::capture(V8DebuggerAgentImpl* agen t, size_t maxStackSize, const String16& description) 124 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::capture(V8DebuggerAgentImpl* agen t, size_t maxStackSize, const String16& description)
125 { 125 {
126 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 126 v8::Isolate* isolate = v8::Isolate::GetCurrent();
127 v8::HandleScope handleScope(isolate); 127 v8::HandleScope handleScope(isolate);
128 v8::Local<v8::StackTrace> stackTrace; 128 v8::Local<v8::StackTrace> stackTrace;
129 if (isolate->InContext()) { 129 if (isolate->InContext()) {
130 #if V8_MAJOR_VERSION >= 5 130 #if V8_MAJOR_VERSION >= 5
131 isolate->GetCpuProfiler()->CollectSample(); 131 isolate->GetCpuProfiler()->CollectSample();
132 #endif 132 #endif
133 stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, st ackTraceOptions); 133 stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, st ackTraceOptions);
134 } 134 }
135 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description ); 135 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description );
136 } 136 }
137 137
138 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::clone() 138 PassOwnPtr<V8StackTrace> V8StackTraceImpl::clone()
139 {
140 OwnPtr<V8StackTraceImpl> copy = cloneImpl();
141 return adoptPtr(static_cast<V8StackTrace*>(copy.leakPtr()));
142 }
143
144 PassOwnPtr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl()
139 { 145 {
140 protocol::Vector<Frame> framesCopy(m_frames); 146 protocol::Vector<Frame> framesCopy(m_frames);
141 return adoptPtr(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m _parent->clone() : nullptr)); 147 return adoptPtr(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m _parent->cloneImpl() : nullptr));
142 } 148 }
143 149
144 V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector <Frame>& frames, PassOwnPtr<V8StackTraceImpl> parent) 150 V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector <Frame>& frames, PassOwnPtr<V8StackTraceImpl> parent)
145 : m_description(description) 151 : m_description(description)
146 , m_parent(std::move(parent)) 152 , m_parent(std::move(parent))
147 { 153 {
148 m_frames.swap(frames); 154 m_frames.swap(frames);
149 } 155 }
150 156
151 V8StackTraceImpl::~V8StackTraceImpl() 157 V8StackTraceImpl::~V8StackTraceImpl()
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 stackTrace.append(':'); 224 stackTrace.append(':');
219 stackTrace.appendNumber(frame.lineNumber()); 225 stackTrace.appendNumber(frame.lineNumber());
220 stackTrace.append(':'); 226 stackTrace.append(':');
221 stackTrace.appendNumber(frame.columnNumber()); 227 stackTrace.appendNumber(frame.columnNumber());
222 stackTrace.append(')'); 228 stackTrace.append(')');
223 } 229 }
224 return stackTrace.toString(); 230 return stackTrace.toString();
225 } 231 }
226 232
227 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698