The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / include / v8-debug.h @ 40c0f755

History | View | Annotate | Download (6.19 KB)

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_DEBUG_H_
29
#define 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)
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

    
67
/**
68
 * Debugger support for the V8 JavaScript engine.
69
 */
70
namespace v8 {
71

    
72
// Debug events which can occur in the V8 JavaScript engine.
73
enum DebugEvent {
74
  Break = 1,
75
  Exception = 2,
76
  NewFunction = 3,
77
  BeforeCompile = 4,
78
  AfterCompile  = 5
79
};
80

    
81

    
82
/**
83
 * Debug event callback function.
84
 *
85
 * \param event the type of the debug event that triggered the callback
86
 *   (enum DebugEvent)
87
 * \param exec_state execution state (JavaScript object)
88
 * \param event_data event specific data (JavaScript object)
89
 * \param data value passed by the user to SetDebugEventListener
90
 */
91
typedef void (*DebugEventCallback)(DebugEvent event,
92
                                   Handle<Object> exec_state,
93
                                   Handle<Object> event_data,
94
                                   Handle<Value> data);
95

    
96

    
97
/**
98
 * Debug message callback function.
99
 *
100
 * \param message the debug message
101
 * \param length length of the message
102
 * \param data the data value passed when registering the message handler
103
 * A DebugMessageHandler does not take posession of the message string,
104
 * and must not rely on the data persisting after the handler returns.
105
 */
106
typedef void (*DebugMessageHandler)(const uint16_t* message, int length,
107
                                    void* data);
108

    
109
/**
110
 * Debug host dispatch callback function.
111
 *
112
 * \param dispatch the dispatch value
113
 * \param data the data value passed when registering the dispatch handler
114
 */
115
typedef void (*DebugHostDispatchHandler)(void* dispatch,
116
                                         void* data);
117

    
118

    
119

    
120
class EXPORT Debug {
121
 public:
122
  // Set a C debug event listener.
123
  static bool SetDebugEventListener(DebugEventCallback that,
124
                                    Handle<Value> data = Handle<Value>());
125

    
126
  // Set a JavaScript debug event listener.
127
  static bool SetDebugEventListener(v8::Handle<v8::Object> that,
128
                                    Handle<Value> data = Handle<Value>());
129

    
130
  // Break execution of JavaScript.
131
  static void DebugBreak();
132

    
133
  // Message based interface. The message protocol is JSON.
134
  static void SetMessageHandler(DebugMessageHandler handler, void* data = NULL,
135
                                bool message_handler_thread = true);
136
  static void SendCommand(const uint16_t* command, int length);
137

    
138
  // Dispatch interface.
139
  static void SetHostDispatchHandler(DebugHostDispatchHandler handler,
140
                                     void* data = NULL);
141
  static void SendHostDispatch(void* dispatch);
142

    
143
 /**
144
  * Run a JavaScript function in the debugger.
145
  * \param fun the function to call
146
  * \param data passed as second argument to the function
147
  * With this call the debugger is entered and the function specified is called
148
  * with the execution state as the first argument. This makes it possible to
149
  * get access to information otherwise not available during normal JavaScript
150
  * execution e.g. details on stack frames. The following example show a
151
  * JavaScript function which when passed to v8::Debug::Call will return the
152
  * current line of JavaScript execution.
153
  *
154
  * \code
155
  *   function frame_source_line(exec_state) {
156
  *     return exec_state.frame(0).sourceLine();
157
  *   }
158
  * \endcode
159
  */
160
  static Handle<Value> Call(v8::Handle<v8::Function> fun,
161
                            Handle<Value> data = Handle<Value>());
162

    
163
 /**
164
  * Enable the V8 builtin debug agent. The debugger agent will listen on the
165
  * supplied TCP/IP port for remote debugger connection.
166
  * \param name the name of the embedding application
167
  * \param port the TCP/IP port to listen on
168
  */
169
  static bool EnableAgent(const char* name, int port);
170
};
171

    
172

    
173
}  // namespace v8
174

    
175

    
176
#undef EXPORT
177

    
178

    
179
#endif  // V8_DEBUG_H_