[cairo] Re: [poppler] Re: poppler profiling on geode with cairo backend

Behdad Esfahbod behdad at behdad.org
Tue Nov 14 17:05:19 PST 2006


On Tue, 2006-11-14 at 19:05 -0500, Carl Worth wrote:
> > On a slightly related note, to investigate this problem I made a
> library
> > that wraps all of the calls to cairo functions and logs them to
> stdout.
> > usage is something like the following:
> > 
> > $ LD_PRELOAD=libcairowrap.so ./clip
> > cairo_image_surface_create(0, 100, 100)
> > cairo_create(0x80537b0)
> 
> This kind of thing looks extremely interesting to me! I've often
> wanted something like this to be able to extract code snippets from
> programs. Here are a couple of things I'd like to see in addition:

Yes, this is a very interesting approach to that problem.  Luckily, the
work to eliminate use of PLT entries for local cairo calls in the
library means that with a preloaded logging library you only get to see
the cairo calls generated by applications, which is exactly what you
want.

> 1) It would be nice if it could log the return values from
>    surface_create and cairo_create so they could be correlated with
>    usage later.

Yes.  Then we can augment it to allocate local variables too.  So it
will generate:

cairo_surface_t surface1 = cairo_image_surface_create(0, 100, 100);
cairo_t cr1 = cairo_create(surface1);

Voila!

> 2) It might be handy if there were an easy way to start and stop the
>    logging so I could focus the extraction on one single chunk of a
>    program's behavior.

D-Trace comes to mind.  Other than that, some time ago I hacked a little
script for doing exactly this kind of things.  It's called bprobe and is
in GNOME CVS.  It makes writing such wrappers very easy.


> > If anyone is interested in such a thing I'd happily share it.
> 
> Yes, please do. Even without either of the above changes, I think this
> would be quite helpful.

I sure am interested.  Actually it should be very easy to add some
script magic to cairo to generate such a bprobe probe automatically
using the header files.  /me heads hacking that.  Thanks for the idea!


-- 
behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
        -- Dan Bern, "New American Language"



More information about the cairo mailing list