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