aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/graph
diff options
context:
space:
mode:
authorHana (Hyang-Ah) Kim <hyangah@gmail.com>2019-11-08 00:06:02 +0900
committerHyang-Ah Hana Kim <hyangah@gmail.com>2019-11-12 21:27:38 +0000
commit2de897f4807aa552c5d223e0744c9624fa498d48 (patch)
treedb7d913e3529a0005af6e601da6e7372aa8745a4 /src/cmd/vendor/github.com/google/pprof/internal/graph
parent00e14afa0d7afdd710ef16080f0fdcbc4abd951a (diff)
downloadgo-2de897f4807aa552c5d223e0744c9624fa498d48.tar.xz
cmd: sync github.com/google/pprof@v0.0.0-20191105193234-27840fff0d09
https://github.com/google/pprof/compare/54271f7e092f...27840fff0d09 Change-Id: I7ded9be6deaaf8d11bd8d228bca8d7eb3ada8774 Reviewed-on: https://go-review.googlesource.com/c/go/+/205780 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go b/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go
index 757be02947..d2397a93d8 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go
@@ -28,9 +28,19 @@ import (
)
var (
+ // Removes package name and method arugments for Java method names.
+ // See tests for examples.
javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
- goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
- cppRegExp = regexp.MustCompile(`^(?:(?:\(anonymous namespace\)::)(\w+$))|(?:(?:\(anonymous namespace\)::)?(?:[_a-zA-Z]\w*\::|)*(_*[A-Z]\w*::~?[_a-zA-Z]\w*)$)`)
+ // Removes package name and method arugments for Go function names.
+ // See tests for examples.
+ goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
+ // Strips C++ namespace prefix from a C++ function / method name.
+ // NOTE: Make sure to keep the template parameters in the name. Normally,
+ // template parameters are stripped from the C++ names but when
+ // -symbolize=demangle=templates flag is used, they will not be.
+ // See tests for examples.
+ cppRegExp = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*(?:<.*>)?)`)
+ cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
)
// Graph summarizes a performance profile into a format that is
@@ -191,7 +201,7 @@ type NodeSet map[NodeInfo]bool
// works as a unique identifier; however, in a tree multiple nodes may share
// identical NodeInfos. A *Node does uniquely identify a node so we can use that
// instead. Though a *Node also uniquely identifies a node in a graph,
-// currently, during trimming, graphs are rebult from scratch using only the
+// currently, during trimming, graphs are rebuilt from scratch using only the
// NodeSet, so there would not be the required context of the initial graph to
// allow for the use of *Node.
type NodePtrSet map[*Node]bool
@@ -429,6 +439,7 @@ func newTree(prof *profile.Profile, o *Options) (g *Graph) {
// ShortenFunctionName returns a shortened version of a function's name.
func ShortenFunctionName(f string) string {
+ f = cppAnonymousPrefixRegExp.ReplaceAllString(f, "")
for _, re := range []*regexp.Regexp{goRegExp, javaRegExp, cppRegExp} {
if matches := re.FindStringSubmatch(f); len(matches) >= 2 {
return strings.Join(matches[1:], "")