From 5093e5bd78c14b61bc9a582567d49f7eba623ea3 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 27 Mar 2021 12:35:43 +0900 Subject: [PATCH] Add type infromation to the debug information --- internal/encoder/compiler.go | 1 + internal/encoder/compiler_norace.go | 1 + internal/encoder/compiler_race.go | 1 + internal/encoder/encoder.go | 1 + internal/encoder/vm_debug/vm.go | 3 +++ 5 files changed, 7 insertions(+) diff --git a/internal/encoder/compiler.go b/internal/encoder/compiler.go index aada822..76751a9 100644 --- a/internal/encoder/compiler.go +++ b/internal/encoder/compiler.go @@ -65,6 +65,7 @@ func compileToGetCodeSetSlowPath(typeptr uintptr) (*OpcodeSet, error) { code = copyOpcode(code) codeLength := code.TotalLength() codeSet := &OpcodeSet{ + Type: copiedType, Code: code, CodeLength: codeLength, } diff --git a/internal/encoder/compiler_norace.go b/internal/encoder/compiler_norace.go index f500779..984a6fb 100644 --- a/internal/encoder/compiler_norace.go +++ b/internal/encoder/compiler_norace.go @@ -30,6 +30,7 @@ func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) { code = copyOpcode(code) codeLength := code.TotalLength() codeSet := &OpcodeSet{ + Type: copiedType, Code: code, CodeLength: codeLength, } diff --git a/internal/encoder/compiler_race.go b/internal/encoder/compiler_race.go index 3fecef7..7c11308 100644 --- a/internal/encoder/compiler_race.go +++ b/internal/encoder/compiler_race.go @@ -36,6 +36,7 @@ func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) { code = copyOpcode(code) codeLength := code.TotalLength() codeSet := &OpcodeSet{ + Type: copiedType, Code: code, CodeLength: codeLength, } diff --git a/internal/encoder/encoder.go b/internal/encoder/encoder.go index 0e348cf..a7371ec 100644 --- a/internal/encoder/encoder.go +++ b/internal/encoder/encoder.go @@ -130,6 +130,7 @@ func (t OpType) IsMultipleOpField() bool { } type OpcodeSet struct { + Type *runtime.Type Code *Opcode CodeLength int } diff --git a/internal/encoder/vm_debug/vm.go b/internal/encoder/vm_debug/vm.go index 0dac507..c55827a 100644 --- a/internal/encoder/vm_debug/vm.go +++ b/internal/encoder/vm_debug/vm.go @@ -45,6 +45,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt defer func() { if err := recover(); err != nil { fmt.Println("=============[DEBUG]===============") + fmt.Println("* [TYPE]") + fmt.Println(codeSet.Type) + fmt.Printf("\n") fmt.Println("* [ALL OPCODE]") fmt.Println(codeSet.Code.Dump()) fmt.Printf("\n")