v8  5.1.281(node6.17.1)
V8 is Google's open source JavaScript engine
v8-debug.h
Go to the documentation of this file.
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 
13 namespace v8 {
14 
15 // Debug events which can occur in the V8 JavaScript engine.
16 enum DebugEvent {
17  Break = 1,
18  Exception = 2,
24 };
25 
27  public:
32  class ClientData {
33  public:
34  virtual ~ClientData() {}
35  };
36 
37 
41  class Message {
42  public:
46  virtual bool IsEvent() const = 0;
47  virtual bool IsResponse() const = 0;
48  virtual DebugEvent GetEvent() const = 0;
49 
54  virtual bool WillStartRunning() const = 0;
55 
61  virtual Local<Object> GetExecutionState() const = 0;
62  virtual Local<Object> GetEventData() const = 0;
63 
67  virtual Local<String> GetJSON() const = 0;
68 
74  virtual Local<Context> GetEventContext() const = 0;
75 
83  virtual ClientData* GetClientData() const = 0;
84 
85  virtual Isolate* GetIsolate() const = 0;
86 
87  virtual ~Message() {}
88  };
89 
90 
94  class EventDetails {
95  public:
99  virtual DebugEvent GetEvent() const = 0;
100 
105  virtual Local<Object> GetExecutionState() const = 0;
106  virtual Local<Object> GetEventData() const = 0;
107 
113  virtual Local<Context> GetEventContext() const = 0;
114 
119  virtual Local<Value> GetCallbackData() const = 0;
120 
126  virtual ClientData* GetClientData() const = 0;
127 
128  virtual ~EventDetails() {}
129  };
130 
139  typedef void (*EventCallback)(const EventDetails& event_details);
140 
149  typedef void (*MessageHandler)(const Message& message);
150 
154  typedef void (*DebugMessageDispatchHandler)();
155 
156  static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
157  Local<Value> data = Local<Value>());
158  V8_DEPRECATED("Use version with an Isolate",
159  static bool SetDebugEventListener(
160  EventCallback that, Local<Value> data = Local<Value>()));
161 
162  // Schedule a debugger break to happen when JavaScript code is run
163  // in the given isolate.
164  static void DebugBreak(Isolate* isolate);
165 
166  // Remove scheduled debugger break in given isolate if it has not
167  // happened yet.
168  static void CancelDebugBreak(Isolate* isolate);
169 
170  // Check if a debugger break is scheduled in the given isolate.
171  static bool CheckDebugBreak(Isolate* isolate);
172 
173  // Message based interface. The message protocol is JSON.
174  static void SetMessageHandler(Isolate* isolate, MessageHandler handler);
175  V8_DEPRECATED("Use version with an Isolate",
176  static void SetMessageHandler(MessageHandler handler));
177 
178  static void SendCommand(Isolate* isolate,
179  const uint16_t* command, int length,
180  ClientData* client_data = NULL);
181 
200  static V8_DEPRECATED("Use maybe version",
202  Local<Value> data = Local<Value>()));
203  // TODO(dcarney): data arg should be a MaybeLocal
204  static MaybeLocal<Value> Call(Local<Context> context,
206  Local<Value> data = Local<Value>());
207 
211  static V8_DEPRECATED("Use maybe version",
212  Local<Value> GetMirror(v8::Local<v8::Value> obj));
213  static MaybeLocal<Value> GetMirror(Local<Context> context,
215 
247  static void ProcessDebugMessages(Isolate* isolate);
248  V8_DEPRECATED("Use version with an Isolate",
249  static void ProcessDebugMessages());
250 
258  static Local<Context> GetDebugContext(Isolate* isolate);
259  V8_DEPRECATED("Use version with an Isolate",
260  static Local<Context> GetDebugContext());
261 
262 
268  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
269 
275  static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
276  Local<Value> value);
277 
283  static bool IsTailCallEliminationEnabled(Isolate* isolate);
284  static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
285 };
286 
287 
288 } // namespace v8
289 
290 
291 #undef EXPORT
292 
293 
294 #endif // V8_V8_DEBUG_H_
virtual ~Message()
Definition: v8-debug.h:87
DebugEvent
Definition: v8-debug.h:16
virtual ~EventDetails()
Definition: v8-debug.h:128
Definition: libplatform.h:10
#define V8_DEPRECATED(message, declarator)
Definition: v8config.h:340
virtual ~ClientData()
Definition: v8-debug.h:34
#define V8_EXPORT
Definition: v8.h:60
Definition: v8.h:113