1 /* Debug code for _dbus_bindings.
3 * Copyright (C) 2006 Collabora Ltd.
5 * Licensed under the Academic Free License version 2.1
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "dbus_bindings-internal.h"
27 _dbus_py_assertion_failed(const char *assertion
)
29 PyErr_SetString(PyExc_AssertionError
, assertion
);
30 #if 1 || defined(USING_DBG) || defined(FATAL_ASSERTIONS)
31 /* print the Python stack, and dump core so we can see the C stack too */
39 _dbus_py_whereami(void)
42 /* This is a little mad. We want to get the traceback without
43 clearing the error indicator, if any. */
44 PyErr_Fetch(&c
, &v
, &t
); /* 3 new refs */
45 Py_XINCREF(c
); Py_XINCREF(v
); Py_XINCREF(t
); /* now we own 6 refs */
46 PyErr_Restore(c
, v
, t
); /* steals 3 refs */
48 if (!PyErr_Occurred()) {
49 PyErr_SetString(PyExc_AssertionError
,
50 "No error, but plz provide traceback kthx");
54 PyErr_Restore(c
, v
, t
); /* steals another 3 refs */
58 _dbus_py_dbg_exc(void)
61 /* This is a little mad. We want to get the traceback without
62 clearing the error indicator. */
63 PyErr_Fetch(&c
, &v
, &t
); /* 3 new refs */
64 Py_XINCREF(c
); Py_XINCREF(v
); Py_XINCREF(t
); /* now we own 6 refs */
65 PyErr_Restore(c
, v
, t
); /* steals 3 refs */
67 PyErr_Restore(c
, v
, t
); /* steals another 3 refs */
71 _dbus_py_dbg_dump_message(DBusMessage
*message
)
74 fprintf(stderr
, "DBusMessage at %p\n", message
);
76 s
= dbus_message_get_destination(message
);
78 fprintf(stderr
, "\tdestination %s\n", s
);
80 s
= dbus_message_get_interface(message
);
82 fprintf(stderr
, "\tinterface %s\n", s
);
84 s
= dbus_message_get_member(message
);
86 fprintf(stderr
, "\tmember %s\n", s
);
88 s
= dbus_message_get_path(message
);
90 fprintf(stderr
, "\tpath %s\n", s
);