func()

in pkg/tools/elf/dwarf_init.go [159:218]


func (r *DwarfReader) getClassInfo(data *dwarf.Data, name string, entry *dwarf.Entry) (*ClassInfo, error) {
	reader := data.Reader()

	reader.Seek(entry.Offset)
	_, err := reader.Next()
	if err != nil {
		return nil, err
	}

	c := &ClassInfo{
		name: name,
	}

	foundMembers := false
	for {
		child, err := reader.Next()
		if err != nil {
			return nil, err
		}
		if child == nil || child.Tag == 0 {
			break
		}

		if child.Tag == dwarf.TagInheritance {
			offset, ok := child.Val(dwarf.AttrDataMemberLoc).(int64)
			if !ok {
				continue
			}
			entryType, err1 := r.entryType(data, child)
			if err1 != nil {
				continue
			}
			structType, ok := entryType.(*dwarf.StructType)
			if !ok {
				continue
			}

			c.inheritances = append(c.inheritances, &ClassInheritance{
				name:   structType.StructName,
				cType:  structType,
				offset: uint64(offset),
			})
		}

		entryType, err := r.entryType(data, child)
		if !foundMembers && err == nil && entryType != nil {
			prtType, ok := entryType.(*dwarf.PtrType)
			if !ok {
				continue
			}
			structType, ok := prtType.Type.(*dwarf.StructType)
			if !ok {
				continue
			}
			c.members = structType.Field
			foundMembers = true
		}
	}
	return c, nil
}