| 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" // NOLINT(build/include) | 8 #include "v8.h" // NOLINT(build/include) |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 */ | 150 */ |
| 151 typedef void (*MessageHandler)(const Message& message); | 151 typedef void (*MessageHandler)(const Message& message); |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * Callback function for the host to ensure debug messages are processed. | 154 * Callback function for the host to ensure debug messages are processed. |
| 155 */ | 155 */ |
| 156 typedef void (*DebugMessageDispatchHandler)(); | 156 typedef void (*DebugMessageDispatchHandler)(); |
| 157 | 157 |
| 158 static bool SetDebugEventListener(Isolate* isolate, EventCallback that, | 158 static bool SetDebugEventListener(Isolate* isolate, EventCallback that, |
| 159 Local<Value> data = Local<Value>()); | 159 Local<Value> data = Local<Value>()); |
| 160 V8_DEPRECATE_SOON( | 160 V8_DEPRECATED("Use version with an Isolate", |
| 161 "Use version with an Isolate", | 161 static bool SetDebugEventListener( |
| 162 static bool SetDebugEventListener(EventCallback that, | 162 EventCallback that, Local<Value> data = Local<Value>())); |
| 163 Local<Value> data = Local<Value>())); | |
| 164 | 163 |
| 165 // Schedule a debugger break to happen when JavaScript code is run | 164 // Schedule a debugger break to happen when JavaScript code is run |
| 166 // in the given isolate. | 165 // in the given isolate. |
| 167 static void DebugBreak(Isolate* isolate); | 166 static void DebugBreak(Isolate* isolate); |
| 168 | 167 |
| 169 // Remove scheduled debugger break in given isolate if it has not | 168 // Remove scheduled debugger break in given isolate if it has not |
| 170 // happened yet. | 169 // happened yet. |
| 171 static void CancelDebugBreak(Isolate* isolate); | 170 static void CancelDebugBreak(Isolate* isolate); |
| 172 | 171 |
| 173 // Check if a debugger break is scheduled in the given isolate. | 172 // Check if a debugger break is scheduled in the given isolate. |
| 174 static bool CheckDebugBreak(Isolate* isolate); | 173 static bool CheckDebugBreak(Isolate* isolate); |
| 175 | 174 |
| 176 // Message based interface. The message protocol is JSON. | 175 // Message based interface. The message protocol is JSON. |
| 177 static void SetMessageHandler(Isolate* isolate, MessageHandler handler); | 176 static void SetMessageHandler(Isolate* isolate, MessageHandler handler); |
| 178 V8_DEPRECATE_SOON("Use version with an Isolate", | 177 V8_DEPRECATED("Use version with an Isolate", |
| 179 static void SetMessageHandler(MessageHandler handler)); | 178 static void SetMessageHandler(MessageHandler handler)); |
| 180 | 179 |
| 181 static void SendCommand(Isolate* isolate, | 180 static void SendCommand(Isolate* isolate, |
| 182 const uint16_t* command, int length, | 181 const uint16_t* command, int length, |
| 183 ClientData* client_data = NULL); | 182 ClientData* client_data = NULL); |
| 184 | 183 |
| 185 /** | 184 /** |
| 186 * Run a JavaScript function in the debugger. | 185 * Run a JavaScript function in the debugger. |
| 187 * \param fun the function to call | 186 * \param fun the function to call |
| 188 * \param data passed as second argument to the function | 187 * \param data passed as second argument to the function |
| 189 * With this call the debugger is entered and the function specified is called | 188 * With this call the debugger is entered and the function specified is called |
| 190 * with the execution state as the first argument. This makes it possible to | 189 * with the execution state as the first argument. This makes it possible to |
| 191 * get access to information otherwise not available during normal JavaScript | 190 * get access to information otherwise not available during normal JavaScript |
| 192 * execution e.g. details on stack frames. Receiver of the function call will | 191 * execution e.g. details on stack frames. Receiver of the function call will |
| 193 * be the debugger context global object, however this is a subject to change. | 192 * be the debugger context global object, however this is a subject to change. |
| 194 * The following example shows a JavaScript function which when passed to | 193 * The following example shows a JavaScript function which when passed to |
| 195 * v8::Debug::Call will return the current line of JavaScript execution. | 194 * v8::Debug::Call will return the current line of JavaScript execution. |
| 196 * | 195 * |
| 197 * \code | 196 * \code |
| 198 * function frame_source_line(exec_state) { | 197 * function frame_source_line(exec_state) { |
| 199 * return exec_state.frame(0).sourceLine(); | 198 * return exec_state.frame(0).sourceLine(); |
| 200 * } | 199 * } |
| 201 * \endcode | 200 * \endcode |
| 202 */ | 201 */ |
| 203 static V8_DEPRECATE_SOON( | 202 static V8_DEPRECATED("Use maybe version", |
| 204 "Use maybe version", | 203 Local<Value> Call(v8::Local<v8::Function> fun, |
| 205 Local<Value> Call(v8::Local<v8::Function> fun, | 204 Local<Value> data = Local<Value>())); |
| 206 Local<Value> data = Local<Value>())); | |
| 207 // TODO(dcarney): data arg should be a MaybeLocal | 205 // TODO(dcarney): data arg should be a MaybeLocal |
| 208 static MaybeLocal<Value> Call(Local<Context> context, | 206 static MaybeLocal<Value> Call(Local<Context> context, |
| 209 v8::Local<v8::Function> fun, | 207 v8::Local<v8::Function> fun, |
| 210 Local<Value> data = Local<Value>()); | 208 Local<Value> data = Local<Value>()); |
| 211 | 209 |
| 212 /** | 210 /** |
| 213 * Returns a mirror object for the given object. | 211 * Returns a mirror object for the given object. |
| 214 */ | 212 */ |
| 215 static V8_DEPRECATE_SOON("Use maybe version", | 213 static V8_DEPRECATED("Use maybe version", |
| 216 Local<Value> GetMirror(v8::Local<v8::Value> obj)); | 214 Local<Value> GetMirror(v8::Local<v8::Value> obj)); |
| 217 static MaybeLocal<Value> GetMirror(Local<Context> context, | 215 static MaybeLocal<Value> GetMirror(Local<Context> context, |
| 218 v8::Local<v8::Value> obj); | 216 v8::Local<v8::Value> obj); |
| 219 | 217 |
| 220 /** | 218 /** |
| 221 * Makes V8 process all pending debug messages. | 219 * Makes V8 process all pending debug messages. |
| 222 * | 220 * |
| 223 * From V8 point of view all debug messages come asynchronously (e.g. from | 221 * From V8 point of view all debug messages come asynchronously (e.g. from |
| 224 * remote debugger) but they all must be handled synchronously: V8 cannot | 222 * remote debugger) but they all must be handled synchronously: V8 cannot |
| 225 * do 2 things at one time so normal script execution must be interrupted | 223 * do 2 things at one time so normal script execution must be interrupted |
| 226 * for a while. | 224 * for a while. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 242 * as V8 script would be invoked from, because: | 240 * as V8 script would be invoked from, because: |
| 243 * a. with "evaluate" command it can do whatever normal script can do, | 241 * a. with "evaluate" command it can do whatever normal script can do, |
| 244 * including all native calls; | 242 * including all native calls; |
| 245 * b. no other thread should call V8 while this method is running | 243 * b. no other thread should call V8 while this method is running |
| 246 * (v8::Locker may be used here). | 244 * (v8::Locker may be used here). |
| 247 * | 245 * |
| 248 * "Evaluate" debug command behavior currently is not specified in scope | 246 * "Evaluate" debug command behavior currently is not specified in scope |
| 249 * of this method. | 247 * of this method. |
| 250 */ | 248 */ |
| 251 static void ProcessDebugMessages(Isolate* isolate); | 249 static void ProcessDebugMessages(Isolate* isolate); |
| 252 V8_DEPRECATE_SOON("Use version with an Isolate", | 250 V8_DEPRECATED("Use version with an Isolate", |
| 253 static void ProcessDebugMessages()); | 251 static void ProcessDebugMessages()); |
| 254 | 252 |
| 255 /** | 253 /** |
| 256 * Debugger is running in its own context which is entered while debugger | 254 * Debugger is running in its own context which is entered while debugger |
| 257 * messages are being dispatched. This is an explicit getter for this | 255 * messages are being dispatched. This is an explicit getter for this |
| 258 * debugger context. Note that the content of the debugger context is subject | 256 * debugger context. Note that the content of the debugger context is subject |
| 259 * to change. The Context exists only when the debugger is active, i.e. at | 257 * to change. The Context exists only when the debugger is active, i.e. at |
| 260 * least one DebugEventListener or MessageHandler is set. | 258 * least one DebugEventListener or MessageHandler is set. |
| 261 */ | 259 */ |
| 262 static Local<Context> GetDebugContext(Isolate* isolate); | 260 static Local<Context> GetDebugContext(Isolate* isolate); |
| 263 V8_DEPRECATE_SOON("Use version with an Isolate", | 261 V8_DEPRECATED("Use version with an Isolate", |
| 264 static Local<Context> GetDebugContext()); | 262 static Local<Context> GetDebugContext()); |
| 265 | 263 |
| 266 | 264 |
| 267 /** | 265 /** |
| 268 * Enable/disable LiveEdit functionality for the given Isolate | 266 * Enable/disable LiveEdit functionality for the given Isolate |
| 269 * (default Isolate if not provided). V8 will abort if LiveEdit is | 267 * (default Isolate if not provided). V8 will abort if LiveEdit is |
| 270 * unexpectedly used. LiveEdit is enabled by default. | 268 * unexpectedly used. LiveEdit is enabled by default. |
| 271 */ | 269 */ |
| 272 static void SetLiveEditEnabled(Isolate* isolate, bool enable); | 270 static void SetLiveEditEnabled(Isolate* isolate, bool enable); |
| 273 | 271 |
| 274 /** | 272 /** |
| 275 * Returns array of internal properties specific to the value type. Result has | 273 * Returns array of internal properties specific to the value type. Result has |
| 276 * the following format: [<name>, <value>,...,<name>, <value>]. Result array | 274 * the following format: [<name>, <value>,...,<name>, <value>]. Result array |
| 277 * will be allocated in the current context. | 275 * will be allocated in the current context. |
| 278 */ | 276 */ |
| 279 static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, | 277 static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, |
| 280 Local<Value> value); | 278 Local<Value> value); |
| 281 }; | 279 }; |
| 282 | 280 |
| 283 | 281 |
| 284 } // namespace v8 | 282 } // namespace v8 |
| 285 | 283 |
| 286 | 284 |
| 287 #undef EXPORT | 285 #undef EXPORT |
| 288 | 286 |
| 289 | 287 |
| 290 #endif // V8_V8_DEBUG_H_ | 288 #endif // V8_V8_DEBUG_H_ |
| OLD | NEW |