Link to this library and it will log all the LibC functions you are calling and how much time you are spending in them!
APACHE-2.0 License
See where you use LibC the most. Trace calls failing tests. Then - roast!
LibSee is a single-file library for profiling LibC calls and 🔜 fuzzy testing. To download and compile the script and run your favorite query:
gcc -g -O2 -fno-builtin -fPIC -nostdlib -nostartfiles -shared -o libsee.so libsee.c
LibSee overrides LibC symbols using LD_PRELOAD
, profiling the most commonly used functions, and, optionally, fuzzing their behaviour for testing.
The library yields a few binaries when compiled:
libsee.so # Profiles LibC calls
libsee_and_knee.so # Correct LibC behaviour, but fuzzed!
There are several things worth knowing, that came handy implementing this.
_start
symbols, but implementing correct loading sequence for a binary is tricky, so I use conventional dlsym
to lookup the symbols on first function invocation.x86_64
architecture, the rdtscp
instruction yields both the CPU cycle and also the unique identifier of the core. Very handy if you are profiling a multi-threaded application.libsee.so
, the STDOUT
is already closed. So if you want to print to the console, you may want to reopen the /dev/tty
device before printing usage stats.sprintf
, vsprintf
, snprintf
, vsnprintf
are macros. You have to #undef
them.Release
builds compilers love replacing your code with memset
and memcpy
calls. As the symbol can't be found from inside LibSee, it will SEGFAULT
so don't forget to disable such optimizations for built-ins -fno-builtin
.open
system call, but it has the generalized openat
number 56.LibC standard is surprisingly long, so not all of the functions are covered. Feel free to suggest PRs covering the rest:
Program support utilities aren't intended.