OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_V8_DEBUG_H_ | 5 #ifndef V8_V8_DEBUG_H_ |
6 #define V8_V8_DEBUG_H_ | 6 #define V8_V8_DEBUG_H_ |
7 | 7 |
8 #include "v8.h" | 8 #include "v8.h" |
9 | 9 |
10 /** | 10 /** |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 DebugBreakForCommand(isolate, data); | 177 DebugBreakForCommand(isolate, data); |
178 } | 178 } |
179 | 179 |
180 // Message based interface. The message protocol is JSON. | 180 // Message based interface. The message protocol is JSON. |
181 static void SetMessageHandler2(MessageHandler2 handler); | 181 static void SetMessageHandler2(MessageHandler2 handler); |
182 | 182 |
183 static void SendCommand(Isolate* isolate, | 183 static void SendCommand(Isolate* isolate, |
184 const uint16_t* command, int length, | 184 const uint16_t* command, int length, |
185 ClientData* client_data = NULL); | 185 ClientData* client_data = NULL); |
186 | 186 |
187 /** | |
188 * Register a callback function to be called when a debug message has been | |
189 * received and is ready to be processed. For the debug messages to be | |
190 * processed V8 needs to be entered, and in certain embedding scenarios this | |
191 * callback can be used to make sure V8 is entered for the debug message to | |
192 * be processed. Note that debug messages will only be processed if there is | |
193 * a V8 break. This can happen automatically by using the option | |
194 * --debugger-auto-break. | |
195 * \param provide_locker requires that V8 acquires v8::Locker for you before | |
196 * calling handler | |
197 */ | |
198 static void SetDebugMessageDispatchHandler( | |
199 DebugMessageDispatchHandler handler, bool provide_locker = false); | |
200 | |
201 /** | 187 /** |
202 * Run a JavaScript function in the debugger. | 188 * Run a JavaScript function in the debugger. |
203 * \param fun the function to call | 189 * \param fun the function to call |
204 * \param data passed as second argument to the function | 190 * \param data passed as second argument to the function |
205 * With this call the debugger is entered and the function specified is called | 191 * With this call the debugger is entered and the function specified is called |
206 * with the execution state as the first argument. This makes it possible to | 192 * with the execution state as the first argument. This makes it possible to |
207 * get access to information otherwise not available during normal JavaScript | 193 * get access to information otherwise not available during normal JavaScript |
208 * execution e.g. details on stack frames. Receiver of the function call will | 194 * execution e.g. details on stack frames. Receiver of the function call will |
209 * be the debugger context global object, however this is a subject to change. | 195 * be the debugger context global object, however this is a subject to change. |
210 * The following example shows a JavaScript function which when passed to | 196 * The following example shows a JavaScript function which when passed to |
211 * v8::Debug::Call will return the current line of JavaScript execution. | 197 * v8::Debug::Call will return the current line of JavaScript execution. |
212 * | 198 * |
213 * \code | 199 * \code |
214 * function frame_source_line(exec_state) { | 200 * function frame_source_line(exec_state) { |
215 * return exec_state.frame(0).sourceLine(); | 201 * return exec_state.frame(0).sourceLine(); |
216 * } | 202 * } |
217 * \endcode | 203 * \endcode |
218 */ | 204 */ |
219 static Local<Value> Call(v8::Handle<v8::Function> fun, | 205 static Local<Value> Call(v8::Handle<v8::Function> fun, |
220 Handle<Value> data = Handle<Value>()); | 206 Handle<Value> data = Handle<Value>()); |
221 | 207 |
222 /** | 208 /** |
223 * Returns a mirror object for the given object. | 209 * Returns a mirror object for the given object. |
224 */ | 210 */ |
225 static Local<Value> GetMirror(v8::Handle<v8::Value> obj); | 211 static Local<Value> GetMirror(v8::Handle<v8::Value> obj); |
226 | 212 |
227 /** | |
228 * Enable the V8 builtin debug agent. The debugger agent will listen on the | |
229 * supplied TCP/IP port for remote debugger connection. | |
230 * \param name the name of the embedding application | |
231 * \param port the TCP/IP port to listen on | |
232 * \param wait_for_connection whether V8 should pause on a first statement | |
233 * allowing remote debugger to connect before anything interesting happened | |
234 */ | |
235 static bool EnableAgent(const char* name, int port, | |
236 bool wait_for_connection = false); | |
237 | |
238 /** | |
239 * Disable the V8 builtin debug agent. The TCP/IP connection will be closed. | |
240 */ | |
241 static void DisableAgent(); | |
242 | |
243 /** | 213 /** |
244 * Makes V8 process all pending debug messages. | 214 * Makes V8 process all pending debug messages. |
245 * | 215 * |
246 * From V8 point of view all debug messages come asynchronously (e.g. from | 216 * From V8 point of view all debug messages come asynchronously (e.g. from |
247 * remote debugger) but they all must be handled synchronously: V8 cannot | 217 * remote debugger) but they all must be handled synchronously: V8 cannot |
248 * do 2 things at one time so normal script execution must be interrupted | 218 * do 2 things at one time so normal script execution must be interrupted |
249 * for a while. | 219 * for a while. |
250 * | 220 * |
251 * Generally when message arrives V8 may be in one of 3 states: | 221 * Generally when message arrives V8 may be in one of 3 states: |
252 * 1. V8 is running script; V8 will automatically interrupt and process all | 222 * 1. V8 is running script; V8 will automatically interrupt and process all |
253 * pending messages; | 223 * pending messages; |
254 * 2. V8 is suspended on debug breakpoint; in this state V8 is dedicated | 224 * 2. V8 is suspended on debug breakpoint; in this state V8 is dedicated |
255 * to reading and processing debug messages; | 225 * to reading and processing debug messages; |
256 * 3. V8 is not running at all or has called some long-working C++ function; | 226 * 3. V8 is not running at all or has called some long-working C++ function; |
257 * by default it means that processing of all debug messages will be deferred | 227 * by default it means that processing of all debug messages will be deferred |
258 * until V8 gets control again; however, embedding application may improve | 228 * until V8 gets control again; however, embedding application may improve |
259 * this by manually calling this method. | 229 * this by manually calling this method. |
260 * | 230 * |
261 * It makes sense to call this method whenever a new debug message arrived and | |
262 * V8 is not already running. Method v8::Debug::SetDebugMessageDispatchHandler | |
263 * should help with the former condition. | |
264 * | |
265 * Technically this method in many senses is equivalent to executing empty | 231 * Technically this method in many senses is equivalent to executing empty |
266 * script: | 232 * script: |
267 * 1. It does nothing except for processing all pending debug messages. | 233 * 1. It does nothing except for processing all pending debug messages. |
268 * 2. It should be invoked with the same precautions and from the same context | 234 * 2. It should be invoked with the same precautions and from the same context |
269 * as V8 script would be invoked from, because: | 235 * as V8 script would be invoked from, because: |
270 * a. with "evaluate" command it can do whatever normal script can do, | 236 * a. with "evaluate" command it can do whatever normal script can do, |
271 * including all native calls; | 237 * including all native calls; |
272 * b. no other thread should call V8 while this method is running | 238 * b. no other thread should call V8 while this method is running |
273 * (v8::Locker may be used here). | 239 * (v8::Locker may be used here). |
274 * | 240 * |
(...skipping 25 matching lines...) Expand all Loading... |
300 }; | 266 }; |
301 | 267 |
302 | 268 |
303 } // namespace v8 | 269 } // namespace v8 |
304 | 270 |
305 | 271 |
306 #undef EXPORT | 272 #undef EXPORT |
307 | 273 |
308 | 274 |
309 #endif // V8_V8_DEBUG_H_ | 275 #endif // V8_V8_DEBUG_H_ |
OLD | NEW |