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/v8-stack-trace-impl.h" | 5 #include "src/inspector/v8-stack-trace-impl.h" |
6 | 6 |
7 #include "src/inspector/string-util.h" | 7 #include "src/inspector/string-util.h" |
8 #include "src/inspector/v8-debugger.h" | 8 #include "src/inspector/v8-debugger.h" |
9 #include "src/inspector/v8-inspector-impl.h" | 9 #include "src/inspector/v8-inspector-impl.h" |
10 #include "src/inspector/v8-profiler-agent-impl.h" | |
11 | 10 |
12 #include "include/v8-debug.h" | 11 #include "include/v8-debug.h" |
13 #include "include/v8-profiler.h" | |
14 #include "include/v8-version.h" | 12 #include "include/v8-version.h" |
15 | 13 |
16 namespace v8_inspector { | 14 namespace v8_inspector { |
17 | 15 |
18 namespace { | 16 namespace { |
19 | 17 |
20 static const v8::StackTrace::StackTraceOptions stackTraceOptions = | 18 static const v8::StackTrace::StackTraceOptions stackTraceOptions = |
21 static_cast<v8::StackTrace::StackTraceOptions>( | 19 static_cast<v8::StackTrace::StackTraceOptions>( |
22 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset | | 20 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset | |
23 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL | | 21 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL | |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 152 } |
155 | 153 |
156 // static | 154 // static |
157 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( | 155 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( |
158 V8Debugger* debugger, int contextGroupId, size_t maxStackSize, | 156 V8Debugger* debugger, int contextGroupId, size_t maxStackSize, |
159 const String16& description) { | 157 const String16& description) { |
160 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 158 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
161 v8::HandleScope handleScope(isolate); | 159 v8::HandleScope handleScope(isolate); |
162 v8::Local<v8::StackTrace> stackTrace; | 160 v8::Local<v8::StackTrace> stackTrace; |
163 if (isolate->InContext()) { | 161 if (isolate->InContext()) { |
164 if (debugger) { | |
165 V8InspectorImpl* inspector = debugger->inspector(); | |
166 V8ProfilerAgentImpl* profilerAgent = | |
167 inspector->enabledProfilerAgentForGroup(contextGroupId); | |
168 if (profilerAgent) profilerAgent->collectSample(); | |
169 } | |
170 stackTrace = v8::StackTrace::CurrentStackTrace( | 162 stackTrace = v8::StackTrace::CurrentStackTrace( |
171 isolate, static_cast<int>(maxStackSize), stackTraceOptions); | 163 isolate, static_cast<int>(maxStackSize), stackTraceOptions); |
172 } | 164 } |
173 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, | 165 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, |
174 maxStackSize, description); | 166 maxStackSize, description); |
175 } | 167 } |
176 | 168 |
177 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { | 169 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { |
178 std::vector<Frame> framesCopy(m_frames); | 170 std::vector<Frame> framesCopy(m_frames); |
179 return wrapUnique( | 171 return wrapUnique( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 stackTrace.append(String16::fromInteger(frame.lineNumber())); | 264 stackTrace.append(String16::fromInteger(frame.lineNumber())); |
273 stackTrace.append(':'); | 265 stackTrace.append(':'); |
274 stackTrace.append(String16::fromInteger(frame.columnNumber())); | 266 stackTrace.append(String16::fromInteger(frame.columnNumber())); |
275 stackTrace.append(')'); | 267 stackTrace.append(')'); |
276 } | 268 } |
277 String16 string = stackTrace.toString(); | 269 String16 string = stackTrace.toString(); |
278 return StringBufferImpl::adopt(string); | 270 return StringBufferImpl::adopt(string); |
279 } | 271 } |
280 | 272 |
281 } // namespace v8_inspector | 273 } // namespace v8_inspector |
OLD | NEW |