Building libdebug from source
Manually building libdebug from source is a straightforward process. This guide will walk you through the steps required to compile and install libdebug on your system.
Resolving Dependencies
To install libdebug, you first need to have some dependencies that will not be automatically resolved. These dependencies are libraries, utilities and development headers which are required by libdebug to compile its internals during installation.
Is your distro missing?
If you are using a Linux distribution that is not included in this section, you can search for equivalent packages for your distro. Chances are the naming convention of your system's repository will only change a prefix or suffix.
Building
To build libdebug from source, from the root directory of the repository, simply run the following command:
Alternatively, without cloning the repository, you can directly install libdebug from the GitHub repository using the following command:
Replace<branch_or_commit>
with the desired branch or commit hash you want to install. If not specified, the default branch will be used.
Editable Install
If you want to install libdebug in editable mode, allowing you to modify the source code and have those changes reflected immediately, you can use the following command, exclusively from a local clone of the repository:
This will ensure that every time you make changes to the source code, they will be immediately available without needing to reinstall the package, even for the compiled C++ extensions.
Build Options
There are some configurable build options that can be set during the installation process, to avoid linking against certain libraries or to enable/disable specific features. These options can be set using environment variables before running the installation command.
Option | Description | Default Value |
---|---|---|
USE_LIBDWARF |
Include libdwarf , which is used for symbol resolution and debugging information. |
True |
USE_LIBELF |
Include libelf , which is used for reading ELF files. |
True |
USE_LIBIBERTY |
Include libiberty , which is used for demangling C++ symbols. |
True |
Changing these options can be done by setting the environment variable before running the installation command. For example, to disable libdwarf
, you can run:
Testing Your Installation
We provide a comprehensive suite of tests to ensure that your installation is working correctly. Here's how you can run the tests:
We have different test suites available. By default, we run the fast
, that skips some tests which require a lot of time to run.
You can specify which test suite to run using the suite
option. The available test suites are:
Suite Name | Description |
---|---|
fast |
Runs all but a few tests to verify full functionality of the library. |
slow |
Runs the complete set of tests, including those that may take longer to execute. |
stress |
Runs a set of tests designed to detect issues in multithreaded processes. |
memory |
Runs a set of tests designed to detect memory leaks in libdebug. |
Troubleshooting
Here we list some common build errors you might encounter when building libdebug from source, along with their solutions. If you encounter any of these errors while installing libdebug from PyPI, please open an Issue to help us improve the installation process.
FileNotFoundError : No such file or directory: '[...]/jumpstart'
What's jumpstart?
jumpstart
is the executable that is used to bootstrap the debugging process, by calling PTRACE_TRACEME
before exeuting the target program.
If building libdebug from source in editable mode, it might not be automatically installed in the correct location.
To resolve this issue, you can manually install jumpstart
by running the following command from the root directory of the repository:
Parameters
- Replace
[ERROR_PATH]
with the path where thejumpstart
executable should be installed, as indicated in the error message.
RuntimeError : Autodetect executable for ptrace_fpregs
layout not found at [...]/autodetect_fpregs_layout
.
What's going on?
This error indicates that the autodetect_fpregs_layout
executable is missing. This executable is used to automatically detect the layout of the floating-point registers for the target architecture. If you are building libdebug from source in editable mode, it might not be automatically installed in the correct location.
To resolve this issue, you can manually install autodetect_fpregs_layout
by running the following command from the root directory of the repository:
Parameters
- Replace
[ERROR_PATH]
with the path where theautodetect_fpregs_layout
executable should be installed, as indicated in the error message. -
Choose
[SRC_PATH]
based on your architecture: