Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Debugging Multithreaded C++ and C Programs with GDB and Pthreads - GDB Tutorial

Undo via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn to debug multithreaded C and C++ programs using GDB and pthreads in this comprehensive 15-minute tutorial. Master the challenging task of debugging concurrent applications where threads interact in complex, timing-dependent ways that can lead to elusive bugs like deadlocks, data races, and missed signals. Explore how GDB interfaces with pthreads through hands-on demonstrations using a controlled demo program. Discover techniques for identifying and managing individual threads, controlling their scheduling, and examining both shared memory and thread-local state. Practice using pthread_setname_np to name threads for easier identification and debugging workflows. Master essential GDB commands including info threads, thread switching, stepi, continue, and set scheduler-locking to manage execution at a granular level. Understand how to enable and utilize GDB's scheduler-locking mode to prevent unintended thread switching during debugging sessions. Learn to diagnose common concurrency issues such as deadlocks, blocking behavior, and race conditions by inspecting internal program state. Develop skills for analyzing shared memory, mutexes, and thread-local storage in multithreaded environments. Practice handling signals like SIGINT within the context of multithreaded debugging scenarios. Gain experience debugging spinners, race conditions, and other parallel programming challenges. Build confidence in isolating specific threads and controlling their execution to identify root causes of threading issues. Acquire best practices for working with applications involving parallel programming, synchronization primitives, and concurrent data structures. Suitable for software engineers, systems programmers, and computer science students with existing knowledge of C/C++, build tools, and basic GDB usage who want to advance their debugging capabilities for concurrent applications.

Syllabus

00:00 - Intro: Why Multithreaded Debugging is Hard
00:35 - Launching the C++ Demo Program
01:25 - Using GDB: Listing and Identifying Threads
02:10 - Switching Threads and Inspecting Backtraces
03:05 - Naming Threads with pthread_setname_np
04:00 - Enabling Scheduler Locking in GDB
04:45 - Understanding Thread Scheduling Behavior
05:30 - Controlling Execution with GDB Commands
06:25 - Diagnosing Deadlocks and Blocking Threads
07:15 - Inspecting Internal Locks and Shared Memory
08:10 - Handling Signals and SIGINT
09:00 - Debugging Spinners and Race Conditions
10:00 - Cleanly Finishing Thread Execution in GDB
11:00 - Recap: Thread Debugging Best Practices
11:45 - Outro: What to Try Next with GDB

Taught by

Undo

Reviews

Start your review of Debugging Multithreaded C++ and C Programs with GDB and Pthreads - GDB Tutorial

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.