[cairo] CAIRO_DEBUG, take 2

Behdad Esfahbod behdad at behdad.org
Thu May 8 14:57:31 PDT 2008


Hi Chris,

Various notes:

+#if ! CAIRO_HAS_C99
+void
+_cairo_debug_maybe_printf (unsigned int flags,
+	                   const char *fmt,
+			   ...)
+{
+#if CAIRO_USE_DEBUG
+    if (_cairo_debug_flags () & flags) {
+	va_list ap;
+
+	va_start (ap, fmt);
+	_cairo_debug_vprintf (fmt, ap);
+	va_end (ap);
+    }
+#endif
+}
+#endif

You should at least put parentheses around "flags".  And since you have
C99, while not use a vararg macro?  Or, why do you check for C99?


    [cairo-debug] Add a description of the various CAIRO_DEBUG flags.

As Adrian suggested, better to move the README.debug content to
CAIRO_DEBUG=help.

    [cairo-debug] Use bfd to provide better backtrace symbols.

Umm, the license is not compatible with cairo's AFAICS :(.


    [cairo-debug] Add enums for backends and fonts.

This is ugly, but I don't have a cleaner suggestion.  What I was
thinking was reusing the surface and font type_t's with a an added
"domain" argument that can be "surface", "font", or "other".  But that
just makes the debug calls longer.


I still think we should think a bit about how we want to handle
font-subsetting and compression in non-debug API at the same time of
adding these, but given that we can break CAIRO_DEBUG format/options
later, I don't have much against pushing this out and tweak later.

Cheers,

behdad



On Wed, 2008-05-07 at 17:39 +0100, Chris Wilson wrote:
> Although there's still a bit more to incorporate from Behdad's feedback,
> I'd like people to have a look over the cairo-debug branch. It's
> hopefully now at a level of basic functionality that should encourage
> everyone to use and improve it...
> 
> The code can found at git://people.freedesktop.org/~ickle/cairo under
> the branch cairo-debug.
> 
> In terms of debugging API, it offers:
> 	_cairo_debug_maybe_printf(),
> 	_cairo_debug_maybe_backtrace_or_abort()
> which check for an enabling flag in CAIRO_DEBUG, along with more
> low-level functions:
> 	_cairo_debug_printf(),
> 	_cairo_debug_backtrace()
> 	etc.
> 
> So far, through CAIRO_DEBUG, you can generate uncompressed pdf output,
> force the use of fallback images and fonts in the pdf/ps/svg backends
> and trigger a backtrace on a cairo_error(). (The backtrace now tries to
> use the better backtrace_symbols() from utils/backtrace-symbols.c.)
> 
> Thanks.
> -- 
> Chris Wilson

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list