> On Feb 1, 2017, at 5:00 PM, Maxim Veksler via swift-users 
> <swift-users@swift.org> wrote:
> 
> My method, though effective is probably barbaric. It's been years since I've 
> touched code that can actually seg fault, and I'm rusty on how you approach 
> debugging such cases, I'm wondering both Mac and Linux, even though my case 
> is Linux only.

You run the program in a debugger, probably gdb if this is Linux. Just run "gdb 
/path/to/binary”. Then at the “(gdb)” prompt enter “run”. (You can type 
command-line arguments after “run" and they’ll be passed to your program.) If 
the process segfaults or otherwise crashes, gdb takes over and prints another 
prompt. Now you can start debugging. The usual first thing I do is enter “bt” 
which will dump the stack. That itself should produce enough output to submit a 
bug report. There are lots of docs and tutorials for gdb online if you want to 
learn more.

gdb is no longer used on Mac (we have lldb instead), so further discussion of 
it would be off-topic here :)

Another possibility, instead of gdb, is getting the OS to produce a crash 
report when the process terminates. On Mac this is enabled by default, but 
maybe you need to toggle some setting on Linux to get similar behavior.

—Jens
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to