v8-debug.h revision b8a8cc1952d61a2f3a2568848933943a543b5d3e
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2008 the V8 project authors. All rights reserved.
2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch// found in the LICENSE file.
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_V8_DEBUG_H_
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_V8_DEBUG_H_
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "v8.h"
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block/**
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Debugger support for the V8 JavaScript engine.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Debug events which can occur in the V8 JavaScript engine.
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum DebugEvent {
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Break = 1,
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Exception = 2,
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  NewFunction = 3,
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  BeforeCompile = 4,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  AfterCompile  = 5,
22b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  CompileError = 6,
23b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  PromiseEvent = 7,
24b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  AsyncTaskEvent = 8,
25b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  BreakForCommand = 9
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
29b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass V8_EXPORT Debug {
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  /**
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * A client object passed to the v8 debugger whose ownership will be taken by
33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * it. v8 is always responsible for deleting the object.
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   */
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  class ClientData {
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   public:
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual ~ClientData() {}
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  /**
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * A message object passed to the debug message handler.
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   */
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  class Message {
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   public:
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Check type of message.
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual bool IsEvent() const = 0;
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual bool IsResponse() const = 0;
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual DebugEvent GetEvent() const = 0;
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Indicate whether this is a response to a continue command which will
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * start the VM running after this is processed.
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual bool WillStartRunning() const = 0;
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Access to execution state and event data. Don't store these cross
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * callbacks as their content becomes invalid. These objects are from the
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * debugger event that started the debug message loop.
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual Handle<Object> GetExecutionState() const = 0;
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual Handle<Object> GetEventData() const = 0;
66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Get the debugger protocol JSON.
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual Handle<String> GetJSON() const = 0;
71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Get the context active when the debug event happened. Note this is not
74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * the current active context as the JavaScript part of the debugger is
75257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch     * running in its own context which is entered at this point.
76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual Handle<Context> GetEventContext() const = 0;
78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    /**
80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * Client data passed with the corresponding request if any. This is the
81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * client_data data value passed into Debug::SendCommand along with the
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * request that led to the message or NULL if the message is an event. The
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * debugger takes ownership of the data and will delete it even if there is
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     * no message handler.
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block     */
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual ClientData* GetClientData() const = 0;
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
88b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch    virtual Isolate* GetIsolate() const = 0;
89b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    virtual ~Message() {}
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
923e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  /**
95f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   * An event details object passed to the debug event listener.
96f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   */
97f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke  class EventDetails {
98f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   public:
99f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    /**
100f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     * Event type.
101f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     */
102f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual DebugEvent GetEvent() const = 0;
103f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke
104f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    /**
105f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     * Access to execution state and event data of the debug event. Don't store
106f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     * these cross callbacks as their content becomes invalid.
107f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     */
108f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual Handle<Object> GetExecutionState() const = 0;
109f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual Handle<Object> GetEventData() const = 0;
110f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke
111f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    /**
112f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     * Get the context active when the debug event happened. Note this is not
113f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     * the current active context as the JavaScript part of the debugger is
114257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch     * running in its own context which is entered at this point.
115f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     */
116f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual Handle<Context> GetEventContext() const = 0;
117f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke
118f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    /**
119257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch     * Client data passed with the corresponding callback when it was
120257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch     * registered.
121f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke     */
122f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual Handle<Value> GetCallbackData() const = 0;
123f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke
1243bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch    /**
1253bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch     * Client data passed to DebugBreakForCommand function. The
1263bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch     * debugger takes ownership of the data and will delete it even if
1273bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch     * there is no message handler.
1283bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch     */
1293bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch    virtual ClientData* GetClientData() const = 0;
1303bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch
131f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke    virtual ~EventDetails() {}
132f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke  };
133f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke
134f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke  /**
135f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   * Debug event callback function.
136f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   *
137f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   * \param event_details object providing information about the debug event
138f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   *
139f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   * A EventCallback2 does not take possession of the event data,
140f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   * and must not rely on the data persisting after the handler returns.
141f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke   */
142b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  typedef void (*EventCallback)(const EventDetails& event_details);
143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  /**
145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * Debug message callback function.
146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   *
147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * \param message the debug message handler message object
14844f0eee88ff00398ff7f715fab053374d808c90dSteve Block   *
149b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   * A MessageHandler2 does not take possession of the message data,
150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * and must not rely on the data persisting after the handler returns.
151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   */
152b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  typedef void (*MessageHandler)(const Message& message);
153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
154d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  /**
155d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block   * Callback function for the host to ensure debug messages are processed.
156d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block   */
157d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  typedef void (*DebugMessageDispatchHandler)();
158d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static bool SetDebugEventListener(EventCallback that,
160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                    Handle<Value> data = Handle<Value>());
161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
16244f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // Schedule a debugger break to happen when JavaScript code is run
163b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // in the given isolate.
164b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void DebugBreak(Isolate* isolate);
165a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
16644f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // Remove scheduled debugger break in given isolate if it has not
167b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // happened yet.
168b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void CancelDebugBreak(Isolate* isolate);
169b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
170b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // Check if a debugger break is scheduled in the given isolate.
171b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static bool CheckDebugBreak(Isolate* isolate);
172f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch
17344f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // Break execution of JavaScript in the given isolate (this method
17444f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // can be invoked from a non-VM thread) for further client command
17544f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // execution on a VM thread. Client data is then passed in
176b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // EventDetails to EventCallback2 at the moment when the VM actually
177b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // stops.
178b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void DebugBreakForCommand(Isolate* isolate, ClientData* data);
179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
180b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  // Message based interface. The message protocol is JSON.
181b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void SetMessageHandler(MessageHandler handler);
182b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
183b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void SendCommand(Isolate* isolate,
184b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          const uint16_t* command, int length,
185b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                          ClientData* client_data = NULL);
186d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /**
188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * Run a JavaScript function in the debugger.
189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * \param fun the function to call
190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * \param data passed as second argument to the function
191a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * With this call the debugger is entered and the function specified is called
192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * with the execution state as the first argument. This makes it possible to
193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * get access to information otherwise not available during normal JavaScript
1946ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  * execution e.g. details on stack frames. Receiver of the function call will
1956ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  * be the debugger context global object, however this is a subject to change.
196257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch  * The following example shows a JavaScript function which when passed to
1976ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  * v8::Debug::Call will return the current line of JavaScript execution.
198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  *
199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * \code
200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  *   function frame_source_line(exec_state) {
201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  *     return exec_state.frame(0).sourceLine();
202a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  *   }
203a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  * \endcode
204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  */
205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Local<Value> Call(v8::Handle<v8::Function> fun,
206b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch                           Handle<Value> data = Handle<Value>());
207a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
208a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  /**
209a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   * Returns a mirror object for the given object.
210a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   */
211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Local<Value> GetMirror(v8::Handle<v8::Value> obj);
212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
2133ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch  /**
214e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * Makes V8 process all pending debug messages.
215e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *
216e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * From V8 point of view all debug messages come asynchronously (e.g. from
217e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * remote debugger) but they all must be handled synchronously: V8 cannot
218e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * do 2 things at one time so normal script execution must be interrupted
219e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * for a while.
220e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *
221e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * Generally when message arrives V8 may be in one of 3 states:
222e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * 1. V8 is running script; V8 will automatically interrupt and process all
223b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   * pending messages;
224e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * 2. V8 is suspended on debug breakpoint; in this state V8 is dedicated
225e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * to reading and processing debug messages;
226e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * 3. V8 is not running at all or has called some long-working C++ function;
227257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch   * by default it means that processing of all debug messages will be deferred
228e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * until V8 gets control again; however, embedding application may improve
229e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * this by manually calling this method.
230e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *
231e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * Technically this method in many senses is equivalent to executing empty
232e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * script:
233e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * 1. It does nothing except for processing all pending debug messages.
234e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * 2. It should be invoked with the same precautions and from the same context
235e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * as V8 script would be invoked from, because:
236e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *   a. with "evaluate" command it can do whatever normal script can do,
237e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *   including all native calls;
238e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *   b. no other thread should call V8 while this method is running
239e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *   (v8::Locker may be used here).
240e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   *
241e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * "Evaluate" debug command behavior currently is not specified in scope
242e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   * of this method.
243e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke   */
244e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  static void ProcessDebugMessages();
2456ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
2466ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  /**
247257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch   * Debugger is running in its own context which is entered while debugger
2486ded16be15dd865a9b21ea304d5273c8be299c87Steve Block   * messages are being dispatched. This is an explicit getter for this
2496ded16be15dd865a9b21ea304d5273c8be299c87Steve Block   * debugger context. Note that the content of the debugger context is subject
2506ded16be15dd865a9b21ea304d5273c8be299c87Steve Block   * to change.
2516ded16be15dd865a9b21ea304d5273c8be299c87Steve Block   */
2526ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  static Local<Context> GetDebugContext();
253b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
254b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch
255b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  /**
256b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   * Enable/disable LiveEdit functionality for the given Isolate
257b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   * (default Isolate if not provided). V8 will abort if LiveEdit is
258b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   * unexpectedly used. LiveEdit is enabled by default.
259b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch   */
260b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch  static void SetLiveEditEnabled(Isolate* isolate, bool enable);
261a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
262a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
263a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
264a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}  // namespace v8
265a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
266a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
267a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#undef EXPORT
268a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
269a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
270a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_V8_DEBUG_H_
271