Apparently glibc already provides the function:
void malloc_stats (void);
So, like we do for backtrace_symbols(), override the public symbol.
It still is defined as __destructor__ and runs at program finalization.
To build, do:
make malloc-stats.so
inside util/, and to use, run:
LD_PRELOAD=malloc-stats.so some-program
For binaries managed by libtool, eg, cairo-perf, do:
../libtool --mode=execute /bin/true ./cairo-perf
LD_PRELOAD="../util/malloc-stats.so" .libs/lt-cairo-perf
The code also includes Jeff Muizelaar's libbacktracesymbols that
is a much better implementation of backtrace_symbols() than what
is provided by glibc. That can be built by:
make backtrace-symbols.so
cairo_select_font -> cairo_select_font_face cairo_pattern_add_color_stop -> cairo_pattern_add_color_stop_rgba
by only substituting if the old name is not immediately followed by an underscore.
Tweak the substitution slightly to allow the script to be run on the cairo source itself, (eg. avoid changing the REPLACED_BY and DEPRECATED_BY macros that must mention the old names).
cairo_copy cairo_get_path cairo_get_path_flat cairo_matrix_create cairo_matrix_destroy cairo_matrix_copy cairo_matrix_get_affine cairo_surface_set_repeat cairo_surface_set_matrix cairo_surface_get_matrix cairo_surface_set_filter cairo_surface_get_filter
Also, eliminate all support for compiling against, or running with old, deprecated names for functions.
Deal with all of the removals.