From afef1e71408224ee85a0e99a6cc04a666434bfa9 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 18 Mar 2021 21:48:22 +0900 Subject: [PATCH] Add debug code --- internal/encoder/vm_escaped/vm.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/encoder/vm_escaped/vm.go b/internal/encoder/vm_escaped/vm.go index 675effb..60b55ea 100644 --- a/internal/encoder/vm_escaped/vm.go +++ b/internal/encoder/vm_escaped/vm.go @@ -50,6 +50,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt ctxptr := ctx.Ptr() code := codeSet.Code + defer func() { + if err := recover(); err != nil { + fmt.Println("error occurred", err) + fmt.Println(codeSet.Code.Dump()) + fmt.Printf("code = %+v\n", code) + fmt.Println("code.op = ", code.Op, "idx = ", code.DisplayIdx, "p = ", load(ctxptr, code.Idx)) + panic(err) + } + }() + for { switch code.Op { default: