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/V8StackTraceImpl.h" | 5 #include "src/inspector/V8StackTraceImpl.h" |
6 | 6 |
7 #include "src/inspector/StringUtil.h" | 7 #include "src/inspector/StringUtil.h" |
8 #include "src/inspector/V8Debugger.h" | 8 #include "src/inspector/V8Debugger.h" |
9 #include "src/inspector/protocol/Protocol.h" | 9 #include "src/inspector/protocol/Protocol.h" |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return result; | 151 return result; |
152 } | 152 } |
153 | 153 |
154 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( | 154 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( |
155 V8Debugger* debugger, int contextGroupId, size_t maxStackSize, | 155 V8Debugger* debugger, int contextGroupId, size_t maxStackSize, |
156 const String16& description) { | 156 const String16& description) { |
157 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 157 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
158 v8::HandleScope handleScope(isolate); | 158 v8::HandleScope handleScope(isolate); |
159 v8::Local<v8::StackTrace> stackTrace; | 159 v8::Local<v8::StackTrace> stackTrace; |
160 if (isolate->InContext()) { | 160 if (isolate->InContext()) { |
161 #if V8_MAJOR_VERSION >= 5 | |
162 isolate->GetCpuProfiler()->CollectSample(); | 161 isolate->GetCpuProfiler()->CollectSample(); |
163 #endif | |
164 stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, | 162 stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, |
165 stackTraceOptions); | 163 stackTraceOptions); |
166 } | 164 } |
167 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, | 165 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, |
168 maxStackSize, description); | 166 maxStackSize, description); |
169 } | 167 } |
170 | 168 |
171 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { | 169 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { |
172 std::vector<Frame> framesCopy(m_frames); | 170 std::vector<Frame> framesCopy(m_frames); |
173 return wrapUnique( | 171 return wrapUnique( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 stackTrace.append(String16::fromInteger(frame.lineNumber())); | 264 stackTrace.append(String16::fromInteger(frame.lineNumber())); |
267 stackTrace.append(':'); | 265 stackTrace.append(':'); |
268 stackTrace.append(String16::fromInteger(frame.columnNumber())); | 266 stackTrace.append(String16::fromInteger(frame.columnNumber())); |
269 stackTrace.append(')'); | 267 stackTrace.append(')'); |
270 } | 268 } |
271 String16 string = stackTrace.toString(); | 269 String16 string = stackTrace.toString(); |
272 return StringBufferImpl::adopt(string); | 270 return StringBufferImpl::adopt(string); |
273 } | 271 } |
274 | 272 |
275 } // namespace v8_inspector | 273 } // namespace v8_inspector |
OLD | NEW |