aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
diff options
context:
space:
mode:
authorHana <hyangah@gmail.com>2020-10-07 17:27:42 -0400
committerHyang-Ah Hana Kim <hyangah@gmail.com>2020-10-22 23:33:06 +0000
commit67bce7c1cf6540a853c6b8a9721e381c8258d7dc (patch)
treeb4619ed6f4222f549ed28a448b71229839c9b69b /src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
parentad36f871512ea54a9044e256b2743b8346b725dd (diff)
downloadgo-67bce7c1cf6540a853c6b8a9721e381c8258d7dc.tar.xz
cmd/vendor: sync pprof@v0.0.0-20201007051231-1066cbb265c7
This is a belated early sync for 1.16 dev cycle For #36905 Change-Id: I387528ae897794841c0c78b0f0910fc5ce8599ab Reviewed-on: https://go-review.googlesource.com/c/go/+/260538 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go b/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
index 09debfb007..cde648f20b 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
@@ -127,7 +127,7 @@ func (b *builder) addLegend() {
}
title := labels[0]
fmt.Fprintf(b, `subgraph cluster_L { "%s" [shape=box fontsize=16`, title)
- fmt.Fprintf(b, ` label="%s\l"`, strings.Join(labels, `\l`))
+ fmt.Fprintf(b, ` label="%s\l"`, strings.Join(escapeForDot(labels), `\l`))
if b.config.LegendURL != "" {
fmt.Fprintf(b, ` URL="%s" target="_blank"`, b.config.LegendURL)
}
@@ -472,3 +472,14 @@ func min64(a, b int64) int64 {
}
return b
}
+
+// escapeForDot escapes double quotes and backslashes, and replaces Graphviz's
+// "center" character (\n) with a left-justified character.
+// See https://graphviz.org/doc/info/attrs.html#k:escString for more info.
+func escapeForDot(in []string) []string {
+ var out = make([]string, len(in))
+ for i := range in {
+ out[i] = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(in[i], `\`, `\\`), `"`, `\"`), "\n", `\l`)
+ }
+ return out
+}