mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/pprof: don't use local symbolization for remote source
If we are using a remote source (a URL), and the user did not specify the executable file to use, then don't try to use a local source. This was misbehaving because the local symbolizer will not fail if there is any memory map available, but the presence of a memory map does not ensure that the files and symbols are actually available. We still need a pprof testsuite. Fixes #16159. Change-Id: I0250082a4d5181c7babc7eeec6bc95b2f3bcaec9 Reviewed-on: https://go-review.googlesource.com/24464 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
83e839f86f
commit
4fcb4eb279
1 changed files with 26 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"debug/gosym"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
@ -50,7 +51,16 @@ func symbolize(mode, source string, p *profile.Profile, obj plugin.ObjTool, ui p
|
|||
ui.PrintErr("expecting -symbolize=[local|remote|none][:force]")
|
||||
fallthrough
|
||||
case "", "force":
|
||||
// Ignore these options, -force is recognized by symbolizer.Symbolize
|
||||
// -force is recognized by symbolizer.Symbolize.
|
||||
// If the source is remote, and the mapping file
|
||||
// does not exist, don't use local symbolization.
|
||||
if isRemote(source) {
|
||||
if len(p.Mapping) == 0 {
|
||||
local = false
|
||||
} else if _, err := os.Stat(p.Mapping[0].File); err != nil {
|
||||
local = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +77,21 @@ func symbolize(mode, source string, p *profile.Profile, obj plugin.ObjTool, ui p
|
|||
return err
|
||||
}
|
||||
|
||||
// isRemote returns whether source is a URL for a remote source.
|
||||
func isRemote(source string) bool {
|
||||
url, err := url.Parse(source)
|
||||
if err != nil {
|
||||
url, err = url.Parse("http://" + source)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if scheme := strings.ToLower(url.Scheme); scheme == "" || scheme == "file" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// flags implements the driver.FlagPackage interface using the builtin flag package.
|
||||
type flags struct {
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue