From a80afd764142e6b6804760fe0c9521fd0df0d1dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 7 May 2021 00:33:05 +0200 Subject: [PATCH] :art: Better traces --- src/vm/vm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vm/vm.c b/src/vm/vm.c index 3bd9f363..d16bebf2 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -86,13 +86,17 @@ ANN static bool unwind(VM_Shred shred, const Symbol effect, const m_uint size) { ANN static void trace(VM_Shred shred, const m_uint size) { const m_uint line = vector_at(&shred->info->line, size-1); m_uint i; + bool can_skip = false; for(i = size; --i;) { - if(VPTR(&shred->info->line, i-1)) + const m_uint val = VPTR(&shred->info->line, i-1); + if(!val) + can_skip = true; + else if(can_skip && val) break; } loc_t loc = {.first={.line=line, .column=1},.last={.line=line, .column=1}}; - gw_err(" {-B}┃{0} in function {+}%s{0}{-}:{0}\n", shred->code->name); gwerr_secondary("called from here", code_name(shred->code->name, true), loc); + gw_err(" {M}┗━╸{0} {-}in code{0} {+W}%s{0}{-}:{0}\n", shred->code->name); if(shred->mem == (m_bit*)shred + sizeof(struct VM_Shred_) + SIZEOF_REG) return; shred_unwind(shred); @@ -113,6 +117,7 @@ ANN void handle(VM_Shred shred, const m_str effect) { shred->reg = reg; shred->mem = mem; shred->code = code; + gw_err("\n{-/}here is the trace:\n"); trace(shred, vector_size(&shred->info->line)); } vm_shred_exit(shred); -- 2.43.0