Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(913)

Side by Side Diff: src/debug/debug-interface.h

Issue 2622253004: [inspector] introduced debug::SetBreakEventListener,SetExceptionEventListener (Closed)
Patch Set: addressed comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 PromiseEventOccurred(debug::PromiseDebugActionType type,
200 void* data); 154 int id) {}
155 virtual void ScriptCompiled(v8::Local<Script> script,
156 bool has_compile_error) {}
157 virtual void BreakProgramRequested(v8::Local<v8::Context> paused_context,
158 v8::Local<v8::Object> exec_state,
159 v8::Local<v8::Value> break_points_hit) {}
160 virtual void ExceptionThrown(v8::Local<v8::Context> paused_context,
161 v8::Local<v8::Object> exec_state,
162 v8::Local<v8::Value> exception,
163 bool is_promise_rejection, bool is_uncaught) {}
164 };
201 165
202 typedef std::function<void(v8::Local<Script> script, bool has_compile_error, 166 void SetDebugEventListener(Isolate* isolate, DebugEventListener* listener);
203 void* data)>
204 CompileEventListener;
205 void SetCompileEventListener(Isolate* isolate, CompileEventListener listener,
206 void* data);
207 167
208 } // namespace debug 168 } // namespace debug
209 } // namespace v8 169 } // namespace v8
210 170
211 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ 171 #endif // V8_DEBUG_DEBUG_INTERFACE_H_
OLDNEW
« src/debug/debug.cc ('K') | « src/debug/debug.cc ('k') | src/inspector/debugger-script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698