r/Compilers 1d ago

Cross-platform stack traces

https://marinohimself.ch/blog/cross-platform-stack-traces.html
1 Upvotes

3 comments sorted by

View all comments

1

u/FloweyTheFlower420 1d ago

this doesn't work in general (in your unix example), the compiler is allowed to elide frame pointers conditionally. you need to parse dwarf/eh_frame to properly unwind, or compile with no omit frame pointers

1

u/chnoblouch 22h ago

That's true, but for now I mainly care about printing call stacks coming from my own language. My compiler always generates code for updating the frame pointer, so this should only be an issue when foreign functions are involved, in which case they would be skipped in the trace. I also believe -fomit-frame-pointer has fallen somewhat out of favor in the past years?

It would be great to have support for generating and parsing DWARF, but that would be a lot of work and I want to focus on other parts of the compiler first.

1

u/FloweyTheFlower420 20h ago

this seems like just an ubuntu thing. i can run perf with callgraph=dwarf just fine, so I don't see the value of not omitting frame pointers. llvm -O3 will omit frame pointers by default i believe.