fetchProfiles fetches and symbolizes the profiles specified by s. It will merge all the profiles it is able to retrieve, even if there are some failures. It will return an error if it is unable to fetch any profiles.
(s *source, o *plugin.Options)
| 39 | // there are some failures. It will return an error if it is unable to |
| 40 | // fetch any profiles. |
| 41 | func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) { |
| 42 | sources := make([]profileSource, 0, len(s.Sources)) |
| 43 | for _, src := range s.Sources { |
| 44 | sources = append(sources, profileSource{ |
| 45 | addr: src, |
| 46 | source: s, |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | bases := make([]profileSource, 0, len(s.Base)) |
| 51 | for _, src := range s.Base { |
| 52 | bases = append(bases, profileSource{ |
| 53 | addr: src, |
| 54 | source: s, |
| 55 | }) |
| 56 | } |
| 57 | |
| 58 | p, pbase, m, mbase, save, err := grabSourcesAndBases(sources, bases, o.Fetch, o.Obj, o.UI, o.HTTPTransport) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | |
| 63 | if pbase != nil { |
| 64 | if s.DiffBase { |
| 65 | pbase.SetLabel("pprof::base", []string{"true"}) |
| 66 | } |
| 67 | if s.Normalize { |
| 68 | err := p.Normalize(pbase) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | } |
| 73 | pbase.Scale(-1) |
| 74 | p, m, err = combineProfiles([]*profile.Profile{p, pbase}, []plugin.MappingSources{m, mbase}) |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if s.AllFrames { |
| 81 | p.DropFrames = "" |
| 82 | p.KeepFrames = "" |
| 83 | } |
| 84 | |
| 85 | // Symbolize the merged profile. |
| 86 | if err := o.Sym.Symbolize(s.Symbolize, m, p); err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | p.RemoveUninteresting() |
| 90 | unsourceMappings(p) |
| 91 | |
| 92 | if s.Comment != "" { |
| 93 | p.Comments = append(p.Comments, s.Comment) |
| 94 | } |
| 95 | |
| 96 | // Save a copy of the merged profile if there is at least one remote source. |
| 97 | if save { |
| 98 | dir, err := setTmpDir(o.UI) |
searching dependent graphs…