A shared library interposer will do job nicely. Here is an excellent article that gives a perfect example of what you need.
If a function is in a shared library, the runtime linker can be instructed to call another 'interposed' function instead. The interposer can totally replace the functionality or it can augment it. A great example is the malloc family of functions. In your case, you can have the interposer check for the malloc size and take special action. gdb can be used to place breakpoint in the interpose library itself, so you can put a breakpoint on the special logic to fulfill your requirements.
Interposers only work for shared (.so) libraries. Static (.a) libraries directly link into the executable and the calls cannot be easily intercepted. The malloc family is normally linked from a shard library in Linux so this should not be an issue in your case.
All major flavors of Linux support interposers using the LD_PRELOAD functionality.