v8  3.28.71(node0.12.18)
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,
26 };
27 
28 
30  public:
35  class ClientData {
36  public:
37  virtual ~ClientData() {}
38  };
39 
40 
44  class Message {
45  public:
49  virtual bool IsEvent() const = 0;
50  virtual bool IsResponse() const = 0;
51  virtual DebugEvent GetEvent() const = 0;
52 
57  virtual bool WillStartRunning() const = 0;
58 
64  virtual Handle<Object> GetExecutionState() const = 0;
65  virtual Handle<Object> GetEventData() const = 0;
66 
70  virtual Handle<String> GetJSON() const = 0;
71 
77  virtual Handle<Context> GetEventContext() const = 0;
78 
86  virtual ClientData* GetClientData() const = 0;
87 
88  virtual Isolate* GetIsolate() const = 0;
89 
90  virtual ~Message() {}
91  };
92 
93 
97  class EventDetails {
98  public:
102  virtual DebugEvent GetEvent() const = 0;
103 
108  virtual Handle<Object> GetExecutionState() const = 0;
109  virtual Handle<Object> GetEventData() const = 0;
110 
116  virtual Handle<Context> GetEventContext() const = 0;
117 
122  virtual Handle<Value> GetCallbackData() const = 0;
123 
129  virtual ClientData* GetClientData() const = 0;
130 
131  virtual ~EventDetails() {}
132  };
133 
142  typedef void (*EventCallback)(const EventDetails& event_details);
143 
152  typedef void (*MessageHandler)(const Message& message);
153 
157  typedef void (*DebugMessageDispatchHandler)();
158 
159  static bool SetDebugEventListener(EventCallback that,
160  Handle<Value> data = Handle<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  // Break execution of JavaScript in the given isolate (this method
171  // can be invoked from a non-VM thread) for further client command
172  // execution on a VM thread. Client data is then passed in
173  // EventDetails to EventCallback2 at the moment when the VM actually
174  // stops.
175  static void DebugBreakForCommand(Isolate* isolate, ClientData* data);
176 
177  // Message based interface. The message protocol is JSON.
178  static void SetMessageHandler(MessageHandler handler);
179 
180  static void SendCommand(Isolate* isolate,
181  const uint16_t* command, int length,
182  ClientData* client_data = NULL);
183 
202  static Local<Value> Call(v8::Handle<v8::Function> fun,
203  Handle<Value> data = Handle<Value>());
204 
208  static Local<Value> GetMirror(v8::Handle<v8::Value> obj);
209 
241  static void ProcessDebugMessages();
242 
249  static Local<Context> GetDebugContext();
250 
251 
257  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
258 };
259 
260 
261 } // namespace v8
262 
263 
264 #undef EXPORT
265 
266 
267 #endif // V8_V8_DEBUG_H_
virtual ~Message()
Definition: v8-debug.h:90
DebugEvent
Definition: v8-debug.h:16
virtual ~EventDetails()
Definition: v8-debug.h:131
Definition: libplatform.h:10
Definition: v8.h:100
virtual ~ClientData()
Definition: v8-debug.h:37
#define V8_EXPORT
Definition: v8.h:53
Definition: v8.h:101