MCPcopy Create free account
hub / github.com/google/pprof / postDecode

Method postDecode

profile/encode.go:249–394  ·  view source on GitHub ↗

postDecode takes the unexported fields populated by decode (with suffix X) and populates the corresponding exported fields. The unexported fields are cleared up to facilitate testing.

()

Source from the content-addressed store, hash-verified

247// suffix X) and populates the corresponding exported fields.
248// The unexported fields are cleared up to facilitate testing.
249func (p *Profile) postDecode() error {
250 var err error
251 mappings := make(map[uint64]*Mapping, len(p.Mapping))
252 mappingIds := make([]*Mapping, len(p.Mapping)+1)
253 for _, m := range p.Mapping {
254 m.File, err = getString(p.stringTable, &m.fileX, err)
255 m.BuildID, err = getString(p.stringTable, &m.buildIDX, err)
256 if m.ID < uint64(len(mappingIds)) {
257 mappingIds[m.ID] = m
258 } else {
259 mappings[m.ID] = m
260 }
261
262 // If this a main linux kernel mapping with a relocation symbol suffix
263 // ("[kernel.kallsyms]_text"), extract said suffix.
264 // It is fairly hacky to handle at this level, but the alternatives appear even worse.
265 const prefix = "[kernel.kallsyms]"
266 if strings.HasPrefix(m.File, prefix) {
267 m.KernelRelocationSymbol = m.File[len(prefix):]
268 }
269 }
270
271 functions := make(map[uint64]*Function, len(p.Function))
272 functionIds := make([]*Function, len(p.Function)+1)
273 for _, f := range p.Function {
274 f.Name, err = getString(p.stringTable, &f.nameX, err)
275 f.SystemName, err = getString(p.stringTable, &f.systemNameX, err)
276 f.Filename, err = getString(p.stringTable, &f.filenameX, err)
277 if f.ID < uint64(len(functionIds)) {
278 functionIds[f.ID] = f
279 } else {
280 functions[f.ID] = f
281 }
282 }
283
284 locations := make(map[uint64]*Location, len(p.Location))
285 locationIds := make([]*Location, len(p.Location)+1)
286 for _, l := range p.Location {
287 if id := l.mappingIDX; id < uint64(len(mappingIds)) {
288 l.Mapping = mappingIds[id]
289 } else {
290 l.Mapping = mappings[id]
291 }
292 l.mappingIDX = 0
293 for i, ln := range l.Line {
294 if id := ln.functionIDX; id != 0 {
295 l.Line[i].functionIDX = 0
296 if id < uint64(len(functionIds)) {
297 l.Line[i].Function = functionIds[id]
298 } else {
299 l.Line[i].Function = functions[id]
300 }
301 }
302 }
303 if l.ID < uint64(len(locationIds)) {
304 locationIds[l.ID] = l
305 } else {
306 locations[l.ID] = l

Callers 2

ParseUncompressedFunction · 0.95
CopyMethod · 0.95

Calls 2

getStringFunction · 0.85
padStringArrayFunction · 0.85

Tested by

no test coverage detected