Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

ClickHouse tips #2: Debugging ClickHouse on Visual Studio Code

How to configure Visual Studio Code to debug ClickHouse on it.
Alberto Romeu
Backend Developer
Feb 10, 2021
 ・ 
  min read

It’s possible to debug ClickHouse on VSCode. These are the steps to do it:

  • Build ClickHouse for debugging docs
  • You can adapt the build with several flags, in my case I want to disable {% code-line %}jemalloc{% code-line-end %}:
  • Doing {% code-line %}ninja clickhouse-server clickhouse-client{% code-line-end %} the whole process takes less than one hour.

And then to debug with Visual Studio Code:

  • Install the C++ extension (and gdb from brew or apt)
  • Create a new run config like this in {% code-line %}.vscode{% code-line-end %}:

Then you can just add breakpoints in any line in the editor and {% code-line %}RUN{% code-line-end %} from inside Visual Studio Code.

After doing any change in a cpp file, you can just recompile it, although there might be better ways to do this (let us know!). There’s a {% code-line %}compile_commands.json{% code-line-end %} file in the build folder with the commands and then call ninja to re-generate the clickhouse binary (it’ll just recompile the dependencies)

That’s it!

Subscribe to our newsletter

Musings on transformations, tables and everything in between.