Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern comment out enough stuff to allow crash to print lo...
details: https://anonhg.NetBSD.org/src/rev/db45886825bc
branches: trunk
changeset: 1008059:db45886825bc
user: christos <christos%NetBSD.org@localhost>
date: Mon Mar 09 01:47:50 2020 +0000
description:
comment out enough stuff to allow crash to print locks.
diffstat:
sys/kern/subr_lockdebug.c | 50 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 41 insertions(+), 9 deletions(-)
diffs (171 lines):
diff -r af9e9fe76410 -r db45886825bc sys/kern/subr_lockdebug.c
--- a/sys/kern/subr_lockdebug.c Mon Mar 09 01:46:24 2020 +0000
+++ b/sys/kern/subr_lockdebug.c Mon Mar 09 01:47:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_lockdebug.c,v 1.74 2020/01/21 20:31:57 ad Exp $ */
+/* $NetBSD: subr_lockdebug.c,v 1.75 2020/03/09 01:47:50 christos Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.74 2020/01/21 20:31:57 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.75 2020/03/09 01:47:50 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -97,13 +97,21 @@
__cpu_simple_lock_t ld_mod_lk;
lockdebuglist_t ld_free = TAILQ_HEAD_INITIALIZER(ld_free);
+#ifdef _KERNEL
lockdebuglist_t ld_all = TAILQ_HEAD_INITIALIZER(ld_all);
+#else
+extern lockdebuglist_t ld_all;
+#define cpu_name(a) "?"
+#define cpu_index(a) -1
+#define curlwp NULL
+#endif /* _KERNEL */
int ld_nfree;
int ld_freeptr;
int ld_recurse;
bool ld_nomore;
lockdebug_t ld_prime[LD_BATCH];
+#ifdef _KERNEL
static void lockdebug_abort1(const char *, size_t, lockdebug_t *, int,
const char *, bool);
static int lockdebug_more(int);
@@ -744,6 +752,13 @@
}
splx(s);
}
+#endif /* _KERNEL */
+
+#ifdef DDB
+#include <machine/db_machdep.h>
+#include <ddb/db_interface.h>
+#include <ddb/db_access.h>
+#endif
/*
* lockdebug_dump:
@@ -755,6 +770,7 @@
__printflike(1, 2))
{
int sleeper = (ld->ld_flags & LD_SLEEPER);
+ lockops_t *lo = ld->ld_lockops;
(*pr)(
"lock address : %#018lx type : %18s\n"
@@ -762,7 +778,12 @@
(long)ld->ld_lock, (sleeper ? "sleep/adaptive" : "spin"),
(long)ld->ld_initaddr);
- if (ld->ld_lockops->lo_type == LOCKOPS_CV) {
+#ifndef _KERNEL
+ lockops_t los;
+ lo = &los;
+ db_read_bytes((db_addr_t)ld->ld_lockops, sizeof(los), (char *)lo);
+#endif
+ if (lo->lo_type == LOCKOPS_CV) {
(*pr)(" interlock: %#018lx\n", (long)ld->ld_locked);
} else {
(*pr)("\n"
@@ -781,14 +802,17 @@
(long)ld->ld_unlocked);
}
- if (ld->ld_lockops->lo_dump != NULL)
- (*ld->ld_lockops->lo_dump)(ld->ld_lock, pr);
+#ifdef _KERNEL
+ if (lo->lo_dump != NULL)
+ (*lo->lo_dump)(ld->ld_lock, pr);
if (sleeper) {
turnstile_print(ld->ld_lock, pr);
}
+#endif
}
+#ifdef _KERNEL
/*
* lockdebug_abort1:
*
@@ -821,6 +845,7 @@
ld->ld_lockops->lo_name, func, line, msg);
}
+#endif /* _KERNEL */
#endif /* LOCKDEBUG */
/*
@@ -829,17 +854,16 @@
* Handle the DDB 'show lock' command.
*/
#ifdef DDB
-#include <machine/db_machdep.h>
-#include <ddb/db_interface.h>
-
void
lockdebug_lock_print(void *addr,
void (*pr)(const char *, ...) __printflike(1, 2))
{
#ifdef LOCKDEBUG
- lockdebug_t *ld;
+ lockdebug_t *ld, lds;
TAILQ_FOREACH(ld, &ld_all, ld_achain) {
+ db_read_bytes((db_addr_t)ld, sizeof(lds), __UNVOLATILE(&lds));
+ ld = &lds;
if (ld->ld_lock == NULL)
continue;
if (addr == NULL || ld->ld_lock == addr) {
@@ -857,6 +881,7 @@
#endif /* LOCKDEBUG */
}
+#ifdef _KERNEL
#ifdef LOCKDEBUG
static void
lockdebug_show_one(lwp_t *l, lockdebug_t *ld, int i,
@@ -864,8 +889,10 @@
{
const char *sym;
+#ifdef _KERNEL
ksyms_getname(NULL, &sym, (vaddr_t)ld->ld_initaddr,
KSYMS_CLOSEST|KSYMS_PROC|KSYMS_ANY);
+#endif
(*pr)("* Lock %d (initialized at %s)\n", i++, sym);
lockdebug_dump(l, ld, pr);
}
@@ -947,8 +974,10 @@
}
}
}
+#endif /* _KERNEL */
#endif /* LOCKDEBUG */
+#ifdef _KERNEL
void
lockdebug_show_all_locks(void (*pr)(const char *, ...) __printflike(1, 2),
const char *modif)
@@ -1019,8 +1048,10 @@
(*pr)("Sorry, kernel not built with the LOCKDEBUG option.\n");
#endif /* LOCKDEBUG */
}
+#endif /* _KERNEL */
#endif /* DDB */
+#ifdef _KERNEL
/*
* lockdebug_dismiss:
*
@@ -1076,3 +1107,4 @@
panic("lock error: %s: %s,%zu: %s: lock %p cpu %d lwp %p",
ops->lo_name, func, line, msg, lock, cpu_index(curcpu()), curlwp);
}
+#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index