summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-13 15:25:22 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-16 10:48:18 +0100
commitb372e439e05e336d5e52aa0ce69c799c15691932 (patch)
treeaf0992be489efc7a5db1907aae140682f10a8b3d /utils
parent84932431cf4fbd494b4597105faed26ed2ac4efe (diff)
utils/rpctrace: fix output so that replies can be attributed to requests
Currently, it is impossible to properly attribute response messages to requests. Even though rpctrace is single-threaded, its tracee may not. Or there might be more than one tracee. In any such case it is not guaranteed that the reply message we just processed is for the request we just printed. Fix this by printing ellipsis with the port name, so that reply messages can be properly attributed: task129(pid3312)->mach_port_allocate (3) ...134 task129(pid3312)->mach_port_deallocate (pn{ 1}) ...160 134... = 0 pn{ 30} 160... = 0 * utils/rpctrace.c (last_reply_port): New variable. (print_ellipsis): New function. (print_request_header): Optionally print ellipsis and update last_reply_port. (print_reply_header): Likewise.
Diffstat (limited to 'utils')
-rw-r--r--utils/rpctrace.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index 0f68f444..d7ee2034 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -1,7 +1,7 @@
/* Trace RPCs sent to selected ports
- Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009, 2011,
+ 2013 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -1486,10 +1486,27 @@ static const char *const msg_types[] =
};
#endif
+/* We keep track of the last reply port used in a request we print to
+ ostream. This way we can end incomplete requests with an ellipsis
+ and the name of the reply port. When the reply finally arrives, we
+ start a new line with that port name and an ellipsis, making it
+ easy to match it to the associated request. */
+static mach_port_t last_reply_port;
+
+/* Print an ellipsis if necessary. */
+static void
+print_ellipsis (void)
+{
+ if (MACH_PORT_VALID (last_reply_port))
+ fprintf (ostream, " ...%u\n", (unsigned int) last_reply_port);
+}
+
static void
print_request_header (struct sender_info *receiver, mach_msg_header_t *msg)
{
const char *msgname = msgid_name (msg->msgh_id);
+ print_ellipsis ();
+ last_reply_port = msg->msgh_local_port;
if (TRACED_INFO (receiver)->name != 0)
fprintf (ostream, "%4s->", TRACED_INFO (receiver)->name);
@@ -1507,6 +1524,13 @@ static void
print_reply_header (struct send_once_info *info, mig_reply_header_t *reply,
struct req_info *req)
{
+ if (last_reply_port != info->pi.pi.port_right)
+ {
+ print_ellipsis ();
+ fprintf (ostream, "%u...", (unsigned int) info->pi.pi.port_right);
+ }
+ last_reply_port = MACH_PORT_NULL;
+
/* We have printed a partial line for the request message,
and now we have the corresponding reply. */
if (reply->Head.msgh_id == req->req_id + 100)