github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/autoprofile/internal/symbolizer_1_9.go (about) 1 // (c) Copyright IBM Corp. 2021 2 // (c) Copyright Instana Inc. 2020 3 4 //go:build !go1.10 5 // +build !go1.10 6 7 package internal 8 9 import ( 10 "github.com/mier85/go-sensor/autoprofile/internal/pprof/profile" 11 "runtime" 12 ) 13 14 func symbolizeProfile(p *profile.Profile) error { 15 functions := make(map[string]*profile.Function) 16 17 for _, l := range p.Location { 18 if l.Address != 0 && len(l.Line) == 0 { 19 if f := runtime.FuncForPC(uintptr(l.Address)); f != nil { 20 name := f.Name() 21 fileName, lineNumber := f.FileLine(uintptr(l.Address)) 22 23 pf := functions[name] 24 if pf == nil { 25 pf = &profile.Function{ 26 ID: uint64(len(p.Function) + 1), 27 Name: name, 28 SystemName: name, 29 Filename: fileName, 30 } 31 32 functions[name] = pf 33 p.Function = append(p.Function, pf) 34 } 35 36 line := profile.Line{ 37 Function: pf, 38 Line: int64(lineNumber), 39 } 40 41 l.Line = []profile.Line{line} 42 if l.Mapping != nil { 43 l.Mapping.HasFunctions = true 44 l.Mapping.HasFilenames = true 45 l.Mapping.HasLineNumbers = true 46 } 47 } 48 } 49 } 50 51 return nil 52 }