From d16ca5bacc2a2f28fe435e138f41c5133128ae18 Mon Sep 17 00:00:00 2001 From: Steven Massey Date: Sat, 8 May 2021 14:03:10 -0700 Subject: [PATCH] trace bug fixes --- source/m3_core.h | 2 +- source/m3_exec.h | 8 ++++---- source/m3_info.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/m3_core.h b/source/m3_core.h index 57eb669..ce07cf3 100644 --- a/source/m3_core.h +++ b/source/m3_core.h @@ -241,7 +241,7 @@ M3Result ReadLEB_i64 (i64 * o_value, bytes_t * io_bytes, cbytes_t M3Result Read_utf8 (cstr_t * o_utf8, bytes_t * io_bytes, cbytes_t i_end); cstr_t SPrintValue (void * i_value, u8 i_type); -size_t SPrintArg (char * o_string, size_t i_stringBufferSize, m3stack_t i_sp, u8 i_type); +size_t SPrintArg (char * o_string, size_t i_stringBufferSize, voidptr_t i_sp, u8 i_type); void ReportError (IM3Runtime io_runtime, IM3Module i_module, IM3Function i_function, ccstr_t i_errorMessage, ccstr_t i_file, u32 i_lineNum); diff --git a/source/m3_exec.h b/source/m3_exec.h index 60d006c..d9c1376 100644 --- a/source/m3_exec.h +++ b/source/m3_exec.h @@ -83,8 +83,8 @@ d_m3BeginExternC #endif #if d_m3EnableStrace >= 3 - #define d_m3TraceLoad(TYPE,offset,val) d_m3TracePrint("load." #TYPE " 0x%x = %" PRI##TYPE, offset, val) - #define d_m3TraceStore(TYPE,offset,val) d_m3TracePrint("store." #TYPE " 0x%x , %" PRI##TYPE, offset, val) + #define d_m3TraceLoad(TYPE,offset,val) d_m3TracePrint("load." #TYPE " %d 0x%x = %" PRI##TYPE, offset, offset, val) + #define d_m3TraceStore(TYPE,offset,val) d_m3TracePrint("store." #TYPE " %d 0x%x , %" PRI##TYPE, offset, offset, val) #else #define d_m3TraceLoad(TYPE,offset,val) #define d_m3TraceStore(TYPE,offset,val) @@ -727,7 +727,7 @@ d_m3Op (Entry) #if d_m3SkipStackCheck if (true) #else - if (LIKELY((void *)((m3slot_t *) _sp + function->maxStackSlots) < _mem->maxStack)) + if (LIKELY ((void *) (_sp + function->maxStackSlots) < _mem->maxStack)) #endif { #if defined(DEBUG) @@ -744,7 +744,7 @@ d_m3Op (Entry) } #if d_m3EnableStrace >= 2 - d_m3TracePrint("%s %s {", m3_GetFunctionName(function), SPrintFunctionArgList (function, _sp)); + d_m3TracePrint("%s %s {", m3_GetFunctionName(function), SPrintFunctionArgList (function, _sp + function->numRetSlots)); trace_rt->callDepth++; #endif diff --git a/source/m3_info.c b/source/m3_info.c index 53710db..15e1f71 100644 --- a/source/m3_info.c +++ b/source/m3_info.c @@ -100,7 +100,7 @@ cstr_t SPrintFuncTypeSignature (IM3FuncType i_funcType) } -size_t SPrintArg (char * o_string, size_t i_stringBufferSize, m3stack_t i_sp, u8 i_type) +size_t SPrintArg (char * o_string, size_t i_stringBufferSize, voidptr_t i_sp, u8 i_type) { int len = 0; @@ -142,7 +142,7 @@ cstr_t SPrintFunctionArgList (IM3Function i_function, m3stack_t i_sp) ret = snprintf (s, e-s, "("); s += M3_MAX (0, ret); - m3stack_t argSp = i_sp; + u64 * argSp = (u64 *) i_sp; IM3FuncType funcType = i_function->funcType; if (funcType)