From 141546d4c962435c8ba439ac7cf91bb48fcacc55 Mon Sep 17 00:00:00 2001 From: xqbumu Date: Tue, 21 Jan 2025 16:05:48 +0800 Subject: [PATCH] fix: handle pointer types with empty package paths. - When the type is a pointer, and the package path is empty, read the package path from the uncommon type. Signed-off-by: xqbumu --- type2.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/type2.go b/type2.go index a1de16f..8a6f54d 100644 --- a/type2.go +++ b/type2.go @@ -366,6 +366,14 @@ func (p *typeParser) parseType(address uint64) (*GoType, error) { count += c if uc.Mcount != 0 { + + // When typ.Kind is reflect.Ptr, PackagePath is not parsed, so read + // PkgPath from uncommonType as typ's PackagePath + if typ.Kind == reflect.Ptr && len(typ.PackagePath) == 0 { + // Resolve package path. + typ.PackagePath, _ = p.resolveName(uint64(uc.PkgPath), 0) + } + // We have some methods that needs to be parsed. From source code // comments the Moff attribute is the offset from the beginning of // the uncommon data structure to where the array of methods start.