[master] d0e986a6d dump argv to panic buffer

Nils Goroll nils.goroll at uplex.de
Mon Oct 5 14:44:06 UTC 2020


commit d0e986a6dd0cd0801531d5c7f9c05d11c24a676b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Oct 5 16:42:24 2020 +0200

    dump argv to panic buffer
    
    This is solely to make bug reports more useful

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 6d7aa5afa..61bde5f43 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -713,6 +713,22 @@ pan_threadattr(struct vsb *vsb)
 }
 #endif
 
+static void
+pan_argv(struct vsb *vsb)
+{
+	int i;
+
+	VSB_printf(pan_vsb, "argv = {\n");
+	VSB_indent(vsb, 2);
+	for (i = 0; i < heritage.argc; i++) {
+		VSB_printf(vsb, "[%d] = ", i);
+		VSB_quote(vsb, heritage.argv[i], -1, VSB_QUOTE_CSTR);
+		VSB_cat(vsb, ",\n");
+	}
+	VSB_cat(vsb, "}\n");
+	VSB_indent(vsb, -2);
+
+}
 /*--------------------------------------------------------------------*/
 
 static void __attribute__((__noreturn__))
@@ -781,6 +797,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 	if (err)
 		VSB_printf(pan_vsb, "errno = %d (%s)\n", err, vstrerror(err));
 
+	pan_argv(pan_vsb);
+
 	VSB_printf(pan_vsb, "pthread.self = %p\n", TRUST_ME(pthread_self()));
 
 	q = THR_GetName();
diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h
index d33fb4d3f..e6daa8db3 100644
--- a/bin/varnishd/common/heritage.h
+++ b/bin/varnishd/common/heritage.h
@@ -89,6 +89,9 @@ struct heritage {
 
 	unsigned			min_vcl_version;
 	unsigned			max_vcl_version;
+
+	int				argc;
+	char * const *			argv;
 };
 
 extern struct heritage heritage;
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 7eb7669cc..65ccfcb3d 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -489,6 +489,9 @@ main(int argc, char * const *argv)
 	struct vsb *vsb;
 	pid_t pid;
 
+	heritage.argc = argc;
+	heritage.argv = argv;
+
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
 


More information about the varnish-commit mailing list