Tips & Tricks

CLion Debugging – Beyond the Basics – Part 1: Suspended

Back in October of last year I wrote "CLion Debugging – Part 1: Fundamentals", to introduce the everyday debugging features in CLion. It was "Part 1", because the promise was that I would follow up with a "Part 2", covering more advanced features. One thing you should never do is call something "Part 1" before you’ve written later parts!

Part 2 has been a long time coming not just because it was bigger than expected, but so much bigger that I am, in turn, splitting it into three parts! Therefore I’ve rebased on "Beyond the Basics – Part 1", and this part covers what you can do while you are suspended at a breakpoint, including some things you can do with expression evaluation that you may not have come across.

We’ll look at setting, muting and inspecting variables, evaluating expressions, adding watches, interactive inline hints (which was added since the previous video), hex and memory views, and the peripherals view for embedded devices.

Here are all the shortcuts used in the video:

Windows/ Linux macOS Command
F2 F2 Set Value
Alt+F8 ⌥F8 Evaluate Expression
F4 ⌘↓ Jump To Source
Ctrl+Alt+Shift+/ ⌥⇧⌘/ Hex View
Ctrl+Enter ⌘⏎ Memory View

I’ll follow up with Parts 2 and 3 (which have been written). Part 2 will cover ways of suspending (break points and watch points) – including how you might not want to suspend at all – and moving the execution pointer. Then Part 3 will go beyond the immediate process to cover attaching to other (local) processes, debugging remote processes, debugging as root and debugging core dumps. It will also look at dropping to a GDB or LLDB terminal, as well as useing .gdbinit or .lldbinit to run debugger commands at the start of every session. Stay tuned!

Update (March 29, 2021): CLion Debugging – Beyond the Basics – Part 2: Dynamic

image description