Module Name:    src
Committed By:   mrg
Date:           Fri Jun  5 04:31:47 UTC 2009

Modified Files:
        src/sys/ddb: db_command.c

Log Message:
extend 'show event' to take /i /t and /m modifiers, to select interrupt,
trap or misc event types.  you can mix them with /f as well, to show all
including zero events for traps and misc, "show event/ftm"


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/ddb/db_command.c

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

Modified files:

Index: src/sys/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.131 src/sys/ddb/db_command.c:1.132
--- src/sys/ddb/db_command.c:1.131	Sat Mar 21 13:06:39 2009
+++ src/sys/ddb/db_command.c	Fri Jun  5 04:31:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_command.c,v 1.131 2009/03/21 13:06:39 ad Exp $	*/
+/*	$NetBSD: db_command.c,v 1.132 2009/06/05 04:31:47 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.131 2009/03/21 13:06:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.132 2009/06/05 04:31:47 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -238,7 +238,7 @@
 	{ DDB_ADD_CMD("buf",	db_buf_print_cmd,	0,
 	    "Print the struct buf at address.", "[/f] address",NULL) },
 	{ DDB_ADD_CMD("event",	db_event_print_cmd,	0,
-	    "Print all the non-zero evcnt(9) event counters.", "[/f]",NULL) },
+	    "Print all the non-zero evcnt(9) event counters.", "[/fitm]",NULL) },
 	{ DDB_ADD_CMD("files", db_show_files_cmd,	0,
 	    "Print the files open by process at address",
 	    "[/f] address", NULL) },
@@ -1059,18 +1059,51 @@
 db_event_print_cmd(db_expr_t addr, bool have_addr,
     db_expr_t count, const char *modif)
 {
-	bool full = false;
+	bool showzero = false;
+	bool showall = true;
+	bool showintr = false;
+	bool showtrap = false;
+	bool showmisc = false;
 	struct evcnt ev, *evp;
 	char buf[80];
+	int i;
 
-	if (modif[0] == 'f')
-		full = true;
+	i = 0;
+	while (modif[i]) {
+		switch (modif[i]) {
+		case 'f':
+			showzero = true;
+			break;
+		case 'i':
+			showintr = true;
+			showall = false;
+			break;
+		case 't':
+			showtrap = true;
+			showall = false;
+			break;
+		case 'm':
+			showmisc = true;
+			showall = false;
+			break;
+		}
+		i++;
+	}
+
+	if (showall)
+		showmisc = showintr = showtrap = true;
 
 	evp = (struct evcnt *)db_read_ptr("allevents");
 	while (evp != NULL) {
 		db_read_bytes((db_addr_t)evp, sizeof(ev), (char *)&ev);
 		evp = ev.ev_list.tqe_next;
-		if (ev.ev_count == 0 && !full)
+		if (ev.ev_count == 0 && !showzero)
+			continue;
+		if (ev.ev_type == EVCNT_TYPE_INTR && !showintr)
+			continue;
+		if (ev.ev_type == EVCNT_TYPE_TRAP && !showtrap)
+			continue;
+		if (ev.ev_type == EVCNT_TYPE_MISC && !showmisc)
 			continue;
 		db_read_bytes((db_addr_t)ev.ev_group, ev.ev_grouplen + 1, buf);
 		db_printf("evcnt type %d: %s ", ev.ev_type, buf);

Reply via email to