mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user