How to wrap a system call (libc function) in Linux demonstrates LD_PRELOAD and ld --wrap techniques.
Generic Library Interception for Improved Performance Measurement and Insight describes creation of wrappers for arbitrary C/C++ libraries in Score-P. See the library_wrapper_generator source code, which uses Clang under the hood.
tau_wrap
implements the same thing for the Tau profiling system, though it seems a lot
more "hacky" and relies on PDT
rather than Clang. The
tau_gen_wrapper
script uses tau_wrap under the hood.
Non-intrusive Performance Analysis of Parallel Hardware Accelerated Applications on Hybrid Architectures uses function call interception to monitor CUDA and OpenCL applications.
VampirTrace provided this functionality but has since been discontinued in favor of Score-P. The implementation is vtlibwrapgen based on the CTool parser (unmaintained).
Google Sandboxed API uses a libtooling-based tool to autogenerate function wrappers (see clang_generator).
Clang Tutorial: Finding Declarations is a first pass at what we want.