Nicolás Brailovsky


A modern blog

gdb: debugging multithreaded applications

author Posted by: nico on date Oct 1st, 2009 | filed Filed under: C++, Linux, Programming
Few things look cooler than debugging a multithreaded application using TUI through ssh on a client, halfway across the world. There you are, felling the geek of the century when all of the sudden gdb starts jumping from one thread to the other. OMFGBBQ! What are you going to do now? thisthreadis128483904188593750

The scheduler locking policy defines when will thread context swtiches occur. If you are debuging a thead and don’t want to be bothered by another then just lock the scheduler.

gdb has a default scheduling locking which defaults to “most annoying”, but fortunately you can easily change it:


set scheduler-locking

The possible values are:

  • off: Disable locking, switches threads whenever gdb damn pleases
  • on: Enable locking, won’t (ever) switch threads. Beware of deadlocks!
  • step: Disable locking while running only

Hopefully this will save you some time.

     Add A Comment

trackback Trackback URI | rsscomment Comments RSS