Module Name:    src
Committed By:   christos
Date:           Mon Mar  9 01:54:31 UTC 2020

Modified Files:
        src/usr.sbin/crash: Makefile crash.c

Log Message:
Add primitive LOCKDEBUG support.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/crash/Makefile
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/crash/crash.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/crash/Makefile
diff -u src/usr.sbin/crash/Makefile:1.42 src/usr.sbin/crash/Makefile:1.43
--- src/usr.sbin/crash/Makefile:1.42	Sun Oct 13 03:28:18 2019
+++ src/usr.sbin/crash/Makefile	Sun Mar  8 21:54:31 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.42 2019/10/13 07:28:18 mrg Exp $
+#	$NetBSD: Makefile,v 1.43 2020/03/09 01:54:31 christos Exp $
 
 PROG=		crash
 MAN=		crash.8
@@ -30,6 +30,10 @@ REALCRASH=yes
 REALCRASH=no
 .endif
 
+CPPFLAGS +=-DLOCKDEBUG
+CPPFLAGS.subr_lockdebug.c += -DCRASH -DDDB
+SRCS += subr_lockdebug.c
+
 .if ${REALCRASH} != "no"	# {
 
 S=		${.CURDIR}/../../sys

Index: src/usr.sbin/crash/crash.c
diff -u src/usr.sbin/crash/crash.c:1.11 src/usr.sbin/crash/crash.c:1.12
--- src/usr.sbin/crash/crash.c:1.11	Tue Jan 10 15:57:26 2017
+++ src/usr.sbin/crash/crash.c	Sun Mar  8 21:54:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: crash.c,v 1.11 2017/01/10 20:57:26 christos Exp $	*/
+/*	$NetBSD: crash.c,v 1.12 2020/03/09 01:54:31 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: crash.c,v 1.11 2017/01/10 20:57:26 christos Exp $");
+__RCSID("$NetBSD: crash.c,v 1.12 2020/03/09 01:54:31 christos Exp $");
 #endif /* not lint */
 
 #include <ddb/ddb.h>
@@ -73,9 +73,24 @@ static struct nlist nl[] = {
 	{ .n_name = "_osrelease" },
 #define	X_PANICSTR	1
 	{ .n_name = "_panicstr" },
+#ifdef LOCKDEBUG
+#define	X_LOCKDEBUG	2
+	{ .n_name = "ld_all" },
+#endif
 	{ .n_name = NULL },
 };
 
+#ifdef LOCKDEBUG
+struct lockdebug;
+TAILQ_HEAD(, lockdebug) ld_all;
+#else
+void lockdebug_lock_print(void);
+void lockdebug_lock_print(void) {
+	warnx("No lockdebug support compiled in");
+}
+#endif
+
+
 static void
 cleanup(void)
 {
@@ -412,6 +427,12 @@ main(int argc, char **argv)
 		errx(EXIT_FAILURE, "cannot read osrelease: %s",
 		    kvm_geterr(kd));
 	}
+#ifdef LOCKDEBUG
+	if ((size_t)kvm_read(kd, nl[X_LOCKDEBUG].n_value, &ld_all,
+	    sizeof(ld_all)) != sizeof(ld_all))
+		warn("Cannot read ld_all (no LOCKDEBUG kernel?): %s",
+		kvm_geterr(kd));
+#endif
 	printf("Crash version %s, image version %s.\n", osrelease, imgrelease);
 	if (strcmp(osrelease, imgrelease) != 0) {
 		printf("WARNING: versions differ, you may not be able to "

Reply via email to