[cairo] CAIRO_DEBUG support

Chris Wilson chris at chris-wilson.co.uk
Sun Apr 13 03:28:02 PDT 2008

I've started work on a framework for providing user-level debugging
facilities for cairo. By selecting between various flags in CAIRO_DEBUG,
the user can currently adjust what happens when cairo detects an error.
In the future, it could be used for simplifying the output - e.g.
uncompressed pdf output and forcing fallbacks.

The initial support is quite rudimentary and is yet to integrate with
the improved backtrace_symbols() in utils/, but it exists as proof of
concept and as a request for comments.

At the moment, it looks like:
ickle at cube:~/src/cairo/test$ CAIRO_DEBUG=backtrace,abort ../libtool
--mode=execute ./create-for-stream

TESTING create-for-stream
_cairo_error (error while writing to output stream [11])
ickle at cube:~/src/cairo/test$ CAIRO_DEBUG=backtrace,abort ../libtool
--mode=execute valgrind ./create-for-stream
==13395== Memcheck, a memory error detector.
==13395== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et
==13395== Using LibVEX rev 1804, a library for dynamic binary
==13395== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==13395== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation
==13395== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et
==13395== For more details, rerun with: -v

TESTING create-for-stream
**13395** _cairo_error (error while writing to output stream [11])
==13395==    at 0x4E34314: _cairo_debug_backtrace_internal
==13395==    by 0x4E34450: _cairo_debug_maybe_backtrace_or_abort
==13395==    by 0x4E2EB12: _cairo_error (cairo.c:89)
==13395==    by 0x4E45C89: cairo_surface_finish (cairo-surface.c:518)
==13395==    by 0x4E4F437: _cairo_paginated_surface_finish
==13395==    by 0x4E45C65: cairo_surface_finish (cairo-surface.c:516)
==13395==    by 0x4031BC: test_surface (create-for-stream.c:156)
==13395==    by 0x40344C: main (create-for-stream.c:238)
==13395== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 1)
==13395== malloc/free: in use at exit: 2,336 bytes in 8 blocks.
==13395== malloc/free: 32 allocs, 24 frees, 9,545 bytes allocated.
==13395== For counts of detected errors, rerun with: -v
==13395== searching for pointers to 8 not-freed blocks.
==13395== checked 332,512 bytes.
==13395== LEAK SUMMARY:
==13395==    definitely lost: 0 bytes in 0 blocks.
==13395==      possibly lost: 0 bytes in 0 blocks.
==13395==    still reachable: 2,336 bytes in 8 blocks.
==13395==         suppressed: 0 bytes in 0 blocks.
==13395== Rerun with --leak-check=full to see details of leaked memory.

The code can found at git://people.freedesktop.org/~ickle/cairo under
the branch cairo-debug.
Chris Wilson

More information about the cairo mailing list