From cf7ec0fa098a46c3b75cc3d625f5d7528fe6e984 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 16 May 2022 18:44:48 -0400 Subject: cmd/pprof: update vendored github.com/google/pprof Pull in the latest published version of github.com/google/pprof as part of go.dev/issue/36905. Done with: go get github.com/google/pprof@upgrade go mod tidy go mod vendor For #36905. Change-Id: I3c8279fce2f20cb940a4e46b2b850703e1fc7964 Reviewed-on: https://go-review.googlesource.com/c/go/+/406359 TryBot-Result: Gopher Robot Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Reviewed-by: Cherry Mui Run-TryBot: Dmitri Shuralyov --- .../google/pprof/internal/driver/webhtml.go | 1419 +------------------- 1 file changed, 43 insertions(+), 1376 deletions(-) (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go') diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go index 63df668321..94f32e3755 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go @@ -15,1387 +15,54 @@ package driver import ( + "embed" + "fmt" "html/template" + "os" "github.com/google/pprof/third_party/d3flamegraph" ) +//go:embed html +var embeddedFiles embed.FS + // addTemplates adds a set of template definitions to templates. func addTemplates(templates *template.Template) { - template.Must(templates.Parse(`{{define "d3flamegraphscript"}}` + d3flamegraph.JSSource + `{{end}}`)) - template.Must(templates.Parse(`{{define "d3flamegraphcss"}}` + d3flamegraph.CSSSource + `{{end}}`)) - template.Must(templates.Parse(` -{{define "css"}} - -{{end}} - -{{define "header"}} -
-
-

pprof

-
- - - - {{$sampleLen := len .SampleTypes}} - {{if gt $sampleLen 1}} - - {{end}} - - - - - - - -
- -
- -
- {{.Title}} -
- {{range .Legend}}
{{.}}
{{end}} -
-
-
- -
- -
-
Save options as
- - {{range .Configs}}{{if .UserConfig}} - - -
- -
-
Delete config
-
- -
- -
{{range .Errors}}
{{.}}
{{end}}
-{{end}} - -{{define "graph" -}} - - - - - {{.Title}} - {{template "css" .}} - - - {{template "header" .}} -
- {{.HTMLBody}} -
- {{template "script" .}} - - - -{{end}} - -{{define "script"}} - -{{end}} - -{{define "top" -}} - - - - - {{.Title}} - {{template "css" .}} - - - - {{template "header" .}} -
- - - - - - - - - - - - - -
FlatFlat%Sum%CumCum%NameInlined?
-
- {{template "script" .}} - - - -{{end}} - -{{define "sourcelisting" -}} - - - - - {{.Title}} - {{template "css" .}} - {{template "weblistcss" .}} - {{template "weblistjs" .}} - - - {{template "header" .}} -
- {{.HTMLBody}} -
- {{template "script" .}} - - - -{{end}} - -{{define "plaintext" -}} - - - - - {{.Title}} - {{template "css" .}} - - - {{template "header" .}} -
-
-      {{.TextBody}}
-    
-
- {{template "script" .}} - - - -{{end}} - -{{define "flamegraph" -}} - - - - - {{.Title}} - {{template "css" .}} - - - - - {{template "header" .}} -
-
-
-
-
-
- {{template "script" .}} - - - - - -{{end}} -`)) + // Load specified file. + loadFile := func(fname string) string { + data, err := embeddedFiles.ReadFile(fname) + if err != nil { + fmt.Fprintf(os.Stderr, "internal/driver: embedded file %q not found\n", + fname) + os.Exit(1) + } + return string(data) + } + loadCSS := func(fname string) string { + return `` + "\n" + } + loadJS := func(fname string) string { + return `` + "\n" + } + + // Define a named template with specified contents. + def := func(name, contents string) { + sub := template.New(name) + template.Must(sub.Parse(contents)) + template.Must(templates.AddParseTree(name, sub.Tree)) + } + + // Pre-packaged third-party files. + def("d3flamegraphscript", d3flamegraph.JSSource) + def("d3flamegraphcss", d3flamegraph.CSSSource) + + // Embeded files. + def("css", loadCSS("html/common.css")) + def("header", loadFile("html/header.html")) + def("graph", loadFile("html/graph.html")) + def("script", loadJS("html/common.js")) + def("top", loadFile("html/top.html")) + def("sourcelisting", loadFile("html/source.html")) + def("plaintext", loadFile("html/plaintext.html")) + def("flamegraph", loadFile("html/flamegraph.html")) } -- cgit v1.3