Unset release flag, and start NEWS for 0.82.5
[dbus-python-phuang.git] / _dbus_bindings / debug.c
blobb34762846b26fa5d1b297e44155bc1e62ca37825
1 /* Debug code for _dbus_bindings.
3 * Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 #include "dbus_bindings-internal.h"
27 #include <stdlib.h>
29 void
30 _dbus_py_assertion_failed(const char *assertion)
32 PyErr_SetString(PyExc_AssertionError, assertion);
33 #if 1 || defined(USING_DBG) || defined(FATAL_ASSERTIONS)
34 /* print the Python stack, and dump core so we can see the C stack too */
35 PyErr_Print();
36 abort();
37 #endif
40 #ifdef USING_DBG
41 void
42 _dbus_py_whereami(void)
44 PyObject *c, *v, *t;
45 /* This is a little mad. We want to get the traceback without
46 clearing the error indicator, if any. */
47 PyErr_Fetch(&c, &v, &t); /* 3 new refs */
48 Py_XINCREF(c); Py_XINCREF(v); Py_XINCREF(t); /* now we own 6 refs */
49 PyErr_Restore(c, v, t); /* steals 3 refs */
51 if (!PyErr_Occurred()) {
52 PyErr_SetString(PyExc_AssertionError,
53 "No error, but plz provide traceback kthx");
55 PyErr_Print();
57 PyErr_Restore(c, v, t); /* steals another 3 refs */
60 void
61 _dbus_py_dbg_exc(void)
63 PyObject *c, *v, *t;
64 /* This is a little mad. We want to get the traceback without
65 clearing the error indicator. */
66 PyErr_Fetch(&c, &v, &t); /* 3 new refs */
67 Py_XINCREF(c); Py_XINCREF(v); Py_XINCREF(t); /* now we own 6 refs */
68 PyErr_Restore(c, v, t); /* steals 3 refs */
69 PyErr_Print();
70 PyErr_Restore(c, v, t); /* steals another 3 refs */
73 void
74 _dbus_py_dbg_dump_message(DBusMessage *message)
76 const char *s;
77 fprintf(stderr, "DBusMessage at %p\n", message);
79 s = dbus_message_get_destination(message);
80 if (!s) s = "(null)";
81 fprintf(stderr, "\tdestination %s\n", s);
83 s = dbus_message_get_interface(message);
84 if (!s) s = "(null)";
85 fprintf(stderr, "\tinterface %s\n", s);
87 s = dbus_message_get_member(message);
88 if (!s) s = "(null)";
89 fprintf(stderr, "\tmember %s\n", s);
91 s = dbus_message_get_path(message);
92 if (!s) s = "(null)";
93 fprintf(stderr, "\tpath %s\n", s);
95 #endif