| 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" |
| 13 |
| 12 namespace v8 { | 14 namespace v8 { |
| 13 | 15 |
| 14 class DebugInterface { | 16 class DebugInterface { |
| 15 public: | 17 public: |
| 16 /** | 18 /** |
| 17 * An event details object passed to the debug event listener. | 19 * An event details object passed to the debug event listener. |
| 18 */ | 20 */ |
| 19 class EventDetails : public v8::Debug::EventDetails { | 21 class EventDetails : public v8::Debug::EventDetails { |
| 20 public: | 22 public: |
| 21 /** | 23 /** |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 StepNext = 1, // Step to the next statement in the current function. | 136 StepNext = 1, // Step to the next statement in the current function. |
| 135 StepIn = 2, // Step into new functions invoked or the next statement | 137 StepIn = 2, // Step into new functions invoked or the next statement |
| 136 // in the current function. | 138 // in the current function. |
| 137 StepFrame = 3 // Step into a new frame or return to previous frame. | 139 StepFrame = 3 // Step into a new frame or return to previous frame. |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 static void PrepareStep(Isolate* isolate, StepAction action); | 142 static void PrepareStep(Isolate* isolate, StepAction action); |
| 141 static void ClearStepping(Isolate* isolate); | 143 static void ClearStepping(Isolate* isolate); |
| 142 | 144 |
| 143 /** | 145 /** |
| 144 * Defines location inside script. | |
| 145 * Lines and columns are 0-based. | |
| 146 */ | |
| 147 class Location { | |
| 148 public: | |
| 149 Location(int lineNumber, int columnNumber); | |
| 150 /** | |
| 151 * Create empty location. | |
| 152 */ | |
| 153 Location(); | |
| 154 | |
| 155 int GetLineNumber() const; | |
| 156 int GetColumnNumber() const; | |
| 157 bool IsEmpty() const; | |
| 158 | |
| 159 private: | |
| 160 int lineNumber_; | |
| 161 int columnNumber_; | |
| 162 }; | |
| 163 | |
| 164 /** | |
| 165 * Native wrapper around v8::internal::Script object. | 146 * Native wrapper around v8::internal::Script object. |
| 166 */ | 147 */ |
| 167 class Script { | 148 class Script { |
| 168 public: | 149 public: |
| 169 v8::Isolate* GetIsolate() const; | 150 v8::Isolate* GetIsolate() const; |
| 170 | 151 |
| 171 ScriptOriginOptions OriginOptions() const; | 152 ScriptOriginOptions OriginOptions() const; |
| 172 bool WasCompiled() const; | 153 bool WasCompiled() const; |
| 173 int Id() const; | 154 int Id() const; |
| 174 int LineOffset() const; | 155 int LineOffset() const; |
| 175 int ColumnOffset() const; | 156 int ColumnOffset() const; |
| 176 std::vector<int> LineEnds() const; | 157 std::vector<int> LineEnds() const; |
| 177 MaybeLocal<String> Name() const; | 158 MaybeLocal<String> Name() const; |
| 178 MaybeLocal<String> SourceURL() const; | 159 MaybeLocal<String> SourceURL() const; |
| 179 MaybeLocal<String> SourceMappingURL() const; | 160 MaybeLocal<String> SourceMappingURL() const; |
| 180 MaybeLocal<String> ContextData() const; | 161 MaybeLocal<String> ContextData() const; |
| 181 MaybeLocal<String> Source() const; | 162 MaybeLocal<String> Source() const; |
| 182 bool IsWasm() const; | 163 bool IsWasm() const; |
| 183 bool GetPossibleBreakpoints(const Location& start, const Location& end, | 164 bool GetPossibleBreakpoints(const debug::Location& start, |
| 184 std::vector<Location>* locations) const; | 165 const debug::Location& end, |
| 166 std::vector<debug::Location>* locations) const; |
| 185 | 167 |
| 186 /** | 168 /** |
| 187 * script parameter is a wrapper v8::internal::JSObject for | 169 * script parameter is a wrapper v8::internal::JSObject for |
| 188 * v8::internal::Script. | 170 * v8::internal::Script. |
| 189 * This function gets v8::internal::Script from v8::internal::JSObject and | 171 * This function gets v8::internal::Script from v8::internal::JSObject and |
| 190 * wraps it with DebugInterface::Script. | 172 * wraps it with DebugInterface::Script. |
| 191 * Returns empty local if not called with a valid wrapper of | 173 * Returns empty local if not called with a valid wrapper of |
| 192 * v8::internal::Script. | 174 * v8::internal::Script. |
| 193 */ | 175 */ |
| 194 static MaybeLocal<Script> Wrap(Isolate* isolate, | 176 static MaybeLocal<Script> Wrap(Isolate* isolate, |
| 195 v8::Local<v8::Object> script); | 177 v8::Local<v8::Object> script); |
| 196 | 178 |
| 197 private: | 179 private: |
| 198 int GetSourcePosition(const Location& location) const; | 180 int GetSourcePosition(const debug::Location& location) const; |
| 199 }; | 181 }; |
| 200 | 182 |
| 201 static void GetLoadedScripts(Isolate* isolate, | 183 static void GetLoadedScripts(Isolate* isolate, |
| 202 PersistentValueVector<Script>& scripts); | 184 PersistentValueVector<Script>& scripts); |
| 203 | 185 |
| 204 /** | 186 /** |
| 205 * Compute the disassembly of a wasm function. | 187 * Compute the disassembly of a wasm function. |
| 206 * Returns the disassembly string and a list of <byte_offset, line, column> | |
| 207 * entries, mapping wasm byte offsets to line and column in the disassembly. | |
| 208 * The list is guaranteed to be ordered by the byte_offset. | |
| 209 */ | 188 */ |
| 210 static std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>> | 189 static debug::WasmDisassembly DisassembleWasmFunction( |
| 211 DisassembleWasmFunction(Isolate* isolate, v8::Local<v8::Object> script, | 190 Isolate* isolate, v8::Local<v8::Object> script, int function_index); |
| 212 int function_index); | 191 |
| 213 static MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, | 192 static MaybeLocal<UnboundScript> CompileInspectorScript(Isolate* isolate, |
| 214 Local<String> source); | 193 Local<String> source); |
| 215 }; | 194 }; |
| 216 | 195 |
| 217 } // namespace v8 | 196 } // namespace v8 |
| 218 | 197 |
| 219 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ | 198 #endif // V8_DEBUG_DEBUG_INTERFACE_H_ |
| OLD | NEW |