1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00
This commit is contained in:
Michael 2024-10-14 15:41:34 +00:00 committed by GitHub
commit 4a4909cbe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 62 additions and 0 deletions

View file

@ -121,6 +121,7 @@
- [Development](development/index.md)
- [Building](development/building.md)
- [Testing](development/testing.md)
- [Debugging](development/debugging.md)
- [Documentation](development/documentation.md)
- [CLI guideline](development/cli-guideline.md)
- [JSON guideline](development/json-guideline.md)

View file

@ -0,0 +1,61 @@
# Debugging Nix
This section provides instructions on how to build and debug Nix with debug
symbols enabled. It assumes you are using Nix with the [`flakes`] and
[`nix-command`] experimental features enabled.
[`flakes`]: @docroot@/development/experimental-features.md#xp-feature-flakes
[`nix-command`]: @docroot@/development/experimental-features.md#xp-nix-command
## Building Nix with Debug Symbols
First, ensure you have set up the development environment as described in the
[building documentation](./building.md).
In the development shell, set the `mesonBuildType` environment variable to
`debug` before configuring the build:
```console
[nix-shell]$ export mesonBuildType=debug
```
Then, configure and build Nix:
```console
[nix-shell]$ mesonConfigurePhase
[nix-shell]$ ninjaBuildPhase
```
This will build Nix with debug symbols, which are essential for effective
debugging.
## Debugging the Nix Binary
### Installing a Debugger
Install your preferred debugger within the development shell. For example, to
install `lldb`:
```console
[nix-shell]$ nix shell nixpkgs#lldb
```
### Launching the Debugger
To debug the Nix binary you just built:
```console
[nix-shell]$ lldb -- ./subprojects/nix/nix
```
### Using the Debugger
Inside `lldb`, you can set breakpoints, run the program, and inspect variables:
```lldb
(lldb) breakpoint set --name main
(lldb) process launch -- <arguments>
```
Refer to the [LLDB Tutorial](https://lldb.llvm.org/use/tutorial.html) for
comprehensive usage instructions.