bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 2/3] utils/rpctrace: generalize tracing code


From: Justus Winter
Subject: [PATCH 2/3] utils/rpctrace: generalize tracing code
Date: Wed, 11 Dec 2013 13:04:00 +0100

Currently, rpctrace dies if a tracee uses select(2) because it asserts
that reply_type is a MACH_MSG_TYPE_PORT_SEND_ONCE right.  Generalize
the code surrounding the failing assertion.

* utils/rpctrace.c (trace_and_forward): Generalize code by switching
over reply_type.
---
 utils/rpctrace.c |   40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index 9433ef3..5d3b2ca 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -1284,24 +1284,30 @@ trace_and_forward (mach_msg_header_t *inp, 
mach_msg_header_t *outp)
        /* The reply port might be dead, e.g., the traced task has died. */
        && MACH_PORT_VALID (inp->msgh_local_port))
       {
-       struct send_once_info *info;
-       // TODO is the reply port always a send once right?
-       assert (reply_type == MACH_MSG_TYPE_PORT_SEND_ONCE);
-       info = new_send_once_wrapper (inp->msgh_local_port,
-                                     &inp->msgh_local_port);
-       reply_type = MACH_MSG_TYPE_MAKE_SEND_ONCE;
-       assert (inp->msgh_local_port);
-
-       if (TRACED_INFO (info)->name == 0)
+       switch (reply_type)
          {
-           if (msgid == 0)
-             asprintf (&TRACED_INFO (info)->name, "reply(%u:%u)",
-                       (unsigned int) TRACED_INFO (info)->pi.port_right,
-                       (unsigned int) inp->msgh_id);
-           else
-             asprintf (&TRACED_INFO (info)->name, "reply(%u:%s)",
-                       (unsigned int) TRACED_INFO (info)->pi.port_right,
-                       msgid->name);
+         case MACH_MSG_TYPE_PORT_SEND_ONCE:;
+           struct send_once_info *info;
+           info = new_send_once_wrapper (inp->msgh_local_port,
+                                         &inp->msgh_local_port);
+           reply_type = MACH_MSG_TYPE_MAKE_SEND_ONCE;
+           assert (inp->msgh_local_port);
+
+           if (TRACED_INFO (info)->name == 0)
+             {
+               if (msgid == 0)
+                 asprintf (&TRACED_INFO (info)->name, "reply(%u:%u)",
+                           (unsigned int) TRACED_INFO (info)->pi.port_right,
+                           (unsigned int) inp->msgh_id);
+               else
+                 asprintf (&TRACED_INFO (info)->name, "reply(%u:%s)",
+                           (unsigned int) TRACED_INFO (info)->pi.port_right,
+                           msgid->name);
+             }
+           break;
+
+         default:
+           error (1, 0, "Reply type %i not handled", reply_type);
          }
       }
 
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]