summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-11 11:35:39 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-16 10:48:18 +0100
commit9a1bb117c165bbedb2b75578ac71e46f2139470e (patch)
treefd8545249c3447d787bbd8a4981e2a5a34737a4b /utils
parentd999b70a3f395afe06d430c14fdf02a64ac28c06 (diff)
utils/rpctrace: generalize tracing code
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.
Diffstat (limited to 'utils')
-rw-r--r--utils/rpctrace.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index 9433ef38..5d3b2ca0 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);
}
}