v8
v8-debug.h
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,
19  NewFunction = 3,
20  BeforeCompile = 4,
21  AfterCompile = 5,
22  CompileError = 6,
23  PromiseEvent = 7,
24  AsyncTaskEvent = 8,
25 };
26 
27 
28 class V8_EXPORT Debug {
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 Handle<Object> GetExecutionState() const = 0;
64  virtual Handle<Object> GetEventData() const = 0;
65 
69  virtual Handle<String> GetJSON() const = 0;
70 
76  virtual Handle<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 Handle<Object> GetExecutionState() const = 0;
108  virtual Handle<Object> GetEventData() const = 0;
109 
115  virtual Handle<Context> GetEventContext() const = 0;
116 
121  virtual Handle<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  Handle<Value> data = Handle<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  Handle<Value> data = Handle<Value>()));
201  // TODO(dcarney): data arg should be a MaybeLocal
202  static MaybeLocal<Value> Call(Local<Context> context,
204  Handle<Value> data = Handle<Value>());
205 
209  static V8_DEPRECATE_SOON("Use maybe version",
210  Local<Value> GetMirror(v8::Handle<v8::Value> obj));
211  static MaybeLocal<Value> GetMirror(Local<Context> context,
213 
245  static void ProcessDebugMessages();
246 
253  static Local<Context> GetDebugContext();
254 
255 
261  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
262 };
263 
264 
265 } // namespace v8
266 
267 
268 #undef EXPORT
269 
270 
271 #endif // V8_V8_DEBUG_H_
Definition: libplatform.h:10
Definition: v8-debug.h:96
Definition: v8-debug.h:34
Definition: v8-debug.h:43
Definition: v8.h:4946
Definition: v8-debug.h:28
Definition: v8.h:109
Definition: v8.h:111