gcc instrumentation based tracer for c/c++/pybind11
Project description
cygtrace
gcc instrumentation based tracer for c/c++/pybind11
Installation
Requirements:
- gcc
- cmake
- python3 with pybind11 (optional)
Python package
pip install .
System-wise library
To build/install the library:
mkdir build
cd build
cmake ..
make
sudo make install # to install the library in /usr/local/lib
To build the examples:
cd examples
mkdir build
cd build
cmake ..
make
Usage
With Python script
Run program/script/command with tracer
cygtrace ./path/to/executable
cygtrace python3 ./path/to/script.py
Demangle json trace file
cygtrace -d -f trace.json
Get compiling parameters (gcc)
gcc example.c $(cygtrace -I -L -p)
When compiling dynamically loaded libraries (e.g., pybind11), add -m flag (disables libcygtrace linking)
g++ example.cpp $(cygtrace -I -L -p -m)
Manual instructions
To enable tracing in pybind11 code, add these to the compiler args (gcc):
-finstrument-functions -Wl,--export-dynamic
for c/cpp programs, also link the cygtrace library:
-finstrument-functions -Wl,--export-dynamic -lcygtrace
To enable tracing in python (pybind11), start the python interpreter like this (assuming library installed in /usr/local/lib):
LD_PRELOAD=/usr/local/lib/libcygtrace.so python3 xxx.py
Notes
- To view JSON-formatted profiling results, go to
chrome://tracingor Perfetto UI - the names of functions with
statickeyword or within anonymous namespace are unobtainable in the tracer (appear as "<unknown>")
Troubleshooting
- CMake could not find pybind11
pip3 install "pybind11[global]"
- "error while loading shared libraries: libcygtrace.so: cannot open shared object file: No such file or directory"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cygtrace-0.0.1.tar.gz.
File metadata
- Download URL: cygtrace-0.0.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b1a57a08f4e72f3436387d9f9b6a3d91871e1141145c3a8ef857ed46584b57e
|
|
| MD5 |
f7a785d087b4272b7b3636eb9737e56e
|
|
| BLAKE2b-256 |
4dc2828f3f66c0bc63c626af0a10f0f0ab793f057b1c386559962eef3e3d4e88
|