From 02be7e9cc7bcaef76c8be96796384bd58a535943 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Thu, 24 Aug 2023 15:35:11 -0300 Subject: [PATCH] feat: forward application exit status --- src/cartesi-machine.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cartesi-machine.lua b/src/cartesi-machine.lua index 7fdb94153..b438c3fb2 100755 --- a/src/cartesi-machine.lua +++ b/src/cartesi-machine.lua @@ -1461,6 +1461,12 @@ local function check_rollup_htif_config(htif) assert(htif.yield_automatic, "yield automatic must be enabled for rollup") end +local function get_halt(machine) + local cmd = machine:read_htif_tohost_cmd() + local data = machine:read_htif_tohost_data() >> 1 -- lsb is always 1 + return cmd, data +end + local function get_yield(machine) local cmd = machine:read_htif_tohost_cmd() local data = machine:read_htif_tohost_data() @@ -1698,7 +1704,8 @@ else cycles = machine:read_mcycle() -- deal with halt if machine:read_iflags_H() then - exit_code = machine:read_htif_tohost_data() >> 1 + local _, data = get_halt(machine) + exit_code = data if exit_code ~= 0 then stderr("\nHalted with payload: %u\n", exit_code) else