[master] 1f00b018c varnishtest: Add backtrace

Nils Goroll nils.goroll at uplex.de
Mon May 19 13:21:05 UTC 2025


commit 1f00b018c3912a3413f48a9b06950d3b33ed643e
Author: Asad Sajjad Ahmed <asadsa at varnish-software.com>
Date:   Wed Jun 5 16:21:49 2024 +0200

    varnishtest: Add backtrace
    
    Signed-off-by: Asad Sajjad Ahmed <asadsa at varnish-software.com>

diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index f96dc9690..c42a94553 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -40,6 +40,7 @@
 #include "vtc_log.h"
 
 #include "vtim.h"
+#include "vbt.h"
 
 static pthread_mutex_t	vtclog_mtx;
 static char		*vtclog_buf;
@@ -298,20 +299,31 @@ static void v_noreturn_
 vtc_log_VAS_Fail(const char *func, const char *file, int line,
     const char *cond, enum vas_e why)
 {
+	char buf[4096] = "";
 	struct vtclog *vl;
 	int e = errno;
 
 	(void)why;
+
+	if (VBT_dump(sizeof buf, buf) < 0) {
+		bprintf(buf, "Failed to print backtrace: %d (%s)\n",
+		    errno, strerror(errno));
+	}
+
 	vl = pthread_getspecific(log_key);
 	if (vl == NULL || vl->act) {
 		fprintf(stderr,
 		    "Assert error in %s(), %s line %d:\n"
-		    "  Condition(%s) not true. (errno=%d %s)\n",
-		    func, file, line, cond, e, strerror(e));
-	} else
+		    "  Condition(%s) not true. (errno=%d %s)\n"
+		    "%s\n",
+		    func, file, line, cond, e, strerror(e), buf);
+	} else {
 		vtc_fatal(vl, "Assert error in %s(), %s line %d:"
 		    "  Condition(%s) not true."
-		    "  Errno=%d %s", func, file, line, cond, e, strerror(e));
+		    "  Errno=%d %s\n"
+		    "%s\n",
+		    func, file, line, cond, e, strerror(e), buf);
+	}
 	abort();
 }
 


More information about the varnish-commit mailing list