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 #ifndef V8_DEBUG_DEBUG_INTERFACE_H_ | 5 #ifndef V8_DEBUG_DEBUG_INTERFACE_H_ |
6 #define V8_DEBUG_DEBUG_INTERFACE_H_ | 6 #define V8_DEBUG_DEBUG_INTERFACE_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "include/v8-debug.h" | 10 #include "include/v8-debug.h" |
11 #include "include/v8-util.h" | 11 #include "include/v8-util.h" |
12 #include "include/v8.h" | 12 #include "include/v8.h" |
13 | 13 |
14 #include "src/debug/interface-types.h" | 14 #include "src/debug/interface-types.h" |
15 #include "src/globals.h" | 15 #include "src/globals.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 | 18 |
19 namespace internal { | 19 namespace internal { |
20 struct CoverageRange; | 20 struct CoverageFunction; |
| 21 struct CoverageScript; |
21 class Coverage; | 22 class Coverage; |
22 class Script; | 23 class Script; |
23 } | 24 } |
24 | 25 |
25 namespace debug { | 26 namespace debug { |
26 | 27 |
27 /** | 28 /** |
28 * Debugger is running in its own context which is entered while debugger | 29 * Debugger is running in its own context which is entered while debugger |
29 * messages are being dispatched. This is an explicit getter for this | 30 * messages are being dispatched. This is an explicit getter for this |
30 * debugger context. Note that the content of the debugger context is subject | 31 * debugger context. Note that the content of the debugger context is subject |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 bool IsSuspended(); | 205 bool IsSuspended(); |
205 | 206 |
206 static v8::Local<debug::GeneratorObject> Cast(v8::Local<v8::Value> value); | 207 static v8::Local<debug::GeneratorObject> Cast(v8::Local<v8::Value> value); |
207 }; | 208 }; |
208 | 209 |
209 /* | 210 /* |
210 * Provide API layer between inspector and code coverage. | 211 * Provide API layer between inspector and code coverage. |
211 */ | 212 */ |
212 class V8_EXPORT_PRIVATE Coverage { | 213 class V8_EXPORT_PRIVATE Coverage { |
213 public: | 214 public: |
214 class V8_EXPORT_PRIVATE Range { | 215 class ScriptData; // Forward declaration. |
| 216 |
| 217 class V8_EXPORT_PRIVATE FunctionData { |
215 public: | 218 public: |
216 // 0-based line and colum numbers. | 219 // 0-based line and colum numbers. |
217 Location Start() { return start_; } | 220 Location Start() { return start_; } |
218 Location End() { return end_; } | 221 Location End() { return end_; } |
219 uint32_t Count(); | 222 uint32_t Count(); |
220 size_t NestedCount(); | |
221 Range GetNested(size_t i); | |
222 MaybeLocal<String> Name(); | 223 MaybeLocal<String> Name(); |
223 | 224 |
224 private: | 225 private: |
225 Range(i::CoverageRange* range, Local<debug::Script> script); | 226 FunctionData(i::CoverageFunction* function, Local<debug::Script> script); |
226 i::CoverageRange* range_; | 227 i::CoverageFunction* function_; |
227 Location start_; | 228 Location start_; |
228 Location end_; | 229 Location end_; |
229 Local<debug::Script> script_; | |
230 | 230 |
231 friend class debug::Coverage; | 231 friend class v8::debug::Coverage::ScriptData; |
232 }; | 232 }; |
233 | 233 |
234 static Coverage Collect(Isolate* isolate); | 234 class V8_EXPORT_PRIVATE ScriptData { |
| 235 public: |
| 236 Local<debug::Script> GetScript(); |
| 237 size_t FunctionCount(); |
| 238 FunctionData GetFunctionData(size_t i); |
| 239 |
| 240 private: |
| 241 explicit ScriptData(i::CoverageScript* script) : script_(script) {} |
| 242 i::CoverageScript* script_; |
| 243 |
| 244 friend class v8::debug::Coverage; |
| 245 }; |
| 246 |
| 247 static Coverage Collect(Isolate* isolate, bool reset_count); |
235 | 248 |
236 static void TogglePrecise(Isolate* isolate, bool enable); | 249 static void TogglePrecise(Isolate* isolate, bool enable); |
237 | 250 |
238 size_t ScriptCount(); | 251 size_t ScriptCount(); |
239 Local<debug::Script> GetScript(size_t i); | 252 ScriptData GetScriptData(size_t i); |
240 Range GetRange(size_t i); | 253 bool IsEmpty() { return coverage_ == nullptr; } |
241 | 254 |
242 ~Coverage(); | 255 ~Coverage(); |
243 | 256 |
244 private: | 257 private: |
245 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} | 258 explicit Coverage(i::Coverage* coverage) : coverage_(coverage) {} |
246 i::Coverage* coverage_; | 259 i::Coverage* coverage_; |
247 }; | 260 }; |
248 } // namespace debug | 261 } // namespace debug |
249 } // namespace v8 | 262 } // namespace v8 |
250 | 263 |
251 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 264 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
OLD | NEW |