Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/kdump kdump now displays Mach services names itself, ...



details:   https://anonhg.NetBSD.org/src/rev/9888d3333025
branches:  trunk
changeset: 555369:9888d3333025
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Nov 15 23:10:31 2003 +0000

description:
kdump now displays Mach services names itself, including a table of
id/names in sys/compat/mach/mach_services_names.c

Remove ports and flags displays, the information is already in the message.

diffstat:

 usr.bin/kdump/kdump.c   |  23 ++++++++++++++++++-----
 usr.bin/kdump/setemul.c |  34 +++++++++++++++++++++++++++++++---
 usr.bin/kdump/setemul.h |   3 ++-
 3 files changed, 51 insertions(+), 9 deletions(-)

diffs (120 lines):

diff -r dd7f294da68f -r 9888d3333025 usr.bin/kdump/kdump.c
--- a/usr.bin/kdump/kdump.c     Sat Nov 15 23:06:42 2003 +0000
+++ b/usr.bin/kdump/kdump.c     Sat Nov 15 23:10:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kdump.c,v 1.62 2003/09/20 22:24:00 matt Exp $  */
+/*     $NetBSD: kdump.c,v 1.63 2003/11/15 23:10:31 manu Exp $  */
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)kdump.c    8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kdump.c,v 1.62 2003/09/20 22:24:00 matt Exp $");
+__RCSID("$NetBSD: kdump.c,v 1.63 2003/11/15 23:10:31 manu Exp $");
 #endif
 #endif /* not lint */
 
@@ -808,9 +808,22 @@
        struct ktr_mmsg *mmsg;
        int len;
 {
-       printf("id %d [0x%x -> 0x%x] flags 0x%x\n", 
-           mmsg->ktr_id, mmsg->ktr_local_port, 
-           mmsg->ktr_remote_port, mmsg->ktr_bits);
+       const char *service_name;
+       char *reply;
+       int id;
+
+       id = mmsg->ktr_id;
+       if ((id / 100) % 2) {  /* Message reply */
+               reply = " reply";
+               id -= 100;
+       } else {
+               reply = "";
+       }
+
+       if ((service_name = mach_service_name(id)) != NULL)
+               printf("%s%s\n", service_name, reply);
+       else 
+               printf("unknown service%s [%d]\n", reply, mmsg->ktr_id);
 
        hexdump_buf(mmsg, len);
 }
diff -r dd7f294da68f -r 9888d3333025 usr.bin/kdump/setemul.c
--- a/usr.bin/kdump/setemul.c   Sat Nov 15 23:06:42 2003 +0000
+++ b/usr.bin/kdump/setemul.c   Sat Nov 15 23:10:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setemul.c,v 1.16 2003/10/19 07:34:38 christos Exp $    */
+/*     $NetBSD: setemul.c,v 1.17 2003/11/15 23:10:31 manu Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: setemul.c,v 1.16 2003/10/19 07:34:38 christos Exp $");
+__RCSID("$NetBSD: setemul.c,v 1.17 2003/11/15 23:10:31 manu Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -140,6 +140,11 @@
 #include "../../sys/compat/osf1/osf1_signo.c"
 #include "../../sys/compat/linux/common/linux_signo.c"
 
+/* For Mach services names in MMSG traces */
+#ifndef LETS_GET_SMALL
+#include "../../sys/compat/mach/mach_services_names.c"
+#endif
+
 #define NELEM(a) (sizeof(a) / sizeof(a[0]))
 
 /* static */
@@ -392,6 +397,29 @@
                if (strcmp("mach ppccalls", emul_idx->name) == 0)
                        mach_ppccalls = emul_idx;
        }
-       if (mach == NULL || mach_fasttraps == NULL || mach_ppccalls == NULL)
+       if (mach == NULL || mach_fasttraps == NULL || mach_ppccalls == NULL) {
                errx(1, "Cannot load mach emulations");
+               exit(1);
+       }
+       return;
 }
+
+/* 
+ * Find the name of the Mach service responsible to a given message Id
+ */
+const char *
+mach_service_name(id)
+       int id;
+{
+       const char *retval = NULL;
+#ifndef LETS_GET_SMALL
+       struct mach_service_name *srv;  
+
+       for (srv = mach_services_names; srv->srv_id; srv++)
+               if (srv->srv_id == id)
+                       break;
+       retval = srv->srv_name;
+#endif /* LETS_GET_SMALL */
+
+       return retval;
+}
diff -r dd7f294da68f -r 9888d3333025 usr.bin/kdump/setemul.h
--- a/usr.bin/kdump/setemul.h   Sat Nov 15 23:06:42 2003 +0000
+++ b/usr.bin/kdump/setemul.h   Sat Nov 15 23:10:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setemul.h,v 1.9 2003/10/19 07:34:38 christos Exp $     */
+/*     $NetBSD: setemul.h,v 1.10 2003/11/15 23:10:31 manu Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -86,4 +86,5 @@
 void ectx_sanify(pid_t);
 int mach_traps_dispatch(int *, const struct emulation **);
 void mach_lookup_emul(void);
+const char *mach_service_name(int);
 



Home | Main Index | Thread Index | Old Index