Skip to content

Conversation

refi64
Copy link
Contributor

@refi64 refi64 commented Oct 4, 2023

Frame pointers are extremely useful for quickly generating accurate stack traces when debugging and profiling release builds. In particular, it allows the use of Linux's perf stack, which offers high-performance profiling but only supports unwinding via frame pointers, barring some extremely slow workarounds:

https://blogs.gnome.org/chergert/2022/12/31/frame-pointers-and-other-practical-near-term-solutions/

@refi64
Copy link
Contributor Author

refi64 commented Oct 4, 2023

As an unrelated aside, I found this in Apple's ARM64 docs:

The frame pointer register (x29) must always address a valid frame record. Some functions — such as leaf functions or tail calls — may opt not to create an entry in this list. As a result, stack traces are always meaningful, even without debug information.

Could the has_flag?("darwin") block use non-leaf instead of always then?

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I have left some comments for improvements.

Frame pointers are extremely useful for quickly generating accurate
stack traces when debugging and profiling release builds. In particular,
it allows the use of Linux's perf stack, which offers high-performance
profiling but only supports unwinding via frame pointers, barring some
extremely slow workarounds:

https://blogs.gnome.org/chergert/2022/12/31/frame-pointers-and-other-practical-near-term-solutions/
refi64 and others added 2 commits November 9, 2023 17:20
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@ysbaddaden
Copy link
Contributor

Nice! I just tested this patch with a program I was analyzing with linux perf tools, and most of the unknown symbols are now explained 🥳

Weirdly I returned to crystal 1.10.1 without the frame pointers, and perf still finds the symbols 🤨

Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
@straight-shoota straight-shoota added this to the 1.12.0 milestone Jan 26, 2024
@straight-shoota straight-shoota changed the title Add --frame-pointers to control the preservation of frame pointers Add --frame-pointers to control preservation of frame pointers Jan 27, 2024
@straight-shoota straight-shoota merged commit 7628de6 into crystal-lang:master Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants