OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_DEBUG_DEBUG_INTERFACE_H_ | 5 #ifndef V8_DEBUG_DEBUG_INTERFACE_H_ |
6 #define V8_DEBUG_DEBUG_INTERFACE_H_ | 6 #define V8_DEBUG_DEBUG_INTERFACE_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "include/v8-debug.h" | 10 #include "include/v8-debug.h" |
11 #include "include/v8-util.h" | 11 #include "include/v8-util.h" |
12 #include "include/v8.h" | 12 #include "include/v8.h" |
13 | 13 |
14 #include "src/debug/interface-types.h" | 14 #include "src/debug/interface-types.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace debug { | 17 namespace debug { |
18 | 18 |
19 /** | 19 /** |
20 * An event details object passed to the debug event listener. | |
21 */ | |
22 class EventDetails : public v8::Debug::EventDetails { | |
23 public: | |
24 /** | |
25 * Event type. | |
26 */ | |
27 virtual v8::DebugEvent GetEvent() const = 0; | |
28 | |
29 /** | |
30 * Access to execution state and event data of the debug event. Don't store | |
31 * these cross callbacks as their content becomes invalid. | |
32 */ | |
33 virtual Local<Object> GetExecutionState() const = 0; | |
34 virtual Local<Object> GetEventData() const = 0; | |
35 | |
36 /** | |
37 * Get the context active when the debug event happened. Note this is not | |
38 * the current active context as the JavaScript part of the debugger is | |
39 * running in its own context which is entered at this point. | |
40 */ | |
41 virtual Local<Context> GetEventContext() const = 0; | |
42 | |
43 /** | |
44 * Client data passed with the corresponding callback when it was | |
45 * registered. | |
46 */ | |
47 virtual Local<Value> GetCallbackData() const = 0; | |
48 | |
49 virtual ~EventDetails() {} | |
50 }; | |
51 | |
52 /** | |
53 * Debug event callback function. | |
54 * | |
55 * \param event_details object providing information about the debug event | |
56 * | |
57 * A EventCallback does not take possession of the event data, | |
58 * and must not rely on the data persisting after the handler returns. | |
59 */ | |
60 typedef void (*EventCallback)(const EventDetails& event_details); | |
61 | |
62 bool SetDebugEventListener(Isolate* isolate, EventCallback that, | |
63 Local<Value> data = Local<Value>()); | |
64 | |
65 /** | |
66 * Debugger is running in its own context which is entered while debugger | 20 * Debugger is running in its own context which is entered while debugger |
67 * messages are being dispatched. This is an explicit getter for this | 21 * messages are being dispatched. This is an explicit getter for this |
68 * debugger context. Note that the content of the debugger context is subject | 22 * debugger context. Note that the content of the debugger context is subject |
69 * to change. The Context exists only when the debugger is active, i.e. at | 23 * to change. The Context exists only when the debugger is active, i.e. at |
70 * least one DebugEventListener or MessageHandler is set. | 24 * least one DebugEventListener or MessageHandler is set. |
71 */ | 25 */ |
72 Local<Context> GetDebugContext(Isolate* isolate); | 26 Local<Context> GetDebugContext(Isolate* isolate); |
73 | 27 |
74 /** | 28 /** |
75 * Run a JavaScript function in the debugger. | 29 * Run a JavaScript function in the debugger. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 AsyncTaskListener; | 152 AsyncTaskListener; |
199 void SetAsyncTaskListener(Isolate* isolate, AsyncTaskListener listener, | 153 void SetAsyncTaskListener(Isolate* isolate, AsyncTaskListener listener, |
200 void* data); | 154 void* data); |
201 | 155 |
202 typedef std::function<void(v8::Local<Script> script, bool has_compile_error, | 156 typedef std::function<void(v8::Local<Script> script, bool has_compile_error, |
203 void* data)> | 157 void* data)> |
204 CompileEventListener; | 158 CompileEventListener; |
205 void SetCompileEventListener(Isolate* isolate, CompileEventListener listener, | 159 void SetCompileEventListener(Isolate* isolate, CompileEventListener listener, |
206 void* data); | 160 void* data); |
207 | 161 |
| 162 typedef void (*BreakEventListener)(v8::Local<v8::Context> paused_context, |
| 163 v8::Local<v8::Object> exec_state, |
| 164 v8::Local<v8::Value> break_points_hit, |
| 165 void* data); |
| 166 void SetBreakEventListener(Isolate* isolate, BreakEventListener listener, |
| 167 void* data); |
| 168 |
| 169 typedef void (*ExceptionEventListener)(v8::Local<v8::Context> paused_context, |
| 170 v8::Local<v8::Object> exec_state, |
| 171 v8::Local<v8::Value> exception, |
| 172 bool is_promise_rejection, |
| 173 bool is_uncaught, void* data); |
| 174 void SetExceptionEventListener(Isolate* isolate, |
| 175 ExceptionEventListener listener, void* data); |
| 176 |
208 } // namespace debug | 177 } // namespace debug |
209 } // namespace v8 | 178 } // namespace v8 |
210 | 179 |
211 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 180 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
OLD | NEW |