Skip to content

Commit 5b92b90

Browse files
authored
Merge pull request #552 from ewasm/wabt-debug
wabt: support all functions in the debug namespace
2 parents 96b7fb3 + 58e3190 commit 5b92b90

1 file changed

Lines changed: 56 additions & 2 deletions

File tree

src/wabt.cpp

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,20 @@ ExecutionResult WabtEngine::execute(
590590
hostModule = env.AppendHostModule("debug");
591591
heraAssert(hostModule, "Failed to create host module.");
592592

593+
hostModule->AppendFuncExport(
594+
"printMem",
595+
{{Type::I32, Type::I32}, {}},
596+
[&interface](
597+
const interp::HostFunc*,
598+
const interp::FuncSignature*,
599+
const interp::TypedValues& args,
600+
interp::TypedValues&
601+
) {
602+
interface.debugPrintMem(false, args[0].value.i32, args[1].value.i32);
603+
return interp::Result::Ok;
604+
}
605+
);
606+
593607
hostModule->AppendFuncExport(
594608
"printMemHex",
595609
{{Type::I32, Type::I32}, {}},
@@ -599,7 +613,21 @@ ExecutionResult WabtEngine::execute(
599613
const interp::TypedValues& args,
600614
interp::TypedValues&
601615
) {
602-
interface.debugPrintMem(1, args[0].value.i32, args[1].value.i32);
616+
interface.debugPrintMem(true, args[0].value.i32, args[1].value.i32);
617+
return interp::Result::Ok;
618+
}
619+
);
620+
621+
hostModule->AppendFuncExport(
622+
"printStorage",
623+
{{Type::I32, Type::I32}, {}},
624+
[&interface](
625+
const interp::HostFunc*,
626+
const interp::FuncSignature*,
627+
const interp::TypedValues& args,
628+
interp::TypedValues&
629+
) {
630+
interface.debugPrintStorage(false, args[0].value.i32);
603631
return interp::Result::Ok;
604632
}
605633
);
@@ -613,7 +641,7 @@ ExecutionResult WabtEngine::execute(
613641
const interp::TypedValues& args,
614642
interp::TypedValues&
615643
) {
616-
interface.debugPrintStorage(1, args[0].value.i32);
644+
interface.debugPrintStorage(true, args[0].value.i32);
617645
return interp::Result::Ok;
618646
}
619647
);
@@ -1124,6 +1152,19 @@ void WabtEngine::verifyContract(bytes_view code) {
11241152
hostModule = env.AppendHostModule("debug");
11251153
heraAssert(hostModule, "Failed to create host module.");
11261154

1155+
hostModule->AppendFuncExport(
1156+
"printMem",
1157+
{{Type::I32, Type::I32}, {}},
1158+
[&](
1159+
const interp::HostFunc*,
1160+
const interp::FuncSignature*,
1161+
const interp::TypedValues&,
1162+
interp::TypedValues&
1163+
) {
1164+
return interp::Result::Ok;
1165+
}
1166+
);
1167+
11271168
hostModule->AppendFuncExport(
11281169
"printMemHex",
11291170
{{Type::I32, Type::I32}, {}},
@@ -1137,6 +1178,19 @@ void WabtEngine::verifyContract(bytes_view code) {
11371178
}
11381179
);
11391180

1181+
hostModule->AppendFuncExport(
1182+
"printStorage",
1183+
{{Type::I32, Type::I32}, {}},
1184+
[&](
1185+
const interp::HostFunc*,
1186+
const interp::FuncSignature*,
1187+
const interp::TypedValues&,
1188+
interp::TypedValues&
1189+
) {
1190+
return interp::Result::Ok;
1191+
}
1192+
);
1193+
11401194
hostModule->AppendFuncExport(
11411195
"printStorageHex",
11421196
{{Type::I32, Type::I32}, {}},

0 commit comments

Comments
 (0)