diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 2a57ee3508a8..b29265ac6536 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -929,6 +929,28 @@ again: return (n); } +const char * +witness_file(struct lock_object *lock) +{ + struct witness *w; + + if (witness_cold || witness_dead || lock->lo_witness == NULL) + return ("?"); + w = lock->lo_witness; + return (w->w_file); +} + +int +witness_line(struct lock_object *lock) +{ + struct witness *w; + + if (witness_cold || witness_dead || lock->lo_witness == NULL) + return (0); + w = lock->lo_witness; + return (w->w_line); +} + static struct witness * enroll(const char *description, struct lock_class *lock_class) { diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 8ecdcb8780f0..3034f99efd70 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -212,6 +212,8 @@ int witness_list_locks(struct lock_list_entry **); int witness_list(struct thread *); int witness_sleep(int, struct lock_object *, const char *, int); void witness_assert(struct lock_object *, int, const char *, int); +int witness_line(struct lock_object *); +const char *witness_file(struct lock_object *); #ifdef WITNESS #define WITNESS_INIT(lock) \ @@ -245,6 +247,12 @@ void witness_assert(struct lock_object *, int, const char *, int); #define WITNESS_RESTORE(lock, n) \ witness_restore((lock), __CONCAT(n, __wf), __CONCAT(n, __wl)) +#define WITNESS_FILE(lock) \ + witness_file(lock) + +#define WITNESS_LINE(lock) \ + witness_line(lock) + #else /* WITNESS */ #define WITNESS_INIT(lock) ((lock)->lo_flags |= LO_INITIALIZED) #define WITNESS_DESTROY(lock) ((lock)->lo_flags &= ~LO_INITIALIZED) @@ -256,6 +264,8 @@ void witness_assert(struct lock_object *, int, const char *, int); #define WITNESS_SAVE_DECL(n) #define WITNESS_SAVE(lock, n) #define WITNESS_RESTORE(lock, n) +#define WITNESS_FILE(lock) ("?") +#define WITNESS_LINE(lock) (0) #endif /* WITNESS */ #endif /* _KERNEL */