v8  5.5.372(node7.10.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 Isolate* GetIsolate() const = 0;
129 
130  virtual ~EventDetails() {}
131  };
132 
141  typedef void (*EventCallback)(const EventDetails& event_details);
142 
151  typedef void (*MessageHandler)(const Message& message);
152 
156  typedef void (*DebugMessageDispatchHandler)();
157 
158  static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
159  Local<Value> data = Local<Value>());
160 
161  // Schedule a debugger break to happen when JavaScript code is run
162  // in the given isolate.
163  static void DebugBreak(Isolate* isolate);
164 
165  // Remove scheduled debugger break in given isolate if it has not
166  // happened yet.
167  static void CancelDebugBreak(Isolate* isolate);
168 
169  // Check if a debugger break is scheduled in the given isolate.
170  static bool CheckDebugBreak(Isolate* isolate);
171 
172  // Message based interface. The message protocol is JSON.
173  static void SetMessageHandler(Isolate* isolate, MessageHandler handler);
174 
175  static void SendCommand(Isolate* isolate,
176  const uint16_t* command, int length,
177  ClientData* client_data = NULL);
178 
197  // TODO(dcarney): data arg should be a MaybeLocal
198  static MaybeLocal<Value> Call(Local<Context> context,
200  Local<Value> data = Local<Value>());
201 
205  static MaybeLocal<Value> GetMirror(Local<Context> context,
207 
239  static void ProcessDebugMessages(Isolate* isolate);
240 
248  static Local<Context> GetDebugContext(Isolate* isolate);
249 
254  static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate);
255 
261  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
262 
268  static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
269  Local<Value> value);
270 
276  static bool IsTailCallEliminationEnabled(Isolate* isolate);
277  static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
278 };
279 
280 
281 } // namespace v8
282 
283 
284 #undef EXPORT
285 
286 
287 #endif // V8_V8_DEBUG_H_
virtual ~Message()
Definition: v8-debug.h:87
DebugEvent
Definition: v8-debug.h:16
virtual ~EventDetails()
Definition: v8-debug.h:130
Definition: libplatform.h:11
virtual ~ClientData()
Definition: v8-debug.h:34
#define V8_EXPORT
Definition: v8.h:61
Definition: v8.h:116