From f0a747d129685b618ee89c973d4fe625c1cd291f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 29 Jan 2020 01:51:21 +0000 Subject: [PATCH] vfs: add VNPASS macro and augment VNASSERT to print more about the assert Sample out put now instead of mere VNASSERT failed: VNASSERT failed: vp->v_holdcnt == 1234 not true at /usr/src/sys/kern/vfs_subr.c:3148 (vputx) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23396 --- sys/sys/systm.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index dc95f26dc9af..628dd4e0f5b1 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -107,16 +107,24 @@ void kassert_panic(const char *fmt, ...) __printflike(1, 2); } while (0) #define VNASSERT(exp, vp, msg) do { \ if (__predict_false(!(exp))) { \ - vn_printf(vp, "VNASSERT failed\n"); \ + vn_printf(vp, "VNASSERT failed: %s not true at %s:%d (%s)\n",\ + #exp, __FILE__, __LINE__, __func__); \ kassert_panic msg; \ } \ } while (0) +#define VNPASS(exp, vp) do { \ + const char *_exp = #exp; \ + VNASSERT(exp, vp, ("condition %s not met at %s:%d (%s)", \ + _exp, __FILE__, __LINE__, __func__)); \ +} while (0) #else #define KASSERT(exp,msg) do { \ } while (0) #define VNASSERT(exp, vp, msg) do { \ } while (0) +#define VNPASS(exp, vp) do { \ +} while (0) #endif #ifndef CTASSERT /* Allow lint to override */