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 : };
43 :
44 : /**
45 : * The result of disassembling a wasm function.
46 : * Consists of the disassembly string and an offset table mapping wasm byte
47 : * offsets to line and column in the disassembly.
48 : * The offset table entries are ordered by the byte_offset.
49 : * All numbers are 0-based.
50 : */
51 : struct WasmDisassemblyOffsetTableEntry {
52 : WasmDisassemblyOffsetTableEntry(uint32_t byte_offset, int line, int column)
53 370 : : byte_offset(byte_offset), line(line), column(column) {}
54 :
55 : uint32_t byte_offset;
56 : int line;
57 : int column;
58 : };
59 :
60 200 : struct WasmDisassembly {
61 : using OffsetTable = std::vector<WasmDisassemblyOffsetTableEntry>;
62 : WasmDisassembly() {}
63 : WasmDisassembly(std::string disassembly, OffsetTable offset_table)
64 : : disassembly(std::move(disassembly)),
65 : offset_table(std::move(offset_table)) {}
66 :
67 : std::string disassembly;
68 : OffsetTable offset_table;
69 : };
70 :
71 : enum PromiseDebugActionType {
72 : kDebugPromiseCreated,
73 : kDebugEnqueueAsyncFunction,
74 : kDebugEnqueuePromiseResolve,
75 : kDebugEnqueuePromiseReject,
76 : kDebugWillHandle,
77 : kDebugDidHandle,
78 : };
79 :
80 : enum BreakLocationType {
81 : kCallBreakLocation,
82 : kReturnBreakLocation,
83 : kDebuggerStatementBreakLocation,
84 : kCommonBreakLocation
85 : };
86 :
87 : class V8_EXPORT_PRIVATE BreakLocation : public Location {
88 : public:
89 : BreakLocation(int line_number, int column_number, BreakLocationType type)
90 3616 : : Location(line_number, column_number), type_(type) {}
91 :
92 : BreakLocationType type() const { return type_; }
93 :
94 : private:
95 : BreakLocationType type_;
96 : };
97 :
98 : class ConsoleCallArguments : private v8::FunctionCallbackInfo<v8::Value> {
99 : public:
100 22792 : int Length() const { return v8::FunctionCallbackInfo<v8::Value>::Length(); }
101 : V8_INLINE Local<Value> operator[](int i) const {
102 : return v8::FunctionCallbackInfo<v8::Value>::operator[](i);
103 : }
104 :
105 : explicit ConsoleCallArguments(const v8::FunctionCallbackInfo<v8::Value>&);
106 : explicit ConsoleCallArguments(internal::BuiltinArguments&);
107 : };
108 :
109 : // v8::FunctionCallbackInfo could be used for getting arguments only. Calling
110 : // of any other getter will produce a crash.
111 33688 : class ConsoleDelegate {
112 : public:
113 0 : virtual void Debug(const ConsoleCallArguments& args) {}
114 0 : virtual void Error(const ConsoleCallArguments& args) {}
115 0 : virtual void Info(const ConsoleCallArguments& args) {}
116 0 : virtual void Log(const ConsoleCallArguments& args) {}
117 0 : virtual void Warn(const ConsoleCallArguments& args) {}
118 0 : virtual void Dir(const ConsoleCallArguments& args) {}
119 0 : virtual void DirXml(const ConsoleCallArguments& args) {}
120 0 : virtual void Table(const ConsoleCallArguments& args) {}
121 0 : virtual void Trace(const ConsoleCallArguments& args) {}
122 0 : virtual void Group(const ConsoleCallArguments& args) {}
123 0 : virtual void GroupCollapsed(const ConsoleCallArguments& args) {}
124 0 : virtual void GroupEnd(const ConsoleCallArguments& args) {}
125 0 : virtual void Clear(const ConsoleCallArguments& args) {}
126 0 : virtual void Count(const ConsoleCallArguments& args) {}
127 0 : virtual void Assert(const ConsoleCallArguments& args) {}
128 0 : virtual void MarkTimeline(const ConsoleCallArguments& args) {}
129 0 : virtual void Profile(const ConsoleCallArguments& args) {}
130 0 : virtual void ProfileEnd(const ConsoleCallArguments& args) {}
131 0 : virtual void Timeline(const ConsoleCallArguments& args) {}
132 0 : virtual void TimelineEnd(const ConsoleCallArguments& args) {}
133 0 : virtual void Time(const ConsoleCallArguments& args) {}
134 0 : virtual void TimeEnd(const ConsoleCallArguments& args) {}
135 0 : virtual void TimeStamp(const ConsoleCallArguments& args) {}
136 33161 : virtual ~ConsoleDelegate() = default;
137 : };
138 :
139 : } // namespace debug
140 : } // namespace v8
141 :
142 : #endif // V8_DEBUG_INTERFACE_TYPES_H_
|