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

Method addStack

internal/report/source.go:465–499  ·  view source on GitHub ↗
(addr uint64, frames []plugin.Frame)

Source from the content-addressed store, hash-verified

463}
464
465func (sp *sourcePrinter) addStack(addr uint64, frames []plugin.Frame) {
466 // See if the stack contains a function we are interested in.
467 for i, f := range frames {
468 if !sp.interest[f.Func] {
469 continue
470 }
471
472 // Record sub-stack under frame's file/line.
473 fname := canonicalizeFileName(f.File)
474 file := sp.files[fname]
475 if file == nil {
476 file = &sourceFile{
477 fname: fname,
478 lines: map[int][]sourceInst{},
479 funcName: map[int]string{},
480 }
481 sp.files[fname] = file
482 }
483 callees := frames[:i]
484 stack := make([]callID, 0, len(callees))
485 for j := len(callees) - 1; j >= 0; j-- { // Reverse so caller is first
486 stack = append(stack, callID{
487 file: callees[j].File,
488 line: callees[j].Line,
489 })
490 }
491 file.lines[f.Line] = append(file.lines[f.Line], sourceInst{addr, stack})
492
493 // Remember the first function name encountered per source line
494 // and assume that line belongs to that function.
495 if _, ok := file.funcName[f.Line]; !ok {
496 file.funcName[f.Line] = f.Func
497 }
498 }
499}
500
501// synthAsm is the special disassembler value used for instructions without an object file.
502const synthAsm = ""

Callers 2

expandAddressesMethod · 0.95
handleUnprocessedMethod · 0.95

Calls 1

canonicalizeFileNameFunction · 0.85

Tested by

no test coverage detected