Debug Clickhouse With VSCode On Mac
Clone Source Code
- git clone https://github.com/ClickHouse/ClickHouse.git
- git pull && git submodule update –init –recursive
Install Tools
- brew install cmake ninja clang
- vscode install plugins
Compile Source Code with VSCode
- use
mkdir -p Clickhouse/build
to create directory for binary files - create file .vscode/task.json to config vscode tasks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21{
"tasks": [
{
"type": "shell",
"label": "clang",
"command": "cd ClickHouse/build; cmake .. -DCMAKE_C_COMPILER=`brew --prefix llvm`/bin/clang -DCMAKE_CXX_COMPILER=`brew --prefix llvm`/bin/clang++ -DCMAKE_PREFIX_PATH=`brew --prefix llvm` -DCMAKE_BUILD_TYPE=Debug -DENABLE_JEMALLOC=0 -DENABLE_LIBRARIES=ON"
},
{
"type": "shell",
"label": "ninja",
"dependsOn": "clang",
"command": "cd ClickHouse/build; ninja -j 4 clickhouse-server"
},
{
"type": "shell",
"label": "Pull Master",
"command": "git pull && git submodule update --init --recursive"
}
],
"version": "2.0.0"
}
Debug Clickhouse Server
- create .vscode/launch.json to config debug info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15{
"version": "0.2.0",
"configurations": [
{
"name": "Clickhouse Server",
"type": "lldb",
"request": "launch",
"program": "ClickHouse/build/programs/clickhouse-server",
"args": [
"server", "--config", "ClickHouse/programs/server/config.xml"
],
"preLaunchTask": "ninja"
}
]
} - Click F5 to run VSCode Debug
Test Debug
- use
curl -sS "localhost:8123" -d "show databases"
to visit local clickhouse-server
https://clickhouse.tech/docs/en/interfaces/http/#cli-queries-with-parameters