|
|
# IDE configuration tips
|
|
|
|
|
|
Some remarks on how to configure the IDE to pleasant work with Kea.
|
|
|
|
|
|
## vscode
|
|
|
|
|
|
The [Visual Studio Code](https://code.visualstudio.com) is a popular IDE with built-in syntax checkers, debugging, and extensions support.
|
|
|
The vscode can easily handle the Kea repository, but the full integration is more challenging.
|
|
|
|
|
|
### Recommended extensions
|
|
|
|
|
|
- Autoconf (maelvalais.autoconf)
|
|
|
- C++ (ms-vscode.cpptools)
|
|
|
- C++ Extension Pack (ms-vscode.cpptools-extension-pack)
|
|
|
- GoogleTest Adapter (davidschuldenfrei.gtest-adapter)
|
|
|
|
|
|
### Intelisensse
|
|
|
|
|
|
The syntax helper should work out-of-the-box, but it takes some time to initialization.
|
|
|
|
|
|
### Debugging
|
|
|
|
|
|
It's pretty tricky. The Kea was designed for dynamic linking with the `libtool` wrapper. The static linking can be used for most use cases, excluding hook support.
|
|
|
Using static linking is also the only known way to integrate the Test Explorer with Kea.
|
|
|
|
|
|
### Files
|
|
|
|
|
|
The Vscode configuration is stored in three files in `.vscode` directory:
|
|
|
|
|
|
- `launch.json` - runner configurations (including debugger)
|
|
|
- `tasks.json` - external command calls
|
|
|
- `settings.json` - general purpose settings
|
|
|
|
|
|
`Launch.json`:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
// Use IntelliSense to learn about possible attributes.
|
|
|
// Hover to view descriptions of existing attributes.
|
|
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
|
"version": "0.2.0",
|
|
|
"configurations": [
|
|
|
{
|
|
|
"name": "(gdb) Launch DHCPv4 (static)",
|
|
|
"type": "cppdbg",
|
|
|
"request": "launch",
|
|
|
"program": "${workspaceFolder}/src/bin/dhcp4/kea-dhcp4",
|
|
|
"args": [
|
|
|
"-v"
|
|
|
],
|
|
|
"stopAtEntry": false,
|
|
|
"cwd": "${workspaceFolder}",
|
|
|
"externalConsole": false,
|
|
|
"miDebuggerPath": "gdb",
|
|
|
"MIMode": "gdb",
|
|
|
"setupCommands": [
|
|
|
{
|
|
|
"description": "Enable pretty-printing for gdb",
|
|
|
"text": "-enable-pretty-printing",
|
|
|
"ignoreFailures": true
|
|
|
},
|
|
|
{
|
|
|
"description": "Set Disassembly Flavor to Intel",
|
|
|
"text": "-gdb-set disassembly-flavor intel",
|
|
|
"ignoreFailures": true
|
|
|
}
|
|
|
],
|
|
|
"preLaunchTask": "make"
|
|
|
},
|
|
|
{
|
|
|
"name": "(gdb) Test DHCPv4 (static)",
|
|
|
"type": "cppdbg",
|
|
|
"request": "launch",
|
|
|
"program": "${workspaceFolder}/src/bin/dhcp4/tests/dhcp4_unittests",
|
|
|
"args": [ ],
|
|
|
"stopAtEntry": false,
|
|
|
"cwd": "${workspaceFolder}/src/bin/dhcp4/tests/",
|
|
|
"externalConsole": false,
|
|
|
"miDebuggerPath": "gdb",
|
|
|
"MIMode": "gdb",
|
|
|
"setupCommands": [
|
|
|
{
|
|
|
"description": "Enable pretty-printing for gdb",
|
|
|
"text": "-enable-pretty-printing",
|
|
|
"ignoreFailures": true
|
|
|
},
|
|
|
{
|
|
|
"description": "Set Disassembly Flavor to Intel",
|
|
|
"text": "-gdb-set disassembly-flavor intel",
|
|
|
"ignoreFailures": true
|
|
|
}
|
|
|
],
|
|
|
"preLaunchTask": "make"
|
|
|
},
|
|
|
{
|
|
|
"name": "(gdb) Launch DHCPv4 (dynamic)",
|
|
|
"type": "cppdbg",
|
|
|
"request": "launch",
|
|
|
"program": "kea-dhcp4",
|
|
|
"cwd": "${workspaceFolder}",
|
|
|
"miDebuggerPath": "gdb",
|
|
|
"pipeTransport": {
|
|
|
"pipeCwd": "${workspaceFolder}",
|
|
|
"pipeProgram": "/usr/bin/libtool",
|
|
|
"pipeArgs": ["--mode=execute"],
|
|
|
"debuggerPath": "gdb ${workspaceFolder}/src/bin/dhcp4/kea-dhcp4",
|
|
|
"quoteArgs": false
|
|
|
},
|
|
|
"MIMode": "gdb",
|
|
|
"customLaunchSetupCommands": [
|
|
|
{ "text": "set args -v", "description": "suppress default commands", "ignoreFailures": false },
|
|
|
],
|
|
|
"targetArchitecture": "x64",
|
|
|
"setupCommands": [
|
|
|
{
|
|
|
"description": "Enable pretty-printing for gdb",
|
|
|
"text": "-enable-pretty-printing",
|
|
|
"ignoreFailures": true
|
|
|
},
|
|
|
{
|
|
|
"description": "Set Disassembly Flavor to Intel",
|
|
|
"text": "-gdb-set disassembly-flavor intel",
|
|
|
"ignoreFailures": true
|
|
|
}
|
|
|
],
|
|
|
"preLaunchTask": "make"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
`tasks.json`:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
|
// for the documentation about the tasks.json format
|
|
|
"version": "2.0.0",
|
|
|
"tasks": [
|
|
|
{
|
|
|
"label": "autoreconf",
|
|
|
"type": "shell",
|
|
|
"command": "autoreconf --install",
|
|
|
"problemMatcher": []
|
|
|
},
|
|
|
{
|
|
|
"label": "configure (static)",
|
|
|
"type": "shell",
|
|
|
"command": "./configure --with-gtest --enable-static-link --disable-shared",
|
|
|
"problemMatcher": []
|
|
|
},
|
|
|
{
|
|
|
"label": "configure (dynamic)",
|
|
|
"type": "shell",
|
|
|
"command": "./configure --with-gtest",
|
|
|
"problemMatcher": []
|
|
|
},
|
|
|
{
|
|
|
"label": "make",
|
|
|
"type": "shell",
|
|
|
"command": "make -j10 -e CXXFLAGS=\"-g -O0\"",
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
### Static linking
|
|
|
|
|
|
First, you need to call the `autoreconf` and `configure (static)` commands.
|
|
|
Now, you should be able to run the `(gdb) Launch DHCPv4 (static)` configuration to start debugging the DHCPv4 service. You can quickly put the breakpoints in any place and show the variable values.
|
|
|
|
|
|
You can add configuration for another service by coping and pasting the existing one and replacing the `program` entry and the `args` array.
|
|
|
|
|
|
In this case, all hook loadings will fail.
|
|
|
|
|
|
### Dynamic linking
|
|
|
|
|
|
First, you need to call the `autoreconf` and `configure (dynamic)` commands.
|
|
|
Now, you should be able to run the `(gdb) Launch DHCPv4 (dynamic)` configuration to start debugging the DHCPv4 service.
|
|
|
|
|
|
This configuration is more complex as the `gdb` is piping by `libtool`. It requires some workarounds in the configuration.
|
|
|
|
|
|
The `args` array is ignored, and the `program` entry is used only for logging purposes.
|
|
|
The executable path must be provided in the `debuggerPath` entry.
|
|
|
You can pass the arguments in the `customLaunchSetupCommands` entry after `set args` command.
|
|
|
|
|
|
If you have no arguments, you need to provide the empty `set args` command to suppress default target loading (the target is just loaded at `gdb` startup).
|
|
|
|
|
|
```
|
|
|
"customLaunchSetupCommands": [
|
|
|
{ "text": "set args -v", "description": "suppress default commands", "ignoreFailures": false },
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### Test Explorer
|
|
|
|
|
|
The Test Explorer can be integrated with the Kea only when the static linking is used.
|
|
|
You need to call the `GTest: Switch Test Configuration` command from the Command Palette and select the `(gdb) Test DHCPv4 (static)` configuration.
|
|
|
|
|
|
### Alternatives
|
|
|
|
|
|
It is possible to configure the dynamic linking solution in the same way as the static linking. But it requires a workaround for the `libtool` and manually set the `LD_LIBRARY_PATH` environment variable:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"name": "(gdb) Launch",
|
|
|
"type": "cppdbg",
|
|
|
"request": "launch",
|
|
|
"program": "${workspaceFolder}/src/bin/dhcp4/.libs/kea-dhcp4",
|
|
|
"args": [
|
|
|
"-v"
|
|
|
//"-t", "kea-dhcp4.conf"
|
|
|
],
|
|
|
"stopAtEntry": false,
|
|
|
"cwd": "${workspaceFolder}",
|
|
|
"environment": [
|
|
|
{ "name": "LD_LIBRARY_PATH", "value": "src/lib/dhcpsrv/.libs:src/lib/dhcpsrv/.libs:src/lib/dhcp_ddns/.libs:src/lib/process/.libs:src/lib/http/.libs:src/lib/hooks/.libs" }
|
|
|
],
|
|
|
"externalConsole": false,
|
|
|
"miDebuggerPath": "gdb",
|
|
|
"MIMode": "gdb",
|
|
|
"setupCommands": [
|
|
|
{
|
|
|
"description": "Enable pretty-printing for gdb",
|
|
|
"text": "-enable-pretty-printing",
|
|
|
"ignoreFailures": true
|
|
|
},
|
|
|
{
|
|
|
"description": "Set Disassembly Flavor to Intel",
|
|
|
"text": "-gdb-set disassembly-flavor intel",
|
|
|
"ignoreFailures": true
|
|
|
}
|
|
|
],
|
|
|
"preLaunchTask": "make"
|
|
|
}
|
|
|
```
|
|
|
|