libv8 6.3.292.48.1-universal-darwin-18

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,255 @@
1
+ // Copyright 2008 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_V8_DEBUG_H_
6
+ #define V8_V8_DEBUG_H_
7
+
8
+ #include "v8.h" // NOLINT(build/include)
9
+
10
+ /**
11
+ * ATTENTION: The debugger API exposed by this file is deprecated and will be
12
+ * removed by the end of 2017. Please use the V8 inspector declared
13
+ * in include/v8-inspector.h instead.
14
+ */
15
+ namespace v8 {
16
+
17
+ // Debug events which can occur in the V8 JavaScript engine.
18
+ enum DebugEvent {
19
+ Break = 1,
20
+ Exception = 2,
21
+ AfterCompile = 3,
22
+ CompileError = 4,
23
+ AsyncTaskEvent = 5,
24
+ };
25
+
26
+ class V8_EXPORT Debug {
27
+ public:
28
+ /**
29
+ * A client object passed to the v8 debugger whose ownership will be taken by
30
+ * it. v8 is always responsible for deleting the object.
31
+ */
32
+ class ClientData {
33
+ public:
34
+ virtual ~ClientData() {}
35
+ };
36
+
37
+
38
+ /**
39
+ * A message object passed to the debug message handler.
40
+ */
41
+ class Message {
42
+ public:
43
+ /**
44
+ * Check type of message.
45
+ */
46
+ virtual bool IsEvent() const = 0;
47
+ virtual bool IsResponse() const = 0;
48
+ virtual DebugEvent GetEvent() const = 0;
49
+
50
+ /**
51
+ * Indicate whether this is a response to a continue command which will
52
+ * start the VM running after this is processed.
53
+ */
54
+ virtual bool WillStartRunning() const = 0;
55
+
56
+ /**
57
+ * Access to execution state and event data. Don't store these cross
58
+ * callbacks as their content becomes invalid. These objects are from the
59
+ * debugger event that started the debug message loop.
60
+ */
61
+ virtual Local<Object> GetExecutionState() const = 0;
62
+ virtual Local<Object> GetEventData() const = 0;
63
+
64
+ /**
65
+ * Get the debugger protocol JSON.
66
+ */
67
+ virtual Local<String> GetJSON() const = 0;
68
+
69
+ /**
70
+ * Get the context active when the debug event happened. Note this is not
71
+ * the current active context as the JavaScript part of the debugger is
72
+ * running in its own context which is entered at this point.
73
+ */
74
+ virtual Local<Context> GetEventContext() const = 0;
75
+
76
+ /**
77
+ * Client data passed with the corresponding request if any. This is the
78
+ * client_data data value passed into Debug::SendCommand along with the
79
+ * request that led to the message or NULL if the message is an event. The
80
+ * debugger takes ownership of the data and will delete it even if there is
81
+ * no message handler.
82
+ */
83
+ virtual ClientData* GetClientData() const = 0;
84
+
85
+ virtual Isolate* GetIsolate() const = 0;
86
+
87
+ virtual ~Message() {}
88
+ };
89
+
90
+ /**
91
+ * An event details object passed to the debug event listener.
92
+ */
93
+ class EventDetails {
94
+ public:
95
+ /**
96
+ * Event type.
97
+ */
98
+ virtual DebugEvent GetEvent() const = 0;
99
+
100
+ /**
101
+ * Access to execution state and event data of the debug event. Don't store
102
+ * these cross callbacks as their content becomes invalid.
103
+ */
104
+ virtual Local<Object> GetExecutionState() const = 0;
105
+ virtual Local<Object> GetEventData() const = 0;
106
+
107
+ /**
108
+ * Get the context active when the debug event happened. Note this is not
109
+ * the current active context as the JavaScript part of the debugger is
110
+ * running in its own context which is entered at this point.
111
+ */
112
+ virtual Local<Context> GetEventContext() const = 0;
113
+
114
+ /**
115
+ * Client data passed with the corresponding callback when it was
116
+ * registered.
117
+ */
118
+ virtual Local<Value> GetCallbackData() const = 0;
119
+
120
+ /**
121
+ * This is now a dummy that returns nullptr.
122
+ */
123
+ virtual ClientData* GetClientData() const = 0;
124
+
125
+ virtual Isolate* GetIsolate() const = 0;
126
+
127
+ virtual ~EventDetails() {}
128
+ };
129
+
130
+ /**
131
+ * Debug event callback function.
132
+ *
133
+ * \param event_details object providing information about the debug event
134
+ *
135
+ * A EventCallback does not take possession of the event data,
136
+ * and must not rely on the data persisting after the handler returns.
137
+ */
138
+ typedef void (*EventCallback)(const EventDetails& event_details);
139
+
140
+ /**
141
+ * This is now a no-op.
142
+ */
143
+ typedef void (*MessageHandler)(const Message& message);
144
+
145
+ V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
146
+ Isolate* isolate, EventCallback that,
147
+ Local<Value> data = Local<Value>()));
148
+
149
+ // Schedule a debugger break to happen when JavaScript code is run
150
+ // in the given isolate.
151
+ V8_DEPRECATED("No longer supported",
152
+ static void DebugBreak(Isolate* isolate));
153
+
154
+ // Remove scheduled debugger break in given isolate if it has not
155
+ // happened yet.
156
+ V8_DEPRECATED("No longer supported",
157
+ static void CancelDebugBreak(Isolate* isolate));
158
+
159
+ // Check if a debugger break is scheduled in the given isolate.
160
+ V8_DEPRECATED("No longer supported",
161
+ static bool CheckDebugBreak(Isolate* isolate));
162
+
163
+ // This is now a no-op.
164
+ V8_DEPRECATED("No longer supported",
165
+ static void SetMessageHandler(Isolate* isolate,
166
+ MessageHandler handler));
167
+
168
+ // This is now a no-op.
169
+ V8_DEPRECATED("No longer supported",
170
+ static void SendCommand(Isolate* isolate,
171
+ const uint16_t* command, int length,
172
+ ClientData* client_data = NULL));
173
+
174
+ /**
175
+ * Run a JavaScript function in the debugger.
176
+ * \param fun the function to call
177
+ * \param data passed as second argument to the function
178
+ * With this call the debugger is entered and the function specified is called
179
+ * with the execution state as the first argument. This makes it possible to
180
+ * get access to information otherwise not available during normal JavaScript
181
+ * execution e.g. details on stack frames. Receiver of the function call will
182
+ * be the debugger context global object, however this is a subject to change.
183
+ * The following example shows a JavaScript function which when passed to
184
+ * v8::Debug::Call will return the current line of JavaScript execution.
185
+ *
186
+ * \code
187
+ * function frame_source_line(exec_state) {
188
+ * return exec_state.frame(0).sourceLine();
189
+ * }
190
+ * \endcode
191
+ */
192
+ V8_DEPRECATED("No longer supported",
193
+ static MaybeLocal<Value> Call(
194
+ Local<Context> context, v8::Local<v8::Function> fun,
195
+ Local<Value> data = Local<Value>()));
196
+
197
+ // This is now a no-op.
198
+ V8_DEPRECATED("No longer supported",
199
+ static void ProcessDebugMessages(Isolate* isolate));
200
+
201
+ /**
202
+ * Debugger is running in its own context which is entered while debugger
203
+ * messages are being dispatched. This is an explicit getter for this
204
+ * debugger context. Note that the content of the debugger context is subject
205
+ * to change. The Context exists only when the debugger is active, i.e. at
206
+ * least one DebugEventListener or MessageHandler is set.
207
+ */
208
+ V8_DEPRECATED("Use v8-inspector",
209
+ static Local<Context> GetDebugContext(Isolate* isolate));
210
+
211
+ /**
212
+ * While in the debug context, this method returns the top-most non-debug
213
+ * context, if it exists.
214
+ */
215
+ V8_DEPRECATED(
216
+ "No longer supported",
217
+ static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate));
218
+
219
+ /**
220
+ * Enable/disable LiveEdit functionality for the given Isolate
221
+ * (default Isolate if not provided). V8 will abort if LiveEdit is
222
+ * unexpectedly used. LiveEdit is enabled by default.
223
+ */
224
+ V8_DEPRECATED("No longer supported",
225
+ static void SetLiveEditEnabled(Isolate* isolate, bool enable));
226
+
227
+ /**
228
+ * Returns array of internal properties specific to the value type. Result has
229
+ * the following format: [<name>, <value>,...,<name>, <value>]. Result array
230
+ * will be allocated in the current context.
231
+ */
232
+ V8_DEPRECATED("No longer supported",
233
+ static MaybeLocal<Array> GetInternalProperties(
234
+ Isolate* isolate, Local<Value> value));
235
+
236
+ /**
237
+ * Defines if the ES2015 tail call elimination feature is enabled or not.
238
+ * The change of this flag triggers deoptimization of all functions that
239
+ * contain calls at tail position.
240
+ */
241
+ V8_DEPRECATED("No longer supported",
242
+ static bool IsTailCallEliminationEnabled(Isolate* isolate));
243
+ V8_DEPRECATED("No longer supported",
244
+ static void SetTailCallEliminationEnabled(Isolate* isolate,
245
+ bool enabled));
246
+ };
247
+
248
+
249
+ } // namespace v8
250
+
251
+
252
+ #undef EXPORT
253
+
254
+
255
+ #endif // V8_V8_DEBUG_H_
@@ -0,0 +1,13 @@
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_V8_INSPECTOR_PROTOCOL_H_
6
+ #define V8_V8_INSPECTOR_PROTOCOL_H_
7
+
8
+ #include "inspector/Debugger.h" // NOLINT(build/include)
9
+ #include "inspector/Runtime.h" // NOLINT(build/include)
10
+ #include "inspector/Schema.h" // NOLINT(build/include)
11
+ #include "v8-inspector.h" // NOLINT(build/include)
12
+
13
+ #endif // V8_V8_INSPECTOR_PROTOCOL_H_
@@ -0,0 +1,269 @@
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_V8_INSPECTOR_H_
6
+ #define V8_V8_INSPECTOR_H_
7
+
8
+ #include <stdint.h>
9
+ #include <cctype>
10
+
11
+ #include <memory>
12
+
13
+ #include "v8.h" // NOLINT(build/include)
14
+
15
+ namespace v8_inspector {
16
+
17
+ namespace protocol {
18
+ namespace Debugger {
19
+ namespace API {
20
+ class SearchMatch;
21
+ }
22
+ }
23
+ namespace Runtime {
24
+ namespace API {
25
+ class RemoteObject;
26
+ class StackTrace;
27
+ }
28
+ }
29
+ namespace Schema {
30
+ namespace API {
31
+ class Domain;
32
+ }
33
+ }
34
+ } // namespace protocol
35
+
36
+ class V8_EXPORT StringView {
37
+ public:
38
+ StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
39
+
40
+ StringView(const uint8_t* characters, size_t length)
41
+ : m_is8Bit(true), m_length(length), m_characters8(characters) {}
42
+
43
+ StringView(const uint16_t* characters, size_t length)
44
+ : m_is8Bit(false), m_length(length), m_characters16(characters) {}
45
+
46
+ bool is8Bit() const { return m_is8Bit; }
47
+ size_t length() const { return m_length; }
48
+
49
+ // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used
50
+ // here.
51
+ const uint8_t* characters8() const { return m_characters8; }
52
+ const uint16_t* characters16() const { return m_characters16; }
53
+
54
+ private:
55
+ bool m_is8Bit;
56
+ size_t m_length;
57
+ union {
58
+ const uint8_t* m_characters8;
59
+ const uint16_t* m_characters16;
60
+ };
61
+ };
62
+
63
+ class V8_EXPORT StringBuffer {
64
+ public:
65
+ virtual ~StringBuffer() {}
66
+ virtual const StringView& string() = 0;
67
+ // This method copies contents.
68
+ static std::unique_ptr<StringBuffer> create(const StringView&);
69
+ };
70
+
71
+ class V8_EXPORT V8ContextInfo {
72
+ public:
73
+ V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
74
+ const StringView& humanReadableName)
75
+ : context(context),
76
+ contextGroupId(contextGroupId),
77
+ humanReadableName(humanReadableName),
78
+ hasMemoryOnConsole(false) {}
79
+
80
+ v8::Local<v8::Context> context;
81
+ // Each v8::Context is a part of a group. The group id must be non-zero.
82
+ int contextGroupId;
83
+ StringView humanReadableName;
84
+ StringView origin;
85
+ StringView auxData;
86
+ bool hasMemoryOnConsole;
87
+
88
+ static int executionContextId(v8::Local<v8::Context> context);
89
+
90
+ private:
91
+ // Disallow copying and allocating this one.
92
+ enum NotNullTagEnum { NotNullLiteral };
93
+ void* operator new(size_t) = delete;
94
+ void* operator new(size_t, NotNullTagEnum, void*) = delete;
95
+ void* operator new(size_t, void*) = delete;
96
+ V8ContextInfo(const V8ContextInfo&) = delete;
97
+ V8ContextInfo& operator=(const V8ContextInfo&) = delete;
98
+ };
99
+
100
+ class V8_EXPORT V8StackTrace {
101
+ public:
102
+ virtual bool isEmpty() const = 0;
103
+ virtual StringView topSourceURL() const = 0;
104
+ virtual int topLineNumber() const = 0;
105
+ virtual int topColumnNumber() const = 0;
106
+ virtual StringView topScriptId() const = 0;
107
+ virtual StringView topFunctionName() const = 0;
108
+
109
+ virtual ~V8StackTrace() {}
110
+ virtual std::unique_ptr<protocol::Runtime::API::StackTrace>
111
+ buildInspectorObject() const = 0;
112
+ virtual std::unique_ptr<StringBuffer> toString() const = 0;
113
+
114
+ // Safe to pass between threads, drops async chain.
115
+ virtual std::unique_ptr<V8StackTrace> clone() = 0;
116
+ };
117
+
118
+ class V8_EXPORT V8InspectorSession {
119
+ public:
120
+ virtual ~V8InspectorSession() {}
121
+
122
+ // Cross-context inspectable values (DOM nodes in different worlds, etc.).
123
+ class V8_EXPORT Inspectable {
124
+ public:
125
+ virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
126
+ virtual ~Inspectable() {}
127
+ };
128
+ virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
129
+
130
+ // Dispatching protocol messages.
131
+ static bool canDispatchMethod(const StringView& method);
132
+ virtual void dispatchProtocolMessage(const StringView& message) = 0;
133
+ virtual std::unique_ptr<StringBuffer> stateJSON() = 0;
134
+ virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
135
+ supportedDomains() = 0;
136
+
137
+ // Debugger actions.
138
+ virtual void schedulePauseOnNextStatement(const StringView& breakReason,
139
+ const StringView& breakDetails) = 0;
140
+ virtual void cancelPauseOnNextStatement() = 0;
141
+ virtual void breakProgram(const StringView& breakReason,
142
+ const StringView& breakDetails) = 0;
143
+ virtual void setSkipAllPauses(bool) = 0;
144
+ virtual void resume() = 0;
145
+ virtual void stepOver() = 0;
146
+ virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
147
+ searchInTextByLines(const StringView& text, const StringView& query,
148
+ bool caseSensitive, bool isRegex) = 0;
149
+
150
+ // Remote objects.
151
+ virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
152
+ v8::Local<v8::Context>, v8::Local<v8::Value>,
153
+ const StringView& groupName) = 0;
154
+ virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
155
+ const StringView& objectId, v8::Local<v8::Value>*,
156
+ v8::Local<v8::Context>*,
157
+ std::unique_ptr<StringBuffer>* objectGroup) = 0;
158
+ virtual void releaseObjectGroup(const StringView&) = 0;
159
+ };
160
+
161
+ class V8_EXPORT V8InspectorClient {
162
+ public:
163
+ virtual ~V8InspectorClient() {}
164
+
165
+ virtual void runMessageLoopOnPause(int contextGroupId) {}
166
+ virtual void quitMessageLoopOnPause() {}
167
+ virtual void runIfWaitingForDebugger(int contextGroupId) {}
168
+
169
+ virtual void muteMetrics(int contextGroupId) {}
170
+ virtual void unmuteMetrics(int contextGroupId) {}
171
+
172
+ virtual void beginUserGesture() {}
173
+ virtual void endUserGesture() {}
174
+
175
+ virtual std::unique_ptr<StringBuffer> valueSubtype(v8::Local<v8::Value>) {
176
+ return nullptr;
177
+ }
178
+ virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) {
179
+ return false;
180
+ }
181
+ virtual bool isInspectableHeapObject(v8::Local<v8::Object>) { return true; }
182
+
183
+ virtual v8::Local<v8::Context> ensureDefaultContextInGroup(
184
+ int contextGroupId) {
185
+ return v8::Local<v8::Context>();
186
+ }
187
+ virtual void beginEnsureAllContextsInGroup(int contextGroupId) {}
188
+ virtual void endEnsureAllContextsInGroup(int contextGroupId) {}
189
+
190
+ virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>,
191
+ v8::Local<v8::Object>) {}
192
+ virtual void consoleAPIMessage(int contextGroupId,
193
+ v8::Isolate::MessageErrorLevel level,
194
+ const StringView& message,
195
+ const StringView& url, unsigned lineNumber,
196
+ unsigned columnNumber, V8StackTrace*) {}
197
+ virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*,
198
+ v8::Local<v8::Context>) {
199
+ return v8::MaybeLocal<v8::Value>();
200
+ }
201
+
202
+ virtual void consoleTime(const StringView& title) {}
203
+ virtual void consoleTimeEnd(const StringView& title) {}
204
+ virtual void consoleTimeStamp(const StringView& title) {}
205
+ virtual void consoleClear(int contextGroupId) {}
206
+ virtual double currentTimeMS() { return 0; }
207
+ typedef void (*TimerCallback)(void*);
208
+ virtual void startRepeatingTimer(double, TimerCallback, void* data) {}
209
+ virtual void cancelTimer(void* data) {}
210
+
211
+ // TODO(dgozman): this was added to support service worker shadow page. We
212
+ // should not connect at all.
213
+ virtual bool canExecuteScripts(int contextGroupId) { return true; }
214
+
215
+ virtual void maxAsyncCallStackDepthChanged(int depth) {}
216
+ };
217
+
218
+ class V8_EXPORT V8Inspector {
219
+ public:
220
+ static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
221
+ virtual ~V8Inspector() {}
222
+
223
+ // Contexts instrumentation.
224
+ virtual void contextCreated(const V8ContextInfo&) = 0;
225
+ virtual void contextDestroyed(v8::Local<v8::Context>) = 0;
226
+ virtual void resetContextGroup(int contextGroupId) = 0;
227
+
228
+ // Various instrumentation.
229
+ virtual void idleStarted() = 0;
230
+ virtual void idleFinished() = 0;
231
+
232
+ // Async stack traces instrumentation.
233
+ virtual void asyncTaskScheduled(const StringView& taskName, void* task,
234
+ bool recurring) = 0;
235
+ virtual void asyncTaskCanceled(void* task) = 0;
236
+ virtual void asyncTaskStarted(void* task) = 0;
237
+ virtual void asyncTaskFinished(void* task) = 0;
238
+ virtual void allAsyncTasksCanceled() = 0;
239
+
240
+ // Exceptions instrumentation.
241
+ virtual unsigned exceptionThrown(
242
+ v8::Local<v8::Context>, const StringView& message,
243
+ v8::Local<v8::Value> exception, const StringView& detailedMessage,
244
+ const StringView& url, unsigned lineNumber, unsigned columnNumber,
245
+ std::unique_ptr<V8StackTrace>, int scriptId) = 0;
246
+ virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
247
+ const StringView& message) = 0;
248
+
249
+ // Connection.
250
+ class V8_EXPORT Channel {
251
+ public:
252
+ virtual ~Channel() {}
253
+ virtual void sendResponse(int callId,
254
+ std::unique_ptr<StringBuffer> message) = 0;
255
+ virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
256
+ virtual void flushProtocolNotifications() = 0;
257
+ };
258
+ virtual std::unique_ptr<V8InspectorSession> connect(
259
+ int contextGroupId, Channel*, const StringView& state) = 0;
260
+
261
+ // API methods.
262
+ virtual std::unique_ptr<V8StackTrace> createStackTrace(
263
+ v8::Local<v8::StackTrace>) = 0;
264
+ virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0;
265
+ };
266
+
267
+ } // namespace v8_inspector
268
+
269
+ #endif // V8_V8_INSPECTOR_H_