[cairo] Making it easier to track down errors

Mathieu Lacage Mathieu.Lacage at sophia.inria.fr
Mon Jun 13 23:41:49 PDT 2005


hi carl,

On Mon, 2005-06-13 at 17:29 -0700, Carl Worth wrote:
> Here's a patch that adds a new function:
> 
> 	_cairo_error
> 
> that will be called whenever cairo detects an error within a cairo_t
> object.
> 
> The idea here is to allow the user to set a breakpoint in _cairo_error
> in order to generate a stack trace for when the user code causes an
> error in cairo.

I have been burned by this kind of API before and I cursed the authors
of the code more than once. Specifically, I wished they had done
something like this:

1) add a function pointer to their structure which is invoked whenever
the error is detected
2) add a public setter for this function pointer
3) initialize it by default to _cairo_error.

That way, you can use the breakpoint thing in a debugger _and_ you can
avoid having to use a debugger if all you want is being notified of the
error event. Specifically, I can imagine lots of people who would want
to use some kind of runtime switch to enable a special error function to
be called in the cairo code to get a bunch of debug spew without running
the application in a debugger.

my 2 cents,
Mathieu
-- 




More information about the cairo mailing list