Commit 0b32af6d authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

panic: Optionally track miniobjs

PAN_dump_struct2() is now renamed to PAN__DumpStruct() following the
guidelines from apispaces.rst in addition to growing a track argument.
This should allow dumping structures that we know ought to be dumped
only once, in case they would be numerous.

There seems to be no good reason to expose it to VMODs yet since they
have no integration point with the panic output, so those definitions
can be confined in cache_varnishd.h for now.

Better diff with the --ignore-all-space option.
parent 3fc78478
......@@ -835,13 +835,3 @@ Tlen(const txt t)
* extra timestamps in cache_pool.c. Hide this detail with a macro
*/
#define W_TIM_real(w) ((w)->lastused = VTIM_real())
int PAN_dump_struct2(struct vsb *vsb, int block, const void *ptr,
const char *smagic, unsigned magic, const char *fmt, ...)
v_printflike_(6,7);
#define PAN_dump_struct(vsb, ptr, magic, ...) \
PAN_dump_struct2(vsb, 1, ptr, #magic, magic, __VA_ARGS__)
#define PAN_dump_oneline(vsb, ptr, magic, ...) \
PAN_dump_struct2(vsb, 0, ptr, #magic, magic, __VA_ARGS__)
......@@ -110,7 +110,7 @@ static const void *already_list[N_ALREADY];
static int already_idx;
int
PAN_dump_struct2(struct vsb *vsb, int block, const void *ptr,
PAN__DumpStruct(struct vsb *vsb, int block, int track, const void *ptr,
const char *smagic, unsigned magic, const char *fmt, ...)
{
va_list ap;
......@@ -128,17 +128,19 @@ PAN_dump_struct2(struct vsb *vsb, int block, const void *ptr,
VSB_printf(vsb, " = %p {", ptr);
if (block)
VSB_putc(vsb, '\n');
for (i = 0; i < already_idx; i++) {
if (already_list[i] == ptr) {
VSB_cat(vsb, " [Already dumped, see above]");
if (block)
VSB_putc(vsb, '\n');
VSB_cat(vsb, "},\n");
return (-2);
if (track) {
for (i = 0; i < already_idx; i++) {
if (already_list[i] == ptr) {
VSB_cat(vsb, " [Already dumped, see above]");
if (block)
VSB_putc(vsb, '\n');
VSB_cat(vsb, "},\n");
return (-2);
}
}
if (already_idx < N_ALREADY)
already_list[already_idx++] = ptr;
}
if (already_idx < N_ALREADY)
already_list[already_idx++] = ptr;
uptr = ptr;
if (*uptr != magic) {
VSB_printf(vsb, " .magic = 0x%08x", *uptr);
......
......@@ -367,6 +367,22 @@ void ObjUnsubscribeEvents(uintptr_t *);
/* cache_panic.c */
void PAN_Init(void);
int PAN__DumpStruct(struct vsb *vsb, int block, int track, const void *ptr,
const char *smagic, unsigned magic, const char *fmt, ...)
v_printflike_(7,8);
#define PAN_dump_struct(vsb, ptr, magic, ...) \
PAN__DumpStruct(vsb, 1, 1, ptr, #magic, magic, __VA_ARGS__)
#define PAN_dump_oneline(vsb, ptr, magic, ...) \
PAN__DumpStruct(vsb, 0, 1, ptr, #magic, magic, __VA_ARGS__)
#define PAN_dump_once(vsb, ptr, magic, ...) \
PAN__DumpStruct(vsb, 1, 0, ptr, #magic, magic, __VA_ARGS__)
#define PAN_dump_once_oneline(vsb, ptr, magic, ...) \
PAN__DumpStruct(vsb, 0, 0, ptr, #magic, magic, __VA_ARGS__)
const char *sess_close_2str(enum sess_close sc, int want_desc);
/* cache_pool.c */
......
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