GDBus: Add `return' debug option

This prints all GDBusMethodInvocation API usage and is normally used
with the `incoming' option. Example:

 # G_DBUS_DEBUG=incoming,return ./polkitd --replace
 Entering main event loop
 Connected to the system bus
 Registering null backend at priority -10
 [...]
 Acquired the name org.freedesktop.PolicyKit1
 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.26
       serial 299
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD ERROR org.freedesktop.PolicyKit1.Error.Failed
       message `Cannot determine session the caller is in'
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.26
       reply-serial 299

 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.2402
       serial 25
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD RETURN
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.2402
       reply-serial 25

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen
2010-08-04 16:59:26 -04:00
parent 89a1b571ad
commit d52e1c33f7
5 changed files with 61 additions and 6 deletions

View File

@@ -381,6 +381,23 @@ g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation,
g_variant_type_free (type);
}
if (G_UNLIKELY (_g_dbus_debug_return ()))
{
_g_dbus_debug_print_lock ();
g_print ("========================================================================\n"
"GDBus-debug:Return:\n"
" >>>> METHOD RETURN\n"
" in response to %s.%s()\n"
" on object %s\n"
" to name %s\n"
" reply-serial %d\n",
invocation->interface_name, invocation->method_name,
invocation->object_path,
invocation->sender,
g_dbus_message_get_serial (invocation->message));
_g_dbus_debug_print_unlock ();
}
reply = g_dbus_message_new_method_reply (invocation->message);
g_dbus_message_set_body (reply, parameters);
error = NULL;
@@ -560,6 +577,26 @@ g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation,
g_return_if_fail (error_name != NULL && g_dbus_is_name (error_name));
g_return_if_fail (error_message != NULL);
if (G_UNLIKELY (_g_dbus_debug_return ()))
{
_g_dbus_debug_print_lock ();
g_print ("========================================================================\n"
"GDBus-debug:Return:\n"
" >>>> METHOD ERROR %s\n"
" message `%s'\n"
" in response to %s.%s()\n"
" on object %s\n"
" to name %s\n"
" reply-serial %d\n",
error_name,
error_message,
invocation->interface_name, invocation->method_name,
invocation->object_path,
invocation->sender,
g_dbus_message_get_serial (invocation->message));
_g_dbus_debug_print_unlock ();
}
reply = g_dbus_message_new_method_error_literal (invocation->message,
error_name,
error_message);