From e7d8a4efc0e6b53221973dcd752157ef20bdb36f Mon Sep 17 00:00:00 2001 From: Kyle Xiao Date: Fri, 18 Oct 2024 23:08:35 +0800 Subject: [PATCH] debug: println tENUM --- internal/reflect/decoder.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/internal/reflect/decoder.go b/internal/reflect/decoder.go index 94f392f..d8e9f24 100644 --- a/internal/reflect/decoder.go +++ b/internal/reflect/decoder.go @@ -74,6 +74,25 @@ func (d *tDecoder) mallocIfPointer(t *tType, p unsafe.Pointer) (ret unsafe.Point return p } +var hextable = "0123456789abcdef" + +func dump4bytes(b []byte) string { + _ = b[3] + return "{" + string([]byte{ + hextable[(b[0]>>4)&0xf], + hextable[b[0]&0xf], + ' ', + hextable[(b[1]>>4)&0xf], + hextable[b[1]&0xf], + ' ', + hextable[(b[2]>>4)&0xf], + hextable[b[2]&0xf], + ' ', + hextable[(b[3]>>4)&0xf], + hextable[b[3]&0xf], + }) + "}" +} + func (d *tDecoder) Decode(b []byte, base unsafe.Pointer, sd *structDesc, maxdepth int) (int, error) { if maxdepth == 0 { return 0, errDepthLimitExceeded @@ -124,6 +143,14 @@ func (d *tDecoder) Decode(b []byte, base unsafe.Pointer, sd *structDesc, maxdept p = d.mallocIfPointer(t, p) if t.FixedSize > 0 { i += decodeFixedSizeTypes(t.T, b[i:], p) + if t.T == tENUM { + println("DEBUG tENUM", + lookupFieldName(sd.rt, f.Offset), + dump4bytes(b[i-4:]), + p, + *(*int64)(p), + ) + } } else { n, err := d.decodeType(t, b[i:], p, maxdepth-1) if err != nil {