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

Function makeWebListInstructions

internal/report/source.go:837–879  ·  view source on GitHub ↗
(srcIndent int, assembly []assemblyInstruction, reader *sourceReader, rpt *Report)

Source from the content-addressed store, hash-verified

835}
836
837func makeWebListInstructions(srcIndent int, assembly []assemblyInstruction, reader *sourceReader, rpt *Report) []WebListInstruction {
838 var result []WebListInstruction
839 var curCalls []callID
840 for i, an := range assembly {
841 var fileline string
842 if an.file != "" {
843 fileline = fmt.Sprintf("%s:%d", template.HTMLEscapeString(filepath.Base(an.file)), an.line)
844 }
845 text := strings.Repeat(" ", srcIndent+4+4*len(an.inlineCalls)) + an.instruction
846 inst := WebListInstruction{
847 NewBlock: (an.startsBlock && i != 0),
848 Flat: valueOrDot(an.flat, rpt),
849 Cumulative: valueOrDot(an.cum, rpt),
850 Synthetic: (an.instruction == synthAsm),
851 Address: an.address,
852 Disasm: rightPad(text, 80),
853 FileLine: fileline,
854 }
855
856 // Add inlined call context.
857 for j, c := range an.inlineCalls {
858 if j < len(curCalls) && curCalls[j] == c {
859 // Skip if same as previous instruction.
860 continue
861 }
862 curCalls = nil
863 fline, ok := reader.line(c.file, c.line)
864 if !ok {
865 fline = ""
866 }
867 srcCode := strings.Repeat(" ", srcIndent+4+4*j) + strings.TrimSpace(fline)
868 inst.InlinedCalls = append(inst.InlinedCalls, WebListCall{
869 SrcLine: rightPad(srcCode, 80),
870 FileBase: filepath.Base(c.file),
871 Line: c.line,
872 })
873 }
874 curCalls = an.inlineCalls
875
876 result = append(result, inst)
877 }
878 return result
879}
880
881// getSourceFromFile collects the sources of a function from a source
882// file and annotates it with the samples in fns. Returns the sources

Callers 1

makeWebListLineFunction · 0.85

Calls 3

valueOrDotFunction · 0.85
rightPadFunction · 0.85
lineMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…