diff --git a/src/debug/debug-evaluate.cc b/src/debug/debug-evaluate.cc index 11cfa37d5c..77683fde1e 100644 --- a/src/debug/debug-evaluate.cc +++ b/src/debug/debug-evaluate.cc @@ -100,7 +100,7 @@ MaybeHandle DebugEvaluate::Local(Isolate* isolate, WasmFrame* frame = WasmFrame::cast(it.frame()); Handle outer_info( isolate->native_context()->empty_function().shared(), isolate); - Handle context_extension = GetJSDebugProxy(frame); + Handle context_extension = GetWasmDebugProxy(frame); Handle scope_info = ScopeInfo::CreateForWithScope(isolate, Handle::null()); Handle context = isolate->factory()->NewWithContext( diff --git a/src/debug/debug-scope-iterator.cc b/src/debug/debug-scope-iterator.cc index 05b1230bac..3260650bd8 100644 --- a/src/debug/debug-scope-iterator.cc +++ b/src/debug/debug-scope-iterator.cc @@ -5,14 +5,11 @@ #include "src/debug/debug-scope-iterator.h" #include "src/api/api-inl.h" -#include "src/debug/debug-wasm-support.h" #include "src/debug/debug.h" #include "src/debug/liveedit.h" #include "src/execution/frames-inl.h" #include "src/execution/isolate.h" #include "src/objects/js-generator-inl.h" -#include "src/wasm/wasm-debug.h" -#include "src/wasm/wasm-objects-inl.h" namespace v8 { @@ -129,92 +126,5 @@ bool DebugScopeIterator::SetVariableValue(v8::Local name, Utils::OpenHandle(*value)); } -DebugWasmScopeIterator::DebugWasmScopeIterator(Isolate* isolate, - WasmFrame* frame) - : isolate_(isolate), - frame_(frame), - 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; -} - -void DebugWasmScopeIterator::Advance() { - DCHECK(!Done()); - switch (type_) { - case ScopeTypeWasmExpressionStack: - type_ = debug::ScopeIterator::ScopeTypeLocal; - break; - case ScopeTypeLocal: - type_ = debug::ScopeIterator::ScopeTypeModule; - break; - case ScopeTypeModule: - // We use ScopeTypeWith type as marker for done. - type_ = debug::ScopeIterator::ScopeTypeWith; - break; - default: - UNREACHABLE(); - } -} - -v8::debug::ScopeIterator::ScopeType DebugWasmScopeIterator::GetType() { - DCHECK(!Done()); - return type_; -} - -v8::Local DebugWasmScopeIterator::GetObject() { - DCHECK(!Done()); - switch (type_) { - case debug::ScopeIterator::ScopeTypeModule: { - Handle instance = - FrameSummary::GetTop(frame_).AsWasm().wasm_instance(); - return Utils::ToLocal(GetModuleScopeObject(instance)); - } - case debug::ScopeIterator::ScopeTypeLocal: { - DCHECK(frame_->is_inspectable()); - return Utils::ToLocal(GetLocalScopeObject(frame_)); - } - case debug::ScopeIterator::ScopeTypeWasmExpressionStack: { - DCHECK(frame_->is_inspectable()); - return Utils::ToLocal(GetStackScopeObject(frame_)); - } - default: - return {}; - } -} - -int DebugWasmScopeIterator::GetScriptId() { - DCHECK(!Done()); - return -1; -} - -v8::Local DebugWasmScopeIterator::GetFunctionDebugName() { - DCHECK(!Done()); - return Utils::ToLocal(isolate_->factory()->empty_string()); -} - -bool DebugWasmScopeIterator::HasLocationInfo() { return false; } - -debug::Location DebugWasmScopeIterator::GetStartLocation() { - DCHECK(!Done()); - return debug::Location(); -} - -debug::Location DebugWasmScopeIterator::GetEndLocation() { - DCHECK(!Done()); - return debug::Location(); -} - -bool DebugWasmScopeIterator::SetVariableValue(v8::Local name, - v8::Local value) { - DCHECK(!Done()); - return false; -} } // namespace internal } // namespace v8 diff --git a/src/debug/debug-scope-iterator.h b/src/debug/debug-scope-iterator.h index a2b5ebcdf8..6607467a02 100644 --- a/src/debug/debug-scope-iterator.h +++ b/src/debug/debug-scope-iterator.h @@ -37,27 +37,6 @@ class DebugScopeIterator final : public debug::ScopeIterator { v8::internal::ScopeIterator iterator_; }; -class DebugWasmScopeIterator final : public debug::ScopeIterator { - public: - DebugWasmScopeIterator(Isolate* isolate, WasmFrame* frame); - - bool Done() override; - void Advance() override; - ScopeType GetType() override; - v8::Local GetObject() override; - v8::Local GetFunctionDebugName() override; - int GetScriptId() override; - bool HasLocationInfo() override; - debug::Location GetStartLocation() override; - debug::Location GetEndLocation() override; - - bool SetVariableValue(v8::Local name, - v8::Local value) override; - private: - Isolate* isolate_; - WasmFrame* frame_; - ScopeType type_; -}; } // namespace internal } // namespace v8 diff --git a/src/debug/debug-stack-trace-iterator.cc b/src/debug/debug-stack-trace-iterator.cc index 2a47bb6f97..782b0c7dda 100644 --- a/src/debug/debug-stack-trace-iterator.cc +++ b/src/debug/debug-stack-trace-iterator.cc @@ -7,6 +7,7 @@ #include "src/api/api-inl.h" #include "src/debug/debug-evaluate.h" #include "src/debug/debug-scope-iterator.h" +#include "src/debug/debug-wasm-support.h" #include "src/debug/debug.h" #include "src/debug/liveedit.h" #include "src/execution/frames-inl.h" @@ -160,8 +161,7 @@ DebugStackTraceIterator::GetScopeIterator() const { DCHECK(!Done()); CommonFrame* frame = iterator_.frame(); if (frame->is_wasm()) { - return std::make_unique(isolate_, - WasmFrame::cast(frame)); + return GetWasmScopeIterator(WasmFrame::cast(frame)); } return std::make_unique(isolate_, frame_inspector_.get()); } diff --git a/src/debug/debug-wasm-support.cc b/src/debug/debug-wasm-support.cc index b436c46f07..59b8ad8c35 100644 --- a/src/debug/debug-wasm-support.cc +++ b/src/debug/debug-wasm-support.cc @@ -16,22 +16,6 @@ namespace v8 { namespace internal { namespace { -template -Handle PrintFToOneByteString(Isolate* isolate, const char* format, - Args... args) { - // Maximum length of a formatted value name ("arg#%d", "local#%d", - // "global#%d", i32 constants, i64 constants), including null character. - static constexpr int kMaxStrLen = 21; - EmbeddedVector value; - int len = SNPrintF(value, format, args...); - CHECK(len > 0 && len < value.length()); - Vector name = - Vector::cast(value.SubVector(0, len)); - return internal - ? isolate->factory()->InternalizeString(name) - : isolate->factory()->NewStringFromOneByte(name).ToHandleChecked(); -} - // Convert a WasmValue to an appropriate JS representation. Handle WasmValueToObject(Isolate* isolate, wasm::WasmValue value) { auto* factory = isolate->factory(); @@ -71,133 +55,8 @@ Handle WasmValueToObject(Isolate* isolate, wasm::WasmValue value) { return factory->undefined_value(); } -MaybeHandle GetLocalNameString(Isolate* isolate, - wasm::NativeModule* native_module, - int func_index, int local_index) { - wasm::WireBytesRef name_ref = - native_module->GetDebugInfo()->GetLocalName(func_index, local_index); - wasm::ModuleWireBytes wire_bytes{native_module->wire_bytes()}; - // Bounds were checked during decoding. - DCHECK(wire_bytes.BoundsCheck(name_ref)); - wasm::WasmName name = wire_bytes.GetNameOrNull(name_ref); - if (name.size() == 0) return {}; - return isolate->factory()->NewStringFromUtf8(name); -} - } // namespace -Handle GetModuleScopeObject(Handle instance) { - Isolate* isolate = instance->GetIsolate(); - Handle module_scope_object = - isolate->factory()->NewJSObjectWithNullProto(); - - Handle instance_name = - isolate->factory()->InternalizeString(StaticCharVector("instance")); - JSObject::AddProperty(isolate, module_scope_object, instance_name, instance, - NONE); - - Handle module_object(instance->module_object(), isolate); - Handle module_name = - isolate->factory()->InternalizeString(StaticCharVector("module")); - JSObject::AddProperty(isolate, module_scope_object, module_name, - module_object, NONE); - - if (instance->has_memory_object()) { - Handle name; - // TODO(duongn): extend the logic when multiple memories are supported. - const uint32_t memory_index = 0; - if (!WasmInstanceObject::GetMemoryNameOrNull(isolate, instance, - memory_index) - .ToHandle(&name)) { - const char* label = "memory%d"; - name = PrintFToOneByteString(isolate, label, memory_index); - } - Handle memory_object(instance->memory_object(), isolate); - JSObject::AddProperty(isolate, module_scope_object, name, memory_object, - NONE); - } - - auto& globals = instance->module()->globals; - if (globals.size() > 0) { - Handle globals_obj = - isolate->factory()->NewJSObjectWithNullProto(); - Handle globals_name = - isolate->factory()->InternalizeString(StaticCharVector("globals")); - JSObject::AddProperty(isolate, module_scope_object, globals_name, - globals_obj, NONE); - - for (uint32_t i = 0; i < globals.size(); ++i) { - Handle name; - if (!WasmInstanceObject::GetGlobalNameOrNull(isolate, instance, i) - .ToHandle(&name)) { - const char* label = "global%d"; - name = PrintFToOneByteString(isolate, label, i); - } - wasm::WasmValue value = - WasmInstanceObject::GetGlobalValue(instance, globals[i]); - Handle value_obj = WasmValueToObject(isolate, value); - LookupIterator it(isolate, globals_obj, name, globals_obj, - LookupIterator::OWN_SKIP_INTERCEPTOR); - JSObject::CreateDataProperty(&it, value_obj).Check(); - } - } - return module_scope_object; -} - -Handle GetLocalScopeObject(WasmFrame* frame) { - Isolate* isolate = frame->isolate(); - auto native_module = frame->native_module(); - auto debug_info = native_module->GetDebugInfo(); - auto function = debug_info->GetFunctionAtAddress(frame->pc()); - Handle local_scope_object = - isolate->factory()->NewJSObjectWithNullProto(); - - // Fill parameters and locals. - int num_locals = debug_info->GetNumLocals(frame->pc()); - DCHECK_LE(static_cast(function.sig->parameter_count()), num_locals); - for (int i = 0; i < num_locals; ++i) { - Handle name; - if (!GetLocalNameString(isolate, native_module, function.func_index, i) - .ToHandle(&name)) { - name = PrintFToOneByteString(isolate, "var%d", i); - } - wasm::WasmValue value = debug_info->GetLocalValue( - i, frame->pc(), frame->fp(), frame->callee_fp()); - Handle value_obj = WasmValueToObject(isolate, value); - // {name} can be a string representation of an element index. - LookupIterator::Key lookup_key{isolate, name}; - LookupIterator it(isolate, local_scope_object, lookup_key, - local_scope_object, LookupIterator::OWN_SKIP_INTERCEPTOR); - if (it.IsFound()) continue; - Object::AddDataProperty(&it, value_obj, NONE, - Just(ShouldThrow::kThrowOnError), - StoreOrigin::kNamed) - .Check(); - } - return local_scope_object; -} - -Handle GetStackScopeObject(WasmFrame* frame) { - Isolate* isolate = frame->isolate(); - auto native_module = frame->native_module(); - auto debug_info = native_module->GetDebugInfo(); - Handle stack_scope_obj = - isolate->factory()->NewJSObjectWithNullProto(); - - // Fill stack values. - // Use an object without prototype instead of an Array, for nicer displaying - // in DevTools. For Arrays, the length field and prototype is displayed, - // which does not make too much sense here. - int value_count = debug_info->GetStackDepth(frame->pc()); - for (int i = 0; i < value_count; ++i) { - wasm::WasmValue value = debug_info->GetStackValue( - i, frame->pc(), frame->fp(), frame->callee_fp()); - Handle value_obj = WasmValueToObject(isolate, value); - JSObject::AddDataElement(stack_scope_obj, i, value_obj, NONE); - } - return stack_scope_obj; -} - namespace { // Helper for unpacking a maybe name that makes a default with an index if @@ -574,7 +433,8 @@ struct TablesProxy : NamedDebugProxy { struct LocalsProxy : NamedDebugProxy { static constexpr char const* kClassName = "Locals"; - static Handle Create(Isolate* isolate, WasmFrame* frame) { + static Handle Create(WasmFrame* frame) { + auto isolate = frame->isolate(); auto debug_info = frame->native_module()->GetDebugInfo(); // TODO(bmeurer): Check if pc is inspectable. int count = debug_info->GetNumLocals(frame->pc()); @@ -621,7 +481,8 @@ struct LocalsProxy : NamedDebugProxy { struct StackProxy : IndexedDebugProxy { static constexpr char const* kClassName = "Stack"; - static Handle Create(Isolate* isolate, WasmFrame* frame) { + static Handle Create(WasmFrame* frame) { + auto isolate = frame->isolate(); auto debug_info = frame->wasm_instance().module_object().native_module()->GetDebugInfo(); int count = debug_info->GetStackDepth(frame->pc()); @@ -709,9 +570,9 @@ class ContextProxy { auto object = isolate->factory()->NewJSObjectFromMap(object_map); Handle instance(frame->wasm_instance(), isolate); object->SetEmbedderField(kInstanceField, *instance); - Handle locals = LocalsProxy::Create(isolate, frame); + Handle locals = LocalsProxy::Create(frame); object->SetEmbedderField(kLocalsField, *locals); - Handle stack = StackProxy::Create(isolate, frame); + Handle stack = StackProxy::Create(frame); object->SetEmbedderField(kStackField, *stack); return object; } @@ -800,11 +661,127 @@ class ContextProxy { } }; +Handle GetModuleScopeObject(Handle instance) { + Isolate* isolate = instance->GetIsolate(); + Handle module_scope_object = + isolate->factory()->NewJSObjectWithNullProto(); + + Handle instance_name = + isolate->factory()->InternalizeString(StaticCharVector("instance")); + JSObject::AddProperty(isolate, module_scope_object, instance_name, instance, + NONE); + + Handle module_object(instance->module_object(), isolate); + Handle module_name = + isolate->factory()->InternalizeString(StaticCharVector("module")); + JSObject::AddProperty(isolate, module_scope_object, module_name, + module_object, NONE); + + uint32_t memory_count = MemoriesProxy::Count(isolate, instance); + for (uint32_t memory_index = 0; memory_index < memory_count; ++memory_index) { + auto memory_name = MemoriesProxy::GetName(isolate, instance, memory_index); + auto memory_value = MemoriesProxy::Get(isolate, instance, memory_index); + JSObject::AddProperty(isolate, module_scope_object, memory_name, + memory_value, NONE); + } + + if (GlobalsProxy::Count(isolate, instance) != 0) { + Handle globals_obj = + GetOrCreateInstanceProxy(isolate, instance); + Handle globals_name = + isolate->factory()->InternalizeString(StaticCharVector("globals")); + JSObject::AddProperty(isolate, module_scope_object, globals_name, + globals_obj, NONE); + } + + return module_scope_object; +} + +class DebugWasmScopeIterator final : public debug::ScopeIterator { + public: + explicit DebugWasmScopeIterator(WasmFrame* frame) + : frame_(frame), + 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 Done() override { return type_ == ScopeTypeWith; } + + void Advance() override { + DCHECK(!Done()); + switch (type_) { + case ScopeTypeWasmExpressionStack: + type_ = debug::ScopeIterator::ScopeTypeLocal; + break; + case ScopeTypeLocal: + type_ = debug::ScopeIterator::ScopeTypeModule; + break; + case ScopeTypeModule: + // We use ScopeTypeWith type as marker for done. + type_ = debug::ScopeIterator::ScopeTypeWith; + break; + default: + UNREACHABLE(); + } + } + + ScopeType GetType() override { return type_; } + + v8::Local GetObject() override { + DCHECK(!Done()); + switch (type_) { + case debug::ScopeIterator::ScopeTypeModule: { + Handle instance = + FrameSummary::GetTop(frame_).AsWasm().wasm_instance(); + return Utils::ToLocal(GetModuleScopeObject(instance)); + } + case debug::ScopeIterator::ScopeTypeLocal: { + DCHECK(frame_->is_inspectable()); + return Utils::ToLocal(LocalsProxy::Create(frame_)); + } + case debug::ScopeIterator::ScopeTypeWasmExpressionStack: { + DCHECK(frame_->is_inspectable()); + return Utils::ToLocal(StackProxy::Create(frame_)); + } + default: + return {}; + } + } + v8::Local GetFunctionDebugName() override { + return Utils::ToLocal(frame_->isolate()->factory()->empty_string()); + } + + int GetScriptId() override { return -1; } + + bool HasLocationInfo() override { return false; } + + debug::Location GetStartLocation() override { return {}; } + + debug::Location GetEndLocation() override { return {}; } + + bool SetVariableValue(v8::Local name, + v8::Local value) override { + return false; + } + + private: + WasmFrame* const frame_; + ScopeType type_; +}; + } // namespace -Handle GetJSDebugProxy(WasmFrame* frame) { +Handle GetWasmDebugProxy(WasmFrame* frame) { return ContextProxy::Create(frame); } +std::unique_ptr GetWasmScopeIterator(WasmFrame* frame) { + return std::make_unique(frame); +} + } // namespace internal } // namespace v8 diff --git a/src/debug/debug-wasm-support.h b/src/debug/debug-wasm-support.h index 124bd8cb5b..fba5759a77 100644 --- a/src/debug/debug-wasm-support.h +++ b/src/debug/debug-wasm-support.h @@ -5,19 +5,23 @@ #ifndef V8_DEBUG_DEBUG_WASM_SUPPORT_H_ #define V8_DEBUG_DEBUG_WASM_SUPPORT_H_ +#include + namespace v8 { +namespace debug { +class ScopeIterator; +} // namespace debug + namespace internal { template class Handle; class JSObject; class WasmFrame; -class WasmInstanceObject; -Handle GetModuleScopeObject(Handle instance); -Handle GetLocalScopeObject(WasmFrame* frame); -Handle GetStackScopeObject(WasmFrame* frame); -Handle GetJSDebugProxy(WasmFrame* frame); +Handle GetWasmDebugProxy(WasmFrame* frame); + +std::unique_ptr GetWasmScopeIterator(WasmFrame* frame); } // namespace internal } // namespace v8 diff --git a/test/inspector/debugger/wasm-global-names-expected.txt b/test/inspector/debugger/wasm-global-names-expected.txt index 2faf3d22bb..b7584c1b72 100644 --- a/test/inspector/debugger/wasm-global-names-expected.txt +++ b/test/inspector/debugger/wasm-global-names-expected.txt @@ -5,4 +5,4 @@ Waiting for wasm script to be parsed. Setting breakpoint in wasm. Running main. Paused in debugger. - globals: {"module_name.imported_global", "exported_global", "global2"} + globals: {"$module_name.imported_global", "$exported_global", "$global2"} diff --git a/test/inspector/debugger/wasm-memory-names-expected.txt b/test/inspector/debugger/wasm-memory-names-expected.txt index f1d997751c..7f39055784 100644 --- a/test/inspector/debugger/wasm-memory-names-expected.txt +++ b/test/inspector/debugger/wasm-memory-names-expected.txt @@ -5,17 +5,17 @@ Waiting for wasm script to be parsed. Setting breakpoint in wasm. Running main. Paused in debugger. -name: memory0 +name: $memory0 Finished. Waiting for wasm script to be parsed. Setting breakpoint in wasm. Running main. Paused in debugger. -name: exported_memory +name: $exported_memory Finished. Waiting for wasm script to be parsed. Setting breakpoint in wasm. Running main. Paused in debugger. -name: module_name.imported_mem +name: $module_name.imported_mem Finished. diff --git a/test/inspector/debugger/wasm-scope-info-expected.txt b/test/inspector/debugger/wasm-scope-info-expected.txt index e1b3dd3059..4fdec85b8d 100644 --- a/test/inspector/debugger/wasm-scope-info-expected.txt +++ b/test/inspector/debugger/wasm-scope-info-expected.txt @@ -16,39 +16,39 @@ Scope: at C (interpreted) (0:169): - scope (wasm-expression-stack): - scope (local): - i32_arg: 42 (number) - i32_local: 0 (number) - var2: 0 (number) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $var2: 0 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at B (liftoff) (0:158): - scope (wasm-expression-stack): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -60,39 +60,39 @@ at C (interpreted) (0:171): - scope (wasm-expression-stack): 0: 42 (number) - scope (local): - i32_arg: 42 (number) - i32_local: 0 (number) - var2: 0 (number) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $var2: 0 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at B (liftoff) (0:158): - scope (wasm-expression-stack): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 0 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 0 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -103,39 +103,39 @@ Scope: at C (interpreted) (0:173): - scope (wasm-expression-stack): - scope (local): - i32_arg: 42 (number) - i32_local: 0 (number) - var2: 0 (number) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $var2: 0 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at B (liftoff) (0:158): - scope (wasm-expression-stack): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -147,39 +147,39 @@ at C (interpreted) (0:175): - scope (wasm-expression-stack): 0: 47 (number) - scope (local): - i32_arg: 42 (number) - i32_local: 0 (number) - var2: 0 (number) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $var2: 0 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at B (liftoff) (0:158): - scope (wasm-expression-stack): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -190,39 +190,39 @@ Scope: at C (interpreted) (0:177): - scope (wasm-expression-stack): - scope (local): - i32_arg: 42 (number) - i32_local: 47 (number) - var2: 0 (number) + $i32_arg: 42 (number) + $i32_local: 47 (number) + $var2: 0 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at B (liftoff) (0:158): - scope (wasm-expression-stack): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -235,26 +235,26 @@ at B (liftoff) (0:160): 0: 42 (number) 1: 3 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -266,26 +266,26 @@ at B (liftoff) (0:161): - scope (wasm-expression-stack): 0: 42 (number) - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -296,26 +296,26 @@ Scope: at B (liftoff) (0:162): - scope (wasm-expression-stack): - scope (local): - 0: 0 (number) - i32_arg: 42 (number) - i32_local: 0 (number) - f32_local: 7.199999809265137 (number) - var5: 0 (number) - v128_local: Uint8Array(16) + $i32_arg: 42 (number) + $i32_local: 0 (number) + $f32_local: 7.199999809265137 (number) + $0: 0 (number) + $var5: 0 (number) + $v128_local: Uint8Array(16) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at A (liftoff) (0:128): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals @@ -326,12 +326,12 @@ Scope: at A (liftoff) (0:130): - scope (wasm-expression-stack): - scope (local): - var0: 42 (number) + $var0: 42 (number) - scope (module): instance: exports: "exported_global" (Global), "exported_memory" (Memory), "exported_table" (Table), "main" (Function) module: Module - exported_memory: Memory(1) - globals: "exported_global": 42 (number) + $exported_memory: Memory(1) + globals: "$exported_global": 42 (number) at (anonymous) (0:17): - scope (global): -- skipped globals diff --git a/test/inspector/debugger/wasm-set-breakpoint-expected.txt b/test/inspector/debugger/wasm-set-breakpoint-expected.txt index 542c7bea86..e3f47f8a2e 100644 --- a/test/inspector/debugger/wasm-set-breakpoint-expected.txt +++ b/test/inspector/debugger/wasm-set-breakpoint-expected.txt @@ -17,7 +17,7 @@ at wasm_A (0:38): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -44,7 +44,7 @@ at wasm_A (0:39): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -56,7 +56,7 @@ Scope: at wasm_B (0:45): - scope (wasm-expression-stack): - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -69,7 +69,7 @@ at wasm_B (0:47): - scope (wasm-expression-stack): 0: 3 (number) - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -81,7 +81,7 @@ Scope: at wasm_B (0:49): - scope (wasm-expression-stack): - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -94,7 +94,7 @@ at wasm_B (0:51): - scope (wasm-expression-stack): 0: 3 (number) - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -108,7 +108,7 @@ at wasm_B (0:53): 0: 3 (number) 1: 1 (number) - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -121,7 +121,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): 0: 2 (number) - scope (local): - var0: 3 (number) + $var0: 3 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -139,7 +139,7 @@ at wasm_A (0:38): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -157,7 +157,7 @@ at wasm_A (0:39): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -169,7 +169,7 @@ Scope: at wasm_B (0:45): - scope (wasm-expression-stack): - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -182,7 +182,7 @@ at wasm_B (0:47): - scope (wasm-expression-stack): 0: 2 (number) - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -194,7 +194,7 @@ Scope: at wasm_B (0:49): - scope (wasm-expression-stack): - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -207,7 +207,7 @@ at wasm_B (0:51): - scope (wasm-expression-stack): 0: 2 (number) - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -221,7 +221,7 @@ at wasm_B (0:53): 0: 2 (number) 1: 1 (number) - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -234,7 +234,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): 0: 1 (number) - scope (local): - var0: 2 (number) + $var0: 2 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -252,7 +252,7 @@ at wasm_A (0:38): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -270,7 +270,7 @@ at wasm_A (0:39): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -282,7 +282,7 @@ Scope: at wasm_B (0:45): - scope (wasm-expression-stack): - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -295,7 +295,7 @@ at wasm_B (0:47): - scope (wasm-expression-stack): 0: 1 (number) - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -307,7 +307,7 @@ Scope: at wasm_B (0:49): - scope (wasm-expression-stack): - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -320,7 +320,7 @@ at wasm_B (0:51): - scope (wasm-expression-stack): 0: 1 (number) - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -334,7 +334,7 @@ at wasm_B (0:53): 0: 1 (number) 1: 1 (number) - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -347,7 +347,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): 0: 0 (number) - scope (local): - var0: 1 (number) + $var0: 1 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -365,7 +365,7 @@ at wasm_A (0:38): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 0 (number) + $var0: 0 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -383,7 +383,7 @@ at wasm_A (0:39): at wasm_B (0:56): - scope (wasm-expression-stack): - scope (local): - var0: 0 (number) + $var0: 0 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -395,7 +395,7 @@ Scope: at wasm_B (0:45): - scope (wasm-expression-stack): - scope (local): - var0: 0 (number) + $var0: 0 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -408,7 +408,7 @@ at wasm_B (0:47): - scope (wasm-expression-stack): 0: 0 (number) - scope (local): - var0: 0 (number) + $var0: 0 (number) - scope (module): instance: exports: "main" (Function) module: Module @@ -420,7 +420,7 @@ Scope: at wasm_B (0:61): - scope (wasm-expression-stack): - scope (local): - var0: 0 (number) + $var0: 0 (number) - scope (module): instance: exports: "main" (Function) module: Module diff --git a/test/inspector/debugger/wasm-step-after-trap-expected.txt b/test/inspector/debugger/wasm-step-after-trap-expected.txt index 278808a024..3424b6987a 100644 --- a/test/inspector/debugger/wasm-step-after-trap-expected.txt +++ b/test/inspector/debugger/wasm-step-after-trap-expected.txt @@ -7,11 +7,11 @@ Paused at: --- 0 --- Script wasm://wasm/a9a86c5e byte offset 46: Wasm opcode 0x6d (kExprI32DivS) scope at div (0:46): - a: 1 - b: 0 - unused: 4711 - local_zero: 0 - local_const_11: 11 + $a: 1 + $b: 0 + $unused: 4711 + $local_zero: 0 + $local_const_11: 11 --- 1 --- try { instance.exports.#div(1, 0, 4711); // traps (div by zero) @@ -37,11 +37,11 @@ Paused at: --- 0 --- Script wasm://wasm/a9a86c5e byte offset 46: Wasm opcode 0x6d (kExprI32DivS) scope at div (0:46): - a: -2147483648 - b: -1 - unused: 4711 - local_zero: 0 - local_const_11: 11 + $a: -2147483648 + $b: -1 + $unused: 4711 + $local_zero: 0 + $local_const_11: 11 --- 1 --- try { instance.exports.#div(0x80000000, -1, 4711); // traps (unrepresentable) diff --git a/test/inspector/debugger/wasm-stepping-with-source-map-expected.txt b/test/inspector/debugger/wasm-stepping-with-source-map-expected.txt index 6afed41f41..12865dec50 100644 --- a/test/inspector/debugger/wasm-stepping-with-source-map-expected.txt +++ b/test/inspector/debugger/wasm-stepping-with-source-map-expected.txt @@ -16,7 +16,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): {"0":3} - scope (local): - {"var0":4} + {"$var0":4} - scope (module): -- skipped at (anonymous) (0:17): @@ -28,7 +28,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":3} + {"$var0":3} - scope (module): -- skipped at (anonymous) (0:17): @@ -47,7 +47,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":3} + {"$var0":3} - scope (module): -- skipped at (anonymous) (0:17): @@ -66,7 +66,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":3} + {"$var0":3} - scope (module): -- skipped at (anonymous) (0:17): @@ -78,7 +78,7 @@ at wasm_B (0:58): - scope (wasm-expression-stack): {} - scope (local): - {"var0":3} + {"$var0":3} - scope (module): -- skipped at (anonymous) (0:17): @@ -90,7 +90,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): {"0":2} - scope (local): - {"var0":3} + {"$var0":3} - scope (module): -- skipped at (anonymous) (0:17): @@ -102,7 +102,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":2} + {"$var0":2} - scope (module): -- skipped at (anonymous) (0:17): @@ -114,7 +114,7 @@ at wasm_B (0:58): - scope (wasm-expression-stack): {} - scope (local): - {"var0":2} + {"$var0":2} - scope (module): -- skipped at (anonymous) (0:17): @@ -126,7 +126,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): {"0":1} - scope (local): - {"var0":2} + {"$var0":2} - scope (module): -- skipped at (anonymous) (0:17): @@ -138,7 +138,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -157,7 +157,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -169,7 +169,7 @@ at wasm_B (0:58): - scope (wasm-expression-stack): {} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -181,7 +181,7 @@ at wasm_B (0:45): - scope (wasm-expression-stack): {} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -193,7 +193,7 @@ at wasm_B (0:47): - scope (wasm-expression-stack): {"0":1} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -205,7 +205,7 @@ at wasm_B (0:49): - scope (wasm-expression-stack): {} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -217,7 +217,7 @@ at wasm_B (0:51): - scope (wasm-expression-stack): {"0":1} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -229,7 +229,7 @@ at wasm_B (0:53): - scope (wasm-expression-stack): {"0":1,"1":1} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -241,7 +241,7 @@ at wasm_B (0:54): - scope (wasm-expression-stack): {"0":0} - scope (local): - {"var0":1} + {"$var0":1} - scope (module): -- skipped at (anonymous) (0:17): @@ -253,7 +253,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":0} + {"$var0":0} - scope (module): -- skipped at (anonymous) (0:17): @@ -272,7 +272,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":0} + {"$var0":0} - scope (module): -- skipped at (anonymous) (0:17): @@ -291,7 +291,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":0} + {"$var0":0} - scope (module): -- skipped at (anonymous) (0:17): @@ -310,7 +310,7 @@ at wasm_B (0:56): - scope (wasm-expression-stack): {} - scope (local): - {"var0":0} + {"$var0":0} - scope (module): -- skipped at (anonymous) (0:17): @@ -322,7 +322,7 @@ at wasm_B (0:58): - scope (wasm-expression-stack): {} - scope (local): - {"var0":0} + {"$var0":0} - scope (module): -- skipped at (anonymous) (0:17): diff --git a/test/inspector/debugger/wasm-stepping-with-source-map.js b/test/inspector/debugger/wasm-stepping-with-source-map.js index 5d3a34c84a..18766b89e8 100644 --- a/test/inspector/debugger/wasm-stepping-with-source-map.js +++ b/test/inspector/debugger/wasm-stepping-with-source-map.js @@ -91,14 +91,15 @@ async function waitForPauseAndStep(stepAction) { if (scope.type === 'global' || scope.type === 'module') { InspectorTest.logObject(' -- skipped'); } else { - const {result: {result: {value}}} = - await Protocol.Runtime.callFunctionOn({ - objectId: scope.object.objectId, - functionDeclaration: 'function() { return this; }', - returnByValue: true + const object = {}; + const {result: {result: properties}} = + await Protocol.Runtime.getProperties({ + objectId: scope.object.objectId }); - - InspectorTest.log(` ${JSON.stringify(value)}`); + for (const {name, value: {value}} of properties) { + object[name] = value; + } + InspectorTest.log(` ${JSON.stringify(object)}`); } } }