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, ...@@ -132,7 +132,13 @@ DebugWasmScopeIterator::DebugWasmScopeIterator(Isolate* isolate,
WasmFrame* frame) WasmFrame* frame)
: isolate_(isolate), : isolate_(isolate),
frame_(frame), 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() { bool DebugWasmScopeIterator::Done() {
return type_ == debug::ScopeIterator::ScopeTypeWith; return type_ == debug::ScopeIterator::ScopeTypeWith;
...@@ -141,16 +147,13 @@ bool DebugWasmScopeIterator::Done() { ...@@ -141,16 +147,13 @@ bool DebugWasmScopeIterator::Done() {
void DebugWasmScopeIterator::Advance() { void DebugWasmScopeIterator::Advance() {
DCHECK(!Done()); DCHECK(!Done());
switch (type_) { switch (type_) {
case ScopeTypeModule: case ScopeTypeWasmExpressionStack:
// Skip local scope and expression stack scope if the frame is not type_ = debug::ScopeIterator::ScopeTypeLocal;
// inspectable.
type_ = frame_->is_inspectable() ? debug::ScopeIterator::ScopeTypeLocal
: debug::ScopeIterator::ScopeTypeWith;
break; break;
case ScopeTypeLocal: case ScopeTypeLocal:
type_ = debug::ScopeIterator::ScopeTypeWasmExpressionStack; type_ = debug::ScopeIterator::ScopeTypeModule;
break; break;
case ScopeTypeWasmExpressionStack: case ScopeTypeModule:
// We use ScopeTypeWith type as marker for done. // We use ScopeTypeWith type as marker for done.
type_ = debug::ScopeIterator::ScopeTypeWith; type_ = debug::ScopeIterator::ScopeTypeWith;
break; break;
...@@ -173,13 +176,13 @@ v8::Local<v8::Object> DebugWasmScopeIterator::GetObject() { ...@@ -173,13 +176,13 @@ v8::Local<v8::Object> DebugWasmScopeIterator::GetObject() {
return Utils::ToLocal(wasm::GetModuleScopeObject(instance)); return Utils::ToLocal(wasm::GetModuleScopeObject(instance));
} }
case debug::ScopeIterator::ScopeTypeLocal: { case debug::ScopeIterator::ScopeTypeLocal: {
DCHECK(frame_->is_wasm()); DCHECK(frame_->is_inspectable());
wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo(); wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo();
return Utils::ToLocal(debug_info->GetLocalScopeObject( return Utils::ToLocal(debug_info->GetLocalScopeObject(
isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp())); isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp()));
} }
case debug::ScopeIterator::ScopeTypeWasmExpressionStack: { case debug::ScopeIterator::ScopeTypeWasmExpressionStack: {
DCHECK(frame_->is_wasm()); DCHECK(frame_->is_inspectable());
wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo(); wasm::DebugInfo* debug_info = frame_->native_module()->GetDebugInfo();
return Utils::ToLocal(debug_info->GetStackScopeObject( return Utils::ToLocal(debug_info->GetStackScopeObject(
isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp())); isolate_, frame_->pc(), frame_->fp(), frame_->callee_fp()));
......
...@@ -4,9 +4,9 @@ Wait for script ...@@ -4,9 +4,9 @@ Wait for script
Got wasm script: wasm://wasm/c84b7cde Got wasm script: wasm://wasm/c84b7cde
Run Run
Expecting to pause at 61 Expecting to pause at 61
Paused at offset 61; local: [12]; wasm-expression-stack: [] Paused at offset 61; wasm-expression-stack: []; local: [12]
Paused at offset 62; local: [12]; wasm-expression-stack: [] Paused at offset 62; wasm-expression-stack: []; local: [12]
Paused at offset 64; local: [12]; wasm-expression-stack: [12] Paused at offset 64; wasm-expression-stack: [12]; local: [12]
Paused at offset 66; local: [12]; wasm-expression-stack: [12, 1] Paused at offset 66; wasm-expression-stack: [12, 1]; local: [12]
Paused at offset 67; local: [12]; wasm-expression-stack: [13] Paused at offset 67; wasm-expression-stack: [13]; local: [12]
Finished! Finished!
...@@ -11,318 +11,318 @@ Setting breakpoint on offset 54 (on the setlocal before the call), url wasm://wa ...@@ -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) Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54): at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":4}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":3} {"0":3}
- scope (local):
{"var0":4}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction) Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56): at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop) Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38): at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":3}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOver called Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop) Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:39): at wasm_A (0:39):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":3}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOut called Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr) Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58): at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOut called Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet) Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54): at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":3}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":2} {"0":2}
- scope (local):
{"var0":3}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOver called Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction) Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56): at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOver called Debugger.stepOver called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr) Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58): at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.resume called Debugger.resume called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet) Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54): at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":2}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":1} {"0":1}
- scope (local):
{"var0":2}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction) Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56): at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop) Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38): at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepOut called Debugger.stepOut called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr) Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58): at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 45: Wasm opcode 0x20 (kExprLocalGet) Script wasm://wasm/9b4bf87e byte offset 45: Wasm opcode 0x20 (kExprLocalGet)
at wasm_B (0:45): at wasm_B (0:45):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 47: Wasm opcode 0x04 (kExprIf) Script wasm://wasm/9b4bf87e byte offset 47: Wasm opcode 0x04 (kExprIf)
at wasm_B (0:47): at wasm_B (0:47):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":1} {"0":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 49: Wasm opcode 0x20 (kExprLocalGet) Script wasm://wasm/9b4bf87e byte offset 49: Wasm opcode 0x20 (kExprLocalGet)
at wasm_B (0:49): at wasm_B (0:49):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 51: Wasm opcode 0x41 (kExprI32Const) Script wasm://wasm/9b4bf87e byte offset 51: Wasm opcode 0x41 (kExprI32Const)
at wasm_B (0:51): at wasm_B (0:51):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":1} {"0":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 53: Wasm opcode 0x6b (kExprI32Sub) Script wasm://wasm/9b4bf87e byte offset 53: Wasm opcode 0x6b (kExprI32Sub)
at wasm_B (0:53): at wasm_B (0:53):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":1,"1":1} {"0":1,"1":1}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet) Script wasm://wasm/9b4bf87e byte offset 54: Wasm opcode 0x21 (kExprLocalSet)
at wasm_B (0:54): at wasm_B (0:54):
- scope (module):
-- skipped
- scope (local):
{"var0":1}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{"0":0} {"0":0}
- scope (local):
{"var0":1}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction) Script wasm://wasm/9b4bf87e byte offset 56: Wasm opcode 0x10 (kExprCallFunction)
at wasm_B (0:56): at wasm_B (0:56):
- scope (module):
-- skipped
- scope (local):
{"var0":0}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop) Script wasm://wasm/9b4bf87e byte offset 38: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:38): at wasm_A (0:38):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":0}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop) Script wasm://wasm/9b4bf87e byte offset 39: Wasm opcode 0x01 (kExprNop)
at wasm_A (0:39): at wasm_A (0:39):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":0}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 40: Wasm opcode 0x0b (kExprEnd) Script wasm://wasm/9b4bf87e byte offset 40: Wasm opcode 0x0b (kExprEnd)
at wasm_A (0:40): at wasm_A (0:40):
- scope (module):
-- skipped
- scope (local):
{}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
at wasm_B (0:56): - scope (local):
{}
- scope (module): - scope (module):
-- skipped -- skipped
- scope (local): at wasm_B (0:56):
{"var0":0}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- skipped
Debugger.stepInto called Debugger.stepInto called
Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr) Script wasm://wasm/9b4bf87e byte offset 58: Wasm opcode 0x0c (kExprBr)
at wasm_B (0:58): at wasm_B (0:58):
- scope (module):
-- skipped
- scope (local):
{"var0":0}
- scope (wasm-expression-stack): - scope (wasm-expression-stack):
{} {}
- scope (local):
{"var0":0}
- scope (module):
-- skipped
at (anonymous) (0:17): at (anonymous) (0:17):
- scope (global): - scope (global):
-- skipped -- 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