v8  4.5.103(node4.8.7)
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"
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,
25 };
26 
27 
29  public:
34  class ClientData {
35  public:
36  virtual ~ClientData() {}
37  };
38 
39 
43  class Message {
44  public:
48  virtual bool IsEvent() const = 0;
49  virtual bool IsResponse() const = 0;
50  virtual DebugEvent GetEvent() const = 0;
51 
56  virtual bool WillStartRunning() const = 0;
57 
63  virtual Local<Object> GetExecutionState() const = 0;
64  virtual Local<Object> GetEventData() const = 0;
65 
69  virtual Local<String> GetJSON() const = 0;
70 
76  virtual Local<Context> GetEventContext() const = 0;
77 
85  virtual ClientData* GetClientData() const = 0;
86 
87  virtual Isolate* GetIsolate() const = 0;
88 
89  virtual ~Message() {}
90  };
91 
92 
96  class EventDetails {
97  public:
101  virtual DebugEvent GetEvent() const = 0;
102 
107  virtual Local<Object> GetExecutionState() const = 0;
108  virtual Local<Object> GetEventData() const = 0;
109 
115  virtual Local<Context> GetEventContext() const = 0;
116 
121  virtual Local<Value> GetCallbackData() const = 0;
122 
128  virtual ClientData* GetClientData() 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(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(MessageHandler handler);
174 
175  static void SendCommand(Isolate* isolate,
176  const uint16_t* command, int length,
177  ClientData* client_data = NULL);
178 
197  static V8_DEPRECATE_SOON(
198  "Use maybe version",
200  Local<Value> data = Local<Value>()));
201  // TODO(dcarney): data arg should be a MaybeLocal
202  static MaybeLocal<Value> Call(Local<Context> context,
204  Local<Value> data = Local<Value>());
205 
209  static V8_DEPRECATE_SOON("Use maybe version",
210  Local<Value> GetMirror(v8::Local<v8::Value> obj));
211  static MaybeLocal<Value> GetMirror(Local<Context> context,
213 
245  static void ProcessDebugMessages();
246 
254  static Local<Context> GetDebugContext();
255 
256 
262  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
263 
269  static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
270  Local<Value> value);
271 };
272 
273 
274 } // namespace v8
275 
276 
277 #undef EXPORT
278 
279 
280 #endif // V8_V8_DEBUG_H_
virtual ~Message()
Definition: v8-debug.h:89
DebugEvent
Definition: v8-debug.h:16
virtual ~EventDetails()
Definition: v8-debug.h:130
#define V8_DEPRECATE_SOON(message, declarator)
Definition: v8config.h:347
Definition: libplatform.h:10
virtual ~ClientData()
Definition: v8-debug.h:36
#define V8_EXPORT
Definition: v8.h:58
Definition: v8.h:109