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 "include/v8-debug.h" | 8 #include "include/v8-debug.h" |
9 #include "include/v8-util.h" | 9 #include "include/v8-util.h" |
10 #include "include/v8.h" | 10 #include "include/v8.h" |
11 | 11 |
12 #include "src/debug/interface-types.h" | 12 #include "src/debug/interface-types.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace debug { | |
15 | 16 |
16 class DebugInterface { | 17 class DebugInterface { |
Yang
2016/12/05 13:36:08
I actually meant to remove this class altogether.
Clemens Hammacher
2016/12/05 18:38:22
Oh, I see. Fixed.
| |
17 public: | 18 public: |
18 /** | 19 /** |
19 * An event details object passed to the debug event listener. | |
20 */ | |
21 class EventDetails : public v8::Debug::EventDetails { | |
22 public: | |
23 /** | |
24 * Event type. | |
25 */ | |
26 virtual v8::DebugEvent GetEvent() const = 0; | |
27 | |
28 /** | |
29 * Access to execution state and event data of the debug event. Don't store | |
30 * these cross callbacks as their content becomes invalid. | |
31 */ | |
32 virtual Local<Object> GetExecutionState() const = 0; | |
33 virtual Local<Object> GetEventData() const = 0; | |
34 | |
35 /** | |
36 * Get the context active when the debug event happened. Note this is not | |
37 * the current active context as the JavaScript part of the debugger is | |
38 * running in its own context which is entered at this point. | |
39 */ | |
40 virtual Local<Context> GetEventContext() const = 0; | |
41 | |
42 /** | |
43 * Client data passed with the corresponding callback when it was | |
44 * registered. | |
45 */ | |
46 virtual Local<Value> GetCallbackData() const = 0; | |
47 | |
48 virtual ~EventDetails() {} | |
49 }; | |
50 | |
51 /** | |
52 * Debug event callback function. | 20 * Debug event callback function. |
53 * | 21 * |
54 * \param event_details object providing information about the debug event | 22 * \param event_details object providing information about the debug event |
55 * | 23 * |
56 * A EventCallback does not take possession of the event data, | 24 * A EventCallback does not take possession of the event data, |
57 * and must not rely on the data persisting after the handler returns. | 25 * and must not rely on the data persisting after the handler returns. |
58 */ | 26 */ |
59 typedef void (*EventCallback)(const EventDetails& event_details); | 27 typedef void (*EventCallback)(const EventDetails& event_details); |
60 | 28 |
61 static bool SetDebugEventListener(Isolate* isolate, EventCallback that, | 29 static bool SetDebugEventListener(Isolate* isolate, EventCallback that, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 static void CancelDebugBreak(Isolate* isolate); | 77 static void CancelDebugBreak(Isolate* isolate); |
110 | 78 |
111 /** | 79 /** |
112 * Returns array of internal properties specific to the value type. Result has | 80 * Returns array of internal properties specific to the value type. Result has |
113 * the following format: [<name>, <value>,...,<name>, <value>]. Result array | 81 * the following format: [<name>, <value>,...,<name>, <value>]. Result array |
114 * will be allocated in the current context. | 82 * will be allocated in the current context. |
115 */ | 83 */ |
116 static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, | 84 static MaybeLocal<Array> GetInternalProperties(Isolate* isolate, |
117 Local<Value> value); | 85 Local<Value> value); |
118 | 86 |
119 enum ExceptionBreakState { | |
120 NoBreakOnException = 0, | |
121 BreakOnUncaughtException = 1, | |
122 BreakOnAnyException = 2 | |
123 }; | |
124 | |
125 /** | 87 /** |
126 * Defines if VM will pause on exceptions or not. | 88 * Defines if VM will pause on exceptions or not. |
127 * If BreakOnAnyExceptions is set then VM will pause on caught and uncaught | 89 * If BreakOnAnyExceptions is set then VM will pause on caught and uncaught |
128 * exception, if BreakOnUncaughtException is set then VM will pause only on | 90 * exception, if BreakOnUncaughtException is set then VM will pause only on |
129 * uncaught exception, otherwise VM won't stop on any exception. | 91 * uncaught exception, otherwise VM won't stop on any exception. |
130 */ | 92 */ |
131 static void ChangeBreakOnException(Isolate* isolate, | 93 static void ChangeBreakOnException(Isolate* isolate, |
132 ExceptionBreakState state); | 94 ExceptionBreakState state); |
133 | 95 |
134 enum StepAction { | |
135 StepOut = 0, // Step out of the current function. | |
136 StepNext = 1, // Step to the next statement in the current function. | |
137 StepIn = 2, // Step into new functions invoked or the next statement | |
138 // in the current function. | |
139 StepFrame = 3 // Step into a new frame or return to previous frame. | |
140 }; | |
141 | |
142 static void PrepareStep(Isolate* isolate, StepAction action); | 96 static void PrepareStep(Isolate* isolate, StepAction action); |
143 static void ClearStepping(Isolate* isolate); | 97 static void ClearStepping(Isolate* isolate); |
144 | 98 |
145 /** | |
146 * Native wrapper around v8::internal::Script object. | |
147 */ | |
148 class Script { | |
149 public: | |
150 v8::Isolate* GetIsolate() const; | |
151 | |
152 ScriptOriginOptions OriginOptions() const; | |
153 bool WasCompiled() const; | |
154 int Id() const; | |
155 int LineOffset() const; | |
156 int ColumnOffset() const; | |
157 std::vector<int> LineEnds() const; | |
158 MaybeLocal<String> Name() const; | |
159 MaybeLocal<String> SourceURL() const; | |
160 MaybeLocal<String> SourceMappingURL() const; | |
161 MaybeLocal<String> ContextData() const; | |
162 MaybeLocal<String> Source() const; | |
163 bool IsWasm() const; | |
164 bool GetPossibleBreakpoints(const debug::Location& start, | |
165 const debug::Location& end, | |
166 std::vector<debug::Location>* locations) const; | |
167 | |
168 /** | |
169 * script parameter is a wrapper v8::internal::JSObject for | |
170 * v8::internal::Script. | |
171 * This function gets v8::internal::Script from v8::internal::JSObject and | |
172 * wraps it with DebugInterface::Script. | |
173 * Returns empty local if not called with a valid wrapper of | |
174 * v8::internal::Script. | |
175 */ | |
176 static MaybeLocal<Script> Wrap(Isolate* isolate, | |
177 v8::Local<v8::Object> script); | |
178 | |
179 private: | |
180 int GetSourcePosition(const debug::Location& location) const; | |
181 }; | |
182 | |
183 static void GetLoadedScripts(Isolate* isolate, | 99 static void GetLoadedScripts(Isolate* isolate, |
184 PersistentValueVector<Script>& scripts); | 100 PersistentValueVector<Script>& scripts); |
185 | 101 |
186 /** | 102 /** |
187 * Compute the disassembly of a wasm function. | 103 * Compute the disassembly of a wasm function. |
188 */ | 104 */ |
189 static debug::WasmDisassembly DisassembleWasmFunction( | 105 static debug::WasmDisassembly DisassembleWasmFunction( |
190 Isolate* isolate, v8::Local<v8::Object> script, int function_index); | 106 Isolate* isolate, v8::Local<v8::Object> script, int function_index); |
191 | 107 |
192 static MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, | 108 static MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, |
193 Local<String> source); | 109 Local<String> source); |
194 }; | 110 }; |
195 | 111 |
112 } // namespace debug | |
196 } // namespace v8 | 113 } // namespace v8 |
197 | 114 |
198 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 115 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
OLD | NEW |