From 039c1fd312b0501bf9607fae44c193e576304661 Mon Sep 17 00:00:00 2001 From: chs Date: Tue, 25 Sep 2001 06:13:29 +0000 Subject: [PATCH] print a stack trace in more LOCKDEBUG cases. add a blank line between complaints. use TAILQ_FOREACH where appropriate. --- sys/kern/kern_lock.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index ec26a0a16369..68b6afc66b88 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.57 2001/09/22 22:36:30 sommerfeld Exp $ */ +/* $NetBSD: kern_lock.c,v 1.58 2001/09/25 06:13:29 chs Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -970,8 +970,12 @@ int simple_lock_debugger = 1; /* more serious on MP */ int simple_lock_debugger = 0; #endif #define SLOCK_DEBUGGER() if (simple_lock_debugger) Debugger() +#define SLOCK_TRACE() \ + db_stack_trace_print((db_expr_t)__builtin_frame_address(0), \ + TRUE, 65535, "", printf); #else #define SLOCK_DEBUGGER() /* nothing */ +#define SLOCK_TRACE() /* nothing */ #endif /* } */ #ifdef MULTIPROCESSOR @@ -983,6 +987,7 @@ int simple_lock_debugger = 0; #define SLOCK_WHERE(str, alp, id, l) \ do { \ + lock_printf("\n"); \ lock_printf(str); \ lock_printf("lock: %p, currently at: %s:%d\n", (alp), (id), (l)); \ SLOCK_MP(); \ @@ -992,6 +997,7 @@ do { \ if ((alp)->unlock_file != NULL) \ lock_printf("last unlocked: %s:%d\n", (alp)->unlock_file, \ (alp)->unlock_line); \ + SLOCK_TRACE() \ SLOCK_DEBUGGER(); \ } while (/*CONSTCOND*/0) @@ -1194,8 +1200,7 @@ simple_lock_dump(void) s = spllock(); SLOCK_LIST_LOCK(); lock_printf("all simple locks:\n"); - for (alp = TAILQ_FIRST(&simplelock_list); alp != NULL; - alp = TAILQ_NEXT(alp, list)) { + TAILQ_FOREACH(alp, &simplelock_list, list) { lock_printf("%p CPU %lu %s:%d\n", alp, alp->lock_holder, alp->lock_file, alp->lock_line); } @@ -1211,8 +1216,7 @@ simple_lock_freecheck(void *start, void *end) s = spllock(); SLOCK_LIST_LOCK(); - for (alp = TAILQ_FIRST(&simplelock_list); alp != NULL; - alp = TAILQ_NEXT(alp, list)) { + TAILQ_FOREACH(alp, &simplelock_list, list) { if ((void *)alp >= start && (void *)alp < end) { lock_printf("freeing simple_lock %p CPU %lu %s:%d\n", alp, alp->lock_holder, alp->lock_file, @@ -1247,8 +1251,7 @@ simple_lock_only_held(volatile struct simplelock *lp, const char *where) } s = spllock(); SLOCK_LIST_LOCK(); - for (alp = TAILQ_FIRST(&simplelock_list); alp != NULL; - alp = TAILQ_NEXT(alp, list)) { + TAILQ_FOREACH(alp, &simplelock_list, list) { if (alp == lp) continue; if (alp->lock_holder == cpu_id) @@ -1258,14 +1261,11 @@ simple_lock_only_held(volatile struct simplelock *lp, const char *where) splx(s); if (alp != NULL) { - lock_printf("%s with held simple_lock %p " + lock_printf("\n%s with held simple_lock %p " "CPU %lu %s:%d\n", where, alp, alp->lock_holder, alp->lock_file, alp->lock_line); -#ifdef DDB - db_stack_trace_print((db_expr_t)__builtin_frame_address(0), - TRUE, 65535, "", printf); -#endif + SLOCK_TRACE(); SLOCK_DEBUGGER(); } }