From 8a3b1e31b6064139356a4748d9920fa4071d5807 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 16 Feb 2015 11:23:00 +0100 Subject: [PATCH 2/2] dbus-monitor.c: unify columns format in --profile mode and display column header. --- tools/dbus-monitor.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index d2ff356..64026e8 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -130,6 +130,13 @@ typedef enum } ProfileAttributeFlags; static void +profile_print_headers (void) +{ + printf ("type\tsec\tusec\tserial\tsender\tdestination\tpath\tinterface\tmember\n"); + printf ("\t\t\t\t\t\t\tref serial\n"); +} + +static void profile_print_with_attrs (const char *type, DBusMessage *message, struct timeval *t, ProfileAttributeFlags attrs) { @@ -138,15 +145,17 @@ profile_print_with_attrs (const char *type, DBusMessage *message, if (attrs & PROFILE_ATTRIBUTE_FLAG_SERIAL) printf ("\t%u", dbus_message_get_serial (message)); - if (attrs & PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL) - printf ("\t%u", dbus_message_get_reply_serial (message)); - if (attrs & PROFILE_ATTRIBUTE_FLAG_SENDER) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_sender (message))); if (attrs & PROFILE_ATTRIBUTE_FLAG_DESTINATION) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_destination (message))); + if (attrs & PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL) + printf ("\t%u", dbus_message_get_reply_serial (message)); + else + printf ("\t"); + if (attrs & PROFILE_ATTRIBUTE_FLAG_PATH) printf ("\t%s", TRAP_NULL_STRING (dbus_message_get_path (message))); @@ -165,6 +174,7 @@ profile_print_with_attrs (const char *type, DBusMessage *message, static void print_message_profile (DBusMessage *message) { + static dbus_bool_t first = TRUE; struct timeval t; if (gettimeofday (&t, NULL) < 0) @@ -173,12 +183,19 @@ print_message_profile (DBusMessage *message) return; } + if (first) + { + profile_print_headers(); + first = FALSE; + } + switch (dbus_message_get_type (message)) { case DBUS_MESSAGE_TYPE_METHOD_CALL: profile_print_with_attrs ("mc", message, &t, PROFILE_ATTRIBUTE_FLAG_SERIAL | PROFILE_ATTRIBUTE_FLAG_SENDER | + PROFILE_ATTRIBUTE_FLAG_DESTINATION | PROFILE_ATTRIBUTE_FLAG_PATH | PROFILE_ATTRIBUTE_FLAG_INTERFACE | PROFILE_ATTRIBUTE_FLAG_MEMBER); @@ -186,18 +203,22 @@ print_message_profile (DBusMessage *message) case DBUS_MESSAGE_TYPE_METHOD_RETURN: profile_print_with_attrs ("mr", message, &t, PROFILE_ATTRIBUTE_FLAG_SERIAL | + PROFILE_ATTRIBUTE_FLAG_SENDER | PROFILE_ATTRIBUTE_FLAG_DESTINATION | PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL); break; case DBUS_MESSAGE_TYPE_ERROR: profile_print_with_attrs ("err", message, &t, PROFILE_ATTRIBUTE_FLAG_SERIAL | + PROFILE_ATTRIBUTE_FLAG_SENDER | PROFILE_ATTRIBUTE_FLAG_DESTINATION | PROFILE_ATTRIBUTE_FLAG_REPLY_SERIAL); break; case DBUS_MESSAGE_TYPE_SIGNAL: profile_print_with_attrs ("sig", message, &t, PROFILE_ATTRIBUTE_FLAG_SERIAL | + PROFILE_ATTRIBUTE_FLAG_SENDER | + PROFILE_ATTRIBUTE_FLAG_DESTINATION | PROFILE_ATTRIBUTE_FLAG_PATH | PROFILE_ATTRIBUTE_FLAG_INTERFACE | PROFILE_ATTRIBUTE_FLAG_MEMBER); -- 1.8.4.5