Skip to content

Commit fb721fc

Browse files
committed
Fix stackusage output highlighting
Currently branches using exactly 512 bytes of stack are highlighted red, which is misleading. This patch changes condition from ">= 512" to "> 512". commit_hash:66c52ad6d0b917d1cc1f21baac6b0cab9d55b0ba
1 parent e64176d commit fb721fc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

perforator/pkg/ebpf/stackusage/stackusage.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,19 @@ func visit(log io.Writer, name string, symbols map[string]*symbol, depth, stack
9797
return 0, err
9898
}
9999
}
100+
var ansiPref, ansiSuf string
101+
if stack > 512 {
102+
ansiPref = "\033[31;1m"
103+
ansiSuf = "\033[0m"
104+
}
100105

101106
var err error
102-
if stack >= 512 {
103-
_, err = fmt.Fprintf(log, "fn <%s> with stack usage of %d bytes (%d bytes before rounding, \033[31;1m%d\033[0m bytes total, %d instructions)\n", name, usage, sym.maxstack, stack, sym.insn)
104-
} else {
105-
_, err = fmt.Fprintf(log, "fn <%s> with stack usage of %d bytes (%d bytes before rounding, %d bytes total, %d instructions)\n", name, usage, sym.maxstack, stack, sym.insn)
106-
}
107+
108+
_, err = fmt.Fprintf(
109+
log,
110+
"fn <%s> with stack usage of %d bytes (%d bytes before rounding, %s%d%s bytes total, %d instructions)\n",
111+
name, usage, sym.maxstack, ansiPref, stack, ansiSuf, sym.insn,
112+
)
107113
if err != nil {
108114
return 0, err
109115
}

0 commit comments

Comments
 (0)