If we cannot get this to work with protected payloads, we can always
add a switch to libports to disable the optimization.
---
utils/rpctrace.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index ef7ab53..035a3fd 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -1213,7 +1213,25 @@ trace_and_forward (mach_msg_header_t *inp,
mach_msg_header_t *outp)
/* Look up our record for the receiving port. There is no need to check
the class, because our port bucket only ever contains one class of
ports (traced_class). */
- info = ports_lookup_port (traced_bucket, inp->msgh_local_port, 0);
+
+ if (MACH_MSGH_BITS_LOCAL (inp->msgh_bits) == MACH_MSG_TYPE_PROTECTED_PAYLOAD)
+ {
+ info = (struct traced_info *) inp->msgh_protected_payload;
+ if (info && info->pi.bucket == traced_bucket)
+ {
+ ports_port_ref (info);
+ /* Undo the protected payload optimization for our tracee. */
+ inp->msgh_bits = MACH_MSGH_BITS (
+ MACH_MSGH_BITS_REMOTE (inp->msgh_bits),
+ MACH_MSG_TYPE_PORT_SEND); /* XXX we cannot know the real type :( */
+ inp->msgh_local_port = ports_payload_get_name (info);
+ }
+ else
+ info = NULL;
+ }
+ else
+ info = ports_lookup_port (traced_bucket, inp->msgh_local_port, 0);
+
assert (info);
/* A notification message from the kernel appears to have been sent
--
1.7.10.4