MCPcopy Create free account
hub / github.com/google/pprof / grabProfile

Function grabProfile

internal/driver/fetch.go:325–360  ·  view source on GitHub ↗

grabProfile fetches a profile. Returns the profile, sources for the profile mappings, a bool indicating if the profile was fetched remotely, and an error.

(s *source, source string, fetcher plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper)

Source from the content-addressed store, hash-verified

323// profile mappings, a bool indicating if the profile was fetched
324// remotely, and an error.
325func 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) {
326 var src string
327 duration, timeout := time.Duration(s.Seconds)*time.Second, time.Duration(s.Timeout)*time.Second
328 if fetcher != nil {
329 p, src, err = fetcher.Fetch(source, duration, timeout)
330 if err != nil {
331 return
332 }
333 }
334 if err != nil || p == nil {
335 // Fetch the profile over HTTP or from a file.
336 p, src, err = fetch(source, duration, timeout, ui, tr)
337 if err != nil {
338 return
339 }
340 }
341
342 if err = p.CheckValid(); err != nil {
343 return
344 }
345
346 // Update the binary locations from command line and paths.
347 locateBinaries(p, s, obj, ui)
348
349 // Collect the source URL for all mappings.
350 if src != "" {
351 msrc = collectMappingSources(p, src)
352 remote = true
353 if strings.HasPrefix(src, "http://"+testSourceAddress) {
354 // Treat test inputs as local to avoid saving
355 // testcase profiles during driver testing.
356 remote = false
357 }
358 }
359 return
360}
361
362// collectMappingSources saves the mapping sources of a profile.
363func collectMappingSources(p *profile.Profile, source string) plugin.MappingSources {

Callers 2

TestFetchFunction · 0.85
concurrentGrabFunction · 0.85

Calls 5

fetchFunction · 0.85
locateBinariesFunction · 0.85
collectMappingSourcesFunction · 0.85
CheckValidMethod · 0.80
FetchMethod · 0.65

Tested by 1

TestFetchFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…