Object Introspection is a memory profiling technology for C++ objects. It provides the ability to dynamically instrument applications to capture the precise memory occupancy of entire object hierarchies including all containers and dynamic allocations. All this with no code modification or recompilation!
For more information on the technology and how to get started applying it to your applications please check out the Object Introspection website.
See the CONTRIBUTING file for how to help out.
Object Introspection is licensed under the Apache 2.0 License.
Nix is the easiest way to get started with oid
as it is non-trivial to build otherwise. Explicit Nix support for Object Introspection as a Library will come down the line, but Nix can currently provide you a reproducible development environment in which to build it.
These examples expect you to have nix
installed and available with no other dependencies required. Find the installation guide at https://nixos.org/download.html.
We also required flake support. To enable flakes globally run:
$ mkdir -p ~/.config/nix
$ echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
Or suffix every nix
command with nix --extra-experimental-features 'nix-command flakes'
.
$ nix run github:facebookexperimental/object-introspection -- --help
This will download the latest source into your Nix store along with all of its dependencies, running help afterwards.
$ git clone https://github.com/facebookexperimental/object-introspection
$ nix build
$ ./result/bin/oid --help
This will build OID from your local sources. Please note that this will NOT pick up changes to extern/drgn
or extern/drgn/libdrgn/velfutils
.
$ nix develop
$ cmake -B build -G Ninja -DFORCE_BOOST_STATIC=Off
$ ninja -C build
$ build/oid --help
This command provides a development shell with all the required dependencies. This is the most flexible option and will pick up source changes as CMake normally would.
Sometimes this developer environment can be polluted by things installed on your normal system. If this is an issue, use:
$ nix develop -i
This removes the environment from your host system and makes the build pure.
$ nix develop
$ cmake -B build -G Ninja -DFORCE_BOOST_STATIC=Off
$ ninja -C build
$ ./tools/config_gen.py -c clang++ build/testing.oid.toml
$ ctest -j --test-dir build/test
Running tests under nix
is new to the project and may take some time to mature. The CI is the source of truth for now.
$ nix fmt
This formats the Nix, C++, and Python code in the repository.