va_list args;
static dbus_bool_t verbose = TRUE;
static dbus_bool_t initted = FALSE;
-
+ static unsigned long pid;
+
/* things are written a bit oddly here so that
* in the non-verbose case we just have the one
* conditional and return immediately.
if (!initted)
{
verbose = _dbus_getenv ("DBUS_VERBOSE") != NULL;
+ pid = _dbus_getpid ();
initted = TRUE;
if (!verbose)
return;
}
+
+ fprintf (stderr, "%lu: ", pid);
va_start (args, format);
vfprintf (stderr, format, args);
return "double";
case DBUS_TYPE_STRING:
return "string";
- case DBUS_TYPE_BOOLEAN_ARRAY:
- return "boolean array";
- case DBUS_TYPE_INT32_ARRAY:
- return "int32 array";
- case DBUS_TYPE_UINT32_ARRAY:
- return "uint32 array";
- case DBUS_TYPE_DOUBLE_ARRAY:
- return "double array";
- case DBUS_TYPE_BYTE_ARRAY:
- return "byte array";
- case DBUS_TYPE_STRING_ARRAY:
- return "string array";
+ case DBUS_TYPE_NAMED:
+ return "named";
+ case DBUS_TYPE_ARRAY:
+ return "array";
+ case DBUS_TYPE_DICT:
+ return "dict";
default:
return "unknown";
}
}
+#ifndef DBUS_DISABLE_ASSERT
+/**
+ * Internals of _dbus_assert(); it's a function
+ * rather than a macro with the inline code so
+ * that the assertion failure blocks don't show up
+ * in test suite coverage, and to shrink code size.
+ *
+ * @param condition TRUE if assertion succeeded
+ * @param condition_text condition as a string
+ * @param file file the assertion is in
+ * @param line line the assertion is in
+ */
+void
+_dbus_real_assert (dbus_bool_t condition,
+ const char *condition_text,
+ const char *file,
+ int line)
+{
+ if (!condition)
+ {
+ _dbus_warn ("Assertion failed \"%s\" file \"%s\" line %d process %lu\n",
+ condition_text, file, line, _dbus_getpid ());
+ _dbus_abort ();
+ }
+}
+
+/**
+ * Internals of _dbus_assert_not_reached(); it's a function
+ * rather than a macro with the inline code so
+ * that the assertion failure blocks don't show up
+ * in test suite coverage, and to shrink code size.
+ *
+ * @param explanation what was reached that shouldn't have been
+ * @param file file the assertion is in
+ * @param line line the assertion is in
+ */
+void
+_dbus_real_assert_not_reached (const char *explanation,
+ const char *file,
+ int line)
+{
+ _dbus_warn ("File \"%s\" line %d process %lu should not have been reached: %s\n",
+ file, line, _dbus_getpid (), explanation);
+ _dbus_abort ();
+}
+#endif /* DBUS_DISABLE_ASSERT */
+
#ifdef DBUS_BUILD_TESTS
static dbus_bool_t
run_failing_each_malloc (int n_mallocs,
_dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
+ _dbus_verbose ("Running once to count mallocs\n");
+
if (!(* func) (data))
return FALSE;
approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
- _dbus_verbose ("=================\n%s: about %d mallocs total\n=================\n",
+ _dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n",
description, approx_mallocs);
_dbus_set_fail_alloc_failures (1);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
- _dbus_verbose ("=================\n%s: all iterations passed\n=================\n",
+ _dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n",
description);
return TRUE;