ATM to get a backtrace on macOS you'd need manually run dsymutil --flat <path to bin>.
I'd suggest running it as a part of the Crystal build process - only on macOS, and only for debug builds.
Agreed. This should be done automatically, but won't having a .dwarf file appear next to the executable feel weird? I thought of generating them in crystal's cache, thought it means the executable needs to know where to find where the file.
yep, I was thinking the same... one solution that seemed sensible was placing it behind a command-line flag non-activated from default.
Or maybe a compile message: Gathering debug info as foo.dwarf?
@ysbaddaden personally I'd go for both, cli flag (enabled from default) + compile message for clarity what's goin' on.
Some solution along these lines would be really cool. I've answered the "I'm on Mac. Why am I not seeing line numbers in my backtraces?" question quite a few times :P
We can at least execute dsymutil when you do crystal run file.cr or just crystal file.cr. The compiler generates an executable in the cache directory, so having it there too won't bother users.
Then there's the issue of having a .dwarf file next to the executable. I think that's a bit weird but it's acceptable. If you imagine a project or application with a single binary as an entry, having one extra file that provides really useful debug information is OK.
Maybe people will start asking what's that dwarf file, but we can answer it and they'll find out by a Google search. We can add an option not to generate that dwarf file, though, in case it's bothersome.
I believe the option to not generate the .dwarf file is --no-debug since we didn't push any debug info in the first place, and the developer specifically stated she didn't want any.
Maybe people will start asking what's that
dwarffile, but we can answer it and they'll find out by a Google search. We can add an option not to generate that dwarf file, though, in case it's bothersome.
Googling crystal and .dwarf is how I found this GitHub issue. Still not quite sure how to use it. But I have figured out --release or --no-debug gets rid of it.
@Juice10 it's neccesary for line numbers in backtraces on macos
Most helpful comment
I believe the option to not generate the
.dwarffile is--no-debugsince we didn't push any debug info in the first place, and the developer specifically stated she didn't want any.