// 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. func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) { … } func grabSourcesAndBases(sources, bases []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, *profile.Profile, plugin.MappingSources, plugin.MappingSources, bool, error) { … } // chunkedGrab fetches the profiles described in source and merges them into // a single profile. It fetches a chunk of profiles concurrently, with a maximum // chunk size to limit its memory usage. func chunkedGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) { … } // concurrentGrab fetches multiple profiles concurrently func concurrentGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) { … } func combineProfiles(profiles []*profile.Profile, msrcs []plugin.MappingSources) (*profile.Profile, plugin.MappingSources, error) { … } type profileSource … func homeEnv() string { … } // setTmpDir prepares the directory to use to save profiles retrieved // remotely. It is selected from PPROF_TMPDIR, defaults to $HOME/pprof, and, if // $HOME is not set, falls back to os.TempDir(). func setTmpDir(ui plugin.UI) (string, error) { … } const testSourceAddress … // grabProfile fetches a profile. Returns the profile, sources for the // profile mappings, a bool indicating if the profile was fetched // remotely, and an error. func grabProfile(s *source, source string, fetcher plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, msrc plugin.MappingSources, remote bool, err error) { … } // collectMappingSources saves the mapping sources of a profile. func collectMappingSources(p *profile.Profile, source string) plugin.MappingSources { … } // unsourceMappings iterates over the mappings in a profile and replaces file // set to the remote source URL by collectMappingSources back to empty string. func unsourceMappings(p *profile.Profile) { … } // locateBinaries searches for binary files listed in the profile and, if found, // updates the profile accordingly. func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin.UI) { … } // fetch fetches a profile from source, within the timeout specified, // producing messages through the ui. It returns the profile and the // url of the actual source of the profile for remote profiles. func fetch(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, src string, err error) { … } // fetchURL fetches a profile from a URL using HTTP. func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.ReadCloser, error) { … } func statusCodeError(resp *http.Response) error { … } // isPerfFile checks if a file is in perf.data format. It also returns false // if it encounters an error during the check. func isPerfFile(path string) bool { … } // convertPerfData converts the file at path which should be in perf.data format // using the perf_to_profile tool and returns the file containing the // profile.proto formatted data. func convertPerfData(perfPath string, ui plugin.UI) (*os.File, error) { … } // adjustURL validates if a profile source is a URL and returns an // cleaned up URL and the timeout to use for retrieval over HTTP. // If the source cannot be recognized as a URL it returns an empty string. func adjustURL(source string, duration, timeout time.Duration) (string, time.Duration) { … }