Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging multithreaded C++ application in CLion

I am able to run my multithreaded C++ application in CLion debug. However, it is virtually useless with the call stack jumping between threads each time I step to the next instruction. After about 3 jumps I lose track of what thread is where. And having to select the thread from a pull down is too awkward.

It seems like there should be a way to monitor each thread separately. There is a feature in other JetBrains products called "Parallel Stacks" that seems to address that. But I don't see it in CLion (2018.2.5).

Ideally, one could force the IDE to stay on (and step through) one thread while the others are running in the background. If a breakpoint is hit in another thread, a separate call stack should appear indicating it stopped, but the source code display would stay at the thread being monitored.

Is there some way to achieve something like this, or another scheme to allow debugging a multithreaded app efficiently and effectively?

like image 653
Cosmo Avatar asked Nov 07 '22 23:11

Cosmo


1 Answers

I encountered the same issue when debugging application built with MSVC using lldb in CLion. I found a partial solution by using lldb command in the debug console (for instance thread step-over). I guess you could apply the same logic if you are using gdb.

like image 87
Romain D. Avatar answered Nov 15 '22 12:11

Romain D.