Skip to content

Commit

Permalink
feat: change layout of uarch json logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpernambuco committed Aug 5, 2024
1 parent 0721f0a commit 3aaee22
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tests/lua/uarch-riscv-tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 3aaee22

Please sign in to comment.