Debian Codegraph @

profile/profile.go

raw symbols SCIP
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 profile provides a representation of profile.proto and
16 // methods to encode/decode profiles in this format.
17 package profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/
18
19 import (
20 "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/"
21 "compress/gzipscip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/"
22 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
23 "ioscip-go gomod github.com/golang/go/src go1.24.0 io/"
24 "mathscip-go gomod github.com/golang/go/src go1.24.0 math/"
25 "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/"
26 "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/"
27 "slicesscip-go gomod github.com/golang/go/src go1.24.0 slices/"
28 "sortscip-go gomod github.com/golang/go/src go1.24.0 sort/"
29 "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/"
30 "syncscip-go gomod github.com/golang/go/src go1.24.0 sync/"
31 "timescip-go gomod github.com/golang/go/src go1.24.0 time/"
32 )
33
34 // Profile is an in-memory representation of profile.proto.
35 type Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# struct {
36 SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType. []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#
37 DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType. string
38 Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#
39 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. []*Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#
40 Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#
41 Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function. []*Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#
42 Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Comments. []string
43 DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL. string
44
45 DropFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DropFrames. string
46 KeepFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#KeepFrames. string
47
48 TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos. int64
49 DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos. int64
50 PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType. *ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#
51 Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period. int64
52
53 // The following fields are modified during encoding and copying,
54 // so are protected by a Mutex.
55 encodeMuscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#encodeMu. syncscip-go gomod github.com/golang/go/src go1.24.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.24.0 sync/Mutex#
56
57 commentXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#commentX. []int64
58 docURLXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#docURLX. int64
59 dropFramesXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#dropFramesX. int64
60 keepFramesXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#keepFramesX. int64
61 stringTablescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#stringTable. []string
62 defaultSampleTypeXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#defaultSampleTypeX. int64
63 }
64
65 // ValueType corresponds to Profile.ValueType
66 type ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType# struct {
67 Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type. string // cpu, wall, inuse_space, etc
68 Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit. string // seconds, nanoseconds, bytes, etc
69
70 typeXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#typeX. int64
71 unitXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#unitX. int64
72 }
73
74 // Sample corresponds to Profile.Sample
75 type Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample# struct {
76 Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location. []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#
77 Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value. []int64
78 // Label is a per-label-key map to values for string labels.
79 //
80 // In general, having multiple values for the given label key is strongly
81 // discouraged - see docs for the sample label field in profile.proto. The
82 // main reason this unlikely state is tracked here is to make the
83 // decoding->encoding roundtrip not lossy. But we expect that the value
84 // slices present in this map are always of length 1.
85 Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. map[string][]string
86 // NumLabel is a per-label-key map to values for numeric labels. See a note
87 // above on handling multiple values for a label.
88 NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. map[string][]int64
89 // NumUnit is a per-label-key map to the unit names of corresponding numeric
90 // label values. The unit info may be missing even if the label is in
91 // NumLabel, see the docs in profile.proto for details. When the value is
92 // slice is present and not nil, its length must be equal to the length of
93 // the corresponding value slice in NumLabel.
94 NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit. map[string][]string
95
96 locationIDXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#locationIDX. []uint64
97 labelXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#labelX. []labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label#
98 }
99
100 // label corresponds to Profile.Label
101 type labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label# struct {
102 keyXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label#keyX. int64
103 // Exactly one of the two following values must be set
104 strXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label#strX. int64
105 numXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label#numX. int64 // Integer value for this label
106 // can be set if numX has value
107 unitXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/label#unitX. int64
108 }
109
110 // Mapping corresponds to Profile.Mapping
111 type Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping# struct {
112 IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. uint64
113 Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start. uint64
114 Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit. uint64
115 Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset. uint64
116 Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. string
117 BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. string
118 HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions. bool
119 HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames. bool
120 HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers. bool
121 HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames. bool
122
123 fileXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#fileX. int64
124 buildIDXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#buildIDX. int64
125
126 // Name of the kernel relocation symbol ("_text" or "_stext"), extracted from File.
127 // For linux kernel mappings generated by some tools, correct symbolization depends
128 // on knowing which of the two possible relocation symbols was used for `Start`.
129 // This is given to us as a suffix in `File` (e.g. "[kernel.kallsyms]_stext").
130 //
131 // Note, this public field is not persisted in the proto. For the purposes of
132 // copying / merging / hashing profiles, it is considered subsumed by `File`.
133 KernelRelocationSymbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#KernelRelocationSymbol. string
134 }
135
136 // Location corresponds to Profile.Location
137 type Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location# struct {
138 IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID. uint64
139 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping. *Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#
140 Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address. uint64
141 Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#
142 IsFoldedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#IsFolded. bool
143
144 mappingIDXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#mappingIDX. uint64
145 }
146
147 // Line corresponds to Profile.Line
148 type Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line# struct {
149 Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function. *Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#
150 Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line. int64
151 Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column. int64
152
153 functionIDXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#functionIDX. uint64
154 }
155
156 // Function corresponds to Profile.Function
157 type Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function# struct {
158 IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID. uint64
159 Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name. string
160 SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName. string
161 Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename. string
162 StartLinescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#StartLine. int64
163
164 nameXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#nameX. int64
165 systemNameXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#systemNameX. int64
166 filenameXscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#filenameX. int64
167 }
168
169 // Parse parses a profile and checks for its validity. The input
170 // may be a gzip-compressed encoded protobuf or one of many legacy
171 // profile formats which may be unsupported in the future.
172 func Parsescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Parse().(r ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Readerscip-go gomod github.com/golang/go/src go1.24.0 io/Reader#) (*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, error) {
173 data, err := ioscip-go gomod github.com/golang/go/src go1.24.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.24.0 io/ReadAll().(r)
174 if err != nil {
175 return nil, err
176 }
177 return ParseDatascip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ParseData().(data)
178 }
179
180 // ParseData parses a profile from a buffer and checks for its
181 // validity.
182 func ParseDatascip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ParseData().(data []byte) (*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, error) {
183 var p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#
184 var err error
185 if len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b {
186 gz, err := gzipscip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/.NewReaderscip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/NewReader().(bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewBuffer().(data))
187 if err == nil {
188 data, err = ioscip-go gomod github.com/golang/go/src go1.24.0 io/.ReadAllscip-go gomod github.com/golang/go/src go1.24.0 io/ReadAll().(gz)
189 }
190 if err != nil {
191 return nil, 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().("decompressing profile: %v", err)
192 }
193 }
194 if p, err = ParseUncompressedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ParseUncompressed().(data); err != nil && err != errNoDatascip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errNoData. && err != errConcatProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errConcatProfile. {
195 p, err = parseLegacyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseLegacy().(data)
196 }
197
198 if err != nil {
199 return nil, 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().("parsing profile: %v", err)
200 }
201
202 if err := p.CheckValidscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#CheckValid().(); err != nil {
203 return nil, 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().("malformed profile: %v", err)
204 }
205 return p, nil
206 }
207
208 var errUnrecognizedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errUnrecognized. = 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().("unrecognized profile format")
209 var errMalformedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errMalformed. = 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().("malformed profile format")
210 var errNoDatascip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errNoData. = 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().("empty input file")
211 var errConcatProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errConcatProfile. = 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().("concatenated profiles detected")
212
213 func parseLegacyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseLegacy().(data []byte) (*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, error) {
214 parsers := []func([]byte) (*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, error){
215 parseCPUscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseCPU().,
216 parseHeapscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseHeap().,
217 parseGoCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseGoCount()., // goroutine, threadcreate
218 parseThreadscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseThread().,
219 parseContentionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseContention().,
220 parseJavaProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/parseJavaProfile().,
221 }
222
223 for _, parser := range parsers {
224 p, err := parser(data)
225 if err == nil {
226 p.addLegacyFrameInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#addLegacyFrameInfo().()
227 return p, nil
228 }
229 if err != errUnrecognizedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errUnrecognized. {
230 return nil, err
231 }
232 }
233 return nil, errUnrecognizedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errUnrecognized.
234 }
235
236 // ParseUncompressed parses an uncompressed protobuf into a profile.
237 func ParseUncompressedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ParseUncompressed().(data []byte) (*Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#, error) {
238 if len(data) == 0 {
239 return nil, errNoDatascip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/errNoData.
240 }
241 p := &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{}
242 if err := unmarshalscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/unmarshal().(data, p); err != nil {
243 return nil, err
244 }
245
246 if err := p.postDecodescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#postDecode().(); err != nil {
247 return nil, err
248 }
249
250 return p, nil
251 }
252
253 var libRxscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/libRx. = regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`([.]so$|[.]so[._][0-9]+)`)
254
255 // massageMappings applies heuristic-based changes to the profile
256 // mappings to account for quirks of some environments.
257 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) massageMappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#massageMappings().() {
258 // Merge adjacent regions with matching names, checking that the offsets match
259 if len(p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.) > 1 {
260 mappings := []*Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0]}
261 for _, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[1:] {
262 lm := mappings[len(mappings)-1]
263 if adjacentscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/adjacent().(lm, m) {
264 lm.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit. = m.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.
265 if m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != "" {
266 lm.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. = m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.
267 }
268 if m.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. != "" {
269 lm.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. = m.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.
270 }
271 p.updateLocationMappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#updateLocationMapping().(m, lm)
272 continue
273 }
274 mappings = append(mappings, m)
275 }
276 p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. = mappings
277 }
278
279 // Use heuristics to identify main binary and move it to the top of the list of mappings
280 for i, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. {
281 file := 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().(stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File., "(deleted)", ""))
282 if len(file) == 0 {
283 continue
284 }
285 if len(libRxscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/libRx..FindStringSubmatchscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#FindStringSubmatch().(file)) > 0 {
286 continue
287 }
288 if file[0] == '[' {
289 continue
290 }
291 // Swap what we guess is main to position 0.
292 p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0], p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[i] = p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[i], p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.[0]
293 break
294 }
295
296 // Keep the mapping IDs neatly sorted
297 for i, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. {
298 m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. = uint64(i + 1)
299 }
300 }
301
302 // adjacent returns whether two mapping entries represent the same
303 // mapping that has been split into two. Check that their addresses are adjacent,
304 // and if the offsets match, if they are available.
305 func adjacentscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/adjacent().(m1, m2 *Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#) bool {
306 if m1.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != "" && m2.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != "" {
307 if m1.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. != m2.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. {
308 return false
309 }
310 }
311 if m1.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. != "" && m2.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. != "" {
312 if m1.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. != m2.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID. {
313 return false
314 }
315 }
316 if m1.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit. != m2.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start. {
317 return false
318 }
319 if m1.Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset. != 0 && m2.Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset. != 0 {
320 offset := m1.Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset. + (m1.Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit. - m1.Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.)
321 if offset != m2.Offsetscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Offset. {
322 return false
323 }
324 }
325 return true
326 }
327
328 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) updateLocationMappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#updateLocationMapping().(from, to *Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#) {
329 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
330 if l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping. == from {
331 l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping. = to
332 }
333 }
334 }
335
336 func serializescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/serialize().(p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) []byte {
337 p.encodeMuscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#encodeMu..Lockscip-go gomod github.com/golang/go/src go1.24.0 sync/Mutex#Lock().()
338 p.preEncodescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#preEncode().()
339 b := marshalscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/marshal().(p)
340 p.encodeMuscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#encodeMu..Unlockscip-go gomod github.com/golang/go/src go1.24.0 sync/Mutex#Unlock().()
341 return b
342 }
343
344 // Write writes the profile as a gzip-compressed marshaled protobuf.
345 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) Writescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Write().(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#) error {
346 zw := gzipscip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/.NewWriterscip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/NewWriter().(w)
347 defer zw.Closescip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/Writer#Close().()
348 _, err := zw.Writescip-go gomod github.com/golang/go/src go1.24.0 `compress/gzip`/Writer#Write().(serializescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/serialize().(p))
349 return err
350 }
351
352 // WriteUncompressed writes the profile as a marshaled protobuf.
353 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) WriteUncompressedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#WriteUncompressed().(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#) error {
354 _, err := w.Writescip-go gomod github.com/golang/go/src go1.24.0 io/Writer#Write().(serializescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/serialize().(p))
355 return err
356 }
357
358 // CheckValid tests whether the profile is valid. Checks include, but are
359 // not limited to:
360 // - len(Profile.Sample[n].value) == len(Profile.value_unit)
361 // - Sample.id has a corresponding Profile.Location
362 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) CheckValidscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#CheckValid().() error {
363 // Check that sample values are consistent
364 sampleLen := len(p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.)
365 if sampleLen == 0 && len(p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.) != 0 {
366 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().("missing sample type information")
367 }
368 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
369 if s == nil {
370 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().("profile has nil sample")
371 }
372 if len(s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.) != sampleLen {
373 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().("mismatch: sample has %d values vs. %d types", len(s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.), len(p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.))
374 }
375 for _, l := range s.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location. {
376 if l == nil {
377 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().("sample has nil location")
378 }
379 }
380 }
381
382 // Check that all mappings/locations/functions are in the tables
383 // Check that there are no duplicate ids
384 mappings := make(map[uint64]*Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#, len(p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.))
385 for _, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. {
386 if m == nil {
387 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().("profile has nil mapping")
388 }
389 if m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. == 0 {
390 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().("found mapping with reserved ID=0")
391 }
392 if mappings[m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.] != nil {
393 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().("multiple mappings with same id: %d", m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.)
394 }
395 mappings[m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.] = m
396 }
397 functions := make(map[uint64]*Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#, len(p.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.))
398 for _, f := range p.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function. {
399 if f == nil {
400 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().("profile has nil function")
401 }
402 if f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID. == 0 {
403 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().("found function with reserved ID=0")
404 }
405 if functions[f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.] != nil {
406 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().("multiple functions with same id: %d", f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.)
407 }
408 functions[f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.] = f
409 }
410 locations := make(map[uint64]*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#, len(p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.))
411 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
412 if l == nil {
413 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().("profile has nil location")
414 }
415 if l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID. == 0 {
416 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().("found location with reserved id=0")
417 }
418 if locations[l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.] != nil {
419 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().("multiple locations with same id: %d", l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.)
420 }
421 locations[l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.] = l
422 if m := l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.; m != nil {
423 if m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID. == 0 || mappings[m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.] != m {
424 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().("inconsistent mapping %p: %d", m, m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.)
425 }
426 }
427 for _, ln := range l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. {
428 f := ln.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.
429 if f == nil {
430 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().("location id: %d has a line with nil function", l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.)
431 }
432 if f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID. == 0 || functions[f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.] != f {
433 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().("inconsistent function %p: %d", f, f.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.)
434 }
435 }
436 }
437 return nil
438 }
439
440 // Aggregate merges the locations in the profile into equivalence
441 // classes preserving the request attributes. It also updates the
442 // samples to point to the merged locations.
443 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) Aggregatescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Aggregate().(inlineFrame, function, filename, linenumber, columnnumber, address bool) error {
444 for _, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. {
445 m.HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames. = m.HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames. && inlineFrame
446 m.HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions. = m.HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions. && function
447 m.HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames. = m.HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames. && filename
448 m.HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers. = m.HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers. && linenumber
449 }
450
451 // Aggregate functions
452 if !function || !filename {
453 for _, f := range p.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function. {
454 if !function {
455 f.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name. = ""
456 f.SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName. = ""
457 }
458 if !filename {
459 f.Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename. = ""
460 }
461 }
462 }
463
464 // Aggregate locations
465 if !inlineFrame || !address || !linenumber || !columnnumber {
466 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
467 if !inlineFrame && len(l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.) > 1 {
468 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. = l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[len(l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.)-1:]
469 }
470 if !linenumber {
471 for i := range l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. {
472 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[i].Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line. = 0
473 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[i].Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column. = 0
474 }
475 }
476 if !columnnumber {
477 for i := range l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. {
478 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[i].Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column. = 0
479 }
480 }
481 if !address {
482 l.Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address. = 0
483 }
484 }
485 }
486
487 return p.CheckValidscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#CheckValid().()
488 }
489
490 // NumLabelUnits returns a map of numeric label keys to the units
491 // associated with those keys and a map of those keys to any units
492 // that were encountered but not used.
493 // Unit for a given key is the first encountered unit for that key. If multiple
494 // units are encountered for values paired with a particular key, then the first
495 // unit encountered is used and all other units are returned in sorted order
496 // in map of ignored units.
497 // If no units are encountered for a particular key, the unit is then inferred
498 // based on the key.
499 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) NumLabelUnitsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#NumLabelUnits().() (map[string]string, map[string][]string) {
500 numLabelUnits := map[string]string{}
501 ignoredUnits := map[string]map[string]bool{}
502 encounteredKeys := map[string]bool{}
503
504 // Determine units based on numeric tags for each sample.
505 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
506 for k := range s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. {
507 encounteredKeys[k] = true
508 for _, unit := range s.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit.[k] {
509 if unit == "" {
510 continue
511 }
512 if wantUnit, ok := numLabelUnits[k]; !ok {
513 numLabelUnits[k] = unit
514 } else if wantUnit != unit {
515 if v, ok := ignoredUnits[k]; ok {
516 v[unit] = true
517 } else {
518 ignoredUnits[k] = map[string]bool{unit: true}
519 }
520 }
521 }
522 }
523 }
524 // Infer units for keys without any units associated with
525 // numeric tag values.
526 for key := range encounteredKeys {
527 unit := numLabelUnits[key]
528 if unit == "" {
529 switch key {
530 case "alignment", "request":
531 numLabelUnits[key] = "bytes"
532 default:
533 numLabelUnits[key] = key
534 }
535 }
536 }
537
538 // Copy ignored units into more readable format
539 unitsIgnored := make(map[string][]string, len(ignoredUnits))
540 for key, values := range ignoredUnits {
541 units := make([]string, len(values))
542 i := 0
543 for unit := range values {
544 units[i] = unit
545 i++
546 }
547 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().(units)
548 unitsIgnored[key] = units
549 }
550
551 return numLabelUnits, unitsIgnored
552 }
553
554 // String dumps a text representation of a profile. Intended mainly
555 // for debugging purposes.
556 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) Stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#String().() string {
557 ss := make([]string, 0, len(p.Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Comments.)+len(p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.)+len(p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.)+len(p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.))
558 for _, c := range p.Commentsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Comments. {
559 ss = append(ss, "Comment: "+c)
560 }
561 if url := p.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL.; url != "" {
562 ss = append(ss, 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().("Doc: %s", url))
563 }
564 if pt := p.PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.; pt != nil {
565 ss = append(ss, 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().("PeriodType: %s %s", pt.Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type., pt.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.))
566 }
567 ss = append(ss, 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().("Period: %d", p.Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.))
568 if p.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos. != 0 {
569 ss = append(ss, 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().("Time: %v", 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, p.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.)))
570 }
571 if p.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos. != 0 {
572 ss = append(ss, 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: %.4v", timescip-go gomod github.com/golang/go/src go1.24.0 time/.Durationscip-go gomod github.com/golang/go/src go1.24.0 time/Duration#(p.DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.)))
573 }
574
575 ss = append(ss, "Samples:")
576 var sh1 string
577 for _, s := range p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType. {
578 dflt := ""
579 if s.Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type. == p.DefaultSampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DefaultSampleType. {
580 dflt = "[dflt]"
581 }
582 sh1 = sh1 + 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().("%s/%s%s ", s.Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type., s.Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., dflt)
583 }
584 ss = append(ss, 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().(sh1))
585 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
586 ss = append(ss, s.stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#string().())
587 }
588
589 ss = append(ss, "Locations")
590 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
591 ss = append(ss, l.stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#string().())
592 }
593
594 ss = append(ss, "Mappings")
595 for _, m := range p.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping. {
596 ss = append(ss, m.stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#string().())
597 }
598
599 return 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().(ss, "\n") + "\n"
600 }
601
602 // string dumps a text representation of a mapping. Intended mainly
603 // for debugging purposes.
604 func (m *Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#) stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#string().() string {
605 bits := ""
606 if m.HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions. {
607 bits = bits + "[FN]"
608 }
609 if m.HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames. {
610 bits = bits + "[FL]"
611 }
612 if m.HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers. {
613 bits = bits + "[LN]"
614 }
615 if m.HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames. {
616 bits = bits + "[IN]"
617 }
618 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: %#x/%#x/%#x %s %s %s",
619 m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.,
620 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.,
621 m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.,
622 m.BuildIDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#BuildID.,
623 bits)
624 }
625
626 // string dumps a text representation of a location. Intended mainly
627 // for debugging purposes.
628 func (l *Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#) stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#string().() string {
629 ss := []string{}
630 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().("%6d: %#x ", l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID., l.Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.)
631 if m := l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.; m != nil {
632 locStr = 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().("M=%d ", m.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.)
633 }
634 if l.IsFoldedscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#IsFolded. {
635 locStr = locStr + "[F] "
636 }
637 if len(l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.) == 0 {
638 ss = append(ss, locStr)
639 }
640 for li := range l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. {
641 lnStr := "??"
642 if fn := l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[li].Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.; fn != nil {
643 lnStr = 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().("%s %s:%d:%d s=%d",
644 fn.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.,
645 fn.Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.,
646 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[li].Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.,
647 l.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.[li].Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column.,
648 fn.StartLinescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#StartLine.)
649 if fn.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name. != fn.SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName. {
650 lnStr = lnStr + "(" + fn.SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName. + ")"
651 }
652 }
653 ss = append(ss, locStr+lnStr)
654 // Do not print location details past the first line
655 locStr = " "
656 }
657 return 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().(ss, "\n")
658 }
659
660 // string dumps a text representation of a sample. Intended mainly
661 // for debugging purposes.
662 func (s *Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#) stringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#string().() string {
663 ss := []string{}
664 var sv string
665 for _, v := range s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value. {
666 sv = 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().("%s %10d", sv, v)
667 }
668 sv = sv + ": "
669 for _, l := range s.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location. {
670 sv = sv + 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 ", l.IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.)
671 }
672 ss = append(ss, sv)
673 const labelHeader = " "
674 if len(s.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.) > 0 {
675 ss = append(ss, labelHeader+labelsToStringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/labelsToString().(s.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.))
676 }
677 if len(s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel.) > 0 {
678 ss = append(ss, labelHeader+numLabelsToStringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/numLabelsToString().(s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel., s.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit.))
679 }
680 return 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().(ss, "\n")
681 }
682
683 // labelsToString returns a string representation of a
684 // map representing labels.
685 func labelsToStringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/labelsToString().(labels map[string][]string) string {
686 ls := []string{}
687 for k, v := range labels {
688 ls = append(ls, 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().("%s:%v", k, v))
689 }
690 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().(ls)
691 return 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().(ls, " ")
692 }
693
694 // numLabelsToString returns a string representation of a map
695 // representing numeric labels.
696 func numLabelsToStringscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/numLabelsToString().(numLabels map[string][]int64, numUnits map[string][]string) string {
697 ls := []string{}
698 for k, v := range numLabels {
699 units := numUnits[k]
700 var labelString string
701 if len(units) == len(v) {
702 values := make([]string, len(v))
703 for i, vv := range v {
704 values[i] = 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", vv, units[i])
705 }
706 labelString = 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().("%s:%v", k, values)
707 } else {
708 labelString = 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().("%s:%v", k, v)
709 }
710 ls = append(ls, labelString)
711 }
712 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().(ls)
713 return 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().(ls, " ")
714 }
715
716 // SetLabel sets the specified key to the specified value for all samples in the
717 // profile.
718 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) SetLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SetLabel().(key string, value []string) {
719 for _, sample := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
720 if sample.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. == nil {
721 sample.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. = map[string][]string{key: value}
722 } else {
723 sample.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.[key] = value
724 }
725 }
726 }
727
728 // RemoveLabel removes all labels associated with the specified key for all
729 // samples in the profile.
730 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) RemoveLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#RemoveLabel().(key string) {
731 for _, sample := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
732 delete(sample.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label., key)
733 }
734 }
735
736 // HasLabel returns true if a sample has a label with indicated key and value.
737 func (s *Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#) HasLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#HasLabel().(key, value string) bool {
738 return slicesscip-go gomod github.com/golang/go/src go1.24.0 slices/.Containsscip-go gomod github.com/golang/go/src go1.24.0 slices/Contains().(s.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.[key], value)
739 }
740
741 // SetNumLabel sets the specified key to the specified value for all samples in the
742 // profile. "unit" is a slice that describes the units that each corresponding member
743 // of "values" is measured in (e.g. bytes or seconds). If there is no relevant
744 // unit for a given value, that member of "unit" should be the empty string.
745 // "unit" must either have the same length as "value", or be nil.
746 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) SetNumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SetNumLabel().(key string, value []int64, unit []string) {
747 for _, sample := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
748 if sample.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. == nil {
749 sample.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. = map[string][]int64{key: value}
750 } else {
751 sample.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel.[key] = value
752 }
753 if sample.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit. == nil {
754 sample.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit. = map[string][]string{key: unit}
755 } else {
756 sample.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit.[key] = unit
757 }
758 }
759 }
760
761 // RemoveNumLabel removes all numerical labels associated with the specified key for all
762 // samples in the profile.
763 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) RemoveNumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#RemoveNumLabel().(key string) {
764 for _, sample := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
765 delete(sample.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel., key)
766 delete(sample.NumUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumUnit., key)
767 }
768 }
769
770 // DiffBaseSample returns true if a sample belongs to the diff base and false
771 // otherwise.
772 func (s *Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#) DiffBaseSamplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#DiffBaseSample().() bool {
773 return s.HasLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#HasLabel().("pprof::base", "true")
774 }
775
776 // Scale multiplies all sample values in a profile by a constant and keeps
777 // only samples that have at least one non-zero value.
778 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) Scalescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Scale().(ratio float64) {
779 if ratio == 1 {
780 return
781 }
782 ratios := make([]float64, len(p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.))
783 for i := range p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType. {
784 ratios[i] = ratio
785 }
786 p.ScaleNscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#ScaleN().(ratios)
787 }
788
789 // ScaleN multiplies each sample values in a sample by a different amount
790 // and keeps only samples that have at least one non-zero value.
791 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) ScaleNscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#ScaleN().(ratios []float64) error {
792 if len(p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.) != len(ratios) {
793 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().("mismatched scale ratios, got %d, want %d", len(ratios), len(p.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.))
794 }
795 allOnes := true
796 for _, r := range ratios {
797 if r != 1 {
798 allOnes = false
799 break
800 }
801 }
802 if allOnes {
803 return nil
804 }
805 fillIdx := 0
806 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
807 keepSample := false
808 for i, v := range s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value. {
809 if ratios[i] != 1 {
810 val := int64(mathscip-go gomod github.com/golang/go/src go1.24.0 math/.Roundscip-go gomod github.com/golang/go/src go1.24.0 math/Round().(float64(v) * ratios[i]))
811 s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.[i] = val
812 keepSample = keepSample || val != 0
813 }
814 }
815 if keepSample {
816 p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.[fillIdx] = s
817 fillIdx++
818 }
819 }
820 p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. = p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.[:fillIdx]
821 return nil
822 }
823
824 // HasFunctions determines if all locations in this profile have
825 // symbolized function information.
826 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#HasFunctions().() bool {
827 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
828 if l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping. != nil && !l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping..HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions. {
829 return false
830 }
831 }
832 return true
833 }
834
835 // HasFileLines determines if all locations in this profile have
836 // symbolized file and line number information.
837 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) HasFileLinesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#HasFileLines().() bool {
838 for _, l := range p.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location. {
839 if l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping. != nil && (!l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping..HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames. || !l.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping..HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers.) {
840 return false
841 }
842 }
843 return true
844 }
845
846 // Unsymbolizable returns true if a mapping points to a binary for which
847 // locations can't be symbolized in principle, at least now. Examples are
848 // "[vdso]", "[vsyscall]" and some others, see the code.
849 func (m *Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#) Unsymbolizablescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Unsymbolizable().() bool {
850 name := 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().(m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.)
851 switch {
852 case 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().(name, "["):
853 case 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().(name, "linux-vdso"):
854 case 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().(m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File., "/dev/dri/"):
855 case m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. == "//anon":
856 case m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File. == "":
857 case 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().(m.Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File., "/memfd:"):
858 default:
859 return false
860 }
861 return true
862 }
863
864 // Copy makes a fully independent copy of a profile.
865 func (p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# {
866 pp := &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{}
867 if err := unmarshalscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/unmarshal().(serializescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/serialize().(p), pp); err != nil {
868 panic(err)
869 }
870 if err := pp.postDecodescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#postDecode().(); err != nil {
871 panic(err)
872 }
873
874 return pp
875 }