diff options
author | Tobias Brunner <tobias@strongswan.org> | 2008-05-19 12:49:35 +0000 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2008-05-19 12:49:35 +0000 |
commit | 6f2ba57a4efa900200e677f022e93bb7e1ec4ba1 (patch) | |
tree | 109f85426374ecf546b70c39be44a69e2c643b08 | |
parent | 550690d23b44d71e03129db3210890dd9d5e7d56 (diff) | |
download | strongswan-6f2ba57a4efa900200e677f022e93bb7e1ec4ba1.tar.bz2 strongswan-6f2ba57a4efa900200e677f022e93bb7e1ec4ba1.tar.xz |
added a fixup for addresses from shared libraries in segmentation fault handler
-rw-r--r-- | src/charon/daemon.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/charon/daemon.c b/src/charon/daemon.c index 9406e89ea..1359a4a93 100644 --- a/src/charon/daemon.c +++ b/src/charon/daemon.c @@ -16,6 +16,11 @@ * for more details. */ +#ifdef HAVE_DLADDR +# define _GNU_SOURCE +# include <dlfcn.h> +#endif /* HAVE_DLADDR */ + #include <stdio.h> #include <linux/capability.h> #include <sys/prctl.h> @@ -427,7 +432,25 @@ static void segv_handler(int signal) for (i = 0; i < size; i++) { - DBG1(DBG_DMN, " %s", strings[i]); +#ifdef HAVE_DLADDR + Dl_info info; + + if (dladdr(array[i], &info)) + { + void *ptr = array[i]; + if (strstr(info.dli_fname, ".so")) + { + ptr = (void*)(array[i] - info.dli_fbase); + } + DBG1(DBG_DMN, " %s [%p]", info.dli_fname, ptr); + } + else + { +#endif /* HAVE_DLADDR */ + DBG1(DBG_DMN, " %s", strings[i]); +#ifdef HAVE_DLADDR + } +#endif /* HAVE_DLADDR */ } free (strings); #else /* !HAVE_BACKTRACE */ |