source: branches/samba-3.5.x/selftest/gdb_backtrace_test.c

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 732 bytes
Line 
1/*
2
3add a usefull tool to test the gdb_backtrace script
4
5just compile it with
6cc -g -o gdb_backtrace_test gdb_backtrace_test.c
7
8and run it in the same directory where your gdb_backtrace script is.
9
102006 - Stefan Metzmacher <metze@samba.org>
11
12*/
13#include <stdio.h>
14#include <string.h>
15#include <stdlib.h>
16#include <unistd.h>
17#include <signal.h>
18
19static const char *prog;
20
21static void sig_fault(int sig)
22{
23 int ret;
24 char cmdstr[200];
25
26 snprintf(cmdstr, sizeof(cmdstr),
27 "./gdb_backtrace %u %s",
28 getpid(), prog);
29 printf("sig_fault start: %s\n", cmdstr);
30 ret = system(cmdstr);
31 printf("sig_fault end: %d\n", ret);
32}
33
34int main(int argc, const char **argv)
35{
36 prog = argv[0];
37
38 signal(SIGABRT, sig_fault);
39
40 abort();
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.