Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Sep 2012 12:40:00 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r240820 - head/usr.bin/kdump
Message-ID:  <201209221240.q8MCe059067641@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Sep 22 12:40:00 2012
New Revision: 240820
URL: http://svn.freebsd.org/changeset/base/240820

Log:
  kdump: Pretty-print signal codes.
  
  MFC after:	1 week

Modified:
  head/usr.bin/kdump/kdump.c
  head/usr.bin/kdump/mksubr

Modified: head/usr.bin/kdump/kdump.c
==============================================================================
--- head/usr.bin/kdump/kdump.c	Sat Sep 22 12:38:19 2012	(r240819)
+++ head/usr.bin/kdump/kdump.c	Sat Sep 22 12:40:00 2012	(r240820)
@@ -1242,11 +1242,15 @@ ktrpsig(struct ktr_psig *psig)
 		printf("SIG%s ", signames[psig->signo]);
 	else
 		printf("SIG %d ", psig->signo);
-	if (psig->action == SIG_DFL)
-		printf("SIG_DFL code=0x%x\n", psig->code);
-	else {
-		printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
-		    (u_long)psig->action, psig->mask.__bits[0], psig->code);
+	if (psig->action == SIG_DFL) {
+		printf("SIG_DFL code=");
+		sigcodename(psig->signo, psig->code);
+		putchar('\n');
+	} else {
+		printf("caught handler=0x%lx mask=0x%x code=",
+		    (u_long)psig->action, psig->mask.__bits[0]);
+		sigcodename(psig->signo, psig->code);
+		putchar('\n');
 	}
 }
 

Modified: head/usr.bin/kdump/mksubr
==============================================================================
--- head/usr.bin/kdump/mksubr	Sat Sep 22 12:38:19 2012	(r240819)
+++ head/usr.bin/kdump/mksubr	Sat Sep 22 12:40:00 2012	(r240820)
@@ -388,7 +388,13 @@ auto_switch_type "schedpolicyname"     "
 auto_switch_type "sendfileflagsname"   "SF_[A-Z]+[[:space:]]+[0-9]+"                  "sys/socket.h"
 auto_or_type     "shmatname"           "SHM_[A-Z]+[[:space:]]+[0-9]{6}+"              "sys/shm.h"
 auto_switch_type "shutdownhowname"     "SHUT_[A-Z]+[[:space:]]+[0-9]+"                "sys/socket.h"
+auto_switch_type "sigbuscodename"      "BUS_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
+auto_switch_type "sigchldcodename"     "CLD_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
+auto_switch_type "sigfpecodename"      "FPE_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
 auto_switch_type "sigprocmaskhowname"  "SIG_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
+auto_switch_type "sigillcodename"      "ILL_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
+auto_switch_type "sigsegvcodename"     "SEGV_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
+auto_switch_type "sigtrapcodename"     "TRAP_[A-Z]+[[:space:]]+[0-9]+"                 "sys/signal.h"
 auto_if_type     "sockdomainname"      "PF_[[:alnum:]]+[[:space:]]+"                  "sys/socket.h"
 auto_if_type     "sockfamilyname"      "AF_[[:alnum:]]+[[:space:]]+"                  "sys/socket.h"
 auto_if_type     "sockipprotoname"     "IPPROTO_[[:alnum:]]+[[:space:]]+"             "netinet/in.h"
@@ -501,4 +507,46 @@ cat <<_EOF_
 	printf(">");
 }
 
+/*
+ * AUTO - Special
+ *
+ * Check general codes first, then defer to signal-specific codes.
+ */
+void
+sigcodename(int sig, int code)
+{
+	switch (code) {
 _EOF_
+egrep "^#[[:space:]]*define[[:space:]]+SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?[[:space:]]*" \
+	$include_dir/sys/signal.h | grep -v SI_UNDEFINED | \
+	awk '{ for (i = 1; i <= NF; i++) \
+		if ($i ~ /define/) \
+			break; \
+		++i; \
+		printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+cat <<_EOF_
+	default:
+		switch (sig) {
+		case SIGILL:
+			sigillcodename(code);
+			break;
+		case SIGBUS:
+			sigbuscodename(code);
+			break;
+		case SIGSEGV:
+			sigsegvcodename(code);
+			break;
+		case SIGFPE:
+			sigfpecodename(code);
+			break;
+		case SIGTRAP:
+			sigtrapcodename(code);
+			break;
+		case SIGCHLD:
+			sigchldcodename(code);
+			break;
+		default:
+			printf("<invalid=%#x>", code);
+		}
+	}
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209221240.q8MCe059067641>