Commit bcddbef7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Autocrap the dladdr() functions existence.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4062 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 52373d96
......@@ -106,6 +106,7 @@ AC_TYPE_SIZE_T
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([strerror])
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([dladdr])
AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS([fmtcheck])
......
......@@ -26,6 +26,8 @@
* $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $
*/
#include "config.h"
#include <sys/types.h>
#include <sys/uio.h>
#include <dlfcn.h>
......@@ -72,15 +74,20 @@ char **
backtrace_symbols(void *const *buffer, int size)
{
size_t clen, alen;
int i, offset;
int i;
char **rval;
Dl_info info;
clen = size * sizeof(char *);
rval = malloc(clen);
if (rval == NULL)
return NULL;
for (i = 0; i < size; i++) {
#ifdef HAVE_DLADDR
{
Dl_info info;
int offset;
if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL)
info.dli_sname = "???";
......@@ -102,15 +109,19 @@ backtrace_symbols(void *const *buffer, int size)
return NULL;
snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s",
buffer[i], info.dli_sname, offset, info.dli_fname);
} else {
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */
rval = realloc_safe(rval, clen + alen);
if (rval == NULL)
return NULL;
snprintf((char *) rval + clen, alen, "%p", buffer[i]);
}
rval[i] = (char *) clen;
clen += alen;
continue;
}
}
#endif
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */
rval = realloc_safe(rval, clen + alen);
if (rval == NULL)
return NULL;
snprintf((char *) rval + clen, alen, "%p", buffer[i]);
rval[i] = (char *) clen;
clen += alen;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment