Closed varichs closed 3 years ago
I'm using Visual Studio Code to debug my Drogon application on Linux.
Not sure what you're having trouble with, but here's how my application is set up:
GCC flags for Drogon and all dependencies: -c -fvisibility=hidden -Wpedantic -Wall -Wextra -Wno-unknown-pragmas -shared-libgcc -fpic -funsafe-math-optimizations -std=c++17 -fvisibility-inlines-hidden -g3 -ggdb -fpie
(the -g3 -ggdb
are important to generate debug information in GDB format, using -Og
actually made debugging worse)
My Visual Studio Code project uses the following .vs/launch.json
file:
{
// 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",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/linux-gcc9.3-amd64-debug/NuclexAlexandriaNative",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
And of course, GDB, the GNU Debugger, must be installed.
mac with apple silicon chip(m1) have not suport to GDB... I Think it work lldb
{
// 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": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/YourProjectName",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
You could run your web application in vscode debugging mode, set breakpoints and run it step by step as debugging any other c++ program. To make an HTTP request, you can use a browser or command-line tool (such as
curl
). And you could also set LogLevel to "Trace" to get more Drogon debug logs.