You can use the liblttng-ust-cyg-profile.so
helper library to obtain LTTng-UST tracepoints from every function entry and exit.
- Recompile the program with
-g -finstrument-functions
.
- Run it by preloading the helper library:
LD_PRELOAD=/path/to/liblttng-ust-cyg-profile.so ./myApp
This will generate trace events for every instrumented function entry and exit. Note that the tracepoints will only contain the function addresses, not the names. This is a limitation of cyg-profile. To map these back to function names, you can use a utility like addr2line
.
See the Function Tracing part of the documentation for more details.
Depending on the amount of instrumented functions, this may have a non-negligible performance impact. Also, -finstrument-functions
should technically work with C++ applications, but it can be finicky. I've had it fail compiling with large, non-trivial C++ applications. Your mileage may vary.