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 3 // found in the LICENSE file. 4 5 #ifndef V8_DEBUG_INTERFACE_TYPES_H_ 6 #define V8_DEBUG_INTERFACE_TYPES_H_ 7 8 #include <cstdint> 9 10 #include "include/v8-function-callback.h" 11 #include "include/v8-local-handle.h" 12 #include "src/common/globals.h" 13 14 namespace v8 { 15 16 class String; 17 18 namespace internal { 19 class BuiltinArguments; 20 } // namespace internal 21 22 namespace debug { 23 24 /** 25 * Defines location inside script. 26 * Lines and columns are 0-based. 27 */ 28 class V8_EXPORT_PRIVATE Location { 29 public: 30 Location(int line_number, int column_number); 31 /** 32 * Create empty location. 33 */ 34 Location(); 35 36 int GetLineNumber() const; 37 int GetColumnNumber() const; 38 bool IsEmpty() const; 39 40 private: 41 int line_number_; 42 int column_number_; 43 bool is_empty_; 44 }; 45 46 enum DebugAsyncActionType { 47 kDebugAwait, 48 kDebugPromiseThen, 49 kDebugPromiseCatch, 50 kDebugPromiseFinally, 51 kDebugWillHandle, 52 kDebugDidHandle 53 }; 54 55 enum BreakLocationType { 56 kCallBreakLocation, 57 kReturnBreakLocation, 58 kDebuggerStatementBreakLocation, 59 kCommonBreakLocation 60 }; 61 62 enum class CoverageMode { 63 // Make use of existing information in feedback vectors on the heap. 64 // Only return a yes/no result. Optimization and GC are not affected. 65 // Collecting best effort coverage does not reset counters. 66 kBestEffort, 67 // Disable optimization and prevent feedback vectors from being garbage 68 // collected in order to preserve precise invocation counts. Collecting 69 // precise count coverage resets counters to get incremental updates. 70 kPreciseCount, 71 // We are only interested in a yes/no result for the function. Optimization 72 // and GC can be allowed once a function has been invoked. Collecting 73 // precise binary coverage resets counters for incremental updates. 74 kPreciseBinary, 75 // Similar to the precise coverage modes but provides coverage at a 76 // lower granularity. Design doc: goo.gl/lA2swZ. 77 kBlockCount, 78 kBlockBinary, 79 }; 80 81 enum class TypeProfileMode { 82 kNone, 83 kCollect, 84 }; 85 86 class V8_EXPORT_PRIVATE BreakLocation : public Location { 87 public: BreakLocation(int line_number,int column_number,BreakLocationType type)88 BreakLocation(int line_number, int column_number, BreakLocationType type) 89 : Location(line_number, column_number), type_(type) {} 90 type()91 BreakLocationType type() const { return type_; } 92 93 private: 94 BreakLocationType type_; 95 }; 96 97 class ConsoleCallArguments : private v8::FunctionCallbackInfo<v8::Value> { 98 public: Length()99 int Length() const { return v8::FunctionCallbackInfo<v8::Value>::Length(); } 100 V8_INLINE Local<Value> operator[](int i) const { 101 return v8::FunctionCallbackInfo<v8::Value>::operator[](i); 102 } 103 104 explicit ConsoleCallArguments(const v8::FunctionCallbackInfo<v8::Value>&); 105 explicit ConsoleCallArguments(const internal::BuiltinArguments&); 106 }; 107 108 class ConsoleContext { 109 public: ConsoleContext(int id,v8::Local<v8::String> name)110 ConsoleContext(int id, v8::Local<v8::String> name) : id_(id), name_(name) {} ConsoleContext()111 ConsoleContext() : id_(0) {} 112 id()113 int id() const { return id_; } name()114 v8::Local<v8::String> name() const { return name_; } 115 116 private: 117 int id_; 118 v8::Local<v8::String> name_; 119 }; 120 121 class ConsoleDelegate { 122 public: Debug(const ConsoleCallArguments & args,const ConsoleContext & context)123 virtual void Debug(const ConsoleCallArguments& args, 124 const ConsoleContext& context) {} Error(const ConsoleCallArguments & args,const ConsoleContext & context)125 virtual void Error(const ConsoleCallArguments& args, 126 const ConsoleContext& context) {} Info(const ConsoleCallArguments & args,const ConsoleContext & context)127 virtual void Info(const ConsoleCallArguments& args, 128 const ConsoleContext& context) {} Log(const ConsoleCallArguments & args,const ConsoleContext & context)129 virtual void Log(const ConsoleCallArguments& args, 130 const ConsoleContext& context) {} Warn(const ConsoleCallArguments & args,const ConsoleContext & context)131 virtual void Warn(const ConsoleCallArguments& args, 132 const ConsoleContext& context) {} Dir(const ConsoleCallArguments & args,const ConsoleContext & context)133 virtual void Dir(const ConsoleCallArguments& args, 134 const ConsoleContext& context) {} DirXml(const ConsoleCallArguments & args,const ConsoleContext & context)135 virtual void DirXml(const ConsoleCallArguments& args, 136 const ConsoleContext& context) {} Table(const ConsoleCallArguments & args,const ConsoleContext & context)137 virtual void Table(const ConsoleCallArguments& args, 138 const ConsoleContext& context) {} Trace(const ConsoleCallArguments & args,const ConsoleContext & context)139 virtual void Trace(const ConsoleCallArguments& args, 140 const ConsoleContext& context) {} Group(const ConsoleCallArguments & args,const ConsoleContext & context)141 virtual void Group(const ConsoleCallArguments& args, 142 const ConsoleContext& context) {} GroupCollapsed(const ConsoleCallArguments & args,const ConsoleContext & context)143 virtual void GroupCollapsed(const ConsoleCallArguments& args, 144 const ConsoleContext& context) {} GroupEnd(const ConsoleCallArguments & args,const ConsoleContext & context)145 virtual void GroupEnd(const ConsoleCallArguments& args, 146 const ConsoleContext& context) {} Clear(const ConsoleCallArguments & args,const ConsoleContext & context)147 virtual void Clear(const ConsoleCallArguments& args, 148 const ConsoleContext& context) {} Count(const ConsoleCallArguments & args,const ConsoleContext & context)149 virtual void Count(const ConsoleCallArguments& args, 150 const ConsoleContext& context) {} CountReset(const ConsoleCallArguments & args,const ConsoleContext & context)151 virtual void CountReset(const ConsoleCallArguments& args, 152 const ConsoleContext& context) {} Assert(const ConsoleCallArguments & args,const ConsoleContext & context)153 virtual void Assert(const ConsoleCallArguments& args, 154 const ConsoleContext& context) {} Profile(const ConsoleCallArguments & args,const ConsoleContext & context)155 virtual void Profile(const ConsoleCallArguments& args, 156 const ConsoleContext& context) {} ProfileEnd(const ConsoleCallArguments & args,const ConsoleContext & context)157 virtual void ProfileEnd(const ConsoleCallArguments& args, 158 const ConsoleContext& context) {} Time(const ConsoleCallArguments & args,const ConsoleContext & context)159 virtual void Time(const ConsoleCallArguments& args, 160 const ConsoleContext& context) {} TimeLog(const ConsoleCallArguments & args,const ConsoleContext & context)161 virtual void TimeLog(const ConsoleCallArguments& args, 162 const ConsoleContext& context) {} TimeEnd(const ConsoleCallArguments & args,const ConsoleContext & context)163 virtual void TimeEnd(const ConsoleCallArguments& args, 164 const ConsoleContext& context) {} TimeStamp(const ConsoleCallArguments & args,const ConsoleContext & context)165 virtual void TimeStamp(const ConsoleCallArguments& args, 166 const ConsoleContext& context) {} 167 virtual ~ConsoleDelegate() = default; 168 }; 169 170 using BreakpointId = int; 171 172 } // namespace debug 173 } // namespace v8 174 175 #endif // V8_DEBUG_INTERFACE_TYPES_H_ 176