Chromium Code Reviews| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 int NumImportedFunctions() const; | 140 int NumImportedFunctions() const; |
| 187 | 141 |
| 188 debug::WasmDisassembly DisassembleFunction(int function_index) const; | 142 debug::WasmDisassembly DisassembleFunction(int function_index) const; |
| 189 }; | 143 }; |
| 190 | 144 |
| 191 void GetLoadedScripts(Isolate* isolate, PersistentValueVector<Script>& scripts); | 145 void GetLoadedScripts(Isolate* isolate, PersistentValueVector<Script>& scripts); |
| 192 | 146 |
| 193 MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, | 147 MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, |
| 194 Local<String> source); | 148 Local<String> source); |
| 195 | 149 |
| 196 typedef std::function<void(debug::PromiseDebugActionType type, int id, | 150 class DebugEventListener { |
| 197 void* data)> | 151 public: |
| 198 AsyncTaskListener; | 152 virtual ~DebugEventListener() {} |
| 199 void SetAsyncTaskListener(Isolate* isolate, AsyncTaskListener listener, | 153 virtual void OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) {} |
|
dgozman
2017/01/18 18:43:05
PromiseEventOccurred
kozy
2017/01/18 21:20:07
Done.
| |
| 200 void* data); | 154 virtual void OnCompileEvent(v8::Local<Script> script, |
|
dgozman
2017/01/18 18:43:05
ScriptCompiled
kozy
2017/01/18 21:20:07
Done.
| |
| 155 bool has_compile_error) {} | |
| 156 virtual void OnBreakEvent(v8::Local<v8::Context> paused_context, | |
|
dgozman
2017/01/18 18:43:05
BreakProgramRequested
kozy
2017/01/18 21:20:07
Done.
| |
| 157 v8::Local<v8::Object> exec_state, | |
| 158 v8::Local<v8::Value> break_points_hit) {} | |
| 159 virtual void OnExceptionEvent(v8::Local<v8::Context> paused_context, | |
|
dgozman
2017/01/18 18:43:05
ExceptionThrown
kozy
2017/01/18 21:20:07
Done.
| |
| 160 v8::Local<v8::Object> exec_state, | |
| 161 v8::Local<v8::Value> exception, | |
| 162 bool is_promise_rejection, bool is_uncaught) {} | |
| 163 }; | |
| 201 | 164 |
| 202 typedef std::function<void(v8::Local<Script> script, bool has_compile_error, | 165 void SetDebugEventListener(Isolate* isolate, DebugEventListener* listener); |
| 203 void* data)> | |
| 204 CompileEventListener; | |
| 205 void SetCompileEventListener(Isolate* isolate, CompileEventListener listener, | |
| 206 void* data); | |
| 207 | 166 |
| 208 } // namespace debug | 167 } // namespace debug |
| 209 } // namespace v8 | 168 } // namespace v8 |
| 210 | 169 |
| 211 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 170 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
| OLD | NEW |