Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --frame-pointers to control preservation of frame pointers #13860

Merged
merged 4 commits into from Jan 27, 2024

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.

src/compiler/crystal/codegen/codegen.cr Outdated Show resolved Hide resolved
src/compiler/crystal/codegen/codegen.cr Outdated Show resolved Hide resolved
src/compiler/crystal/codegen/fun.cr Outdated Show resolved Hide resolved
src/compiler/crystal/codegen/fun.cr Outdated Show resolved Hide resolved
src/compiler/crystal/command.cr Outdated Show resolved Hide resolved
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/
src/compiler/crystal/codegen/codegen.cr Outdated Show resolved Hide resolved
src/compiler/crystal/command.cr Outdated Show resolved Hide resolved
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 🚀

src/llvm/lib_llvm/core.cr Outdated Show resolved Hide resolved
@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
57 checks passed
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.

None yet

5 participants