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 8014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch#include "v8.h" // NOLINT(build/include) 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, 211b268ca467c924004286c97bac133db489cf43d0Ben Murdoch AfterCompile = 5, 22b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch CompileError = 6, 231b268ca467c924004286c97bac133db489cf43d0Ben Murdoch AsyncTaskEvent = 7, 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 26b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochclass V8_EXPORT Debug { 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * A client object passed to the v8 debugger whose ownership will be taken by 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * it. v8 is always responsible for deleting the object. 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block class ClientData { 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ~ClientData() {} 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block }; 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * A message object passed to the debug message handler. 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block class Message { 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Check type of message. 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool IsEvent() const = 0; 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool IsResponse() const = 0; 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual DebugEvent GetEvent() const = 0; 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Indicate whether this is a response to a continue command which will 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * start the VM running after this is processed. 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool WillStartRunning() const = 0; 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Access to execution state and event data. Don't store these cross 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * callbacks as their content becomes invalid. These objects are from the 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * debugger event that started the debug message loop. 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 61014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Object> GetExecutionState() const = 0; 62014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Object> GetEventData() const = 0; 63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Get the debugger protocol JSON. 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 67014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<String> GetJSON() const = 0; 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Get the context active when the debug event happened. Note this is not 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * the current active context as the JavaScript part of the debugger is 72257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * running in its own context which is entered at this point. 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 74014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Context> GetEventContext() const = 0; 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Client data passed with the corresponding request if any. This is the 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * client_data data value passed into Debug::SendCommand along with the 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * request that led to the message or NULL if the message is an event. The 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * debugger takes ownership of the data and will delete it even if there is 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * no message handler. 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ClientData* GetClientData() const = 0; 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 85b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch virtual Isolate* GetIsolate() const = 0; 86b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ~Message() {} 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block }; 893e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 92f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * An event details object passed to the debug event listener. 93f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 94f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke class EventDetails { 95f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke public: 96f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke /** 97f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * Event type. 98f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 99f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke virtual DebugEvent GetEvent() const = 0; 100f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 101f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke /** 102f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * Access to execution state and event data of the debug event. Don't store 103f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * these cross callbacks as their content becomes invalid. 104f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 105014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Object> GetExecutionState() const = 0; 106014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Object> GetEventData() const = 0; 107f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 108f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke /** 109f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * Get the context active when the debug event happened. Note this is not 110f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * the current active context as the JavaScript part of the debugger is 111257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * running in its own context which is entered at this point. 112f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 113014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Context> GetEventContext() const = 0; 114f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 115f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke /** 116257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * Client data passed with the corresponding callback when it was 117257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * registered. 118f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 119014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch virtual Local<Value> GetCallbackData() const = 0; 120f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 1213bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch /** 1223bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch * Client data passed to DebugBreakForCommand function. The 1233bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch * debugger takes ownership of the data and will delete it even if 1243bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch * there is no message handler. 1253bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch */ 1263bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch virtual ClientData* GetClientData() const = 0; 1273bec4d28b1f388dbc06a9c4276e1a03e86c52b04Ben Murdoch 12821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch virtual Isolate* GetIsolate() const = 0; 12921efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch 130f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke virtual ~EventDetails() {} 131f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke }; 132f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 133f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke /** 134f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * Debug event callback function. 135f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * 136f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * \param event_details object providing information about the debug event 137f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * 138f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * A EventCallback2 does not take possession of the event data, 139f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke * and must not rely on the data persisting after the handler returns. 140f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke */ 141b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch typedef void (*EventCallback)(const EventDetails& event_details); 142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Debug message callback function. 145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * 146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * \param message the debug message handler message object 14744f0eee88ff00398ff7f715fab053374d808c90dSteve Block * 148b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch * A MessageHandler2 does not take possession of the message data, 149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * and must not rely on the data persisting after the handler returns. 150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 151b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch typedef void (*MessageHandler)(const Message& message); 152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 153d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block /** 154d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block * Callback function for the host to ensure debug messages are processed. 155d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block */ 156d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block typedef void (*DebugMessageDispatchHandler)(); 157d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block 158014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static bool SetDebugEventListener(Isolate* isolate, EventCallback that, 159014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> data = Local<Value>()); 160014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch V8_DEPRECATED("Use version with an Isolate", 161014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static bool SetDebugEventListener( 162014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch EventCallback that, Local<Value> data = Local<Value>())); 163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 16444f0eee88ff00398ff7f715fab053374d808c90dSteve Block // Schedule a debugger break to happen when JavaScript code is run 165b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // in the given isolate. 166b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static void DebugBreak(Isolate* isolate); 167a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 16844f0eee88ff00398ff7f715fab053374d808c90dSteve Block // Remove scheduled debugger break in given isolate if it has not 169b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // happened yet. 170b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static void CancelDebugBreak(Isolate* isolate); 171b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 172b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Check if a debugger break is scheduled in the given isolate. 173b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static bool CheckDebugBreak(Isolate* isolate); 174f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch 175b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch // Message based interface. The message protocol is JSON. 176014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static void SetMessageHandler(Isolate* isolate, MessageHandler handler); 177014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch V8_DEPRECATED("Use version with an Isolate", 178014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static void SetMessageHandler(MessageHandler handler)); 179b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 180b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static void SendCommand(Isolate* isolate, 181b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch const uint16_t* command, int length, 182b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch ClientData* client_data = NULL); 183d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block 184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Run a JavaScript function in the debugger. 186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * \param fun the function to call 187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * \param data passed as second argument to the function 188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * With this call the debugger is entered and the function specified is called 189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * with the execution state as the first argument. This makes it possible to 190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * get access to information otherwise not available during normal JavaScript 1916ded16be15dd865a9b21ea304d5273c8be299c87Steve Block * execution e.g. details on stack frames. Receiver of the function call will 1926ded16be15dd865a9b21ea304d5273c8be299c87Steve Block * be the debugger context global object, however this is a subject to change. 193257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * The following example shows a JavaScript function which when passed to 1946ded16be15dd865a9b21ea304d5273c8be299c87Steve Block * v8::Debug::Call will return the current line of JavaScript execution. 195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * 196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * \code 197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * function frame_source_line(exec_state) { 198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * return exec_state.frame(0).sourceLine(); 199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * } 200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * \endcode 201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 202014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static V8_DEPRECATED("Use maybe version", 203014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> Call(v8::Local<v8::Function> fun, 204014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> data = Local<Value>())); 205014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch // TODO(dcarney): data arg should be a MaybeLocal 206014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static MaybeLocal<Value> Call(Local<Context> context, 207014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch v8::Local<v8::Function> fun, 208014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> data = Local<Value>()); 209a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 210a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block /** 211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block * Returns a mirror object for the given object. 212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block */ 213014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static V8_DEPRECATED("Use maybe version", 214014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> GetMirror(v8::Local<v8::Value> obj)); 215014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static MaybeLocal<Value> GetMirror(Local<Context> context, 216014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch v8::Local<v8::Value> obj); 217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 2183ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch /** 219e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * Makes V8 process all pending debug messages. 220e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 221e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * From V8 point of view all debug messages come asynchronously (e.g. from 222e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * remote debugger) but they all must be handled synchronously: V8 cannot 223e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * do 2 things at one time so normal script execution must be interrupted 224e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * for a while. 225e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 226e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * Generally when message arrives V8 may be in one of 3 states: 227e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 1. V8 is running script; V8 will automatically interrupt and process all 228b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch * pending messages; 229e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 2. V8 is suspended on debug breakpoint; in this state V8 is dedicated 230e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * to reading and processing debug messages; 231e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 3. V8 is not running at all or has called some long-working C++ function; 232257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * by default it means that processing of all debug messages will be deferred 233e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * until V8 gets control again; however, embedding application may improve 234e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * this by manually calling this method. 235e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 236e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * Technically this method in many senses is equivalent to executing empty 237e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * script: 238e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 1. It does nothing except for processing all pending debug messages. 239e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 2. It should be invoked with the same precautions and from the same context 240e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * as V8 script would be invoked from, because: 241e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * a. with "evaluate" command it can do whatever normal script can do, 242e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * including all native calls; 243e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * b. no other thread should call V8 while this method is running 244e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * (v8::Locker may be used here). 245e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * 246e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * "Evaluate" debug command behavior currently is not specified in scope 247e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke * of this method. 248e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke */ 249014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static void ProcessDebugMessages(Isolate* isolate); 250014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch V8_DEPRECATED("Use version with an Isolate", 251014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static void ProcessDebugMessages()); 2526ded16be15dd865a9b21ea304d5273c8be299c87Steve Block 2536ded16be15dd865a9b21ea304d5273c8be299c87Steve Block /** 254257744e915dfc84d6d07a6b2accf8402d9ffc708Ben Murdoch * Debugger is running in its own context which is entered while debugger 2556ded16be15dd865a9b21ea304d5273c8be299c87Steve Block * messages are being dispatched. This is an explicit getter for this 2566ded16be15dd865a9b21ea304d5273c8be299c87Steve Block * debugger context. Note that the content of the debugger context is subject 257014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch * to change. The Context exists only when the debugger is active, i.e. at 258014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch * least one DebugEventListener or MessageHandler is set. 2596ded16be15dd865a9b21ea304d5273c8be299c87Steve Block */ 260014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static Local<Context> GetDebugContext(Isolate* isolate); 261014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch V8_DEPRECATED("Use version with an Isolate", 262014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static Local<Context> GetDebugContext()); 263b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 26421efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch /** 26521efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch * While in the debug context, this method returns the top-most non-debug 26621efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch * context, if it exists. 26721efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch */ 26821efce637eb329c94f1323b6a2334a1c977e1a9dBen Murdoch static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate); 269b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 270b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch /** 271b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch * Enable/disable LiveEdit functionality for the given Isolate 272b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch * (default Isolate if not provided). V8 will abort if LiveEdit is 273b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch * unexpectedly used. LiveEdit is enabled by default. 274b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch */ 275b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch static void SetLiveEditEnabled(Isolate* isolate, bool enable); 276014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 277014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch /** 278014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch * Returns array of internal properties specific to the value type. Result has 279014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch * the following format: [<name>, <value>,...,<name>, <value>]. Result array 280014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch * will be allocated in the current context. 281014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch */ 282014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, 283014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch Local<Value> value); 2841b268ca467c924004286c97bac133db489cf43d0Ben Murdoch 2851b268ca467c924004286c97bac133db489cf43d0Ben Murdoch /** 2861b268ca467c924004286c97bac133db489cf43d0Ben Murdoch * Defines if the ES2015 tail call elimination feature is enabled or not. 2871b268ca467c924004286c97bac133db489cf43d0Ben Murdoch * The change of this flag triggers deoptimization of all functions that 2881b268ca467c924004286c97bac133db489cf43d0Ben Murdoch * contain calls at tail position. 2891b268ca467c924004286c97bac133db489cf43d0Ben Murdoch */ 2901b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static bool IsTailCallEliminationEnabled(Isolate* isolate); 2911b268ca467c924004286c97bac133db489cf43d0Ben Murdoch static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled); 292a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 293a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 294a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 295a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} // namespace v8 296a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 297a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 298a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#undef EXPORT 299a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 300a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 301a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_V8_DEBUG_H_ 302