From: phk Date: Fri, 1 Aug 2008 10:50:36 +0000 (+0000) Subject: Add WRONG(expl) macro for panicing from places we just shouldn't get to. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bac0c759c1c3054094d268efc18a039d8339dd50;p=varnish Add WRONG(expl) macro for panicing from places we just shouldn't get to. Dump the handling value from the last VCL method on panic git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3057 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_panic.c b/varnish-cache/bin/varnishd/cache_panic.c index decc017b..fc6dc42c 100644 --- a/varnish-cache/bin/varnishd/cache_panic.c +++ b/varnish-cache/bin/varnishd/cache_panic.c @@ -194,7 +194,7 @@ pan_wrk(const struct worker *wrk) static void pan_sess(const struct sess *sp) { - const char *stp; + const char *stp, *hand; vsb_printf(vsp, "sp = %p {\n", sp); vsb_printf(vsp, @@ -207,6 +207,16 @@ pan_sess(const struct sess *sp) #define STEP(l, u) case STP_##u: stp = "STP_" #u; break; #include "steps.h" #undef STEP +/*lint -restore */ + default: stp = NULL; + } + switch (sp->handling) { +/*lint -save -e525 */ +#define VCL_RET_MAC(l, u, b, v) case VCL_RET_##u: hand = #u; break; +#define VCL_RET_MAC_E(l, u, b, v) case VCL_RET_##u: hand = #u; break; +#include "vcl_returns.h" +#undef VCL_RET_MAC +#undef VCL_RET_MAC_E /*lint -restore */ default: stp = NULL; } @@ -214,6 +224,10 @@ pan_sess(const struct sess *sp) vsb_printf(vsp, " step = %s,\n", stp); else vsb_printf(vsp, " step = 0x%x,\n", sp->step); + if (stp != NULL) + vsb_printf(vsp, " handling = %s,\n", hand); + else + vsb_printf(vsp, " handling = 0x%x,\n", sp->handling); if (sp->err_code) vsb_printf(vsp, " err_code = %d, err_reason = %s,\n", sp->err_code, @@ -247,6 +261,10 @@ pan_ic(const char *func, const char *file, int line, const char *cond, int err, const struct sess *sp; switch(xxx) { + case 3: + vsb_printf(vsp, + "Wrong turn:\n%s\n", cond); + break; case 2: vsb_printf(vsp, "Panic from VCL:\n%s\n", cond); diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index 15acdc68..8f74f839 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -98,3 +98,7 @@ do { \ #define XXXAZ(foo) do { xxxassert((foo) == 0); } while (0) #define XXXAN(foo) do { xxxassert((foo) != 0); } while (0) #define diagnostic(foo) assert(foo) +#define WRONG(expl) \ +do { \ + lbv_assert(__func__, __FILE__, __LINE__, expl, errno, 3); \ +} while (0)