summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2015-02-16 11:23:00 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-16 12:53:16 +0000
commita52ef07c8057459563c0e55a188721492926e427 (patch)
treebf8c26f357d3f40f9f2771080e1b2d397372d96d /tools
parent1ddaffffb8c5664c24e28d7eee13da6e3ccea8c6 (diff)
dbus-monitor.c: unify columns format in --profile mode and display column header.
[rebase onto correctly indented version -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-monitor.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c
index 2025a442..c5d39926 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);