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