Is there a way to get a crash report (not a core dump) for a command line program?

If a macOS application crashes, CrashReporter will (optionally) pop up a window with a human-readable set of stack traces and the "Send to Apple" button.

Is there a straightforward way to get the same results for a non-.app program which crashes when started from the command line? That is, the situation I want more information out of is

$ some-program
Segmentation fault: 11
$ 

I've only found instructions about how to enable core dumps, but not how to get something readable out of them. I know that Activity Monitor can "sample" running programs, but I'm looking for the crash event, not profiling.

I've thought of creating a dummy .app package that actually runs the command that's crashing, but that'll be a bit of work and probably run into some Gatekeeper trouble, though I haven't actually tried doing that since a few major versions ago. I'm currently on Catalina 10.15.7.


Solution 1:

Looking back, past crashes are logged in the log system, and also individual dump files are saved for about a month in /Library/Logs/DiagnosticReports

Looking forward, to cause them is a bit harder and risky. You could try issuing a SIGABRT or SIGQUIT signal if you know the process:

  • How to crash an application to produce Crash Report

Something more generic would be the general system diagnostics will capture much more. The main difference in these two options is a crash has an end point, system diagnosis grabs an arbitrary snapshot, so it isn’t necessarily as final as a crash. I don’t recommend forcing an app to crash and certainly don’t recommend forcing a kernel panic but you could try both. Why not start with a general diagnostic dump:

sudo sysdiagnose

You can pass a process ID or process name to sysdiagnose or also trigger it from the Activity Monitor app.

  • https://support.apple.com/guide/activity-monitor/welcome/mac

If you need to halt the program or process, try Instruments from Xcode.

  • https://apps.apple.com/us/app/xcode/id497799835?mt=12