1

I have a program written in OCaml that tends to stack-overflow on platforms with small stacks.

Rather than 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.

8
  • Is DTrace available on your platform? – fpmurphy Apr 1 '18 at 3:02
  • Apparently there's github.com/dtrace4linux/linux; I have never used it. – Clément Apr 1 '18 at 3:07
  • It would help if you told us what Linux distribution and version you are using. – fpmurphy Apr 1 '18 at 3:13
  • Other options might be SystemTap or ktap – fpmurphy Apr 1 '18 at 3:16
  • @fpmurphy1, indeed, any of these would be fine by me. – Clément Apr 1 '18 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.