Commit f4d408fd authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[wasm][debug] Make Scope order consistent.

JavaScript scopes are reported from inner-most to outer-most, while
previously we would report WebAssembly frames from outer-most to
inner-most. This is quite confusing for developers, and also doesn't
really make sense, so this CL fixes this inconsistency.

Bug: chromium:1071432
Change-Id: I6a4742f13b9a0df33e50c6fcd40992873996aaf5
Fixed: chromium:1159309
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2602947
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71875}
parent 7a7027f8
......@@ -132,7 +132,13 @@ DebugWasmScopeIterator::DebugWasmScopeIterator(Isolate* isolate,
WasmFrame* frame)
: isolate_(isolate),
frame_(frame),
type_(debug::ScopeIterator::ScopeTypeModule) {}
type_(debug::ScopeIterator::ScopeTypeWasmExpressionStack) {
// Skip local scope and expression stack scope if the frame is not
// inspectable.
if (!frame->is_inspectable()) {
type_ = debug::ScopeIterator::ScopeTypeModule;
}
}
bool DebugWasmScopeIterator::Done() {
return type_ == debug::ScopeIterator::ScopeTypeWith;
......@@ -141,16 +147,13 @@ bool DebugWasmScopeIterator::Done() {
void DebugWasmScopeIterator::Advance() {
DCHECK(!Done());
switch (type_) {
case ScopeTypeModule:
// Skip local scope and expression stack scope if the frame is not
// inspectable.
type_ = frame_->is_inspectable() ? debug::ScopeIterator::ScopeTypeLocal
: debug::ScopeIterator::ScopeTypeWith;
case ScopeTypeWasmExpressionStack:
type_ = debug::ScopeIterator::ScopeTypeLocal;
break;
case ScopeTypeLocal:
type_ = debug::ScopeIterator::ScopeTypeWasmExpressionStack;
type_ = debug::ScopeIterator::ScopeTypeModule;
break;
case ScopeTypeWasmExpressionStack:
case ScopeTypeModule:
// We use ScopeTypeWith type as marker for done.
type_ = debug::ScopeIterator::ScopeTypeWith;
break;
......@@ -173,13 +176,13 @@ v8::Local<v8::Object> DebugWasmScopeIterator::GetObject() {
return Utils::ToLocal(wasm::GetModuleScopeObject(instance));
}
case debug::ScopeIterator::ScopeTypeLocal: {
DCHECK(frame_->is_wasm());
DCHECK(frame_->is_inspectable());
wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo();
return Utils::ToLocal(debug_info->GetLocalScopeObject(
isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp()));
}
case debug::ScopeIterator::ScopeTypeWasmExpressionStack: {
DCHECK(frame_->is_wasm());
DCHECK(frame_->is_inspectable());
wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo();
return Utils::ToLocal(debug_info->GetStackScopeObject(
isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp()));
......
......@@ -4,9 +4,9 @@ Wait for script
Got wasm script: wasm://wasm/c84b7cde
Run
Expecting to pause at 61
Paused at offset 61; local: [12]; wasm-expression-stack: []
Paused at offset 62; local: [12]; wasm-expression-stack: []
Paused at offset 64; local: [12]; wasm-expression-stack: [12]
Paused at offset 66; local: [12]; wasm-expression-stack: [12, 1]
Paused at offset 67; local: [12]; wasm-expression-stack: [13]
Paused at offset 61; wasm-expression-stack: []; local: [12]
Paused at offset 62; wasm-expression-stack: []; local: [12]
Paused at offset 64; wasm-expression-stack: [12]; local: [12]
Paused at offset 66; wasm-expression-stack: [12, 1]; local: [12]
Paused at offset 67; wasm-expression-stack: [13]; local: [12]
Finished!
......@@ -11,318 +11,318 @@ Setting breakpoint on offset 54 (on the setlocal before the call), url wasm://wa
}
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":4}
- scope (wasm-expression-stack):
{"0":3}
- scope (local):
{"var0":4}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":3}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:39):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":3}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack):
{"0":2}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.resume called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack):
{"0":1}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":1}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 45: Wasm opcode 0x20 (kExprLocalGet)
at wasm_B (0:45):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 47: Wasm opcode 0x04 (kExprIf)
at wasm_B (0:47):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{"0":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 49: Wasm opcode 0x20 (kExprLocalGet)
at wasm_B (0:49):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 51: Wasm opcode 0x41 (kExprI32Const)
at wasm_B (0:51):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{"0":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 53: Wasm opcode 0x6b (kExprI32Sub)
at wasm_B (0:53):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{"0":1,"1":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack):
{"0":0}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":0}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":0}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:39):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":0}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 40: Wasm opcode 0x0b (kExprEnd)
at wasm_A (0:40):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack):
{}
at wasm_B (0:56):
- scope (local):
{}
- scope (module):
-- skipped
- scope (local):
{"var0":0}
at wasm_B (0:56):
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":0}
- scope (wasm-expression-stack):
{}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17):
- scope (global):
-- skipped
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment