Line data Source code
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 : #include <string>
10 : #include <vector>
11 :
12 : #include "include/v8.h"
13 : #include "src/globals.h"
14 :
15 : namespace v8 {
16 :
17 : namespace internal {
18 : class BuiltinArguments;
19 : } // internal
20 :
21 : namespace debug {
22 :
23 : /**
24 : * Defines location inside script.
25 : * Lines and columns are 0-based.
26 : */
27 : class V8_EXPORT_PRIVATE Location {
28 : public:
29 : Location(int line_number, int column_number);
30 : /**
31 : * Create empty location.
32 : */
33 : Location();
34 :
35 : int GetLineNumber() const;
36 : int GetColumnNumber() const;
37 : bool IsEmpty() const;
38 :
39 : private:
40 : int line_number_;
41 : int column_number_;
42 : bool is_empty_;
43 : };
44 :
45 : /**
46 : * The result of disassembling a wasm function.
47 : * Consists of the disassembly string and an offset table mapping wasm byte
48 : * offsets to line and column in the disassembly.
49 : * The offset table entries are ordered by the byte_offset.
50 : * All numbers are 0-based.
51 : */
52 : struct WasmDisassemblyOffsetTableEntry {
53 : WasmDisassemblyOffsetTableEntry(uint32_t byte_offset, int line, int column)
54 376 : : byte_offset(byte_offset), line(line), column(column) {}
55 :
56 : uint32_t byte_offset;
57 : int line;
58 : int column;
59 : };
60 :
61 160 : struct WasmDisassembly {
62 : using OffsetTable = std::vector<WasmDisassemblyOffsetTableEntry>;
63 : WasmDisassembly() = default;
64 : WasmDisassembly(std::string disassembly, OffsetTable offset_table)
65 : : disassembly(std::move(disassembly)),
66 : offset_table(std::move(offset_table)) {}
67 :
68 : std::string disassembly;
69 : OffsetTable offset_table;
70 : };
71 :
72 : enum DebugAsyncActionType {
73 : kDebugPromiseThen,
74 : kDebugPromiseCatch,
75 : kDebugPromiseFinally,
76 : kDebugWillHandle,
77 : kDebugDidHandle,
78 : kAsyncFunctionSuspended,
79 : kAsyncFunctionFinished
80 : };
81 :
82 : enum BreakLocationType {
83 : kCallBreakLocation,
84 : kReturnBreakLocation,
85 : kDebuggerStatementBreakLocation,
86 : kCommonBreakLocation
87 : };
88 :
89 : class V8_EXPORT_PRIVATE BreakLocation : public Location {
90 : public:
91 : BreakLocation(int line_number, int column_number, BreakLocationType type)
92 5242 : : Location(line_number, column_number), type_(type) {}
93 :
94 : BreakLocationType type() const { return type_; }
95 :
96 : private:
97 : BreakLocationType type_;
98 : };
99 :
100 : class ConsoleCallArguments : private v8::FunctionCallbackInfo<v8::Value> {
101 : public:
102 36855 : int Length() const { return v8::FunctionCallbackInfo<v8::Value>::Length(); }
103 : V8_INLINE Local<Value> operator[](int i) const {
104 : return v8::FunctionCallbackInfo<v8::Value>::operator[](i);
105 : }
106 :
107 : explicit ConsoleCallArguments(const v8::FunctionCallbackInfo<v8::Value>&);
108 : explicit ConsoleCallArguments(internal::BuiltinArguments&);
109 : };
110 :
111 : class ConsoleContext {
112 : public:
113 12511 : ConsoleContext(int id, v8::Local<v8::String> name) : id_(id), name_(name) {}
114 425 : ConsoleContext() : id_(0) {}
115 :
116 : int id() const { return id_; }
117 : v8::Local<v8::String> name() const { return name_; }
118 :
119 : private:
120 : int id_;
121 : v8::Local<v8::String> name_;
122 : };
123 :
124 33834 : class ConsoleDelegate {
125 : public:
126 0 : virtual void Debug(const ConsoleCallArguments& args,
127 0 : const ConsoleContext& context) {}
128 0 : virtual void Error(const ConsoleCallArguments& args,
129 0 : const ConsoleContext& context) {}
130 0 : virtual void Info(const ConsoleCallArguments& args,
131 0 : const ConsoleContext& context) {}
132 0 : virtual void Log(const ConsoleCallArguments& args,
133 0 : const ConsoleContext& context) {}
134 0 : virtual void Warn(const ConsoleCallArguments& args,
135 0 : const ConsoleContext& context) {}
136 0 : virtual void Dir(const ConsoleCallArguments& args,
137 0 : const ConsoleContext& context) {}
138 0 : virtual void DirXml(const ConsoleCallArguments& args,
139 0 : const ConsoleContext& context) {}
140 0 : virtual void Table(const ConsoleCallArguments& args,
141 0 : const ConsoleContext& context) {}
142 0 : virtual void Trace(const ConsoleCallArguments& args,
143 0 : const ConsoleContext& context) {}
144 0 : virtual void Group(const ConsoleCallArguments& args,
145 0 : const ConsoleContext& context) {}
146 0 : virtual void GroupCollapsed(const ConsoleCallArguments& args,
147 0 : const ConsoleContext& context) {}
148 0 : virtual void GroupEnd(const ConsoleCallArguments& args,
149 0 : const ConsoleContext& context) {}
150 0 : virtual void Clear(const ConsoleCallArguments& args,
151 0 : const ConsoleContext& context) {}
152 0 : virtual void Count(const ConsoleCallArguments& args,
153 0 : const ConsoleContext& context) {}
154 0 : virtual void CountReset(const ConsoleCallArguments& args,
155 0 : const ConsoleContext& context) {}
156 0 : virtual void Assert(const ConsoleCallArguments& args,
157 0 : const ConsoleContext& context) {}
158 0 : virtual void Profile(const ConsoleCallArguments& args,
159 0 : const ConsoleContext& context) {}
160 0 : virtual void ProfileEnd(const ConsoleCallArguments& args,
161 0 : const ConsoleContext& context) {}
162 0 : virtual void Time(const ConsoleCallArguments& args,
163 0 : const ConsoleContext& context) {}
164 0 : virtual void TimeLog(const ConsoleCallArguments& args,
165 0 : const ConsoleContext& context) {}
166 0 : virtual void TimeEnd(const ConsoleCallArguments& args,
167 0 : const ConsoleContext& context) {}
168 0 : virtual void TimeStamp(const ConsoleCallArguments& args,
169 0 : const ConsoleContext& context) {}
170 33229 : virtual ~ConsoleDelegate() = default;
171 : };
172 :
173 : typedef int BreakpointId;
174 :
175 : } // namespace debug
176 : } // namespace v8
177 :
178 : #endif // V8_DEBUG_INTERFACE_TYPES_H_
|