v8  3.14.5(node0.10.28)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
v8-debug.h
Go to the documentation of this file.
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_V8_DEBUG_H_
29 #define V8_V8_DEBUG_H_
30 
31 #include "v8.h"
32 
33 #ifdef _WIN32
34 typedef int int32_t;
35 typedef unsigned int uint32_t;
36 typedef unsigned short uint16_t; // NOLINT
37 typedef long long int64_t; // NOLINT
38 
39 // Setup for Windows DLL export/import. See v8.h in this directory for
40 // information on how to build/use V8 as a DLL.
41 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
42 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
43  build configuration to ensure that at most one of these is set
44 #endif
45 
46 #ifdef BUILDING_V8_SHARED
47 #define EXPORT __declspec(dllexport)
48 #elif USING_V8_SHARED
49 #define EXPORT __declspec(dllimport)
50 #else
51 #define EXPORT
52 #endif
53 
54 #else // _WIN32
55 
56 // Setup for Linux shared library export. See v8.h in this directory for
57 // information on how to build/use V8 as shared library.
58 #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
59 #define EXPORT __attribute__ ((visibility("default")))
60 #else // defined(__GNUC__) && (__GNUC__ >= 4)
61 #define EXPORT
62 #endif // defined(__GNUC__) && (__GNUC__ >= 4)
63 
64 #endif // _WIN32
65 
66 
70 namespace v8 {
71 
72 // Debug events which can occur in the V8 JavaScript engine.
73 enum DebugEvent {
74  Break = 1,
75  Exception = 2,
81 };
82 
83 
84 class EXPORT Debug {
85  public:
90  class ClientData {
91  public:
92  virtual ~ClientData() {}
93  };
94 
95 
99  class Message {
100  public:
104  virtual bool IsEvent() const = 0;
105  virtual bool IsResponse() const = 0;
106  virtual DebugEvent GetEvent() const = 0;
107 
112  virtual bool WillStartRunning() const = 0;
113 
119  virtual Handle<Object> GetExecutionState() const = 0;
120  virtual Handle<Object> GetEventData() const = 0;
121 
125  virtual Handle<String> GetJSON() const = 0;
126 
132  virtual Handle<Context> GetEventContext() const = 0;
133 
141  virtual ClientData* GetClientData() const = 0;
142 
143  virtual ~Message() {}
144  };
145 
146 
150  class EventDetails {
151  public:
155  virtual DebugEvent GetEvent() const = 0;
156 
161  virtual Handle<Object> GetExecutionState() const = 0;
162  virtual Handle<Object> GetEventData() const = 0;
163 
169  virtual Handle<Context> GetEventContext() const = 0;
170 
175  virtual Handle<Value> GetCallbackData() const = 0;
176 
182  virtual ClientData* GetClientData() const = 0;
183 
184  virtual ~EventDetails() {}
185  };
186 
187 
197  typedef void (*EventCallback)(DebugEvent event,
198  Handle<Object> exec_state,
199  Handle<Object> event_data,
200  Handle<Value> data);
201 
210  typedef void (*EventCallback2)(const EventDetails& event_details);
211 
224  typedef void (*MessageHandler)(const uint16_t* message, int length,
225  ClientData* client_data);
226 
235  typedef void (*MessageHandler2)(const Message& message);
236 
240  typedef void (*HostDispatchHandler)();
241 
245  typedef void (*DebugMessageDispatchHandler)();
246 
247  // Set a C debug event listener.
248  static bool SetDebugEventListener(EventCallback that,
249  Handle<Value> data = Handle<Value>());
250  static bool SetDebugEventListener2(EventCallback2 that,
251  Handle<Value> data = Handle<Value>());
252 
253  // Set a JavaScript debug event listener.
254  static bool SetDebugEventListener(v8::Handle<v8::Object> that,
255  Handle<Value> data = Handle<Value>());
256 
257  // Schedule a debugger break to happen when JavaScript code is run
258  // in the given isolate. If no isolate is provided the default
259  // isolate is used.
260  static void DebugBreak(Isolate* isolate = NULL);
261 
262  // Remove scheduled debugger break in given isolate if it has not
263  // happened yet. If no isolate is provided the default isolate is
264  // used.
265  static void CancelDebugBreak(Isolate* isolate = NULL);
266 
267  // Break execution of JavaScript in the given isolate (this method
268  // can be invoked from a non-VM thread) for further client command
269  // execution on a VM thread. Client data is then passed in
270  // EventDetails to EventCallback at the moment when the VM actually
271  // stops. If no isolate is provided the default isolate is used.
272  static void DebugBreakForCommand(ClientData* data = NULL,
273  Isolate* isolate = NULL);
274 
275  // Message based interface. The message protocol is JSON. NOTE the message
276  // handler thread is not supported any more parameter must be false.
277  static void SetMessageHandler(MessageHandler handler,
278  bool message_handler_thread = false);
279  static void SetMessageHandler2(MessageHandler2 handler);
280 
281  // If no isolate is provided the default isolate is
282  // used.
283  static void SendCommand(const uint16_t* command, int length,
284  ClientData* client_data = NULL,
285  Isolate* isolate = NULL);
286 
287  // Dispatch interface.
288  static void SetHostDispatchHandler(HostDispatchHandler handler,
289  int period = 100);
290 
302  static void SetDebugMessageDispatchHandler(
303  DebugMessageDispatchHandler handler, bool provide_locker = false);
304 
323  static Local<Value> Call(v8::Handle<v8::Function> fun,
324  Handle<Value> data = Handle<Value>());
325 
329  static Local<Value> GetMirror(v8::Handle<v8::Value> obj);
330 
339  static bool EnableAgent(const char* name, int port,
340  bool wait_for_connection = false);
341 
345  static void DisableAgent();
346 
382  static void ProcessDebugMessages();
383 
390  static Local<Context> GetDebugContext();
391 
392 
398  static void SetLiveEditEnabled(bool enable, Isolate* isolate = NULL);
399 };
400 
401 
402 } // namespace v8
403 
404 
405 #undef EXPORT
406 
407 
408 #endif // V8_V8_DEBUG_H_
virtual ~Message()
Definition: v8-debug.h:143
int int32_t
Definition: unicode.cc:47
DebugEvent
Definition: v8-debug.h:73
unsigned short uint16_t
Definition: unicode.cc:46
virtual ~EventDetails()
Definition: v8-debug.h:184
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
#define EXPORT
Definition: v8-debug.h:61
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
virtual ~ClientData()
Definition: v8-debug.h:92
Definition: v8.h:106