Index: src/wasm/wasm-debug.h |
diff --git a/src/wasm/wasm-debug.h b/src/wasm/wasm-debug.h |
index 965995127122cbbc599a7089f4b6d4a10e5db478..f2cc9fa54b7813594f94257f8439f18fe4a7d231 100644 |
--- a/src/wasm/wasm-debug.h |
+++ b/src/wasm/wasm-debug.h |
@@ -7,21 +7,83 @@ |
#include "src/handles.h" |
#include "src/objects.h" |
+#include "src/wasm/ast-decoder.h" |
namespace v8 { |
namespace internal { |
namespace wasm { |
+class WasmInstructionIterator { |
+ const byte* const start_; |
+ const byte* pc_; |
+ const byte* const end_; |
+ |
+ public: |
+ WasmInstructionIterator(const byte* start, const byte* end); |
+ |
+ bool Done() const { return pc_ >= end_; } |
+ void Next(); |
+ int pc_offset() const { |
+ DCHECK_LE(pc_ - start_, kMaxInt); |
+ return static_cast<int>(pc_ - start_); |
+ } |
+}; |
+ |
+class WasmDebugInfo; |
+ |
+class InterpreterFrameInfo { |
+ Handle<WasmDebugInfo> debug_info_; |
+ int func_index_; |
+ int pc_offset_; |
+ |
+ InterpreterFrameInfo(Handle<WasmDebugInfo> debug_info, int func_index, |
+ int pc_offset) |
+ : debug_info_(debug_info), |
+ func_index_(func_index), |
+ pc_offset_(pc_offset) {} |
+ friend class InterpreterFrameIterator; |
+ |
+ public: |
+ InterpreterFrameInfo(const InterpreterFrameInfo& other) |
+ : func_index_(other.func_index_), pc_offset_(other.pc_offset_) {} |
+ int func_index() const { return func_index_; } |
+ int pc_offset() const { return pc_offset_; } |
+ Script* GetScript() const; |
+}; |
+ |
+class WasmInterpreter; |
+ |
+class InterpreterFrameIterator { |
+ int frame_nr_; |
+ int frame_count_; |
+ |
+ Handle<WasmDebugInfo> debug_info_; |
+ |
+ explicit InterpreterFrameIterator(Handle<WasmDebugInfo> debug_info); |
+ friend class WasmDebugInfo; |
+ |
+ public: |
+ bool Done() const { return frame_nr_ == frame_count_; } |
+ void Next() { |
+ DCHECK(!Done()); |
+ ++frame_nr_; |
+ } |
+ int Remaining() const { return frame_count_ - frame_nr_ - 1; } |
+ InterpreterFrameInfo GetFrameInfo() const; |
+}; |
+ |
class WasmDebugInfo : public FixedArray { |
public: |
static Handle<WasmDebugInfo> New(Handle<JSObject> wasm); |
- static bool IsDebugInfo(Object* object); |
+ static bool IsWasmDebugInfo(Object* object); |
static WasmDebugInfo* cast(Object* object); |
JSObject* wasm_object(); |
- bool SetBreakPoint(int byte_offset); |
+ static void SetBreakpoint(Handle<WasmDebugInfo> debug_info, int func_index, |
+ int byte_offset); |
+ bool HasBreakpoint(int func_index, int byte_offset); |
// Get the Script for the specified function. |
static Script* GetFunctionScript(Handle<WasmDebugInfo> debug_info, |
@@ -37,6 +99,36 @@ class WasmDebugInfo : public FixedArray { |
// column. |
static Handle<FixedArray> GetFunctionOffsetTable( |
Handle<WasmDebugInfo> debug_info, int func_index); |
+ |
+ // Get the DebugInfo for the specified function. |
+ static DebugInfo* GetDebugInfo(Handle<WasmDebugInfo> debug_info, |
+ int func_index); |
+ |
+ enum InstructionType { CALL, RETURN, OTHER }; |
+ |
+ // Determine the type of instruction for the given function and offset. |
+ // Used to determine the BreakLocation::DebugBreakType. |
+ InstructionType GetInstructionType(int func_index, int byte_offset); |
+ |
+ // Get an instruction iterator for the given function. |
+ // This iterator might be invalidated when gc happens, so the caller has to |
+ // ensure that no heap allocations happen as long as the iterator is in use. |
+ static WasmInstructionIterator GetInstructionIterator( |
+ Handle<WasmDebugInfo> debug_info, int func_index); |
+ |
+ // Get an iterator to inspect the frames inside the current interpreter. |
+ // The frames are inspected upwards, i.e. caller before callee. |
+ InterpreterFrameIterator GetInterpreterFrameIterator(); |
+ |
+ // Get a pointer to a buffer where arguments to be passed to the interpreter |
+ // can be stored. |
+ // This is a raw C pointer, encoded in an Object*. Since it is aligned, the GC |
+ // will handle it like a Smi. |
+ Object* GetInterpreterArgBuffer(int func_index); |
+ |
+ // Run a specific function in the interpreter. The arg buffer must have been |
+ // filled before (see GetInterpreterArgBuffer). |
+ void RunInterpreter(int func_index); |
}; |
} // namespace wasm |