From 500b9f78838fb484bc84e058fab1b04a417a6d5a Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <tuxillo@quantumachine.net>
Date: Thu, 7 Jan 2010 01:55:28 +0100
Subject: [PATCH] test - Cleanup a bit debug tests

---
 test/debug/Makefile   |   45 +++++++++++++++++++++++++++++++++++++++++++++
 test/debug/README     |   33 ++++++++++++++++++++-------------
 test/debug/kmapinfo.c |   12 ++++--------
 3 files changed, 69 insertions(+), 21 deletions(-)
 create mode 100644 test/debug/Makefile

diff --git a/test/debug/Makefile b/test/debug/Makefile
new file mode 100644
index 0000000..8bd7abb
--- /dev/null
+++ b/test/debug/Makefile
@@ -0,0 +1,45 @@
+DESTDIR= /usr/local/bin
+TARGETS= $(DESTDIR)/fdpassing $(DESTDIR)/kmapinfo $(DESTDIR)/kwrite \
+	 $(DESTDIR)/ncptrace $(DESTDIR)/posixlock $(DESTDIR)/revoke  \
+	 $(DESTDIR)/ttyinfo $(DESTDIR)/umtx $(DESTDIR)/vmpageinfo \
+	 $(DESTDIR)/vnodeinfo $(DESTDIR)/wildcardinfo
+
+CFLAGS= -O -g -Wall -I/usr/src/sys
+
+all:	$(TARGETS)
+
+$(DESTDIR)/fdpassing: fdpassing.c
+	$(CC) $(CFLAGS) fdpassing.c -o ${.TARGET}
+
+$(DESTDIR)/kmapinfo: kmapinfo.c
+	$(CC) $(CFLAGS) -lkvm kmapinfo.c -o ${.TARGET}
+
+$(DESTDIR)/kwrite: kwrite.c
+	$(CC) $(CFLAGS) -lkvm kwrite.c -o ${.TARGET}
+
+$(DESTDIR)/ncptrace: ncptrace.c
+	$(CC) $(CFLAGS) -lkvm ncptrace.c -o ${.TARGET}
+
+$(DESTDIR)/posixlock: posixlock.c
+	$(CC) $(CFLAGS) posixlock.c -o ${.TARGET}
+
+$(DESTDIR)/revoke: revoke.c
+	$(CC) $(CFLAGS) revoke.c -o ${.TARGET}
+
+$(DESTDIR)/ttyinfo: ttyinfo.c
+	$(CC) $(CFLAGS) -lkvm ttyinfo.c -o ${.TARGET}
+
+$(DESTDIR)/umtx: umtx.c
+	$(CC) $(CFLAGS) umtx.c -o ${.TARGET}
+
+$(DESTDIR)/vmpageinfo: vmpageinfo.c
+	$(CC) $(CFLAGS) vmpageinfo.c -o ${.TARGET}
+
+$(DESTDIR)/vnodeinfo: vnodeinfo.c
+	$(CC) $(CFLAGS) vnodeinfo.c -o ${.TARGET}
+
+$(DESTDIR)/wildcardinfo: wildcardinfo.c
+	$(CC) $(CFLAGS) wildcardinfo.c -o ${.TARGET}
+
+clean:
+	rm -f $(TARGETS)
diff --git a/test/debug/README b/test/debug/README
index 0de8682..1213139 100644
--- a/test/debug/README
+++ b/test/debug/README
@@ -3,22 +3,29 @@ $DragonFly: src/test/debug/README,v 1.4 2004/12/14 23:58:32 dillon Exp $
 
 Files in this directory:
 
-	gdb.kernel -	Kernel debugging macro set for GDB
+	gdb.kernel     - Kernel debugging macro set for GDB
 
-	ncptrace.c -	Trace the kernel's namecache hierarchy.  Namecache
-			records are typically in one of three states:
-			unresolved (marked UNRESOLVED -- cache state not yet
-			known), positive cache hit (non-NULL vp), or negative
-			cache hit (NULL vp)
+	ncptrace.c     - Trace the kernel's namecache hierarchy.  Namecache
+			 records are typically in one of three states:
+			 unresolved (marked UNRESOLVED -- cache state not yet
+			 known), positive cache hit (non-NULL vp), or negative
+			 cache hit (NULL vp)
 
-	ttyinfo.c  -	Extract clist information and check the
-			block counts looking for corruption.
+	ttyinfo.c      - Extract clist information and check the
+			 block counts looking for corruption.
 
-	vnodeinfo.c -	Run through the mountlist and scan and display
-			summary counts and all related vnodes.
+	vnodeinfo.c    - Run through the mountlist and scan and display
+			 summary counts and all related vnodes.
 			
-	vmpageinfo.c -	Run through the vm_page_array and the vm_page_buckets
-			hash table and check that all the pages have the
-			correct hash table association.
+	vmpageinfo.c   - Run through the vm_page_array and the vm_page_buckets
+			 hash table and check that all the pages have the
+			 correct hash table association.
 				
+	kmapinfo.c     - Dumps the kernel_map, so you can have more information
+			 about the amount of KVM being used. It also works with
+			 coredumps.
+
+	kwrite.c       - A tool to write/read kernel memory.
+
+	wildcardinfo.c - Dump the tcbinfo[] array and wildcard hash table for each cpu.
 
diff --git a/test/debug/kmapinfo.c b/test/debug/kmapinfo.c
index 1299e1d..6878630 100644
--- a/test/debug/kmapinfo.c
+++ b/test/debug/kmapinfo.c
@@ -83,15 +83,8 @@ main(int ac, char **av)
 {
     const char *corefile = NULL;
     const char *sysfile = NULL;
-    vm_page_t mptr;
-    struct vm_page m;
-    struct vm_object obj;
     kvm_t *kd;
     int ch;
-    int hv;
-    int i;
-    const char *qstr;
-    const char *ostr;
     vm_offset_t last;
 
     while ((ch = getopt(ac, av, "M:N:dv")) != -1) {
@@ -130,6 +123,8 @@ main(int ac, char **av)
     printf("-----------------------------------------------\n");
     printf("Total empty space: %7ldK\n", total_empty / 1024);
     printf("Total used  space: %7ldK\n", total_used / 1024);
+
+    return 0;
 }
 
 static void
@@ -157,10 +152,11 @@ mapscan(kvm_t *kd, vm_map_entry_t entryp, vm_offset_t *lastp)
 	entry.start, entry.end,
 	(entry.end - entry.start) / 1024,
 	entry.maptype,
-	entry.object);
+	&entry.object);
     total_used += entry.end - entry.start;
     *lastp = entry.end;
     mapscan(kd, entry.rb_entry.rbe_right, lastp);
+
 }
 
 static void
-- 
1.6.3.3

