CLion Debugging – Part 1: Fundamentals

Phil Nash

An important part of writing code is debugging. Despite the name this is not limited to just finding bugs in our code, but can help us to understand what the code is actually doing at runtime – often in a specific environment. While it’s possible to do this to some extent using, so-called, “printf-debugging” (inserting code to write out messages and values to the console or a log file), that process is tedious, time-consuming, and very limited. Using a debugger well can make an order of magnitude difference in productivity at this stage – so it would be a shame not to learn our debugging tools well.

CLion exposes the full power of GDB and/ or LLDB (even on Windows, where we have built an MSVC compatible debugger on top of LLDB), and even builds on it with more features, in an easy – and fast – to use way. Learning the shortcuts for the things you do often is essential to becoming fluent with the debugger. But first you need to know what’s available and how it works.

I’ve prepared a couple of videos to give a tour of CLion’s debugging features. The first one covers the fundamentals that everyone should be familiar with. If you’ve used a visual debugger with another IDE this should mostly be familiar, but it’s useful to know how things work specifically in CLion. Even here there are some unique features, too, such as inline debug variables.

Here are all the shortcuts used in the video:

Windows/ Linux macOS Command
Ctrl+F8 ⌘F8 Toggle Line Breakpoint
Ctrl+D ⇧F9 Start debugging
F8 F8 Step over
F7 F7 Step into
Shift+F8 ⇧F8 Step out
Alt+F9 ⌥F9 Run to cursor
Ctrl+Alt+F9 ⌘⌥F9 Force Run to cursor
Shift+Alt+F7 ⇧⌥F9 Force Step Into
F9 ⌘⌥R Force Run to cursor
Ctrl+Shift+A ⇧⌘A Find Action

In the next installment we’ll look at some more advanced features, such as memory view, watchpoints, setting variables, attach to process and others.

Subscribe

Subscribe for updates