Commit f41941a0 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

Use WasmValue in inspector

Convert wasm-value into internal::WasmValue, then to debug::WasmValue.
This is then copied into a CDP protocol object via a new class,
WasmValueMirror.

Bug: v8:10347
Change-Id: I5778d2cc5701caf82e4a97ac329303e510695b74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2151130Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarKim-Anh Tran <kimanh@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67908}
parent 4e5fabae
......@@ -10311,8 +10311,8 @@ int debug::WasmValue::value_type() {
v8::Local<v8::Array> debug::WasmValue::bytes() {
i::Handle<i::WasmValue> obj = Utils::OpenHandle(this);
// Should only be called on i32, i64, f32, f64, s128.
DCHECK_GE(1, obj->value_type());
DCHECK_LE(5, obj->value_type());
DCHECK_LE(1, obj->value_type());
DCHECK_GE(5, obj->value_type());
i::Isolate* isolate = obj->GetIsolate();
i::Handle<i::Object> bytes_or_ref(obj->bytes_or_ref(), isolate);
......
......@@ -39,6 +39,26 @@ V8InternalValueType v8InternalValueTypeFrom(v8::Local<v8::Context> context,
return inspectedContext->getInternalType(value.As<v8::Object>());
}
template <typename ResultType>
ResultType unpackWasmValue(v8::Local<v8::Context> context,
v8::Local<v8::Array> array) {
ResultType result;
constexpr int kSize = sizeof(result);
uint8_t buffer[kSize];
for (int i = 0; i < kSize; i++) {
v8::Local<v8::Int32> i32 =
array->Get(context, i).ToLocalChecked().As<v8::Int32>();
buffer[i] = static_cast<uint8_t>(i32->Value());
}
memcpy(&result, buffer, kSize);
return result;
}
// Partial list of Wasm's ValueType, copied here to avoid including internal
// header. Using an unscoped enumeration here to allow implicit conversions from
// int. Keep in sync with ValueType::Kind in wasm/value-type.h.
enum WasmValueType { kStmt, kI32, kI64, kF32, kF64, kS128, kAnyRef };
Response toProtocolValue(v8::Local<v8::Context> context,
v8::Local<v8::Value> value, int maxDepth,
std::unique_ptr<protocol::Value>* result) {
......@@ -128,6 +148,49 @@ Response toProtocolValue(v8::Local<v8::Context> context,
*result = std::move(jsonObject);
return Response::Success();
}
if (v8::debug::WasmValue::IsWasmValue(value)) {
auto wasmValue = value.As<v8::debug::WasmValue>();
// Convert serializable Wasm values (i32, f32, f64) into protocol values.
// Not all i64 values are representable by double, so always represent it as
// a String here.
switch (wasmValue->value_type()) {
case kI32: {
*result = protocol::FundamentalValue::create(
unpackWasmValue<int32_t>(context, wasmValue->bytes()));
break;
}
case kI64: {
*result = protocol::StringValue::create(String16::fromInteger64(
unpackWasmValue<int64_t>(context, wasmValue->bytes())));
break;
}
case kF32: {
*result = protocol::FundamentalValue::create(
unpackWasmValue<float>(context, wasmValue->bytes()));
break;
}
case kF64: {
*result = protocol::FundamentalValue::create(
unpackWasmValue<double>(context, wasmValue->bytes()));
break;
}
case kAnyRef: {
std::unique_ptr<protocol::Value> anyrefValue;
Response response =
toProtocolValue(context, wasmValue->ref(), maxDepth, &anyrefValue);
if (!response.IsSuccess()) return response;
*result = std::move(anyrefValue);
break;
}
default: {
UNIMPLEMENTED();
}
}
return Response::Success();
}
return Response::ServerError("Object couldn't be returned by value");
}
......@@ -398,6 +461,112 @@ class PrimitiveValueMirror final : public ValueMirror {
String16 m_subtype;
};
class WasmValueMirror final : public ValueMirror {
public:
explicit WasmValueMirror(v8::Local<v8::debug::WasmValue> value)
: m_value(value) {}
v8::Local<v8::Value> v8Value() const override { return m_value; }
Response buildRemoteObject(
v8::Local<v8::Context> context, WrapMode mode,
std::unique_ptr<RemoteObject>* result) const override {
bool serializable;
String16 descriptionValue = description(context, &serializable);
*result = RemoteObject::create()
.setType(RemoteObject::TypeEnum::Wasm)
.setSubtype(subtype())
.setDescription(descriptionValue)
.build();
if (serializable) {
std::unique_ptr<protocol::Value> protocolValue;
toProtocolValue(context, m_value, &protocolValue);
(*result)->setValue(std::move(protocolValue));
} else {
(*result)->setUnserializableValue(descriptionValue);
}
return Response::Success();
}
void buildPropertyPreview(
v8::Local<v8::Context> context, const String16& name,
std::unique_ptr<PropertyPreview>* result) const override {
bool serializable;
*result = PropertyPreview::create()
.setName(name)
.setType(RemoteObject::TypeEnum::Wasm)
.setSubtype(subtype())
.setValue(description(context, &serializable))
.build();
}
void buildEntryPreview(
v8::Local<v8::Context> context, int* nameLimit, int* indexLimit,
std::unique_ptr<ObjectPreview>* preview) const override {
bool serializable;
*preview =
ObjectPreview::create()
.setType(RemoteObject::TypeEnum::Wasm)
.setSubtype(subtype())
.setDescription(description(context, &serializable))
.setOverflow(false)
.setProperties(std::make_unique<protocol::Array<PropertyPreview>>())
.build();
}
private:
String16 subtype() const {
switch (m_value->value_type()) {
case kI32:
return RemoteObject::SubtypeEnum::I32;
case kI64:
return RemoteObject::SubtypeEnum::I64;
case kF32:
return RemoteObject::SubtypeEnum::F32;
case kF64:
return RemoteObject::SubtypeEnum::F64;
case kAnyRef:
return RemoteObject::SubtypeEnum::Anyref;
default:
UNREACHABLE();
}
}
String16 description(v8::Local<v8::Context> context,
bool* serializable) const {
*serializable = true;
switch (m_value->value_type()) {
case kI32: {
return String16::fromInteger(
unpackWasmValue<int32_t>(context, m_value->bytes()));
}
case kI64: {
*serializable = false;
return String16::fromInteger64(
unpackWasmValue<int64_t>(context, m_value->bytes()));
}
case kF32: {
return String16::fromDouble(
unpackWasmValue<float>(context, m_value->bytes()));
}
case kF64: {
return String16::fromDouble(
unpackWasmValue<double>(context, m_value->bytes()));
}
case kAnyRef: {
return descriptionForObject(context->GetIsolate(),
m_value->ref().As<v8::Object>());
}
default: {
*serializable = false;
return String16("Unknown");
}
}
}
v8::Local<v8::debug::WasmValue> m_value;
};
class NumberMirror final : public ValueMirror {
public:
explicit NumberMirror(v8::Local<v8::Number> value) : m_value(value) {}
......@@ -1603,8 +1772,7 @@ std::unique_ptr<ValueMirror> ValueMirror::create(v8::Local<v8::Context> context,
return std::make_unique<SymbolMirror>(value.As<v8::Symbol>());
}
if (v8::debug::WasmValue::IsWasmValue(value)) {
// TODO(v8:10347) WasmValue is not created anywhere yet.
UNIMPLEMENTED();
return std::make_unique<WasmValueMirror>(value.As<v8::debug::WasmValue>());
}
auto clientSubtype = (value->IsUndefined() || value->IsObject())
? clientFor(context)->valueSubtype(value)
......
......@@ -50,28 +50,43 @@ Handle<String> PrintFToOneByteString(Isolate* isolate, const char* format,
}
Handle<Object> WasmValueToValueObject(Isolate* isolate, WasmValue value) {
Handle<ByteArray> bytes;
switch (value.type().kind()) {
case ValueType::kI32:
if (Smi::IsValid(value.to<int32_t>()))
return handle(Smi::FromInt(value.to<int32_t>()), isolate);
return PrintFToOneByteString<false>(isolate, "%d", value.to<int32_t>());
case ValueType::kI32: {
int32_t val = value.to_i32();
bytes = isolate->factory()->NewByteArray(sizeof(val));
memcpy(bytes->GetDataStartAddress(), &val, sizeof(val));
break;
}
case ValueType::kI64: {
int64_t i64 = value.to<int64_t>();
int32_t i32 = static_cast<int32_t>(i64);
if (i32 == i64 && Smi::IsValid(i32))
return handle(Smi::FromIntptr(i32), isolate);
return PrintFToOneByteString<false>(isolate, "%" PRId64, i64);
int64_t val = value.to_i64();
bytes = isolate->factory()->NewByteArray(sizeof(val));
memcpy(bytes->GetDataStartAddress(), &val, sizeof(val));
break;
}
case ValueType::kF32:
return isolate->factory()->NewNumber(value.to<float>());
case ValueType::kF64:
return isolate->factory()->NewNumber(value.to<double>());
case ValueType::kAnyRef:
return value.to_anyref();
default:
case ValueType::kF32: {
float val = value.to_f32();
bytes = isolate->factory()->NewByteArray(sizeof(val));
memcpy(bytes->GetDataStartAddress(), &val, sizeof(val));
break;
}
case ValueType::kF64: {
double val = value.to_f64();
bytes = isolate->factory()->NewByteArray(sizeof(val));
memcpy(bytes->GetDataStartAddress(), &val, sizeof(val));
break;
}
case ValueType::kAnyRef: {
return isolate->factory()->NewWasmValue(
static_cast<int32_t>(value.type().kind()), value.to_anyref());
}
default: {
UNIMPLEMENTED();
return isolate->factory()->undefined_value();
}
}
return isolate->factory()->NewWasmValue(
static_cast<int32_t>(value.type().kind()), bytes);
}
MaybeHandle<String> GetLocalNameString(Isolate* isolate,
......
......@@ -29,6 +29,11 @@ function instantiate(bytes) {
const evalWithUrl = (code, url) => Protocol.Runtime.evaluate(
{'expression': code + '\n//# sourceURL=v8://test/' + url});
function getWasmValue(value) {
return typeof (value.value) === 'undefined' ? value.unserializableValue :
value.value;
}
Protocol.Debugger.onPaused(async msg => {
let loc = msg.params.callFrames[0].location;
let line = [`Paused at offset ${loc.columnNumber}`];
......@@ -42,11 +47,11 @@ Protocol.Debugger.onPaused(async msg => {
for (var value of scope_properties.result.result) {
let msg = await Protocol.Runtime.getProperties(
{objectId: value.value.objectId});
let str = msg.result.result.map(elem => elem.value.value).join(', ');
let str = msg.result.result.map(elem => getWasmValue(elem.value)).join(', ');
line.push(`${value.name}: [${str}]`);
}
} else {
let str = scope_properties.result.result.map(elem => elem.value.value).join(', ');
let str = scope_properties.result.result.map(elem => getWasmValue(elem.value)).join(', ');
line.push(`${scope.type}: [${str}]`);
}
}
......
......@@ -14,23 +14,23 @@ Script wasm://wasm/c4eb034a byte offset 85: Wasm opcode 0x20
Scope:
at C (interpreted) (0:85):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "i32_arg": 42 (number), "i32_local": 0 (number)
locals: "i32_arg": 42 (i32), "i32_local": 0 (i32)
- scope (wasm-expression-stack):
at B (liftoff) (0:76):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -41,24 +41,24 @@ Script wasm://wasm/c4eb034a byte offset 87: Wasm opcode 0x24
Scope:
at C (interpreted) (0:87):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "i32_arg": 42 (number), "i32_local": 0 (number)
locals: "i32_arg": 42 (i32), "i32_local": 0 (i32)
- scope (wasm-expression-stack):
0: 42 (number)
0: 42 (i32)
at B (liftoff) (0:76):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 0 (number)
globals: "global0": 0 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -69,23 +69,23 @@ Script wasm://wasm/c4eb034a byte offset 89: Wasm opcode 0x41
Scope:
at C (interpreted) (0:89):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "i32_arg": 42 (number), "i32_local": 0 (number)
locals: "i32_arg": 42 (i32), "i32_local": 0 (i32)
- scope (wasm-expression-stack):
at B (liftoff) (0:76):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -96,24 +96,24 @@ Script wasm://wasm/c4eb034a byte offset 91: Wasm opcode 0x21
Scope:
at C (interpreted) (0:91):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "i32_arg": 42 (number), "i32_local": 0 (number)
locals: "i32_arg": 42 (i32), "i32_local": 0 (i32)
- scope (wasm-expression-stack):
0: 47 (number)
0: 47 (i32)
at B (liftoff) (0:76):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -124,23 +124,23 @@ Script wasm://wasm/c4eb034a byte offset 93: Wasm opcode 0x0b
Scope:
at C (interpreted) (0:93):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "i32_arg": 42 (number), "i32_local": 47 (number)
locals: "i32_arg": 42 (i32), "i32_local": 47 (i32)
- scope (wasm-expression-stack):
at B (liftoff) (0:76):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -151,17 +151,17 @@ Script wasm://wasm/c4eb034a byte offset 78: Wasm opcode 0x1a
Scope:
at B (liftoff) (0:78):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
1: 3 (number)
0: 42 (i32)
1: 3 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -172,16 +172,16 @@ Script wasm://wasm/c4eb034a byte offset 79: Wasm opcode 0x1a
Scope:
at B (liftoff) (0:79):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
0: 42 (number)
0: 42 (i32)
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -192,15 +192,15 @@ Script wasm://wasm/c4eb034a byte offset 80: Wasm opcode 0x0b
Scope:
at B (liftoff) (0:80):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "0": 0 (number), "i32_arg": 42 (number), "i32_local": 0 (number), "f32_local": 7.199999809265137 (number), "var5": 0 (number)
locals: "0": 0 (f32), "i32_arg": 42 (i32), "i32_local": 0 (i32), "f32_local": 7.199999809265137 (f32), "var5": 0 (f32)
- scope (wasm-expression-stack):
at A (liftoff) (0:54):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......@@ -211,9 +211,9 @@ Script wasm://wasm/c4eb034a byte offset 56: Wasm opcode 0x0b
Scope:
at A (liftoff) (0:56):
- scope (module):
globals: "global0": 42 (number)
globals: "global0": 42 (i32)
- scope (local):
locals: "var0": 42 (number)
locals: "var0": 42 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
- scope (global):
......
......@@ -149,11 +149,11 @@ async function getScopeValues(value) {
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
printIfFailure(msg);
const printProperty = function(elem) {
return `"${elem.name}": ${elem.value.value} (${elem.value.type})`;
return `"${elem.name}": ${getWasmValue(elem.value)} (${elem.value.subtype})`;
}
return msg.result.result.map(printProperty).join(', ');
}
return value.value + ' (' + value.type + ')';
return getWasmValue(value) + ' (' + value.subtype + ')';
}
async function dumpScopeProperties(message) {
......@@ -163,3 +163,9 @@ async function dumpScopeProperties(message) {
InspectorTest.log(' ' + value.name + ': ' + value_str);
}
}
function getWasmValue(wasmValue) {
return typeof (wasmValue.value) === 'undefined' ?
wasmValue.unserializableValue :
wasmValue.value;
}
......@@ -147,11 +147,11 @@ async function getScopeValues(value) {
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
printIfFailure(msg);
const printProperty = function(elem) {
return `"${elem.name}": ${elem.value.value} (${elem.value.type})`;
return `"${elem.name}": ${getWasmValue(elem.value)} (${elem.value.subtype})`;
}
return msg.result.result.map(printProperty).join(', ');
}
return value.value + ' (' + value.type + ')';
return getWasmValue(value) + ' (' + value.subtype + ')';
}
async function dumpScopeProperties(message) {
......@@ -161,3 +161,9 @@ async function dumpScopeProperties(message) {
InspectorTest.log(' ' + value.name + ': ' + value_str);
}
}
function getWasmValue(wasmValue) {
return typeof (wasmValue.value) === 'undefined' ?
wasmValue.unserializableValue :
wasmValue.value;
}
......@@ -13,7 +13,7 @@ at wasm_A (0:38):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -36,7 +36,7 @@ at wasm_A (0:39):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -46,7 +46,7 @@ Scope:
at wasm_B (0:45):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -56,9 +56,9 @@ Scope:
at wasm_B (0:47):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
0: 3 (number)
0: 3 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -67,7 +67,7 @@ Scope:
at wasm_B (0:49):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -77,9 +77,9 @@ Scope:
at wasm_B (0:51):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
0: 3 (number)
0: 3 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -88,10 +88,10 @@ Scope:
at wasm_B (0:53):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
0: 3 (number)
1: 1 (number)
0: 3 (i32)
1: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -100,9 +100,9 @@ Scope:
at wasm_B (0:54):
- scope (module):
- scope (local):
locals: "var0": 3 (number)
locals: "var0": 3 (i32)
- scope (wasm-expression-stack):
0: 2 (number)
0: 2 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -115,7 +115,7 @@ at wasm_A (0:38):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -129,7 +129,7 @@ at wasm_A (0:39):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -139,7 +139,7 @@ Scope:
at wasm_B (0:45):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -149,9 +149,9 @@ Scope:
at wasm_B (0:47):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
0: 2 (number)
0: 2 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -160,7 +160,7 @@ Scope:
at wasm_B (0:49):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -170,9 +170,9 @@ Scope:
at wasm_B (0:51):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
0: 2 (number)
0: 2 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -181,10 +181,10 @@ Scope:
at wasm_B (0:53):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
0: 2 (number)
1: 1 (number)
0: 2 (i32)
1: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -193,9 +193,9 @@ Scope:
at wasm_B (0:54):
- scope (module):
- scope (local):
locals: "var0": 2 (number)
locals: "var0": 2 (i32)
- scope (wasm-expression-stack):
0: 1 (number)
0: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -208,7 +208,7 @@ at wasm_A (0:38):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -222,7 +222,7 @@ at wasm_A (0:39):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -232,7 +232,7 @@ Scope:
at wasm_B (0:45):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -242,9 +242,9 @@ Scope:
at wasm_B (0:47):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
0: 1 (number)
0: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -253,7 +253,7 @@ Scope:
at wasm_B (0:49):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -263,9 +263,9 @@ Scope:
at wasm_B (0:51):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
0: 1 (number)
0: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -274,10 +274,10 @@ Scope:
at wasm_B (0:53):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
0: 1 (number)
1: 1 (number)
0: 1 (i32)
1: 1 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -286,9 +286,9 @@ Scope:
at wasm_B (0:54):
- scope (module):
- scope (local):
locals: "var0": 1 (number)
locals: "var0": 1 (i32)
- scope (wasm-expression-stack):
0: 0 (number)
0: 0 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -301,7 +301,7 @@ at wasm_A (0:38):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 0 (number)
locals: "var0": 0 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -315,7 +315,7 @@ at wasm_A (0:39):
at wasm_B (0:56):
- scope (module):
- scope (local):
locals: "var0": 0 (number)
locals: "var0": 0 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -325,7 +325,7 @@ Scope:
at wasm_B (0:45):
- scope (module):
- scope (local):
locals: "var0": 0 (number)
locals: "var0": 0 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......@@ -335,9 +335,9 @@ Scope:
at wasm_B (0:47):
- scope (module):
- scope (local):
locals: "var0": 0 (number)
locals: "var0": 0 (i32)
- scope (wasm-expression-stack):
0: 0 (number)
0: 0 (i32)
at (anonymous) (0:17):
-- skipped
Paused:
......@@ -346,7 +346,7 @@ Scope:
at wasm_B (0:61):
- scope (module):
- scope (local):
locals: "var0": 0 (number)
locals: "var0": 0 (i32)
- scope (wasm-expression-stack):
at (anonymous) (0:17):
-- skipped
......
......@@ -103,15 +103,20 @@ Protocol.Debugger.onPaused(async msg => {
Protocol.Debugger.resume();
});
function getWasmValue(value) {
return typeof (value.value) === 'undefined' ? value.unserializableValue :
value.value;
}
async function getScopeValues(value) {
if (value.type == 'object') {
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
const printProperty = function(elem) {
return `"${elem.name}": ${elem.value.value} (${elem.value.type})`;
return `"${elem.name}": ${getWasmValue(elem.value)} (${elem.value.subtype})`;
}
return msg.result.result.map(printProperty).join(', ');
}
return value.value + ' (' + value.type + ')';
return getWasmValue(value) + ' (' + value.subtype + ')';
}
(async function test() {
......
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