Upstreaming change from golang/go@39366326.
HTTP body will be read and displayed when both conditions are true:
* Response includes non-empty header "X-Go-Pprof".
* Content-Type is text/plain.
Add a message recommending the use of PPROF_BINARY_PATH
The common mechanism to locate the main binary has several drawbacks:
- The identification of the main mapping is done through heuristics
- It can only override the main binary
PPROF_BINARY_PATH is a more robust mechanism, but it isn't widely known.
Add a message when symbolization fails recommending its usage.
Ensure symbolz is called after local symbolization
Even after local symbolization completes successfully we should
call remote symbolization in case there are some mapping that couldn't
be symbolized otherwise.
Add some tests to ensure both local and symbolz symbolization are called.
Reset mapping file to empty string if it was patched to be the source URL.
When the source is remote and a mapping doesn't have either build ID or
file field set, the file field is set to the source URL so that the
proper source from the source mapping is used during symbolz processing.
Before this change, the file field would continue to point to the URL
producing the URL in pprof output which confuses users.
With the change it resets the file field back to the empty string. It
also now skips the URL-like paths during local symbolization as
reading at that path is not going to succeed.
We discussed switching to generating more unique IDs. On the second
thought, I propose leaving these to be URLs as that seems unique enough
and in case this field leaks into the tool or log output seeing the URL
seems still friendlier than some arbitrarily prefixed string.
When reconciling samples, cleanup file paths to allow functions to be
combined if their source filenames match after cleanup (eg "src.cpp" and
"./src.cpp").
Also clean up existing uses of filepath to avoid passing empty strings
to it: filepath.Base("") returns "."