On Fri, May 10, 2013 at 11:07 AM, Stefan Priebe - Profihost AG
<address@hidden> wrote:
Am 10.05.2013 09:42, schrieb Stefan Hajnoczi:
On Fri, May 10, 2013 at 08:12:39AM +0200, Stefan Priebe - Profihost AG wrote:
3. Either use gdb or an LD_PRELOAD library that catches exit(3) and
_exit(2) and dumps core using abort(3). Make sure core dumps are
enabled.
LD_PRELOAD sounds good can you point me to such a lib?
$ cat /tmp/catchexit.c
#include <unistd.h>
#include <stdlib.h>
void exit(int status)
{
const char msg[] = "*** CAUGHT EXIT, DUMPING CORE ***\n";
write(2, msg, sizeof msg);
abort();
}
void _exit(int status) __attribute__((alias("exit")));
$ gcc -o catchexit.so -shared -fPIC -std=gnu99 catchexit.c
$ LD_PRELOAD=/tmp/catchexit.so x86_64-softmmu/qemu-system-x86_64 -m
1024 -enable-kvm -cpu host -vga asdf
Unknown vga type: asdf
*** CAUGHT EXIT, DUMPING CORE ***
Aborted (core dumped)
Make sure to give the absolute path to catchexit.so. Also keep in
mind that this does not catch a normal return from main() or possibly
other ways of terminating the process.
You can hook more library functions, if necessary.
Stefan