From 6bc9fb887fa685a595b019c5ad6fc77f2fa3e914 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 28 Oct 2008 12:20:59 +0100 Subject: selftest: move gdb_* and valgrind_* scripts to selftest/ metze --- selftest/gdb_backtrace_test.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 selftest/gdb_backtrace_test.c (limited to 'selftest/gdb_backtrace_test.c') diff --git a/selftest/gdb_backtrace_test.c b/selftest/gdb_backtrace_test.c new file mode 100644 index 0000000000..506784f675 --- /dev/null +++ b/selftest/gdb_backtrace_test.c @@ -0,0 +1,42 @@ +/* + +add a usefull tool to test the gdb_backtrace script + +just compile it with +cc -g -o gdb_backtrace_test gdb_backtrace_test.c + +and run it in the same directory where your gdb_backtrace script is. + +2006 - Stefan Metzmacher + +*/ +#include +#include +#include +#include +#include + +static const char *prog; + +static void sig_fault(int sig) +{ + int ret; + char cmdstr[200]; + + snprintf(cmdstr, sizeof(cmdstr), + "./gdb_backtrace %u %s", + getpid(), prog); + printf("sig_fault start: %s\n", cmdstr); + ret = system(cmdstr); + printf("sig_fault end: %d\n", ret); +} + +int main(int argc, const char **argv) +{ + prog = argv[0]; + + signal(SIGABRT, sig_fault); + + abort(); + return 0; +} -- cgit