5 #ifndef V8_DEBUG_DEBUG_INTERFACE_H_ 6 #define V8_DEBUG_DEBUG_INTERFACE_H_ 8 #include "include/v8-inspector.h" 9 #include "include/v8-util.h" 10 #include "include/v8.h" 12 #include "src/debug/interface-types.h" 13 #include "src/globals.h" 19 struct CoverageFunction;
20 struct CoverageScript;
21 struct TypeProfileEntry;
22 struct TypeProfileScript;
24 class PostponeInterruptsScope;
31 void SetContextId(Local<Context> context,
int id);
32 int GetContextId(Local<Context> context);
39 void SetBreakOnNextFunctionCall(Isolate* isolate);
43 void ClearBreakOnNextFunctionCall(Isolate* isolate);
50 MaybeLocal<Array> GetInternalProperties(Isolate* isolate, Local<Value> value);
52 enum ExceptionBreakState {
53 NoBreakOnException = 0,
54 BreakOnUncaughtException = 1,
55 BreakOnAnyException = 2
64 void ChangeBreakOnException(Isolate* isolate, ExceptionBreakState state);
66 void RemoveBreakpoint(Isolate* isolate, BreakpointId
id);
67 void SetBreakPointsActive(Isolate* isolate,
bool is_active);
76 void PrepareStep(Isolate* isolate, StepAction action);
77 void ClearStepping(Isolate* isolate);
78 void BreakRightNow(Isolate* isolate);
80 bool AllFramesOnStackAreBlackboxed(Isolate* isolate);
88 BLOCKED_BY_RUNNING_GENERATOR,
89 BLOCKED_BY_FUNCTION_ABOVE_BREAK_FRAME,
90 BLOCKED_BY_FUNCTION_BELOW_NON_DROPPABLE_FRAME,
91 BLOCKED_BY_ACTIVE_FUNCTION,
92 BLOCKED_BY_NEW_TARGET_IN_RESTART_FRAME,
93 FRAME_RESTART_IS_NOT_SUPPORTED
96 bool stack_changed =
false;
101 int line_number = -1;
102 int column_number = -1;
110 v8::Isolate* GetIsolate()
const;
113 bool WasCompiled()
const;
114 bool IsEmbedded()
const;
116 int LineOffset()
const;
117 int ColumnOffset()
const;
118 std::vector<int> LineEnds()
const;
125 bool IsModule()
const;
126 bool GetPossibleBreakpoints(
128 bool restrict_to_function,
129 std::vector<debug::BreakLocation>* locations)
const;
143 int NumFunctions()
const;
144 int NumImportedFunctions()
const;
146 std::pair<int, int> GetFunctionRange(
int function_index)
const;
149 uint32_t GetFunctionHash(
int function_index);
157 enum ExceptionType { kException, kPromiseRejection };
163 bool has_compile_error) {}
166 virtual void BreakProgramRequested(
168 const std::vector<debug::BreakpointId>& inspector_break_points_hit) {}
172 ExceptionType exception_type) {}
180 void SetDebugDelegate(Isolate* isolate,
DebugDelegate* listener);
185 virtual void AsyncEventOccurred(debug::DebugAsyncActionType
type,
int id,
186 bool is_blackboxed) = 0;
191 void ResetBlackboxedStateCache(Isolate* isolate,
196 enum Builtin { kStringToLowerCase };
200 V8_EXPORT_PRIVATE
void SetConsoleDelegate(Isolate* isolate,
201 ConsoleDelegate* delegate);
226 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(
Coverage);
253 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(
BlockData);
255 int StartOffset()
const;
256 int EndOffset()
const;
261 std::shared_ptr<i::Coverage> coverage)
262 : block_(block), coverage_(std::move(coverage)) {}
265 std::shared_ptr<i::Coverage> coverage_;
274 int StartOffset()
const;
275 int EndOffset()
const;
278 size_t BlockCount()
const;
279 bool HasBlockCoverage()
const;
284 std::shared_ptr<i::Coverage> coverage)
285 : function_(
function), coverage_(std::move(coverage)) {}
288 std::shared_ptr<i::Coverage> coverage_;
298 size_t FunctionCount()
const;
302 explicit ScriptData(
size_t index, std::shared_ptr<i::Coverage> c);
305 std::shared_ptr<i::Coverage> coverage_;
310 static Coverage CollectPrecise(Isolate* isolate);
311 static Coverage CollectBestEffort(Isolate* isolate);
313 static void SelectMode(Isolate* isolate, Mode mode);
315 size_t ScriptCount()
const;
317 bool IsEmpty()
const {
return coverage_ ==
nullptr; }
320 explicit Coverage(std::shared_ptr<i::Coverage> coverage)
321 : coverage_(
std::move(coverage)) {}
322 std::shared_ptr<i::Coverage> coverage_;
340 MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(
Entry);
342 int SourcePosition()
const;
343 std::vector<MaybeLocal<String>> Types()
const;
347 std::shared_ptr<i::TypeProfile> type_profile)
348 : entry_(entry), type_profile_(std::move(type_profile)) {}
351 std::shared_ptr<i::TypeProfile> type_profile_;
361 std::vector<Entry> Entries()
const;
365 std::shared_ptr<i::TypeProfile> type_profile);
368 std::shared_ptr<i::TypeProfile> type_profile_;
375 static void SelectMode(Isolate* isolate, Mode mode);
377 size_t ScriptCount()
const;
381 explicit TypeProfile(std::shared_ptr<i::TypeProfile> type_profile)
382 : type_profile_(
std::move(type_profile)) {}
384 std::shared_ptr<i::TypeProfile> type_profile_;
389 static std::unique_ptr<ScopeIterator> CreateForFunction(
391 static std::unique_ptr<ScopeIterator> CreateForGeneratorObject(
409 virtual bool Done() = 0;
410 virtual void Advance() = 0;
411 virtual ScopeType GetType() = 0;
414 virtual int GetScriptId() = 0;
415 virtual bool HasLocationInfo() = 0;
428 static std::unique_ptr<StackTraceIterator> Create(Isolate* isolate,
433 virtual bool Done()
const = 0;
434 virtual void Advance() = 0;
436 virtual int GetContextId()
const = 0;
443 virtual std::unique_ptr<ScopeIterator> GetScopeIterator()
const = 0;
445 virtual bool Restart() = 0;
447 bool throw_on_side_effect) = 0;
468 enum class NativeAccessorType {
474 int64_t GetNextRandomInt64(v8::Isolate* isolate);
478 bool throw_on_side_effect);
493 std::unique_ptr<i::PostponeInterruptsScope> scope_;
513 bool has_enumerable : 1;
514 bool configurable : 1;
515 bool has_configurable : 1;
517 bool has_writable : 1;
529 virtual bool Done()
const = 0;
530 virtual void Advance() = 0;
534 virtual bool is_native_accessor() = 0;
535 virtual bool has_native_getter() = 0;
536 virtual bool has_native_setter() = 0;
540 virtual bool is_own() = 0;
541 virtual bool is_array_index() = 0;
546 #endif // V8_DEBUG_DEBUG_INTERFACE_H_