From 6cd489408fcb605781c5832d224871be255b8464 Mon Sep 17 00:00:00 2001 From: Marcos Pernambuco Motta <1091485+mpernambuco@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:10:42 -0300 Subject: [PATCH] feat: change layout of uarch json logs --- src/Makefile | 2 +- tests/lua/uarch-riscv-tests.lua | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Makefile b/src/Makefile index 0c26e7c50..d4819122e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,7 @@ EMULATOR_MARCHID=17 EMULATOR_VERSION_MAJOR=0 EMULATOR_VERSION_MINOR=18 EMULATOR_VERSION_PATCH=0 -EMULATOR_VERSION_LABEL= +EMULATOR_VERSION_LABEL=-test5 TARGET_OS?=$(shell uname) diff --git a/tests/lua/uarch-riscv-tests.lua b/tests/lua/uarch-riscv-tests.lua index d2ef4fd6f..148ccbbf1 100755 --- a/tests/lua/uarch-riscv-tests.lua +++ b/tests/lua/uarch-riscv-tests.lua @@ -389,18 +389,16 @@ local function write_access_to_log(access, out, indent, last) util.indentout(out, indent + 1, '"type": "%s",\n', access.type) util.indentout(out, indent + 1, '"address": %u,\n', access.address) util.indentout(out, indent + 1, '"log2_size": %u,\n', access.log2_size) + local read_value = '""' -- Solidity JSON parser breaks, if this field is null + if access.read then read_value = '"' .. util.hexstring(access.read) .. '"' end + util.indentout(out, indent + 1, '"read_value": %s,\n', read_value) + util.indentout(out, indent + 1, '"read_hash": "%s",\n', util.hexhash(access.read_hash)) if access.type == "write" then - local value = "null" - if access.written then value = '"' .. util.hexstring(access.written) .. '"' end - util.indentout(out, indent + 1, '"value": %s,', value) - util.indentout(out, indent + 1, '"hash": "%s",', util.hexhash(access.written_hash)) - util.indentout(out, indent + 1, '"read_hash": "%s"', util.hexhash(access.read_hash)) + util.indentout(out, indent + 1, '"written_hash": "%s"', util.hexhash(access.written_hash)) else - local value = "null" - if access.read then value = '"' .. util.hexstring(access.read) .. '"' end - util.indentout(out, indent + 1, '"value": %s,', value) - util.indentout(out, indent + 1, '"hash": "%s",', util.hexhash(access.read_hash)) - util.indentout(out, indent + 1, '"read_hash": "%s"', util.hexhash(access.read_hash)) + -- This field must always be present and can't be null, in order to allow the Solidity JSON + -- parser to read log correctly. + util.indentout(out, indent + 1, '"written_hash": ""') end if access.sibling_hashes then out:write(",\n")