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

Unified Diff: src/wasm/wasm-debug.cc

Issue 2629823003: [wasm] Implement frame inspection for interpreted frames (Closed)
Patch Set: Document that the forward declaration is only needed for VS 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 side-by-side diff with in-line comments
Download patch
Index: src/wasm/wasm-debug.cc
diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc
index b2e2bd08453b66d957ac7c2919883a6472808c1d..bb9bb07c06e418855c9abe983b29c6e24d0332b3 100644
--- a/src/wasm/wasm-debug.cc
+++ b/src/wasm/wasm-debug.cc
@@ -25,13 +25,15 @@ class InterpreterHandle {
AccountingAllocator allocator_;
WasmInstance instance_;
WasmInterpreter interpreter_;
+ Isolate *isolate_;
public:
// Initialize in the right order, using helper methods to make this possible.
// WasmInterpreter has to be allocated in place, since it is not movable.
InterpreterHandle(Isolate *isolate, WasmDebugInfo *debug_info)
: instance_(debug_info->wasm_instance()->compiled_module()->module()),
- interpreter_(GetBytesEnv(&instance_, debug_info), &allocator_) {
+ interpreter_(GetBytesEnv(&instance_, debug_info), &allocator_),
+ isolate_(isolate) {
Handle<JSArrayBuffer> mem_buffer =
handle(debug_info->wasm_instance()->memory_buffer(), isolate);
if (mem_buffer->IsUndefined(isolate)) {
@@ -97,7 +99,8 @@ class InterpreterHandle {
switch (state) {
case WasmInterpreter::State::PAUSED: {
// We hit a breakpoint.
- // TODO(clemensh): Handle this.
+ StackTraceFrameIterator frame_it(isolate_);
+ isolate_->debug()->Break(frame_it.frame());
} break;
case WasmInterpreter::State::FINISHED:
// Perfect, just break the switch and exit the loop.
@@ -136,6 +139,30 @@ class InterpreterHandle {
}
}
}
+
+ std::vector<std::pair<uint32_t, int>> GetInterpretedStack(
+ Address frame_pointer) {
+ // TODO(clemensh): Use frame_pointer.
+ USE(frame_pointer);
+
+ DCHECK_EQ(1, interpreter()->GetThreadCount());
+ WasmInterpreter::Thread *thread = interpreter()->GetThread(0);
+ std::vector<std::pair<uint32_t, int>> stack;
+ for (int i = thread->GetFrameCount() - 1; i >= 0; --i) {
+ wasm::InterpretedFrame frame = thread->GetFrame(0);
+ stack.push_back({frame.function()->func_index, frame.pc()});
+ }
+ return stack;
+ }
+
+ wasm::InterpretedFrame GetInterpretedFrame(Address frame_pointer, int idx) {
+ // TODO(clemensh): Use frame_pointer.
+ USE(frame_pointer);
+
+ DCHECK_EQ(1, interpreter()->GetThreadCount());
+ WasmInterpreter::Thread *thread = interpreter()->GetThread(0);
+ return thread->GetMutableFrame(idx);
+ }
};
InterpreterHandle *GetOrCreateInterpreterHandle(
@@ -272,3 +299,18 @@ void WasmDebugInfo::RunInterpreter(Handle<WasmDebugInfo> debug_info,
GetOrCreateInterpreterHandle(debug_info->GetIsolate(), debug_info);
interp_handle->Execute(static_cast<uint32_t>(func_index), arg_buffer);
}
+
+std::vector<std::pair<uint32_t, int>> WasmDebugInfo::GetInterpretedStack(
+ Handle<WasmDebugInfo> debug_info, Address frame_pointer) {
+ InterpreterHandle *interp_handle =
+ GetOrCreateInterpreterHandle(debug_info->GetIsolate(), debug_info);
+ return interp_handle->GetInterpretedStack(frame_pointer);
+}
+
+std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame(
+ Handle<WasmDebugInfo> debug_info, Address frame_pointer, int idx) {
+ InterpreterHandle *interp_handle =
+ GetOrCreateInterpreterHandle(debug_info->GetIsolate(), debug_info);
+ return std::unique_ptr<wasm::InterpretedFrame>(new wasm::InterpretedFrame(
+ interp_handle->GetInterpretedFrame(frame_pointer, idx)));
+}
« no previous file with comments | « src/frames.cc ('k') | src/wasm/wasm-interpreter.h » ('j') | src/wasm/wasm-interpreter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698