| 1 | // Copyright 2014 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // Package report summarizes a performance profile into a |
| 16 | // human-readable report. |
| 17 | package reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ |
| 18 | |
| 19 | import ( |
| 20 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 21 | "ioscip-go gomod github.com/golang/go/src go1.24.0 io/" |
| 22 | "net/urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/" |
| 23 | "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/" |
| 24 | "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/" |
| 25 | "sortscip-go gomod github.com/golang/go/src go1.24.0 sort/" |
| 26 | "strconvscip-go gomod github.com/golang/go/src go1.24.0 strconv/" |
| 27 | "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/" |
| 28 | "text/tabwriterscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/" |
| 29 | "timescip-go gomod github.com/golang/go/src go1.24.0 time/" |
| 30 | |
| 31 | "github.com/google/pprof/internal/graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/" |
| 32 | "github.com/google/pprof/internal/measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/" |
| 33 | "github.com/google/pprof/internal/pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/" |
| 34 | "github.com/google/pprof/profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/" |
| 35 | ) |
| 36 | |
| 37 | // Output formats. |
| 38 | const ( |
| 39 | Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind. = iota |
| 40 | Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Comments. |
| 41 | Disscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dis. |
| 42 | Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot. |
| 43 | Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List. |
| 44 | Protoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Proto. |
| 45 | Rawscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Raw. |
| 46 | Tagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Tags. |
| 47 | Textscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Text. |
| 48 | TopProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TopProto. |
| 49 | Tracesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Traces. |
| 50 | Treescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Tree. |
| 51 | WebListscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/WebList. |
| 52 | ) |
| 53 | |
| 54 | // Options are the formatting and filtering options used to generate a |
| 55 | // profile. |
| 56 | type Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options# struct { |
| 57 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. int |
| 58 | |
| 59 | CumSortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CumSort. bool |
| 60 | CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CallTree. bool |
| 61 | DropNegativescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#DropNegative. bool |
| 62 | CompactLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CompactLabels. bool |
| 63 | Ratioscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Ratio. float64 |
| 64 | Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Title. string |
| 65 | ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ProfileLabels. []string |
| 66 | ActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ActiveFilters. []string |
| 67 | NumLabelUnitsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NumLabelUnits. map[string]string |
| 68 | |
| 69 | NodeCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeCount. int |
| 70 | NodeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeFraction. float64 |
| 71 | EdgeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#EdgeFraction. float64 |
| 72 | |
| 73 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue. func(s []int64) int64 |
| 74 | SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleMeanDivisor. func(s []int64) int64 |
| 75 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleType. string |
| 76 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit. string // Unit for the sample data from the profile. |
| 77 | |
| 78 | OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit. string // Units for data formatting in report. |
| 79 | |
| 80 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol. *regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp# // Symbols to include on disassembly report. |
| 81 | SourcePathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SourcePath. string // Search path for source files. |
| 82 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath. string // Paths to trim from source file paths. |
| 83 | |
| 84 | IntelSyntaxscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#IntelSyntax. bool // Whether or not to print assembly in Intel syntax. |
| 85 | } |
| 86 | |
| 87 | // Generate generates a report as directed by the Report. |
| 88 | func Generatescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Generate().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#, obj pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjToolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#) error { |
| 89 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 90 | |
| 91 | switch o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. { |
| 92 | case Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Comments.: |
| 93 | return printCommentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printComments().(w, rpt) |
| 94 | case Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot.: |
| 95 | return printDOTscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printDOT().(w, rpt) |
| 96 | case Treescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Tree.: |
| 97 | return printTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTree().(w, rpt) |
| 98 | case Textscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Text.: |
| 99 | return printTextscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printText().(w, rpt) |
| 100 | case Tracesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Traces.: |
| 101 | return printTracesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTraces().(w, rpt) |
| 102 | case Rawscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Raw.: |
| 103 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprint().(w, rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof..Stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#String().()) |
| 104 | return nil |
| 105 | case Tagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Tags.: |
| 106 | return printTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTags().(w, rpt) |
| 107 | case Protoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Proto.: |
| 108 | return printProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printProto().(w, rpt) |
| 109 | case TopProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TopProto.: |
| 110 | return printTopProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTopProto().(w, rpt) |
| 111 | case Disscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dis.: |
| 112 | return printAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printAssembly().(w, rpt, obj) |
| 113 | case Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List.: |
| 114 | return printSourcescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printSource().(w, rpt) |
| 115 | case Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind.: |
| 116 | return printCallgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printCallgrind().(w, rpt) |
| 117 | } |
| 118 | // Note: WebList handling is in driver package. |
| 119 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unexpected output format %v", o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.) |
| 120 | } |
| 121 | |
| 122 | // newTrimmedGraph creates a graph for this report, trimmed according |
| 123 | // to the report options. |
| 124 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() (g *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#, origCount, droppedNodes, droppedEdges int) { |
| 125 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 126 | |
| 127 | // Build a graph and refine it. On each refinement step we must rebuild the graph from the samples, |
| 128 | // as the graph itself doesn't contain enough information to preserve full precision. |
| 129 | visualMode := o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot. |
| 130 | cumSort := o.CumSortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CumSort. |
| 131 | |
| 132 | // The call_tree option is only honored when generating visual representations of the callgraph. |
| 133 | callTree := o.CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CallTree. && (o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot. || o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind.) |
| 134 | |
| 135 | // First step: Build complete graph to identify low frequency nodes, based on their cum weight. |
| 136 | g = rpt.newGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newGraph().(nil) |
| 137 | totalValue, _ := g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes..Sumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#Sum().() |
| 138 | nodeCutoff := abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(int64(float64(totalValue) * o.NodeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeFraction.)) |
| 139 | edgeCutoff := abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(int64(float64(totalValue) * o.EdgeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#EdgeFraction.)) |
| 140 | |
| 141 | // Filter out nodes with cum value below nodeCutoff. |
| 142 | if nodeCutoff > 0 { |
| 143 | if callTree { |
| 144 | if nodesKept := g.DiscardLowFrequencyNodePtrsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#DiscardLowFrequencyNodePtrs().(nodeCutoff); len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) != len(nodesKept) { |
| 145 | droppedNodes = len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) - len(nodesKept) |
| 146 | g.TrimTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimTree().(nodesKept) |
| 147 | } |
| 148 | } else { |
| 149 | if nodesKept := g.DiscardLowFrequencyNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#DiscardLowFrequencyNodes().(nodeCutoff); len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) != len(nodesKept) { |
| 150 | droppedNodes = len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) - len(nodesKept) |
| 151 | g = rpt.newGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newGraph().(nodesKept) |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | origCount = len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) |
| 156 | |
| 157 | // Second step: Limit the total number of nodes. Apply specialized heuristics to improve |
| 158 | // visualization when generating dot output. |
| 159 | g.SortNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#SortNodes().(cumSort, visualMode) |
| 160 | if nodeCount := o.NodeCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeCount.; nodeCount > 0 { |
| 161 | // Remove low frequency tags and edges as they affect selection. |
| 162 | g.TrimLowFrequencyTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimLowFrequencyTags().(nodeCutoff) |
| 163 | g.TrimLowFrequencyEdgesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimLowFrequencyEdges().(edgeCutoff) |
| 164 | if callTree { |
| 165 | if nodesKept := g.SelectTopNodePtrsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#SelectTopNodePtrs().(nodeCount, visualMode); len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) != len(nodesKept) { |
| 166 | g.TrimTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimTree().(nodesKept) |
| 167 | g.SortNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#SortNodes().(cumSort, visualMode) |
| 168 | } |
| 169 | } else { |
| 170 | if nodesKept := g.SelectTopNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#SelectTopNodes().(nodeCount, visualMode); len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) != len(nodesKept) { |
| 171 | g = rpt.newGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newGraph().(nodesKept) |
| 172 | g.SortNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#SortNodes().(cumSort, visualMode) |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // Final step: Filter out low frequency tags and edges, and remove redundant edges that clutter |
| 178 | // the graph. |
| 179 | g.TrimLowFrequencyTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimLowFrequencyTags().(nodeCutoff) |
| 180 | droppedEdges = g.TrimLowFrequencyEdgesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#TrimLowFrequencyEdges().(edgeCutoff) |
| 181 | if visualMode { |
| 182 | g.RemoveRedundantEdgesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#RemoveRedundantEdges().() |
| 183 | } |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#) { |
| 188 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 189 | |
| 190 | // Select best unit for profile output. |
| 191 | // Find the appropriate units for the smallest non-zero sample |
| 192 | if o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit. != "minimum" || len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) == 0 { |
| 193 | return |
| 194 | } |
| 195 | var minValue int64 |
| 196 | |
| 197 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 198 | nodeMin := abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().()) |
| 199 | if nodeMin == 0 { |
| 200 | nodeMin = abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(n.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().()) |
| 201 | } |
| 202 | if nodeMin > 0 && (minValue == 0 || nodeMin < minValue) { |
| 203 | minValue = nodeMin |
| 204 | } |
| 205 | } |
| 206 | maxValue := rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total. |
| 207 | if minValue == 0 { |
| 208 | minValue = maxValue |
| 209 | } |
| 210 | |
| 211 | if r := o.Ratioscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Ratio.; r > 0 && r != 1 { |
| 212 | minValue = int64(float64(minValue) * r) |
| 213 | maxValue = int64(float64(maxValue) * r) |
| 214 | } |
| 215 | |
| 216 | _, minUnit := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(minValue, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., "minimum") |
| 217 | _, maxUnit := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(maxValue, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., "minimum") |
| 218 | |
| 219 | unit := minUnit |
| 220 | if minUnit != maxUnit && minValue*100 < maxValue && o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. != Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind. { |
| 221 | // Minimum and maximum values have different units. Scale |
| 222 | // minimum by 100 to use larger units, allowing minimum value to |
| 223 | // be scaled down to 0.01, except for callgrind reports since |
| 224 | // they can only represent integer values. |
| 225 | _, unit = measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(100*minValue, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., "minimum") |
| 226 | } |
| 227 | |
| 228 | if unit != "" { |
| 229 | o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit. = unit |
| 230 | } else { |
| 231 | o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit. = o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit. |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // newGraph creates a new graph for this report. If nodes is non-nil, |
| 236 | // only nodes whose info matches are included. Otherwise, all nodes |
| 237 | // are included, without trimming. |
| 238 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) newGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newGraph().(nodes graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeSetscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeSet#) *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph# { |
| 239 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 240 | |
| 241 | // Clean up file paths using heuristics. |
| 242 | prof := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 243 | for _, f := range prof.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function. { |
| 244 | f.Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename. = trimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/trimPath().(f.Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename., o.TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath., o.SourcePathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SourcePath.) |
| 245 | } |
| 246 | // Removes all numeric tags except for the bytes tag prior |
| 247 | // to making graph. |
| 248 | // TODO: modify to select first numeric tag if no bytes tag |
| 249 | for _, s := range prof.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. { |
| 250 | numLabels := make(map[string][]int64, len(s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel.)) |
| 251 | numUnits := make(map[string][]string, len(s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel.)) |
| 252 | for k, vs := range s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. { |
| 253 | if k == "bytes" { |
| 254 | unit := o.NumLabelUnitsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NumLabelUnits.[k] |
| 255 | numValues := make([]int64, len(vs)) |
| 256 | numUnit := make([]string, len(vs)) |
| 257 | for i, v := range vs { |
| 258 | numValues[i] = v |
| 259 | numUnit[i] = unit |
| 260 | } |
| 261 | numLabels[k] = append(numLabels[k], numValues...) |
| 262 | numUnits[k] = append(numUnits[k], numUnit...) |
| 263 | } |
| 264 | } |
| 265 | s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. = numLabels |
| 266 | s.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit. = numUnits |
| 267 | } |
| 268 | |
| 269 | // Remove label marking samples from the base profiles, so it does not appear |
| 270 | // as a nodelet in the graph view. |
| 271 | prof.RemoveLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#RemoveLabel().("pprof::base") |
| 272 | |
| 273 | formatTag := func(v int64, key string) string { |
| 274 | return measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.ScaledLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/ScaledLabel().(v, key, o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 275 | } |
| 276 | |
| 277 | gopt := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#{ |
| 278 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#SampleValue.: o.SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue., |
| 279 | SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#SampleMeanDivisor.: o.SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleMeanDivisor., |
| 280 | FormatTagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#FormatTag.: formatTag, |
| 281 | CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#CallTree.: o.CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CallTree. && (o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot. || o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind.), |
| 282 | DropNegativescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#DropNegative.: o.DropNegativescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#DropNegative., |
| 283 | KeptNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#KeptNodes.: nodes, |
| 284 | } |
| 285 | |
| 286 | // Only keep binary names for disassembly-based reports, otherwise |
| 287 | // remove it to allow merging of functions across binaries. |
| 288 | switch o.OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. { |
| 289 | case Rawscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Raw., Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List., WebListscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/WebList., Disscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dis., Callgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Callgrind.: |
| 290 | gopt.ObjNamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#ObjNames. = true |
| 291 | } |
| 292 | |
| 293 | return graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/New().(rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof., gopt) |
| 294 | } |
| 295 | |
| 296 | // printProto writes the incoming proto via the writer w. |
| 297 | // If the divide_by option has been specified, samples are scaled appropriately. |
| 298 | func printProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printProto().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 299 | p, o := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof., rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 300 | |
| 301 | // Apply the sample ratio to all samples before saving the profile. |
| 302 | if r := o.Ratioscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Ratio.; r > 0 && r != 1 { |
| 303 | for _, sample := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. { |
| 304 | for i, v := range sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value. { |
| 305 | sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.[i] = int64(float64(v) * r) |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | return p.Writescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Write().(w) |
| 310 | } |
| 311 | |
| 312 | // printTopProto writes a list of the hottest routines in a profile as a profile.proto. |
| 313 | func printTopProtoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTopProto().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 314 | p := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 315 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 316 | g, _, _, _ := rpt.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 317 | rpt.selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g) |
| 318 | |
| 319 | out := profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 320 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 321 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cum", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.}, |
| 322 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "flat", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.}, |
| 323 | }, |
| 324 | TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.: p.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos., |
| 325 | DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.: p.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos., |
| 326 | PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: p.PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType., |
| 327 | Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.: p.Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period., |
| 328 | } |
| 329 | functionMap := make(functionMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#) |
| 330 | for i, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 331 | f, added := functionMap.findOrAddscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#findOrAdd().(n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.) |
| 332 | if added { |
| 333 | out.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function. = append(out.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function., f) |
| 334 | } |
| 335 | flat, cum := n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().(), n.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().() |
| 336 | l := &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{ |
| 337 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: uint64(i + 1), |
| 338 | Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address., |
| 339 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 340 | { |
| 341 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: int64(n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Linenoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Lineno.), |
| 342 | Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column.: int64(n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Columnnoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Columnno.), |
| 343 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: f, |
| 344 | }, |
| 345 | }, |
| 346 | } |
| 347 | |
| 348 | fv, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(flat, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 349 | cv, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(cum, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 350 | s := &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 351 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{l}, |
| 352 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{int64(cv), int64(fv)}, |
| 353 | } |
| 354 | out.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. = append(out.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location., l) |
| 355 | out.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. = append(out.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample., s) |
| 356 | } |
| 357 | |
| 358 | return out.Writescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Write().(w) |
| 359 | } |
| 360 | |
| 361 | type functionMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap# map[string]*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function# |
| 362 | |
| 363 | // findOrAdd takes a node representing a function, adds the function |
| 364 | // represented by the node to the map if the function is not already present, |
| 365 | // and returns the function the node represents. This also returns a boolean, |
| 366 | // which is true if the function was added and false otherwise. |
| 367 | func (fm functionMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#) findOrAddscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#findOrAdd().(ni graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#) (*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#, bool) { |
| 368 | fName := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%q%q%q%d", ni.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., ni.OrigNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#OrigName., ni.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File., ni.StartLinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#StartLine.) |
| 369 | |
| 370 | if f := fm[fName]; f != nil { |
| 371 | return f, false |
| 372 | } |
| 373 | |
| 374 | f := &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{ |
| 375 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: uint64(len(fm) + 1), |
| 376 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: ni.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., |
| 377 | SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: ni.OrigNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#OrigName., |
| 378 | Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: ni.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File., |
| 379 | StartLinescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#StartLine.: int64(ni.StartLinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#StartLine.), |
| 380 | } |
| 381 | fm[fName] = f |
| 382 | return f, true |
| 383 | } |
| 384 | |
| 385 | // printAssembly prints an annotated assembly listing. |
| 386 | func printAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printAssembly().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#, obj pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjToolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#) error { |
| 387 | return PrintAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/PrintAssembly().(w, rpt, obj, -1) |
| 388 | } |
| 389 | |
| 390 | // PrintAssembly prints annotated disassembly of rpt to w. |
| 391 | func PrintAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/PrintAssembly().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#, obj pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjToolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#, maxFuncs int) error { |
| 392 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 393 | prof := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 394 | |
| 395 | g := rpt.newGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newGraph().(nil) |
| 396 | |
| 397 | // If the regexp source can be parsed as an address, also match |
| 398 | // functions that land on that address. |
| 399 | var address *uint64 |
| 400 | if hex, err := strconvscip-go gomod github.com/golang/go/src go1.24.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.24.0 strconv/ParseUint().(o.Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol..Stringscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#String().(), 0, 64); err == nil { |
| 401 | address = &hex |
| 402 | } |
| 403 | |
| 404 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "Total:", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.)) |
| 405 | symbols := symbolsFromBinariesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/symbolsFromBinaries().(prof, g, o.Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol., address, obj) |
| 406 | symNodes := nodesPerSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/nodesPerSymbol().(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes., symbols) |
| 407 | |
| 408 | // Sort for printing. |
| 409 | var syms []*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol# |
| 410 | for s := range symNodes { |
| 411 | syms = append(syms, s) |
| 412 | } |
| 413 | byName := func(a, b *objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#) bool { |
| 414 | if na, nb := a.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Name.[0], b.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Name.[0]; na != nb { |
| 415 | return na < nb |
| 416 | } |
| 417 | return a.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Start. < b.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Start. |
| 418 | } |
| 419 | if maxFuncs < 0 { |
| 420 | sortscip-go gomod github.com/golang/go/src go1.24.0 sort/.Sortscip-go gomod github.com/golang/go/src go1.24.0 sort/Sort().(orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#{syms, byName}) |
| 421 | } else { |
| 422 | byFlatSum := func(a, b *objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#) bool { |
| 423 | suma, _ := symNodes[a].Sumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#Sum().() |
| 424 | sumb, _ := symNodes[b].Sumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#Sum().() |
| 425 | if suma != sumb { |
| 426 | return suma > sumb |
| 427 | } |
| 428 | return byName(a, b) |
| 429 | } |
| 430 | sortscip-go gomod github.com/golang/go/src go1.24.0 sort/.Sortscip-go gomod github.com/golang/go/src go1.24.0 sort/Sort().(orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#{syms, byFlatSum}) |
| 431 | if len(syms) > maxFuncs { |
| 432 | syms = syms[:maxFuncs] |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | if len(syms) == 0 { |
| 437 | // The symbol regexp case |
| 438 | if address == nil { |
| 439 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("no matches found for regexp %s", o.Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.) |
| 440 | } |
| 441 | |
| 442 | // The address case |
| 443 | if len(symbols) == 0 { |
| 444 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("no matches found for address 0x%x", *address) |
| 445 | } |
| 446 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("address 0x%x found in binary, but the corresponding symbols do not have samples in the profile", *address) |
| 447 | } |
| 448 | |
| 449 | // Correlate the symbols from the binary with the profile samples. |
| 450 | for _, s := range syms { |
| 451 | sns := symNodes[s] |
| 452 | |
| 453 | // Gather samples for this symbol. |
| 454 | flatSum, cumSum := sns.Sumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#Sum().() |
| 455 | |
| 456 | // Get the function assembly. |
| 457 | insts, err := obj.Disasmscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#Disasm.(s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#File., s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Start., s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Endscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#End., o.IntelSyntaxscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#IntelSyntax.) |
| 458 | if err != nil { |
| 459 | return err |
| 460 | } |
| 461 | |
| 462 | ns := annotateAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/annotateAssembly().(insts, sns, s.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#file.) |
| 463 | |
| 464 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "ROUTINE ======================== %s\n", s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Name.[0]) |
| 465 | for _, name := range s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Name.[1:] { |
| 466 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, " AKA ======================== %s\n", name) |
| 467 | } |
| 468 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %10s (flat, cum) %s of Total\n", |
| 469 | rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(flatSum), rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(cumSum), |
| 470 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(cumSum, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.)) |
| 471 | |
| 472 | function, file, line := "", "", 0 |
| 473 | for _, n := range ns { |
| 474 | locStr := "" |
| 475 | // Skip loc information if it hasn't changed from previous instruction. |
| 476 | if n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. != function || n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. != file || n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. != line { |
| 477 | function, file, line = n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function., n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file., n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. |
| 478 | if n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. != "" { |
| 479 | locStr = n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. + " " |
| 480 | } |
| 481 | if n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. != "" { |
| 482 | locStr += n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. |
| 483 | if n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. != 0 { |
| 484 | locStr += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(":%d", n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line.) |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | switch { |
| 489 | case locStr == "": |
| 490 | // No location info, just print the instruction. |
| 491 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %10s %10x: %s\n", |
| 492 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.flatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatValue().(), rpt), |
| 493 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.cumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumValue().(), rpt), |
| 494 | n.addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#address., n.instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction., |
| 495 | ) |
| 496 | case len(n.instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction.) < 40: |
| 497 | // Short instruction, print loc on the same line. |
| 498 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %10s %10x: %-40s;%s\n", |
| 499 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.flatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatValue().(), rpt), |
| 500 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.cumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumValue().(), rpt), |
| 501 | n.addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#address., n.instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction., |
| 502 | locStr, |
| 503 | ) |
| 504 | default: |
| 505 | // Long instruction, print loc on a separate line. |
| 506 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%74s;%s\n", "", locStr) |
| 507 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %10s %10x: %s\n", |
| 508 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.flatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatValue().(), rpt), |
| 509 | valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(n.cumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumValue().(), rpt), |
| 510 | n.addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#address., n.instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction., |
| 511 | ) |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | return nil |
| 516 | } |
| 517 | |
| 518 | // symbolsFromBinaries examines the binaries listed on the profile that have |
| 519 | // associated samples, and returns the identified symbols matching rx. |
| 520 | func symbolsFromBinariesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/symbolsFromBinaries().(prof *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, g *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#, rx *regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#, address *uint64, obj pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjToolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#) []*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol# { |
| 521 | // fileHasSamplesAndMatched is for optimization to speed up pprof: when later |
| 522 | // walking through the profile mappings, it will only examine the ones that have |
| 523 | // samples and are matched to the regexp. |
| 524 | fileHasSamplesAndMatched := make(map[string]bool) |
| 525 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 526 | if name := n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(); rx.MatchStringscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#MatchString().(name) && n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Objfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Objfile. != "" { |
| 527 | fileHasSamplesAndMatched[n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Objfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Objfile.] = true |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | // Walk all mappings looking for matching functions with samples. |
| 532 | var objSyms []*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol# |
| 533 | for _, m := range prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. { |
| 534 | // Skip the mapping if its file does not have samples or is not matched to |
| 535 | // the regexp (unless the regexp is an address and the mapping's range covers |
| 536 | // the address) |
| 537 | if !fileHasSamplesAndMatched[m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.] { |
| 538 | if address == nil || m.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start. > *address || *address > m.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit. { |
| 539 | continue |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | f, err := obj.Openscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjTool#Open.(m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File., m.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start., m.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit., m.Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset., m.KernelRelocationSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#KernelRelocationSymbol.) |
| 544 | if err != nil { |
| 545 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Printf().("%v\n", err) |
| 546 | continue |
| 547 | } |
| 548 | |
| 549 | // Find symbols in this binary matching the user regexp. |
| 550 | var addr uint64 |
| 551 | if address != nil { |
| 552 | addr = *address |
| 553 | } |
| 554 | msyms, err := f.Symbolsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile#Symbols.(rx, addr) |
| 555 | f.Closescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile#Close.() |
| 556 | if err != nil { |
| 557 | continue |
| 558 | } |
| 559 | for _, ms := range msyms { |
| 560 | objSyms = append(objSyms, |
| 561 | &objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#{ |
| 562 | symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym.: ms, |
| 563 | filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#file.: f, |
| 564 | }, |
| 565 | ) |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | return objSyms |
| 570 | } |
| 571 | |
| 572 | // objSymbol represents a symbol identified from a binary. It includes |
| 573 | // the SymbolInfo from the disasm package and the base that must be |
| 574 | // added to correspond to sample addresses |
| 575 | type objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol# struct { |
| 576 | symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym. *pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.Symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym# |
| 577 | filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#file. pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile# |
| 578 | } |
| 579 | |
| 580 | // orderSyms is a wrapper type to sort []*objSymbol by a supplied comparator. |
| 581 | type orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms# struct { |
| 582 | vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v. []*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol# |
| 583 | lessscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#less. func(a, b *objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#) bool |
| 584 | } |
| 585 | |
| 586 | func (o orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#) Lenscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#Len().() int { return len(o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.) } |
| 587 | func (o orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#) Lessscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#Less().(i, j int) bool { return o.lessscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#less.(o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[i], o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[j]) } |
| 588 | func (o orderSymsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#) Swapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#Swap().(i, j int) { o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[i], o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[j] = o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[j], o.vscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/orderSyms#v.[i] } |
| 589 | |
| 590 | // nodesPerSymbol classifies nodes into a group of symbols. |
| 591 | func nodesPerSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/nodesPerSymbol().(ns graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#, symbols []*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#) map[*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#]graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes# { |
| 592 | symNodes := make(map[*objSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#]graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#) |
| 593 | for _, s := range symbols { |
| 594 | // Gather samples for this symbol. |
| 595 | for _, n := range ns { |
| 596 | if address, err := s.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#file..ObjAddrscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile#ObjAddr.(n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address.); err == nil && address >= s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#Start. && address < s.symscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/objSymbol#sym..Endscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Sym#End. { |
| 597 | symNodes[s] = append(symNodes[s], n) |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | return symNodes |
| 602 | } |
| 603 | |
| 604 | type assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction# struct { |
| 605 | addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#address. uint64 |
| 606 | instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction. string |
| 607 | functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. string |
| 608 | filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. string |
| 609 | linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. int |
| 610 | flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flat., cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cum. int64 |
| 611 | flatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatDiv., cumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumDiv. int64 |
| 612 | startsBlockscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#startsBlock. bool |
| 613 | inlineCallsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#inlineCalls. []callIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callID# |
| 614 | } |
| 615 | |
| 616 | type callIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callID# struct { |
| 617 | filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callID#file. string |
| 618 | linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callID#line. int |
| 619 | } |
| 620 | |
| 621 | func (a *assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#) flatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatValue().() int64 { |
| 622 | if a.flatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatDiv. != 0 { |
| 623 | return a.flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flat. / a.flatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatDiv. |
| 624 | } |
| 625 | return a.flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flat. |
| 626 | } |
| 627 | |
| 628 | func (a *assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#) cumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumValue().() int64 { |
| 629 | if a.cumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumDiv. != 0 { |
| 630 | return a.cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cum. / a.cumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumDiv. |
| 631 | } |
| 632 | return a.cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cum. |
| 633 | } |
| 634 | |
| 635 | // annotateAssembly annotates a set of assembly instructions with a |
| 636 | // set of samples. It returns a set of nodes to display. base is an |
| 637 | // offset to adjust the sample addresses. |
| 638 | func annotateAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/annotateAssembly().(insts []pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.Instscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#, samples graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#, file pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.ObjFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile#) []assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction# { |
| 639 | // Add end marker to simplify printing loop. |
| 640 | insts = append(insts, pluginscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/.Instscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#{ |
| 641 | Addrscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Addr.: ^uint64(0), |
| 642 | }) |
| 643 | |
| 644 | // Ensure samples are sorted by address. |
| 645 | samples.Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Nodes#Sort().(graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.AddressOrderscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/AddressOrder.) |
| 646 | |
| 647 | s := 0 |
| 648 | asm := make([]assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#, 0, len(insts)) |
| 649 | for ix, in := range insts[:len(insts)-1] { |
| 650 | n := assemblyInstructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#{ |
| 651 | addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#address.: in.Addrscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Addr., |
| 652 | instructionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#instruction.: in.Textscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Text., |
| 653 | functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function.: in.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Function., |
| 654 | linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line.: in.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Line., |
| 655 | } |
| 656 | if in.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#File. != "" { |
| 657 | n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. = filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Base().(in.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#File.) |
| 658 | } |
| 659 | |
| 660 | // Sum all the samples until the next instruction (to account |
| 661 | // for samples attributed to the middle of an instruction). |
| 662 | for next := insts[ix+1].Addrscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/Inst#Addr.; s < len(samples); s++ { |
| 663 | if addr, err := file.ObjAddrscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/plugin`/ObjFile#ObjAddr.(samples[s].Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address.); err != nil || addr >= next { |
| 664 | break |
| 665 | } |
| 666 | sample := samples[s] |
| 667 | n.flatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flatDiv. += sample.FlatDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatDiv. |
| 668 | n.flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#flat. += sample.Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Flat. |
| 669 | n.cumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cumDiv. += sample.CumDivscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumDiv. |
| 670 | n.cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#cum. += sample.Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Cum. |
| 671 | if f := sample.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.; f != "" && n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. == "" { |
| 672 | n.filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#file. = filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Base().(f) |
| 673 | } |
| 674 | if ln := sample.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Linenoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Lineno.; ln != 0 && n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. == 0 { |
| 675 | n.linescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#line. = ln |
| 676 | } |
| 677 | if f := sample.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.; f != "" && n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. == "" { |
| 678 | n.functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/assemblyInstruction#function. = f |
| 679 | } |
| 680 | } |
| 681 | asm = append(asm, n) |
| 682 | } |
| 683 | |
| 684 | return asm |
| 685 | } |
| 686 | |
| 687 | // valueOrDot formats a value according to a report, intercepting zero |
| 688 | // values. |
| 689 | func valueOrDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/valueOrDot().(value int64, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) string { |
| 690 | if value == 0 { |
| 691 | return "." |
| 692 | } |
| 693 | return rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(value) |
| 694 | } |
| 695 | |
| 696 | // printTags collects all tags referenced in the profile and prints |
| 697 | // them in a sorted table. |
| 698 | func printTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTags().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 699 | p := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 700 | |
| 701 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 702 | formatTag := func(v int64, unit string) string { |
| 703 | return measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.ScaledLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/ScaledLabel().(v, unit, o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 704 | } |
| 705 | |
| 706 | // Accumulate tags as key,value,count. |
| 707 | tagMap := make(map[string]map[string]int64) |
| 708 | // Note that we assume single value per tag per sample. Multiple values are |
| 709 | // encodable in the format but are discouraged. |
| 710 | tagTotalMap := make(map[string]int64) |
| 711 | for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. { |
| 712 | sampleValue := o.SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.(s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) |
| 713 | for key, vals := range s.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. { |
| 714 | for _, val := range vals { |
| 715 | valueMap, ok := tagMap[key] |
| 716 | if !ok { |
| 717 | valueMap = make(map[string]int64) |
| 718 | tagMap[key] = valueMap |
| 719 | } |
| 720 | valueMap[val] += sampleValue |
| 721 | tagTotalMap[key] += sampleValue |
| 722 | } |
| 723 | } |
| 724 | for key, vals := range s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. { |
| 725 | unit := o.NumLabelUnitsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NumLabelUnits.[key] |
| 726 | for _, nval := range vals { |
| 727 | val := formatTag(nval, unit) |
| 728 | valueMap, ok := tagMap[key] |
| 729 | if !ok { |
| 730 | valueMap = make(map[string]int64) |
| 731 | tagMap[key] = valueMap |
| 732 | } |
| 733 | valueMap[val] += sampleValue |
| 734 | tagTotalMap[key] += sampleValue |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | tagKeys := make([]*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#, 0, len(tagMap)) |
| 740 | for key := range tagMap { |
| 741 | tagKeys = append(tagKeys, &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.: key}) |
| 742 | } |
| 743 | tabw := tabwriterscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/.NewWriterscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/NewWriter().(w, 0, 0, 1, ' ', tabwriterscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/.AlignRightscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/AlignRight.) |
| 744 | for _, tagKey := range graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.SortTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/SortTags().(tagKeys, true) { |
| 745 | key := tagKey.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name. |
| 746 | tags := make([]*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#, 0, len(tagMap[key])) |
| 747 | for t, c := range tagMap[key] { |
| 748 | tags = append(tags, &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Tagscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.: t, Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Flat.: c}) |
| 749 | } |
| 750 | |
| 751 | tagTotal, profileTotal := tagTotalMap[key], rpt.Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#Total().() |
| 752 | if profileTotal > 0 { |
| 753 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(tabw, "%s:\t Total %s of %s (%s)\n", key, rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(tagTotal), rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(profileTotal), measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(tagTotal, profileTotal)) |
| 754 | } else { |
| 755 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(tabw, "%s:\t Total %s of %s\n", key, rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(tagTotal), rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(profileTotal)) |
| 756 | } |
| 757 | for _, t := range graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.SortTagsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/SortTags().(tags, true) { |
| 758 | if profileTotal > 0 { |
| 759 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(tabw, " \t%s (%s):\t %s\n", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().()), measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().(), profileTotal), t.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.) |
| 760 | } else { |
| 761 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(tabw, " \t%s:\t %s\n", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(t.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#FlatValue().()), t.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Tag#Name.) |
| 762 | } |
| 763 | } |
| 764 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(tabw) |
| 765 | } |
| 766 | return tabw.Flushscip-go gomod github.com/golang/go/src go1.24.0 `text/tabwriter`/Writer#Flush().() |
| 767 | } |
| 768 | |
| 769 | // printComments prints all freeform comments in the profile. |
| 770 | func printCommentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printComments().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 771 | p := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 772 | |
| 773 | for _, c := range p.Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Comments. { |
| 774 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, c) |
| 775 | } |
| 776 | return nil |
| 777 | } |
| 778 | |
| 779 | // TextItem holds a single text report entry. |
| 780 | type TextItemscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem# struct { |
| 781 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Name. string |
| 782 | InlineLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#InlineLabel. string // Not empty if inlined |
| 783 | Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Flat., Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Cum. int64 // Raw values |
| 784 | FlatFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#FlatFormat., CumFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#CumFormat. string // Formatted values |
| 785 | } |
| 786 | |
| 787 | // TextItems returns a list of text items from the report and a list |
| 788 | // of labels that describe the report. |
| 789 | func TextItemsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItems().(rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) ([]TextItemscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#, []string) { |
| 790 | g, origCount, droppedNodes, _ := rpt.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 791 | rpt.selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g) |
| 792 | labels := reportLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/reportLabels().(rpt, graphTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/graphTotal().(g), len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.), origCount, droppedNodes, 0, false) |
| 793 | |
| 794 | var items []TextItemscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem# |
| 795 | var flatSum int64 |
| 796 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 797 | name, flat, cum := n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(), n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().(), n.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().() |
| 798 | |
| 799 | var inline, noinline bool |
| 800 | for _, e := range n.Inscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#In. { |
| 801 | if e.Inlinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Inline. { |
| 802 | inline = true |
| 803 | } else { |
| 804 | noinline = true |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | var inl string |
| 809 | if inline { |
| 810 | if noinline { |
| 811 | inl = "(partial-inline)" |
| 812 | } else { |
| 813 | inl = "(inline)" |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | flatSum += flat |
| 818 | items = append(items, TextItemscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#{ |
| 819 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Name.: name, |
| 820 | InlineLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#InlineLabel.: inl, |
| 821 | Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Flat.: flat, |
| 822 | Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Cum.: cum, |
| 823 | FlatFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#FlatFormat.: rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(flat), |
| 824 | CumFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#CumFormat.: rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(cum), |
| 825 | }) |
| 826 | } |
| 827 | return items, labels |
| 828 | } |
| 829 | |
| 830 | // printText prints a flat text report for a profile. |
| 831 | func printTextscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printText().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 832 | items, labels := TextItemsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItems().(rpt) |
| 833 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(labels, "\n")) |
| 834 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %5s%% %5s%% %10s %5s%%\n", |
| 835 | "flat", "flat", "sum", "cum", "cum") |
| 836 | var flatSum int64 |
| 837 | for _, item := range items { |
| 838 | inl := item.InlineLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#InlineLabel. |
| 839 | if inl != "" { |
| 840 | inl = " " + inl |
| 841 | } |
| 842 | flatSum += item.Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Flat. |
| 843 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %s %s %10s %s %s%s\n", |
| 844 | item.FlatFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#FlatFormat., measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(item.Flatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Flat., rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 845 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(flatSum, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 846 | item.CumFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#CumFormat., measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(item.Cumscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Cum., rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 847 | item.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TextItem#Name., inl) |
| 848 | } |
| 849 | return nil |
| 850 | } |
| 851 | |
| 852 | // printTraces prints all traces from a profile. |
| 853 | func printTracesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTraces().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 854 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ProfileLabels().(rpt), "\n")) |
| 855 | |
| 856 | prof := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 857 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 858 | |
| 859 | const separator = "-----------+-------------------------------------------------------" |
| 860 | |
| 861 | _, locations := graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.CreateNodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/CreateNodes().(prof, &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Options#{}) |
| 862 | for _, sample := range prof.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. { |
| 863 | type stk struct { |
| 864 | *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo# |
| 865 | inline bool |
| 866 | } |
| 867 | var stack []stk |
| 868 | for _, loc := range sample.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location. { |
| 869 | nodes := locations[loc.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.] |
| 870 | for i, n := range nodes { |
| 871 | // The inline flag may be inaccurate if 'show' or 'hide' filter is |
| 872 | // used. See https://github.com/google/pprof/issues/511. |
| 873 | inline := i != len(nodes)-1 |
| 874 | stack = append(stack, stk{&n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info., inline}) |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | if len(stack) == 0 { |
| 879 | continue |
| 880 | } |
| 881 | |
| 882 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, separator) |
| 883 | // Print any text labels for the sample. |
| 884 | var labels []string |
| 885 | for s, vs := range sample.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. { |
| 886 | labels = append(labels, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%10s: %s\n", s, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(vs, " "))) |
| 887 | } |
| 888 | sortscip-go gomod github.com/golang/go/src go1.24.0 sort/.Stringsscip-go gomod github.com/golang/go/src go1.24.0 sort/Strings().(labels) |
| 889 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprint().(w, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(labels, "")) |
| 890 | |
| 891 | // Print any numeric labels for the sample |
| 892 | var numLabels []string |
| 893 | for key, vals := range sample.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. { |
| 894 | unit := o.NumLabelUnitsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NumLabelUnits.[key] |
| 895 | numValues := make([]string, len(vals)) |
| 896 | for i, vv := range vals { |
| 897 | numValues[i] = measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Label().(vv, unit) |
| 898 | } |
| 899 | numLabels = append(numLabels, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%10s: %s\n", key, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(numValues, " "))) |
| 900 | } |
| 901 | sortscip-go gomod github.com/golang/go/src go1.24.0 sort/.Stringsscip-go gomod github.com/golang/go/src go1.24.0 sort/Strings().(numLabels) |
| 902 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprint().(w, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(numLabels, "")) |
| 903 | |
| 904 | var d, v int64 |
| 905 | v = o.SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.(sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) |
| 906 | if o.SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleMeanDivisor. != nil { |
| 907 | d = o.SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleMeanDivisor.(sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) |
| 908 | } |
| 909 | // Print call stack. |
| 910 | if d != 0 { |
| 911 | v = v / d |
| 912 | } |
| 913 | for i, s := range stack { |
| 914 | var vs, inline string |
| 915 | if i == 0 { |
| 916 | vs = rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(v) |
| 917 | } |
| 918 | if s.inline { |
| 919 | inline = " (inline)" |
| 920 | } |
| 921 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %s%s\n", vs, s.PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(), inline) |
| 922 | } |
| 923 | } |
| 924 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, separator) |
| 925 | return nil |
| 926 | } |
| 927 | |
| 928 | // printCallgrind prints a graph for a profile on callgrind format. |
| 929 | func printCallgrindscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printCallgrind().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 930 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 931 | rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..NodeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeFraction. = 0 |
| 932 | rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..EdgeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#EdgeFraction. = 0 |
| 933 | rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..NodeCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeCount. = 0 |
| 934 | |
| 935 | g, _, _, _ := rpt.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 936 | rpt.selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g) |
| 937 | |
| 938 | nodeNames := getDisambiguatedNamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/getDisambiguatedNames().(g) |
| 939 | |
| 940 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "positions: instr line") |
| 941 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "events:", o.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleType.+"("+o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.+")") |
| 942 | |
| 943 | objfiles := make(map[string]int) |
| 944 | files := make(map[string]int) |
| 945 | names := make(map[string]int) |
| 946 | |
| 947 | // prevInfo points to the previous NodeInfo. |
| 948 | // It is used to group cost lines together as much as possible. |
| 949 | var prevInfo *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo# |
| 950 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 951 | if prevInfo == nil || n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Objfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Objfile. != prevInfo.Objfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Objfile. || n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File. != prevInfo.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File. || n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. != prevInfo.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. { |
| 952 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w) |
| 953 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "ob="+callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(objfiles, n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Objfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Objfile.)) |
| 954 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "fl="+callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(files, n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.)) |
| 955 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "fn="+callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(names, n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.)) |
| 956 | } |
| 957 | |
| 958 | addr := callgrindAddressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindAddress().(prevInfo, n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address.) |
| 959 | sv, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().(), o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 960 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%s %d %d\n", addr, n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Linenoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Lineno., int64(sv)) |
| 961 | |
| 962 | // Print outgoing edges. |
| 963 | for _, out := range n.Outscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Out..Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/EdgeMap#Sort().() { |
| 964 | c, _ := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(out.Weightscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Weight., o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 965 | callee := out.Destscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Dest. |
| 966 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "cfl="+callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(files, callee.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.)) |
| 967 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, "cfn="+callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(names, nodeNames[callee])) |
| 968 | // pprof doesn't have a flat weight for a call, leave as 0. |
| 969 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "calls=0 %s %d\n", callgrindAddressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindAddress().(prevInfo, callee.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address.), callee.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Linenoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Lineno.) |
| 970 | // TODO: This address may be in the middle of a call |
| 971 | // instruction. It would be best to find the beginning |
| 972 | // of the instruction, but the tools seem to handle |
| 973 | // this OK. |
| 974 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "* * %d\n", int64(c)) |
| 975 | } |
| 976 | |
| 977 | prevInfo = &n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info. |
| 978 | } |
| 979 | |
| 980 | return nil |
| 981 | } |
| 982 | |
| 983 | // getDisambiguatedNames returns a map from each node in the graph to |
| 984 | // the name to use in the callgrind output. Callgrind merges all |
| 985 | // functions with the same [file name, function name]. Add a [%d/n] |
| 986 | // suffix to disambiguate nodes with different values of |
| 987 | // node.Function, which we want to keep separate. In particular, this |
| 988 | // affects graphs created with --call_tree, where nodes from different |
| 989 | // contexts are associated to different Functions. |
| 990 | func getDisambiguatedNamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/getDisambiguatedNames().(g *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#) map[*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]string { |
| 991 | nodeName := make(map[*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]string, len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.)) |
| 992 | |
| 993 | type names struct { |
| 994 | file, function string |
| 995 | } |
| 996 | |
| 997 | // nameFunctionIndex maps the callgrind names (filename, function) |
| 998 | // to the node.Function values found for that name, and each |
| 999 | // node.Function value to a sequential index to be used on the |
| 1000 | // disambiguated name. |
| 1001 | nameFunctionIndex := make(map[names]map[*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]int) |
| 1002 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 1003 | nm := names{n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File., n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.} |
| 1004 | p, ok := nameFunctionIndex[nm] |
| 1005 | if !ok { |
| 1006 | p = make(map[*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]int) |
| 1007 | nameFunctionIndex[nm] = p |
| 1008 | } |
| 1009 | if _, ok := p[n.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.]; !ok { |
| 1010 | p[n.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.] = len(p) |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 1015 | nm := names{n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File., n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.} |
| 1016 | nodeName[n] = n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name. |
| 1017 | if p := nameFunctionIndex[nm]; len(p) > 1 { |
| 1018 | // If there is more than one function, add suffix to disambiguate. |
| 1019 | nodeName[n] += fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().(" [%d/%d]", p[n.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.]+1, len(p)) |
| 1020 | } |
| 1021 | } |
| 1022 | return nodeName |
| 1023 | } |
| 1024 | |
| 1025 | // callgrindName implements the callgrind naming compression scheme. |
| 1026 | // For names not previously seen returns "(N) name", where N is a |
| 1027 | // unique index. For names previously seen returns "(N)" where N is |
| 1028 | // the index returned the first time. |
| 1029 | func callgrindNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindName().(names map[string]int, name string) string { |
| 1030 | if name == "" { |
| 1031 | return "" |
| 1032 | } |
| 1033 | if id, ok := names[name]; ok { |
| 1034 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("(%d)", id) |
| 1035 | } |
| 1036 | id := len(names) + 1 |
| 1037 | names[name] = id |
| 1038 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("(%d) %s", id, name) |
| 1039 | } |
| 1040 | |
| 1041 | // callgrindAddress implements the callgrind subposition compression scheme if |
| 1042 | // possible. If prevInfo != nil, it contains the previous address. The current |
| 1043 | // address can be given relative to the previous address, with an explicit +/- |
| 1044 | // to indicate it is relative, or * for the same address. |
| 1045 | func callgrindAddressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/callgrindAddress().(prevInfo *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#, curr uint64) string { |
| 1046 | abs := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%#x", curr) |
| 1047 | if prevInfo == nil { |
| 1048 | return abs |
| 1049 | } |
| 1050 | |
| 1051 | prev := prevInfo.Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Address. |
| 1052 | if prev == curr { |
| 1053 | return "*" |
| 1054 | } |
| 1055 | |
| 1056 | diff := int64(curr - prev) |
| 1057 | relative := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%+d", diff) |
| 1058 | |
| 1059 | // Only bother to use the relative address if it is actually shorter. |
| 1060 | if len(relative) < len(abs) { |
| 1061 | return relative |
| 1062 | } |
| 1063 | |
| 1064 | return abs |
| 1065 | } |
| 1066 | |
| 1067 | // printTree prints a tree-based report in text form. |
| 1068 | func printTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printTree().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 1069 | const separator = "----------------------------------------------------------+-------------" |
| 1070 | const legend = " flat flat% sum% cum cum% calls calls% + context " |
| 1071 | |
| 1072 | g, origCount, droppedNodes, _ := rpt.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 1073 | rpt.selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g) |
| 1074 | |
| 1075 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(reportLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/reportLabels().(rpt, graphTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/graphTotal().(g), len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.), origCount, droppedNodes, 0, false), "\n")) |
| 1076 | |
| 1077 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, separator) |
| 1078 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, legend) |
| 1079 | var flatSum int64 |
| 1080 | |
| 1081 | rx := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol. |
| 1082 | matched := 0 |
| 1083 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 1084 | name, flat, cum := n.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(), n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().(), n.CumValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#CumValue().() |
| 1085 | |
| 1086 | // Skip any entries that do not match the regexp (for the "peek" command). |
| 1087 | if rx != nil && !rx.MatchStringscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#MatchString().(name) { |
| 1088 | continue |
| 1089 | } |
| 1090 | matched++ |
| 1091 | |
| 1092 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, separator) |
| 1093 | // Print incoming edges. |
| 1094 | inEdges := n.Inscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#In..Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/EdgeMap#Sort().() |
| 1095 | for _, in := range inEdges { |
| 1096 | var inline string |
| 1097 | if in.Inlinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Inline. { |
| 1098 | inline = " (inline)" |
| 1099 | } |
| 1100 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%50s %s | %s%s\n", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(in.Weightscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Weight.), |
| 1101 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(in.Weightscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Weight., cum), in.Srcscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Src..Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(), inline) |
| 1102 | } |
| 1103 | |
| 1104 | // Print current node. |
| 1105 | flatSum += flat |
| 1106 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%10s %s %s %10s %s | %s\n", |
| 1107 | rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(flat), |
| 1108 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(flat, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 1109 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(flatSum, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 1110 | rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(cum), |
| 1111 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(cum, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), |
| 1112 | name) |
| 1113 | |
| 1114 | // Print outgoing edges. |
| 1115 | outEdges := n.Outscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Out..Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/EdgeMap#Sort().() |
| 1116 | for _, out := range outEdges { |
| 1117 | var inline string |
| 1118 | if out.Inlinescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Inline. { |
| 1119 | inline = " (inline)" |
| 1120 | } |
| 1121 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(w, "%50s %s | %s%s\n", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(out.Weightscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Weight.), |
| 1122 | measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(out.Weightscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Weight., cum), out.Destscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Edge#Dest..Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..PrintableNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#PrintableName().(), inline) |
| 1123 | } |
| 1124 | } |
| 1125 | if len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.) > 0 { |
| 1126 | fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintln().(w, separator) |
| 1127 | } |
| 1128 | if rx != nil && matched == 0 { |
| 1129 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("no matches found for regexp: %s", rx) |
| 1130 | } |
| 1131 | return nil |
| 1132 | } |
| 1133 | |
| 1134 | // GetDOT returns a graph suitable for dot processing along with some |
| 1135 | // configuration information. |
| 1136 | func GetDOTscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/GetDOT().(rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) (*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#, *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.DotConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#) { |
| 1137 | g, origCount, droppedNodes, droppedEdges := rpt.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 1138 | rpt.selectOutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#selectOutputUnit().(g) |
| 1139 | labels := reportLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/reportLabels().(rpt, graphTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/graphTotal().(g), len(g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.), origCount, droppedNodes, droppedEdges, true) |
| 1140 | |
| 1141 | c := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.DotConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#{ |
| 1142 | Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Title.: rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Title., |
| 1143 | Labelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Labels.: labels, |
| 1144 | FormatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#FormatValue.: rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue., |
| 1145 | Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotConfig#Total.: rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total., |
| 1146 | } |
| 1147 | return g, c |
| 1148 | } |
| 1149 | |
| 1150 | // printDOT prints an annotated callgraph in DOT format. |
| 1151 | func printDOTscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/printDOT().(w ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) error { |
| 1152 | g, c := GetDOTscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/GetDOT().(rpt) |
| 1153 | graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.ComposeDotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/ComposeDot().(w, g, &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.DotAttributesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/DotAttributes#{}, c) |
| 1154 | return nil |
| 1155 | } |
| 1156 | |
| 1157 | // ProfileLabels returns printable labels for a profile. |
| 1158 | func ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ProfileLabels().(rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) []string { |
| 1159 | label := []string{} |
| 1160 | prof := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. |
| 1161 | o := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. |
| 1162 | if len(prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.) > 0 { |
| 1163 | if prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != "" { |
| 1164 | label = append(label, "File: "+filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Base().(prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.)) |
| 1165 | } |
| 1166 | if prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. != "" { |
| 1167 | label = append(label, "Build ID: "+prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.) |
| 1168 | } |
| 1169 | } |
| 1170 | // Only include comments that do not start with '#'. |
| 1171 | for _, c := range prof.Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Comments. { |
| 1172 | if !stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.24.0 strings/HasPrefix().(c, "#") { |
| 1173 | label = append(label, c) |
| 1174 | } |
| 1175 | } |
| 1176 | if o.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleType. != "" { |
| 1177 | label = append(label, "Type: "+o.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleType.) |
| 1178 | } |
| 1179 | if url := prof.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL.; url != "" { |
| 1180 | label = append(label, "Doc: "+url) |
| 1181 | } |
| 1182 | if prof.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos. != 0 { |
| 1183 | const layout = "2006-01-02 15:04:05 MST" |
| 1184 | label = append(label, "Time: "+timescip-go gomod github.com/golang/go/src go1.24.0 time/.Unixscip-go gomod github.com/golang/go/src go1.24.0 time/Unix().(0, prof.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.).Formatscip-go gomod github.com/golang/go/src go1.24.0 time/Time#Format().(layout)) |
| 1185 | } |
| 1186 | if prof.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos. != 0 { |
| 1187 | duration := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Label().(prof.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos., "nanoseconds") |
| 1188 | totalNanos, totalUnit := measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Scale().(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total., o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., "nanoseconds") |
| 1189 | var ratio string |
| 1190 | if totalUnit == "ns" && totalNanos != 0 { |
| 1191 | ratio = "(" + measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(int64(totalNanos), prof.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.) + ")" |
| 1192 | } |
| 1193 | label = append(label, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("Duration: %s, Total samples = %s %s", duration, rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.), ratio)) |
| 1194 | } |
| 1195 | return label |
| 1196 | } |
| 1197 | |
| 1198 | func graphTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/graphTotal().(g *graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#) int64 { |
| 1199 | var total int64 |
| 1200 | for _, n := range g.Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes. { |
| 1201 | total += n.FlatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#FlatValue().() |
| 1202 | } |
| 1203 | return total |
| 1204 | } |
| 1205 | |
| 1206 | // reportLabels returns printable labels for a report. Includes |
| 1207 | // profileLabels. |
| 1208 | func reportLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/reportLabels().(rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#, shownTotal int64, nodeCount, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string { |
| 1209 | nodeFraction := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..NodeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#NodeFraction. |
| 1210 | edgeFraction := rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..EdgeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#EdgeFraction. |
| 1211 | |
| 1212 | var label []string |
| 1213 | if len(rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ProfileLabels.) > 0 { |
| 1214 | label = append(label, rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ProfileLabels....) |
| 1215 | } else if fullHeaders || !rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..CompactLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CompactLabels. { |
| 1216 | label = ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ProfileLabels().(rpt) |
| 1217 | } |
| 1218 | |
| 1219 | if len(rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..ActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ActiveFilters.) > 0 { |
| 1220 | activeFilters := legendActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/legendActiveFilters().(rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..ActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#ActiveFilters.) |
| 1221 | label = append(label, activeFilters...) |
| 1222 | } |
| 1223 | |
| 1224 | label = append(label, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("Showing nodes accounting for %s, %s of %s total", rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(shownTotal), stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.24.0 strings/TrimSpace().(measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.Percentagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/Percentage().(shownTotal, rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.)), rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.))) |
| 1225 | |
| 1226 | if rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total. != 0 { |
| 1227 | if droppedNodes > 0 { |
| 1228 | label = append(label, genLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/genLabel().(droppedNodes, "node", "cum", |
| 1229 | rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(int64(float64(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.)*nodeFraction))))) |
| 1230 | } |
| 1231 | if droppedEdges > 0 { |
| 1232 | label = append(label, genLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/genLabel().(droppedEdges, "edge", "freq", |
| 1233 | rpt.formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue.(abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(int64(float64(rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total.)*edgeFraction))))) |
| 1234 | } |
| 1235 | if nodeCount > 0 && nodeCount < origCount { |
| 1236 | label = append(label, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("Showing top %d nodes out of %d", |
| 1237 | nodeCount, origCount)) |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | // Help new users understand the graph. |
| 1242 | // A new line is intentionally added here to better show this message. |
| 1243 | if fullHeaders { |
| 1244 | label = append(label, "\nSee https://git.io/JfYMW for how to read the graph") |
| 1245 | } |
| 1246 | |
| 1247 | return label |
| 1248 | } |
| 1249 | |
| 1250 | func legendActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/legendActiveFilters().(activeFilters []string) []string { |
| 1251 | legendActiveFilters := make([]string, len(activeFilters)+1) |
| 1252 | legendActiveFilters[0] = "Active filters:" |
| 1253 | for i, s := range activeFilters { |
| 1254 | if len(s) > 80 { |
| 1255 | s = s[:80] + "…" |
| 1256 | } |
| 1257 | legendActiveFilters[i+1] = " " + s |
| 1258 | } |
| 1259 | return legendActiveFilters |
| 1260 | } |
| 1261 | |
| 1262 | func genLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/genLabel().(d int, n, l, f string) string { |
| 1263 | if d > 1 { |
| 1264 | n = n + "s" |
| 1265 | } |
| 1266 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("Dropped %d %s (%s <= %s)", d, n, l, f) |
| 1267 | } |
| 1268 | |
| 1269 | // New builds a new report indexing the sample values interpreting the |
| 1270 | // samples with the provided function. |
| 1271 | func Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(prof *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, o *Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#) *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report# { |
| 1272 | format := func(v int64) string { |
| 1273 | if r := o.Ratioscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Ratio.; r > 0 && r != 1 { |
| 1274 | fv := float64(v) * r |
| 1275 | v = int64(fv) |
| 1276 | } |
| 1277 | return measurementscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/.ScaledLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/measurement`/ScaledLabel().(v, o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit., o.OutputUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputUnit.) |
| 1278 | } |
| 1279 | return &Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#{prof, computeTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/computeTotal().(prof, o.SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue., o.SampleMeanDivisorscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleMeanDivisor.), |
| 1280 | o, format} |
| 1281 | } |
| 1282 | |
| 1283 | // NewDefault builds a new report indexing the last sample value |
| 1284 | // available. |
| 1285 | func NewDefaultscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/NewDefault().(prof *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, options Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#) *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report# { |
| 1286 | index := len(prof.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.) - 1 |
| 1287 | o := &options |
| 1288 | if o.Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Title. == "" && len(prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.) > 0 && prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != "" { |
| 1289 | o.Titlescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Title. = filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Base().(prof.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0].Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.) |
| 1290 | } |
| 1291 | o.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleType. = prof.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[index].Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type. |
| 1292 | o.SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit. = stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.24.0 strings/ToLower().(prof.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[index].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.) |
| 1293 | o.SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue. = func(v []int64) int64 { |
| 1294 | return v[index] |
| 1295 | } |
| 1296 | return Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(prof, o) |
| 1297 | } |
| 1298 | |
| 1299 | // computeTotal computes the sum of the absolute value of all sample values. |
| 1300 | // If any samples have label indicating they belong to the diff base, then the |
| 1301 | // total will only include samples with that label. |
| 1302 | func computeTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/computeTotal().(prof *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, value, meanDiv func(v []int64) int64) int64 { |
| 1303 | var div, total, diffDiv, diffTotal int64 |
| 1304 | for _, sample := range prof.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. { |
| 1305 | var d, v int64 |
| 1306 | v = value(sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) |
| 1307 | if meanDiv != nil { |
| 1308 | d = meanDiv(sample.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) |
| 1309 | } |
| 1310 | if v < 0 { |
| 1311 | v = -v |
| 1312 | } |
| 1313 | total += v |
| 1314 | div += d |
| 1315 | if sample.DiffBaseSamplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#DiffBaseSample().() { |
| 1316 | diffTotal += v |
| 1317 | diffDiv += d |
| 1318 | } |
| 1319 | } |
| 1320 | if diffTotal > 0 { |
| 1321 | total = diffTotal |
| 1322 | div = diffDiv |
| 1323 | } |
| 1324 | if div != 0 { |
| 1325 | return total / div |
| 1326 | } |
| 1327 | return total |
| 1328 | } |
| 1329 | |
| 1330 | // Report contains the data and associated routines to extract a |
| 1331 | // report from a profile. |
| 1332 | type Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report# struct { |
| 1333 | profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof. *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# |
| 1334 | totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total. int64 |
| 1335 | optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options. *Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options# |
| 1336 | formatValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#formatValue. func(int64) string |
| 1337 | } |
| 1338 | |
| 1339 | // Total returns the total number of samples in a report. |
| 1340 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) Totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#Total().() int64 { return rpt.totalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#total. } |
| 1341 | |
| 1342 | // OutputFormat returns the output format for the report. |
| 1343 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#OutputFormat().() int { return rpt.optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. } |
| 1344 | |
| 1345 | // DocURL returns the documentation URL for Report, or "" if not available. |
| 1346 | func (rpt *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#) DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#DocURL().() string { |
| 1347 | u := rpt.profscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#prof..DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL. |
| 1348 | if u == "" || !absoluteURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/absoluteURL().(u) { |
| 1349 | return "" |
| 1350 | } |
| 1351 | return u |
| 1352 | } |
| 1353 | |
| 1354 | func absoluteURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/absoluteURL().(str string) bool { |
| 1355 | // Avoid returning relative URLs to prevent unwanted local navigation |
| 1356 | // within pprof server. |
| 1357 | u, err := urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.24.0 `net/url`/Parse().(str) |
| 1358 | return err == nil && (u.Schemescip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#Scheme. == "https" || u.Schemescip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#Scheme. == "http") |
| 1359 | } |
| 1360 | |
| 1361 | func abs64scip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/abs64().(i int64) int64 { |
| 1362 | if i < 0 { |
| 1363 | return -i |
| 1364 | } |
| 1365 | return i |
| 1366 | } |