wasm.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <AK/MemoryStream.h>
  8. #include <AK/StackInfo.h>
  9. #include <LibCore/ArgsParser.h>
  10. #include <LibCore/File.h>
  11. #include <LibCore/MappedFile.h>
  12. #include <LibFileSystem/FileSystem.h>
  13. #include <LibLine/Editor.h>
  14. #include <LibMain/Main.h>
  15. #include <LibWasm/AbstractMachine/AbstractMachine.h>
  16. #include <LibWasm/AbstractMachine/BytecodeInterpreter.h>
  17. #include <LibWasm/Printer/Printer.h>
  18. #include <LibWasm/Types.h>
  19. #include <LibWasm/Wasi.h>
  20. #include <signal.h>
  21. #include <unistd.h>
  22. RefPtr<Line::Editor> g_line_editor;
  23. static OwnPtr<Stream> g_stdout {};
  24. static OwnPtr<Wasm::Printer> g_printer {};
  25. static bool g_continue { false };
  26. static void (*old_signal)(int);
  27. static StackInfo g_stack_info;
  28. static Wasm::DebuggerBytecodeInterpreter g_interpreter(g_stack_info);
  29. static void sigint_handler(int)
  30. {
  31. if (!g_continue) {
  32. signal(SIGINT, old_signal);
  33. kill(getpid(), SIGINT);
  34. }
  35. g_continue = false;
  36. }
  37. static bool post_interpret_hook(Wasm::Configuration&, Wasm::InstructionPointer& ip, Wasm::Instruction const& instr, Wasm::Interpreter const& interpreter)
  38. {
  39. if (interpreter.did_trap()) {
  40. g_continue = false;
  41. warnln("Trapped when executing ip={}", ip);
  42. g_printer->print(instr);
  43. warnln("Trap reason: {}", interpreter.trap_reason());
  44. const_cast<Wasm::Interpreter&>(interpreter).clear_trap();
  45. }
  46. return true;
  47. }
  48. static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPointer& ip, Wasm::Instruction const& instr)
  49. {
  50. static bool always_print_stack = false;
  51. static bool always_print_instruction = false;
  52. if (always_print_stack)
  53. config.dump_stack();
  54. if (always_print_instruction) {
  55. g_stdout->write_until_depleted(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
  56. g_printer->print(instr);
  57. }
  58. if (g_continue)
  59. return true;
  60. g_stdout->write_until_depleted(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
  61. g_printer->print(instr);
  62. DeprecatedString last_command = "";
  63. for (;;) {
  64. auto result = g_line_editor->get_line("> ");
  65. if (result.is_error()) {
  66. return false;
  67. }
  68. auto str = result.release_value();
  69. g_line_editor->add_to_history(str);
  70. if (str.is_empty())
  71. str = last_command;
  72. else
  73. last_command = str;
  74. auto args = str.split_view(' ');
  75. if (args.is_empty())
  76. continue;
  77. auto& cmd = args[0];
  78. if (cmd.is_one_of("h", "help")) {
  79. warnln("Wasm shell commands");
  80. warnln("Toplevel:");
  81. warnln("- [s]tep Run one instruction");
  82. warnln("- next Alias for step");
  83. warnln("- [c]ontinue Execute until a trap or the program exit point");
  84. warnln("- [p]rint <args...> Print various things (see section on print)");
  85. warnln("- call <fn> <args...> Call the function <fn> with the given arguments");
  86. warnln("- set <args...> Set shell option (see section on settings)");
  87. warnln("- unset <args...> Unset shell option (see section on settings)");
  88. warnln("- [h]elp Print this help");
  89. warnln();
  90. warnln("Print:");
  91. warnln("- print [s]tack Print the contents of the stack, including frames and labels");
  92. warnln("- print [[m]em]ory <index> Print the contents of the memory identified by <index>");
  93. warnln("- print [[i]nstr]uction Print the current instruction");
  94. warnln("- print [[f]unc]tion <index> Print the function identified by <index>");
  95. warnln();
  96. warnln("Settings:");
  97. warnln("- set print stack Make the shell print the stack on every instruction executed");
  98. warnln("- set print [instr]uction Make the shell print the instruction that will be executed next");
  99. warnln();
  100. continue;
  101. }
  102. if (cmd.is_one_of("s", "step", "next")) {
  103. return true;
  104. }
  105. if (cmd.is_one_of("p", "print")) {
  106. if (args.size() < 2) {
  107. warnln("Print what?");
  108. continue;
  109. }
  110. auto& what = args[1];
  111. if (what.is_one_of("s", "stack")) {
  112. config.dump_stack();
  113. continue;
  114. }
  115. if (what.is_one_of("m", "mem", "memory")) {
  116. if (args.size() < 3) {
  117. warnln("print what memory?");
  118. continue;
  119. }
  120. auto value = args[2].to_uint<u64>();
  121. if (!value.has_value()) {
  122. warnln("invalid memory index {}", args[2]);
  123. continue;
  124. }
  125. auto mem = config.store().get(Wasm::MemoryAddress(value.value()));
  126. if (!mem) {
  127. warnln("invalid memory index {} (not found)", args[2]);
  128. continue;
  129. }
  130. warnln("{:>32hex-dump}", mem->data().bytes());
  131. continue;
  132. }
  133. if (what.is_one_of("i", "instr", "instruction")) {
  134. g_printer->print(instr);
  135. continue;
  136. }
  137. if (what.is_one_of("f", "func", "function")) {
  138. if (args.size() < 3) {
  139. warnln("print what function?");
  140. continue;
  141. }
  142. auto value = args[2].to_uint<u64>();
  143. if (!value.has_value()) {
  144. warnln("invalid function index {}", args[2]);
  145. continue;
  146. }
  147. auto fn = config.store().get(Wasm::FunctionAddress(value.value()));
  148. if (!fn) {
  149. warnln("invalid function index {} (not found)", args[2]);
  150. continue;
  151. }
  152. if (auto* fn_value = fn->get_pointer<Wasm::HostFunction>()) {
  153. warnln("Host function at {:p}", &fn_value->function());
  154. continue;
  155. }
  156. if (auto* fn_value = fn->get_pointer<Wasm::WasmFunction>()) {
  157. g_printer->print(fn_value->code());
  158. continue;
  159. }
  160. }
  161. }
  162. if (cmd == "call"sv) {
  163. if (args.size() < 2) {
  164. warnln("call what?");
  165. continue;
  166. }
  167. Optional<Wasm::FunctionAddress> address;
  168. auto index = args[1].to_uint<u64>();
  169. if (index.has_value()) {
  170. address = config.frame().module().functions()[index.value()];
  171. } else {
  172. auto& name = args[1];
  173. for (auto& export_ : config.frame().module().exports()) {
  174. if (export_.name() == name) {
  175. if (auto addr = export_.value().get_pointer<Wasm::FunctionAddress>()) {
  176. address = *addr;
  177. break;
  178. }
  179. }
  180. }
  181. }
  182. if (!address.has_value()) {
  183. failed_to_find:;
  184. warnln("Could not find a function {}", args[1]);
  185. continue;
  186. }
  187. auto fn = config.store().get(*address);
  188. if (!fn)
  189. goto failed_to_find;
  190. auto type = fn->visit([&](auto& value) { return value.type(); });
  191. if (type.parameters().size() + 2 != args.size()) {
  192. warnln("Expected {} arguments for call, but found only {}", type.parameters().size(), args.size() - 2);
  193. continue;
  194. }
  195. Vector<u64> values_to_push;
  196. Vector<Wasm::Value> values;
  197. for (size_t index = 2; index < args.size(); ++index)
  198. values_to_push.append(args[index].to_uint().value_or(0));
  199. for (auto& param : type.parameters())
  200. values.append(Wasm::Value { param, values_to_push.take_last() });
  201. Wasm::Result result { Wasm::Trap {} };
  202. {
  203. Wasm::BytecodeInterpreter::CallFrameHandle handle { g_interpreter, config };
  204. result = config.call(g_interpreter, *address, move(values)).assert_wasm_result();
  205. }
  206. if (result.is_trap()) {
  207. warnln("Execution trapped: {}", result.trap().reason);
  208. } else {
  209. if (!result.values().is_empty())
  210. warnln("Returned:");
  211. for (auto& value : result.values()) {
  212. g_stdout->write_until_depleted(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
  213. g_printer->print(value);
  214. }
  215. }
  216. continue;
  217. }
  218. if (cmd.is_one_of("set", "unset")) {
  219. auto value = !cmd.starts_with('u');
  220. if (args.size() < 3) {
  221. warnln("(un)set what (to what)?");
  222. continue;
  223. }
  224. if (args[1] == "print"sv) {
  225. if (args[2] == "stack"sv)
  226. always_print_stack = value;
  227. else if (args[2].is_one_of("instr", "instruction"))
  228. always_print_instruction = value;
  229. else
  230. warnln("Unknown print category '{}'", args[2]);
  231. continue;
  232. }
  233. warnln("Unknown set category '{}'", args[1]);
  234. continue;
  235. }
  236. if (cmd.is_one_of("c", "continue")) {
  237. g_continue = true;
  238. return true;
  239. }
  240. warnln("Command not understood: {}", cmd);
  241. }
  242. }
  243. static Optional<Wasm::Module> parse(StringView filename)
  244. {
  245. auto result = Core::MappedFile::map(filename);
  246. if (result.is_error()) {
  247. warnln("Failed to open {}: {}", filename, result.error());
  248. return {};
  249. }
  250. auto parse_result = Wasm::Module::parse(*result.value());
  251. if (parse_result.is_error()) {
  252. warnln("Something went wrong, either the file is invalid, or there's a bug with LibWasm!");
  253. warnln("The parse error was {}", Wasm::parse_error_to_deprecated_string(parse_result.error()));
  254. return {};
  255. }
  256. return parse_result.release_value();
  257. }
  258. static void print_link_error(Wasm::LinkError const& error)
  259. {
  260. for (auto const& missing : error.missing_imports)
  261. warnln("Missing import '{}'", missing);
  262. }
  263. ErrorOr<int> serenity_main(Main::Arguments arguments)
  264. {
  265. StringView filename;
  266. bool print = false;
  267. bool attempt_instantiate = false;
  268. bool debug = false;
  269. bool export_all_imports = false;
  270. bool shell_mode = false;
  271. bool wasi = false;
  272. DeprecatedString exported_function_to_execute;
  273. Vector<u64> values_to_push;
  274. Vector<DeprecatedString> modules_to_link_in;
  275. Vector<StringView> args_if_wasi;
  276. Vector<StringView> wasi_preopened_mappings;
  277. Core::ArgsParser parser;
  278. parser.add_positional_argument(filename, "File name to parse", "file");
  279. parser.add_option(debug, "Open a debugger", "debug", 'd');
  280. parser.add_option(print, "Print the parsed module", "print", 'p');
  281. parser.add_option(attempt_instantiate, "Attempt to instantiate the module", "instantiate", 'i');
  282. parser.add_option(exported_function_to_execute, "Attempt to execute the named exported function from the module (implies -i)", "execute", 'e', "name");
  283. parser.add_option(export_all_imports, "Export noop functions corresponding to imports", "export-noop", 0);
  284. parser.add_option(shell_mode, "Launch a REPL in the module's context (implies -i)", "shell", 's');
  285. parser.add_option(wasi, "Enable WASI", "wasi", 'w');
  286. parser.add_option(Core::ArgsParser::Option {
  287. .argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
  288. .help_string = "Directory mappings to expose via WASI",
  289. .long_name = "wasi-map-dir",
  290. .short_name = 0,
  291. .value_name = "path[:path]",
  292. .accept_value = [&](StringView str) {
  293. if (!str.is_empty()) {
  294. wasi_preopened_mappings.append(str);
  295. return true;
  296. }
  297. return false;
  298. },
  299. });
  300. parser.add_option(Core::ArgsParser::Option {
  301. .argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
  302. .help_string = "Extra modules to link with, use to resolve imports",
  303. .long_name = "link",
  304. .short_name = 'l',
  305. .value_name = "file",
  306. .accept_value = [&](StringView str) {
  307. if (!str.is_empty()) {
  308. modules_to_link_in.append(str);
  309. return true;
  310. }
  311. return false;
  312. },
  313. });
  314. parser.add_option(Core::ArgsParser::Option {
  315. .argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
  316. .help_string = "Supply arguments to the function (default=0) (expects u64, casts to required type)",
  317. .long_name = "arg",
  318. .short_name = 0,
  319. .value_name = "u64",
  320. .accept_value = [&](StringView str) -> bool {
  321. if (auto v = str.to_uint<u64>(); v.has_value()) {
  322. values_to_push.append(v.value());
  323. return true;
  324. }
  325. return false;
  326. },
  327. });
  328. parser.add_positional_argument(args_if_wasi, "Arguments to pass to the WASI module", "args", Core::ArgsParser::Required::No);
  329. parser.parse(arguments);
  330. if (shell_mode) {
  331. debug = true;
  332. attempt_instantiate = true;
  333. }
  334. if (!shell_mode && debug && exported_function_to_execute.is_empty()) {
  335. warnln("Debug what? (pass -e fn)");
  336. return 1;
  337. }
  338. if (debug || shell_mode) {
  339. old_signal = signal(SIGINT, sigint_handler);
  340. }
  341. if (!exported_function_to_execute.is_empty())
  342. attempt_instantiate = true;
  343. auto parse_result = parse(filename);
  344. if (!parse_result.has_value())
  345. return 1;
  346. g_stdout = TRY(Core::File::standard_output());
  347. g_printer = TRY(try_make<Wasm::Printer>(*g_stdout));
  348. if (print && !attempt_instantiate) {
  349. Wasm::Printer printer(*g_stdout);
  350. printer.print(parse_result.value());
  351. }
  352. if (attempt_instantiate) {
  353. Wasm::AbstractMachine machine;
  354. Optional<Wasm::Wasi::Implementation> wasi_impl;
  355. if (wasi) {
  356. wasi_impl.emplace(Wasm::Wasi::Implementation::Details {
  357. .provide_arguments = [&] {
  358. Vector<String> strings;
  359. for (auto& string : args_if_wasi)
  360. strings.append(String::from_utf8(string).release_value_but_fixme_should_propagate_errors());
  361. return strings; },
  362. .provide_environment = {},
  363. .provide_preopened_directories = [&] {
  364. Vector<Wasm::Wasi::Implementation::MappedPath> paths;
  365. for (auto& string : wasi_preopened_mappings) {
  366. auto split_index = string.find(':');
  367. if (split_index.has_value()) {
  368. LexicalPath host_path { FileSystem::real_path(string.substring_view(0, *split_index)).release_value_but_fixme_should_propagate_errors().to_deprecated_string() };
  369. LexicalPath mapped_path { string.substring_view(*split_index + 1) };
  370. paths.append({move(host_path), move(mapped_path)});
  371. } else {
  372. LexicalPath host_path { FileSystem::real_path(string).release_value_but_fixme_should_propagate_errors().to_deprecated_string() };
  373. LexicalPath mapped_path { string };
  374. paths.append({move(host_path), move(mapped_path)});
  375. }
  376. }
  377. return paths; },
  378. });
  379. }
  380. Core::EventLoop main_loop;
  381. if (debug) {
  382. g_line_editor = Line::Editor::construct();
  383. g_interpreter.pre_interpret_hook = pre_interpret_hook;
  384. g_interpreter.post_interpret_hook = post_interpret_hook;
  385. }
  386. // First, resolve the linked modules
  387. Vector<NonnullOwnPtr<Wasm::ModuleInstance>> linked_instances;
  388. Vector<Wasm::Module> linked_modules;
  389. for (auto& name : modules_to_link_in) {
  390. auto parse_result = parse(name);
  391. if (!parse_result.has_value()) {
  392. warnln("Failed to parse linked module '{}'", name);
  393. return 1;
  394. }
  395. linked_modules.append(parse_result.release_value());
  396. Wasm::Linker linker { linked_modules.last() };
  397. for (auto& instance : linked_instances)
  398. linker.link(*instance);
  399. auto link_result = linker.finish();
  400. if (link_result.is_error()) {
  401. warnln("Linking imported module '{}' failed", name);
  402. print_link_error(link_result.error());
  403. return 1;
  404. }
  405. auto instantiation_result = machine.instantiate(linked_modules.last(), link_result.release_value());
  406. if (instantiation_result.is_error()) {
  407. warnln("Instantiation of imported module '{}' failed: {}", name, instantiation_result.error().error);
  408. return 1;
  409. }
  410. linked_instances.append(instantiation_result.release_value());
  411. }
  412. Wasm::Linker linker { parse_result.value() };
  413. for (auto& instance : linked_instances)
  414. linker.link(*instance);
  415. if (wasi) {
  416. HashMap<Wasm::Linker::Name, Wasm::ExternValue> wasi_exports;
  417. for (auto& entry : linker.unresolved_imports()) {
  418. if (entry.module != "wasi_snapshot_preview1"sv)
  419. continue;
  420. auto function = wasi_impl->function_by_name(entry.name);
  421. if (function.is_error()) {
  422. dbgln("wasi function {} not implemented :(", entry.name);
  423. continue;
  424. }
  425. auto address = machine.store().allocate(function.release_value());
  426. wasi_exports.set(entry, *address);
  427. }
  428. linker.link(wasi_exports);
  429. }
  430. if (export_all_imports) {
  431. HashMap<Wasm::Linker::Name, Wasm::ExternValue> exports;
  432. for (auto& entry : linker.unresolved_imports()) {
  433. if (!entry.type.has<Wasm::TypeIndex>())
  434. continue;
  435. auto type = parse_result.value().type(entry.type.get<Wasm::TypeIndex>());
  436. auto address = machine.store().allocate(Wasm::HostFunction(
  437. [name = entry.name, type = type](auto&, auto& arguments) -> Wasm::Result {
  438. StringBuilder argument_builder;
  439. bool first = true;
  440. for (auto& argument : arguments) {
  441. AllocatingMemoryStream stream;
  442. Wasm::Printer { stream }.print(argument);
  443. if (first)
  444. first = false;
  445. else
  446. argument_builder.append(", "sv);
  447. auto buffer = ByteBuffer::create_uninitialized(stream.used_buffer_size()).release_value_but_fixme_should_propagate_errors();
  448. stream.read_until_filled(buffer).release_value_but_fixme_should_propagate_errors();
  449. argument_builder.append(StringView(buffer).trim_whitespace());
  450. }
  451. dbgln("[wasm runtime] Stub function {} was called with the following arguments: {}", name, argument_builder.to_deprecated_string());
  452. Vector<Wasm::Value> result;
  453. result.ensure_capacity(type.results().size());
  454. for (auto& result_type : type.results())
  455. result.append(Wasm::Value { result_type, 0ull });
  456. return Wasm::Result { move(result) };
  457. },
  458. type));
  459. exports.set(entry, *address);
  460. }
  461. linker.link(exports);
  462. }
  463. auto link_result = linker.finish();
  464. if (link_result.is_error()) {
  465. warnln("Linking main module failed");
  466. print_link_error(link_result.error());
  467. return 1;
  468. }
  469. auto result = machine.instantiate(parse_result.value(), link_result.release_value());
  470. if (result.is_error()) {
  471. warnln("Module instantiation failed: {}", result.error().error);
  472. return 1;
  473. }
  474. auto module_instance = result.release_value();
  475. auto launch_repl = [&] {
  476. Wasm::Configuration config { machine.store() };
  477. Wasm::Expression expression { {} };
  478. config.set_frame(Wasm::Frame {
  479. *module_instance,
  480. Vector<Wasm::Value> {},
  481. expression,
  482. 0,
  483. });
  484. Wasm::Instruction instr { Wasm::Instructions::nop };
  485. Wasm::InstructionPointer ip { 0 };
  486. g_continue = false;
  487. pre_interpret_hook(config, ip, instr);
  488. };
  489. auto print_func = [&](auto const& address) {
  490. Wasm::FunctionInstance* fn = machine.store().get(address);
  491. g_stdout->write_until_depleted(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors();
  492. if (fn) {
  493. g_stdout->write_until_depleted(DeprecatedString::formatted(" wasm function? {}\n", fn->has<Wasm::WasmFunction>()).bytes()).release_value_but_fixme_should_propagate_errors();
  494. fn->visit(
  495. [&](Wasm::WasmFunction const& func) {
  496. Wasm::Printer printer { *g_stdout, 3 };
  497. g_stdout->write_until_depleted(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
  498. printer.print(func.type());
  499. g_stdout->write_until_depleted(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
  500. printer.print(func.code());
  501. },
  502. [](Wasm::HostFunction const&) {});
  503. }
  504. };
  505. if (print) {
  506. // Now, let's dump the functions!
  507. for (auto& address : module_instance->functions()) {
  508. print_func(address);
  509. }
  510. }
  511. if (shell_mode) {
  512. launch_repl();
  513. return 0;
  514. }
  515. if (!exported_function_to_execute.is_empty()) {
  516. Optional<Wasm::FunctionAddress> run_address;
  517. Vector<Wasm::Value> values;
  518. for (auto& entry : module_instance->exports()) {
  519. if (entry.name() == exported_function_to_execute) {
  520. if (auto addr = entry.value().get_pointer<Wasm::FunctionAddress>())
  521. run_address = *addr;
  522. }
  523. }
  524. if (!run_address.has_value()) {
  525. warnln("No such exported function, sorry :(");
  526. return 1;
  527. }
  528. auto instance = machine.store().get(*run_address);
  529. VERIFY(instance);
  530. if (instance->has<Wasm::HostFunction>()) {
  531. warnln("Exported function is a host function, cannot run that yet");
  532. return 1;
  533. }
  534. for (auto& param : instance->get<Wasm::WasmFunction>().type().parameters()) {
  535. if (values_to_push.is_empty())
  536. values.append(Wasm::Value { param, 0ull });
  537. else
  538. values.append(Wasm::Value { param, values_to_push.take_last() });
  539. }
  540. if (print) {
  541. outln("Executing ");
  542. print_func(*run_address);
  543. outln();
  544. }
  545. auto result = machine.invoke(g_interpreter, run_address.value(), move(values)).assert_wasm_result();
  546. if (debug)
  547. launch_repl();
  548. if (result.is_trap()) {
  549. warnln("Execution trapped: {}", result.trap().reason);
  550. } else {
  551. if (!result.values().is_empty())
  552. warnln("Returned:");
  553. for (auto& value : result.values()) {
  554. g_stdout->write_until_depleted(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
  555. g_printer->print(value);
  556. }
  557. }
  558. }
  559. }
  560. return 0;
  561. }