Commit 73632b2c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a debug parameter and start moving diag_bitmap stuff into it.

XXX: doc-update needed
parent 9232cd63
......@@ -976,12 +976,6 @@ void VSLbt(struct vsl_log *, enum VSL_tag_e tag, txt t);
void VSL_Flush(struct vsl_log *, int overflow);
#define DSL(flag, tag, id, ...) \
do { \
if (cache_param->diag_bitmap & (flag)) \
VSL((tag), (id), __VA_ARGS__); \
} while (0)
#endif
/* cache_response.c */
......@@ -1122,3 +1116,16 @@ Tadd(txt *t, const char *p, int l)
* extra timestamps in cache_pool.c. Hide this detail with a macro
*/
#define W_TIM_real(w) ((w)->lastused = VTIM_real())
static inline int
DO_DEBUG(enum debug_bits x)
{
return (cache_param->debug_bits[(unsigned)x>>3] &
(0x80U >> ((unsigned)x & 7)));
}
#define DSL(flag, tag, id, ...) \
do { \
if (cache_param->diag_bitmap & (flag)) \
VSL((tag), (id), __VA_ARGS__); \
} while (0)
......@@ -1220,7 +1220,7 @@ CNT_Request(struct worker *wrk, struct req *req)
switch (req->req_step) {
#define REQ_STEP(l,u,arg) \
case R_STP_##u: \
if (cache_param->diag_bitmap & 0x01) \
if (DO_DEBUG(DBG_REQ_STATE)) \
cnt_diag(req, #u); \
done = cnt_##l arg; \
break;
......
......@@ -33,6 +33,13 @@
#define VSM_CLASS_PARAM "Params"
enum debug_bits {
#define DEBUG_BIT(U, l, p, d) DBG_##U,
#include "tbl/debug_bits.h"
#undef DEBUG_BIT
DBG_Reserved
};
struct poolparam {
unsigned min_pool;
unsigned max_pool;
......@@ -198,5 +205,6 @@ struct params {
struct poolparam sess_pool;
struct poolparam vbo_pool;
uint8_t vsl_mask[256/8];
uint8_t vsl_mask[256>>3];
uint8_t debug_bits[(DBG_Reserved+7)>>3];
};
......@@ -1046,7 +1046,6 @@ static const struct parspec input_parspec[] = {
WAITER_DEFAULT, NULL },
{ "diag_bitmap", tweak_diag_bitmap, 0, 0, 0,
"Bitmap controlling diagnostics code:\n"
" 0x00000001 - CNT_Session states.\n"
" 0x00000002 - workspace debugging.\n"
" 0x00000004 - kqueue debugging.\n"
" 0x00000008 - mutex logging.\n"
......
......@@ -153,6 +153,45 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
}
}
/*--------------------------------------------------------------------
* The debug parameter
*/
static const char * const debug_tags[] = {
# define DEBUG_BIT(U,l,p,d) [DBG_##U] = #l,
# include "tbl/debug_bits.h"
# undef DEBUG_BIT
NULL
};
static void
tweak_debug(struct cli *cli, const struct parspec *par, const char *arg)
{
const char *s;
unsigned j;
(void)par;
if (arg != NULL) {
if (!strcmp(arg, "none")) {
memset(mgt_param.debug_bits,
0, sizeof mgt_param.debug_bits);
} else {
bit_tweak(cli, mgt_param.debug_bits,
DBG_Reserved, arg, debug_tags, "debug bit", "+");
}
} else {
s = "";
for (j = 0; j < (unsigned)DBG_Reserved; j++) {
if (bit(mgt_param.debug_bits, j, BTST)) {
VCLI_Out(cli, "%s+%s", s, debug_tags[j]);
s = ",";
}
}
if (*s == '\0')
VCLI_Out(cli, "none");
}
}
/*--------------------------------------------------------------------
* The parameter table itself
*/
......@@ -164,5 +203,13 @@ const struct parspec VSL_parspec[] = {
"Use +/- prefixe in front of VSL tag name, to mask/unmask "
"individual VSL messages.",
0, "default", "" },
{ "debug", tweak_debug, NULL, 0, 0,
"Enable/Disable various kinds of debugging.\n"
"\tnone\t\tDisable all debugging\n"
"Use +/- prefix to set/reset individual bits:\n"
#define DEBUG_BIT(U, l, p, d) "\t" #l "\t" p d "\n"
#include "tbl/debug_bits.h"
#undef DEBUG_BIT
, 0, "none", "" },
{ NULL, NULL, NULL }
};
......@@ -20,7 +20,7 @@ varnish v1 -vcl+backend {
}
} -start
varnish v1 -cliok "param.set diag_bitmap 1"
varnish v1 -cliok "param.set debug +req_state"
client c1 {
txreq -hdr "foo: /foo"
......
......@@ -15,7 +15,7 @@ server s1 {
varnish v1 -vcl+backend {
} -start
varnish v1 -cliok "param.set diag_bitmap 1"
varnish v1 -cliok "param.set debug +req_state"
client c1 {
txreq -hdr "foo: /foo"
......
......@@ -6,6 +6,7 @@ nobase_pkginclude_HEADERS = \
tbl/backend_poll.h \
tbl/ban_vars.h \
tbl/body_status.h \
tbl/debug_bits.h \
tbl/http_headers.h \
tbl/http_response.h \
tbl/locks.h \
......
/*-
* Copyright (c) 2012 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Fields in the debug parameter
*
*/
DEBUG_BIT(REQ_STATE, req_state, "", "Request state engine")
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