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

Hide GCC specific backtrace() compat function under a #ifdef.

We do not want to be dependent on GCC.

Fixes #577



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4349 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0da4a755
...@@ -271,6 +271,8 @@ pan_backtrace(void) ...@@ -271,6 +271,8 @@ pan_backtrace(void)
size_t i; size_t i;
size = backtrace (array, 10); size = backtrace (array, 10);
if (size == 0)
return;
vsb_printf(vsp, "Backtrace:\n"); vsb_printf(vsp, "Backtrace:\n");
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
vsb_printf (vsp, " "); vsb_printf (vsp, " ");
......
...@@ -11,6 +11,17 @@ ...@@ -11,6 +11,17 @@
-esym(850, av) -esym(850, av)
-esym(528, svnid)
-ffc // No automatic custody
-e712 // 14 Info 712 Loss of precision (___) (___ to ___)
-e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___
// -header(../../config.h) // -header(../../config.h)
......
#!/bin/sh #!/bin/sh
T=/tmp/_$$
flexelint \ flexelint \
-I/usr/include \ -I/usr/include \
-I. \ -I. \
-I../../include \ -I../../include \
-I../.. \ -I../.. \
flint.lnt \ flint.lnt \
*.c > $T 2>&1 *.c
for t in Error Warning Info Note
do
sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T
done | awk '
$2 == 830 { next }
$2 == 831 { next }
{
i=$2"_"$1
h[i]++
n++
}
END {
printf "%5d %s\n", n, "Total"
for (i in h)
printf "%5d %s\n", h[i], i
}
' | sort -rn
cat $T
...@@ -52,7 +52,7 @@ const char *vtc_file; ...@@ -52,7 +52,7 @@ const char *vtc_file;
char *vtc_desc; char *vtc_desc;
int vtc_error; /* Error encountered */ int vtc_error; /* Error encountered */
int vtc_stop; /* Stops current test without error */ int vtc_stop; /* Stops current test without error */
pthread_t vtc_thread;; pthread_t vtc_thread;
/********************************************************************** /**********************************************************************
* Read a file into memory * Read a file into memory
......
...@@ -39,7 +39,6 @@ SVNID("$Id$") ...@@ -39,7 +39,6 @@ SVNID("$Id$")
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <ctype.h>
#include "libvarnish.h" #include "libvarnish.h"
#include "vct.h" #include "vct.h"
...@@ -521,6 +520,7 @@ cmd_http_txresp(CMD_ARGS) ...@@ -521,6 +520,7 @@ cmd_http_txresp(CMD_ARGS)
if (!strcmp(*av, "-body")) { if (!strcmp(*av, "-body")) {
AZ(body); AZ(body);
REPLACE(body, av[1]); REPLACE(body, av[1]);
AN(body);
av++; av++;
bodylen = strlen(body); bodylen = strlen(body);
for (b = body; *b != '\0'; b++) { for (b = body; *b != '\0'; b++) {
......
...@@ -33,7 +33,6 @@ SVNID("$Id$") ...@@ -33,7 +33,6 @@ SVNID("$Id$")
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -103,7 +103,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) ...@@ -103,7 +103,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
if (i != 0) { if (i != 0) {
vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s", vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s",
cmd, i, retval, r); cmd, i, retval, r);
return (retval); return ((enum cli_status_e)retval);
} }
assert(i == 0); assert(i == 0);
vtc_dump(v->vl, 4, "CLI RX", r); vtc_dump(v->vl, 4, "CLI RX", r);
...@@ -213,12 +213,13 @@ varnish_thread(void *priv) ...@@ -213,12 +213,13 @@ varnish_thread(void *priv)
{ {
struct varnish *v; struct varnish *v;
char buf[BUFSIZ]; char buf[BUFSIZ];
struct pollfd fds[1]; struct pollfd *fds, fd;
int i; int i;
CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC);
TCP_nonblocking(v->fds[0]); TCP_nonblocking(v->fds[0]);
while (1) { while (1) {
fds = &fd;
memset(fds, 0, sizeof fds); memset(fds, 0, sizeof fds);
fds->fd = v->fds[0]; fds->fd = v->fds[0];
fds->events = POLLIN; fds->events = POLLIN;
...@@ -406,7 +407,7 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp) ...@@ -406,7 +407,7 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp)
return; return;
u = varnish_ask_cli(v, cli, NULL); u = varnish_ask_cli(v, cli, NULL);
vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli); vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli);
if (exp != 0 && exp != u) if (exp != 0 && exp != (unsigned)u)
vtc_log(v->vl, 0, "FAIL CLI response %u expected %u", u, exp); vtc_log(v->vl, 0, "FAIL CLI response %u expected %u", u, exp);
} }
...@@ -616,7 +617,7 @@ cmd_varnish(CMD_ARGS) ...@@ -616,7 +617,7 @@ cmd_varnish(CMD_ARGS)
} }
if (!strcmp(*av, "-cliok")) { if (!strcmp(*av, "-cliok")) {
AN(av[1]); AN(av[1]);
varnish_cli(v, av[1], CLIS_OK); varnish_cli(v, av[1], (unsigned)CLIS_OK);
av++; av++;
continue; continue;
} }
......
...@@ -35,7 +35,6 @@ extern "C" { ...@@ -35,7 +35,6 @@ extern "C" {
int backtrace(void **, int); int backtrace(void **, int);
char ** backtrace_symbols(void *const *, int); char ** backtrace_symbols(void *const *, int);
void backtrace_symbols_fd(void *const *, int, int);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include "svnid.h" #include "svnid.h"
SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $") SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $")
#include "compat/execinfo.h"
#if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */
#include <sys/types.h> #include <sys/types.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <dlfcn.h> #include <dlfcn.h>
...@@ -39,10 +43,9 @@ SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $") ...@@ -39,10 +43,9 @@ SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $")
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "compat/execinfo.h"
void *getreturnaddr(int); static void *getreturnaddr(int);
void *getframeaddr(int); static void *getframeaddr(int);
#define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1))) #define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1)))
...@@ -133,51 +136,7 @@ backtrace_symbols(void *const *buffer, int size) ...@@ -133,51 +136,7 @@ backtrace_symbols(void *const *buffer, int size)
return rval; return rval;
} }
#if 0 static void *
void
backtrace_symbols_fd(void *const *buffer, int size, int fd)
{
int i, len, offset;
char *buf;
Dl_info info;
for (i = 0; i < size; i++) {
if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL)
info.dli_sname = "???";
if (info.dli_saddr == NULL)
info.dli_saddr = buffer[i];
offset = (const char *)buffer[i] - (const char *)info.dli_saddr;
/* "0x01234567 <function+offset> at filename" */
len = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
2 + /* " <" */
strlen(info.dli_sname) + /* "function" */
1 + /* "+" */
D10(offset) + /* "offset */
5 + /* "> at " */
strlen(info.dli_fname) + /* "filename" */
2; /* "\n\0" */
buf = alloca(len);
if (buf == NULL)
return;
snprintf(buf, len, "%p <%s+%d> at %s\n",
buffer[i], info.dli_sname, offset, info.dli_fname);
} else {
len = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
2; /* "\n\0" */
buf = alloca(len);
if (buf == NULL)
return;
snprintf(buf, len, "%p\n", buffer[i]);
}
write(fd, buf, len - 1);
}
}
#endif
void *
getreturnaddr(int level) getreturnaddr(int level)
{ {
...@@ -314,7 +273,7 @@ getreturnaddr(int level) ...@@ -314,7 +273,7 @@ getreturnaddr(int level)
} }
} }
void * static void *
getframeaddr(int level) getframeaddr(int level)
{ {
...@@ -450,3 +409,23 @@ getframeaddr(int level) ...@@ -450,3 +409,23 @@ getframeaddr(int level)
default: return NULL; default: return NULL;
} }
} }
#else
int
backtrace(void **buffer, int size)
{
(void)buffer;
(void)size;
return (0);
}
char **
backtrace_symbols(void *const *buffer, int size)
{
(void)buffer;
(void)size;
return (0);
}
#endif
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