|
Packit |
130fc8 |
/* Debug code for _dbus_bindings.
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* Permission is hereby granted, free of charge, to any person
|
|
Packit |
130fc8 |
* obtaining a copy of this software and associated documentation
|
|
Packit |
130fc8 |
* files (the "Software"), to deal in the Software without
|
|
Packit |
130fc8 |
* restriction, including without limitation the rights to use, copy,
|
|
Packit |
130fc8 |
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
130fc8 |
* of the Software, and to permit persons to whom the Software is
|
|
Packit |
130fc8 |
* furnished to do so, subject to the following conditions:
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* The above copyright notice and this permission notice shall be
|
|
Packit |
130fc8 |
* included in all copies or substantial portions of the Software.
|
|
Packit |
130fc8 |
*
|
|
Packit |
130fc8 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
130fc8 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
130fc8 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit |
130fc8 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
130fc8 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
Packit |
130fc8 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
Packit |
130fc8 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit |
130fc8 |
* DEALINGS IN THE SOFTWARE.
|
|
Packit |
130fc8 |
*/
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#include "dbus_bindings-internal.h"
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#include <stdlib.h>
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
void
|
|
Packit |
130fc8 |
_dbus_py_assertion_failed(const char *assertion)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyErr_SetString(PyExc_AssertionError, assertion);
|
|
Packit |
130fc8 |
#if 1 || defined(USING_DBG) || defined(FATAL_ASSERTIONS)
|
|
Packit |
130fc8 |
/* print the Python stack, and dump core so we can see the C stack too */
|
|
Packit |
130fc8 |
PyErr_Print();
|
|
Packit |
130fc8 |
abort();
|
|
Packit |
130fc8 |
#endif
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
#ifdef USING_DBG
|
|
Packit |
130fc8 |
void
|
|
Packit |
130fc8 |
_dbus_py_whereami(void)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyObject *c, *v, *t;
|
|
Packit |
130fc8 |
/* This is a little mad. We want to get the traceback without
|
|
Packit |
130fc8 |
clearing the error indicator, if any. */
|
|
Packit |
130fc8 |
PyErr_Fetch(&c, &v, &t); /* 3 new refs */
|
|
Packit |
130fc8 |
Py_XINCREF(c); Py_XINCREF(v); Py_XINCREF(t); /* now we own 6 refs */
|
|
Packit |
130fc8 |
PyErr_Restore(c, v, t); /* steals 3 refs */
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if (!PyErr_Occurred()) {
|
|
Packit |
130fc8 |
PyErr_SetString(PyExc_AssertionError,
|
|
Packit |
130fc8 |
"No error, but plz provide traceback kthx");
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
PyErr_Print();
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
PyErr_Restore(c, v, t); /* steals another 3 refs */
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
void
|
|
Packit |
130fc8 |
_dbus_py_dbg_exc(void)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
PyObject *c, *v, *t;
|
|
Packit |
130fc8 |
/* This is a little mad. We want to get the traceback without
|
|
Packit |
130fc8 |
clearing the error indicator. */
|
|
Packit |
130fc8 |
PyErr_Fetch(&c, &v, &t); /* 3 new refs */
|
|
Packit |
130fc8 |
Py_XINCREF(c); Py_XINCREF(v); Py_XINCREF(t); /* now we own 6 refs */
|
|
Packit |
130fc8 |
PyErr_Restore(c, v, t); /* steals 3 refs */
|
|
Packit |
130fc8 |
PyErr_Print();
|
|
Packit |
130fc8 |
PyErr_Restore(c, v, t); /* steals another 3 refs */
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
void
|
|
Packit |
130fc8 |
_dbus_py_dbg_dump_message(DBusMessage *message)
|
|
Packit |
130fc8 |
{
|
|
Packit |
130fc8 |
const char *s;
|
|
Packit |
130fc8 |
fprintf(stderr, "DBusMessage at %p\n", message);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
s = dbus_message_get_destination(message);
|
|
Packit |
130fc8 |
if (!s) s = "(null)";
|
|
Packit |
130fc8 |
fprintf(stderr, "\tdestination %s\n", s);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
s = dbus_message_get_interface(message);
|
|
Packit |
130fc8 |
if (!s) s = "(null)";
|
|
Packit |
130fc8 |
fprintf(stderr, "\tinterface %s\n", s);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
s = dbus_message_get_member(message);
|
|
Packit |
130fc8 |
if (!s) s = "(null)";
|
|
Packit |
130fc8 |
fprintf(stderr, "\tmember %s\n", s);
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
s = dbus_message_get_path(message);
|
|
Packit |
130fc8 |
if (!s) s = "(null)";
|
|
Packit |
130fc8 |
fprintf(stderr, "\tpath %s\n", s);
|
|
Packit |
130fc8 |
}
|
|
Packit |
130fc8 |
#endif
|