I have a program written in OCaml that tends to stack-overflow on platforms with small stacks.
ulimiting the program to find and solve stack overflows one by one, I'd like to get a sorted list of the deepest (and/or most stack-hungry) call chains in a typical execution.
I can record call graphs using perf:
perf record -F 99 --call-graph dwarf -- ./a.out input.txt
And then get call chains using the stackcollapse script in FlameGraph.
perf script > out.perf FlameGraph/stackcollapse-perf.pl out.perf > out.folded
Unfortunately, the call chains obtained in that way are limited to 127 entries.
perf report has an option to show more entries:
--max-stack n. But
perf script doesn't seem to have a similar option.
How can I record a program's execution, and find the deepest call chains? What about call chains using the most stack space (accounting for frame sizes rather than just frame count)?
I'm on Linux Mint 18.2, with kernel 4.4.0-112-generic.