From e955b30872467b116d315e1682be8a82b30b8053 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Sun, 20 Aug 2023 19:39:56 -0500 Subject: [PATCH] Make ALYS_BACKTRACE_TYPE=addr the default on systems with PIE support alys_converter's symbolization gives much better results. --- README.md | 34 ++++++++++++++++++++-------------- src/alys.cr | 6 +++++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 6c84d2d..6b49ac3 100644 --- a/README.md +++ b/README.md @@ -49,28 +49,31 @@ JSON, Go pprof, folded stacks (for use with flamegraph), or a direct flamegraph via: ```bash +# NOTE: passing `--symbolize` with the binary is *required* on systems where +# ALYS_BACKTRACE_TYPE=addr by default (see below). + # Outputs myfile.alys.json: -bin/alys_converter myfile.alys +bin/alys_converter --symbolize myprog myfile.alys # You can rename the output file: -bin/alys_converter myfile.alys myfile.json +bin/alys_converter --symbolize myprog myfile.alys myfile.json # and/or format & indent the JSON file: -bin/alys_converter --indent myfile.alys -bin/alys_converter --indent myfile.alys myfile.json +bin/alys_converter --symbolize myprog --indent myfile.alys +bin/alys_converter --symbolize myprog --indent myfile.alys myfile.json # Outputs myfile.pb.gz (pprof format): -bin/alys_converter -f pprof myfile.alys +bin/alys_converter --symbolize myprog -f pprof myfile.alys # You can rename the output file: -bin/alys_converter -f pprof myfile.alys myfile.pb.gz +bin/alys_converter --symbolize myprog -f pprof myfile.alys myfile.pb.gz # Outputs myfile.folded (folded stacks): -bin/alys_converter -f folded-stacks myfile.alys +bin/alys_converter --symbolize myprog -f folded-stacks myfile.alys # You can rename the output file: -bin/alys_converter -f folded-stacks myfile.alys myfile.folded +bin/alys_converter --symbolize myprog -f folded-stacks myfile.alys myfile.folded # Outputs myfile.svg (flamegraph, via inferno-flamegraph): -bin/alys_converter -f inferno-flamegraph myfile.alys +bin/alys_converter --symbolize myprog -f inferno-flamegraph myfile.alys # You can rename the output file: -bin/alys_converter -f inferno-flamegraph myfile.alys myfile.svg +bin/alys_converter --symbolize myprog -f inferno-flamegraph myfile.alys myfile.svg ``` (Note that .alys files are only compatible with an identical alys_converter @@ -179,12 +182,15 @@ via `ALYS_BACKTRACE_TYPE`: PIE randomizes the memory location of the executable at runtime, so it's impossible to know what was where after the fact. - `llvm-symbolizer` must be installed. + **This is the default on non-macOS systems.** - `ALYS_BACKTRACE_TYPE=name` will create backtraces that contain the function names but no files or line numbers. This is usually only slightly slower than - `ALYS_BACKTRACE_TYPE=addr` while giving enough information for proper - analysis, thus **this is the default value**. -- `ALYS_BACKTRACE_TYPE=full` (the default) will create backtraces that contain - the function names, as well as the source file paths and line numbers. + `ALYS_BACKTRACE_TYPE=addr`, and it supports position-independent executables + on macOS, but the symbol names aren't as detailed as using `alys_converter`'s + symbolization. + **This is the default on macOS.** +- `ALYS_BACKTRACE_TYPE=full` will create backtraces that contain the function + names, as well as the source file paths and line numbers. TODO: add support for & document flipping Alys on / off at runtime diff --git a/src/alys.cr b/src/alys.cr index eafd665..332f245 100644 --- a/src/alys.cr +++ b/src/alys.cr @@ -42,7 +42,11 @@ module Alys backtrace_limit : UInt32? = nil, sample_interval : UInt64 = 0 do def self.default - self.name + {% if flag?(:darwin) %} + self.name + {% else %} + self.addr + {% end %} end def self.none -- 2.45.2