v8  3.25.30(node0.11.13)
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 
36 namespace v8 {
37 
38 // Debug events which can occur in the V8 JavaScript engine.
39 enum DebugEvent {
40  Break = 1,
41  Exception = 2,
47 };
48 
49 
51  public:
56  class ClientData {
57  public:
58  virtual ~ClientData() {}
59  };
60 
61 
65  class Message {
66  public:
70  virtual bool IsEvent() const = 0;
71  virtual bool IsResponse() const = 0;
72  virtual DebugEvent GetEvent() const = 0;
73 
78  virtual bool WillStartRunning() const = 0;
79 
85  virtual Handle<Object> GetExecutionState() const = 0;
86  virtual Handle<Object> GetEventData() const = 0;
87 
91  virtual Handle<String> GetJSON() const = 0;
92 
98  virtual Handle<Context> GetEventContext() const = 0;
99 
107  virtual ClientData* GetClientData() const = 0;
108 
109  virtual Isolate* GetIsolate() const = 0;
110 
111  virtual ~Message() {}
112  };
113 
114 
118  class EventDetails {
119  public:
123  virtual DebugEvent GetEvent() const = 0;
124 
129  virtual Handle<Object> GetExecutionState() const = 0;
130  virtual Handle<Object> GetEventData() const = 0;
131 
137  virtual Handle<Context> GetEventContext() const = 0;
138 
143  virtual Handle<Value> GetCallbackData() const = 0;
144 
150  virtual ClientData* GetClientData() const = 0;
151 
152  virtual ~EventDetails() {}
153  };
154 
163  typedef void (*EventCallback2)(const EventDetails& event_details);
164 
173  typedef void (*MessageHandler2)(const Message& message);
174 
178  typedef void (*HostDispatchHandler)();
179 
183  typedef void (*DebugMessageDispatchHandler)();
184 
185  static bool SetDebugEventListener2(EventCallback2 that,
186  Handle<Value> data = Handle<Value>());
187 
188  // Set a JavaScript debug event listener.
189  static bool SetDebugEventListener(v8::Handle<v8::Object> that,
190  Handle<Value> data = Handle<Value>());
191 
192  // Schedule a debugger break to happen when JavaScript code is run
193  // in the given isolate. If no isolate is provided the default
194  // isolate is used.
195  static void DebugBreak(Isolate* isolate = NULL);
196 
197  // Remove scheduled debugger break in given isolate if it has not
198  // happened yet. If no isolate is provided the default isolate is
199  // used.
200  static void CancelDebugBreak(Isolate* isolate = NULL);
201 
202  // Break execution of JavaScript in the given isolate (this method
203  // can be invoked from a non-VM thread) for further client command
204  // execution on a VM thread. Client data is then passed in
205  // EventDetails to EventCallback2 at the moment when the VM actually
206  // stops. If no isolate is provided the default isolate is used.
207  static void DebugBreakForCommand(ClientData* data = NULL,
208  Isolate* isolate = NULL);
209 
210  // Message based interface. The message protocol is JSON.
211  static void SetMessageHandler2(MessageHandler2 handler);
212 
213  // If no isolate is provided the default isolate is
214  // used.
215  // TODO(dcarney): remove
216  static void SendCommand(const uint16_t* command, int length,
217  ClientData* client_data = NULL,
218  Isolate* isolate = NULL);
219  static void SendCommand(Isolate* isolate,
220  const uint16_t* command, int length,
221  ClientData* client_data = NULL);
222 
223  // Dispatch interface.
224  static void SetHostDispatchHandler(HostDispatchHandler handler,
225  int period = 100);
226 
238  static void SetDebugMessageDispatchHandler(
239  DebugMessageDispatchHandler handler, bool provide_locker = false);
240 
259  static Local<Value> Call(v8::Handle<v8::Function> fun,
260  Handle<Value> data = Handle<Value>());
261 
265  static Local<Value> GetMirror(v8::Handle<v8::Value> obj);
266 
275  static bool EnableAgent(const char* name, int port,
276  bool wait_for_connection = false);
277 
281  static void DisableAgent();
282 
318  static void ProcessDebugMessages();
319 
326  static Local<Context> GetDebugContext();
327 
328 
334  static void SetLiveEditEnabled(bool enable, Isolate* isolate = NULL);
335 };
336 
337 
338 } // namespace v8
339 
340 
341 #undef EXPORT
342 
343 
344 #endif // V8_V8_DEBUG_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
virtual ~Message()
Definition: v8-debug.h:111
DebugEvent
Definition: v8-debug.h:39
unsigned short uint16_t
Definition: unicode.cc:46
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage message
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing 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 statistics of the maximum memory committed for the heap in name
virtual ~EventDetails()
Definition: v8-debug.h:152
#define V8_EXPORT
Definition: v8.h:76
virtual ~ClientData()
Definition: v8-debug.h:58
HeapObject * obj
Definition: v8.h:124