Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get crash/hangs reports for applications, daemons and OSX programatically?

I know there is a way to get crashes and hangs for all applications. These files are placed in "/Users/user/Library/Logs/DiagnosticReports". So I could get version, time and name of the app.

But how to get daemon/process crashes and hangs? I need to know which exactly daemon was crashed/hanged and time when it happened.

Also is there is a way to get some system(OSX) crash with the same info?

Also would be great to get some resource failures/warnings: out of memory or out of disk space.

I need to get it programatically.

On Windows we can do this using NotifyChangeEventLog () API. All these info we can gather using such method. Also it notifies if something happened.

like image 884
Steven Koposov Avatar asked Jun 02 '13 18:06

Steven Koposov


2 Answers

For the daemons crash/hang report see the "/Library/Logs/DiagnosticReports" directory. According to this document you can also find there kernel panic reports (i.e. system crash).
Don't know about NotifyChangeEventLog-like API, but in situations like "out of memory" there will be an exception, so you just need to catch it. See Error Handling Programming Guide for details. Also take a look at Exception Programming Topics

Edit: for the information about Crash Reporter take a look at Chapter 5 of Levin's book "Mac OS X and iOS Internals: To the Apple's Core"

like image 113
cody Avatar answered Sep 28 '22 16:09

cody


in 10.9 the activity monitor offers you two tools when you have a hang but no crash hence no crash report:

spindump - memory dump like crash report and sys digs which produces a bundle of files

like image 32
Nick Lightbody Avatar answered Sep 28 '22 17:09

Nick Lightbody