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)
| 323 | // profile mappings, a bool indicating if the profile was fetched |
| 324 | // remotely, and an error. |
| 325 | 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) { |
| 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. |
| 363 | func collectMappingSources(p *profile.Profile, source string) plugin.MappingSources { |
searching dependent graphs…