mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/pprof: use copy of svgpan library instead of link to remote site
Fixes #10375. Change-Id: I78dc3e12035d130c405bdb284b0cceea19f084f6 Reviewed-on: https://go-review.googlesource.com/10690 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
fddc3ca11c
commit
14da5bef5f
4 changed files with 301 additions and 17 deletions
|
|
@ -42,7 +42,7 @@ type Completer func(prefix string) string
|
|||
type PostProcessor func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error
|
||||
|
||||
// PProf returns the basic pprof report-generation commands
|
||||
func PProf(c Completer, interactive **bool, svgpan **string) Commands {
|
||||
func PProf(c Completer, interactive **bool) Commands {
|
||||
return Commands{
|
||||
// Commands that require no post-processing.
|
||||
"tags": {nil, report.Tags, nil, false, "Outputs all tags in the profile"},
|
||||
|
|
@ -66,13 +66,13 @@ func PProf(c Completer, interactive **bool, svgpan **string) Commands {
|
|||
"ps": {c, report.Dot, invokeDot("ps"), false, "Outputs a graph in PS format"},
|
||||
|
||||
// Save SVG output into a file after including svgpan library
|
||||
"svg": {c, report.Dot, saveSVGToFile(svgpan), false, "Outputs a graph in SVG format"},
|
||||
"svg": {c, report.Dot, saveSVGToFile(), false, "Outputs a graph in SVG format"},
|
||||
|
||||
// Visualize postprocessed dot output
|
||||
"eog": {c, report.Dot, invokeVisualizer(interactive, invokeDot("svg"), "svg", []string{"eog"}), false, "Visualize graph through eog"},
|
||||
"evince": {c, report.Dot, invokeVisualizer(interactive, invokeDot("pdf"), "pdf", []string{"evince"}), false, "Visualize graph through evince"},
|
||||
"gv": {c, report.Dot, invokeVisualizer(interactive, invokeDot("ps"), "ps", []string{"gv --noantialias"}), false, "Visualize graph through gv"},
|
||||
"web": {c, report.Dot, invokeVisualizer(interactive, saveSVGToFile(svgpan), "svg", browsers()), false, "Visualize graph through web browser"},
|
||||
"web": {c, report.Dot, invokeVisualizer(interactive, saveSVGToFile(), "svg", browsers()), false, "Visualize graph through web browser"},
|
||||
|
||||
// Visualize HTML directly generated by report.
|
||||
"weblist": {c, report.WebList, invokeVisualizer(interactive, awayFromTTY("html"), "html", browsers()), true, "Output annotated source in HTML for functions matching regexp or address"},
|
||||
|
|
@ -169,14 +169,14 @@ func invokeDot(format string) PostProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
func saveSVGToFile(svgpan **string) PostProcessor {
|
||||
func saveSVGToFile() PostProcessor {
|
||||
generateSVG := invokeDot("svg")
|
||||
divert := awayFromTTY("svg")
|
||||
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
||||
baseSVG := &bytes.Buffer{}
|
||||
generateSVG(input, baseSVG, ui)
|
||||
massaged := &bytes.Buffer{}
|
||||
fmt.Fprint(massaged, svg.Massage(*baseSVG, **svgpan))
|
||||
fmt.Fprint(massaged, svg.Massage(*baseSVG))
|
||||
return divert(massaged, output, ui)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue