gdb: debugging multithreaded applications

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.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s