Line | |
---|
1 | /*
|
---|
2 |
|
---|
3 | add a usefull tool to test the gdb_backtrace script
|
---|
4 |
|
---|
5 | just compile it with
|
---|
6 | cc -g -o gdb_backtrace_test gdb_backtrace_test.c
|
---|
7 |
|
---|
8 | and run it in the same directory where your gdb_backtrace script is.
|
---|
9 |
|
---|
10 | 2006 - 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 |
|
---|
19 | static const char *prog;
|
---|
20 |
|
---|
21 | static 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 |
|
---|
34 | int 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.