Debugging with Multiple Threads (gdb, pthreads)

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025
  • Patreon ➤ / jacobsorber
    Courses ➤ jacobsorber.th...
    Website ➤ www.jacobsorbe...
    ---
    Related Videos:
    GDB/debugging
    • Learn GDB in 60 seconds
    • How to examine memory ...
    • Debug Faster With Cond...
    • GDB Debugging with for...
    • A Buggy Place (Hallowe...
    Threads
    • How to create and join...
    • How to pass arguments ...
    • Safety and Speed Issue...
    ***
    Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
    About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
    More about me and what I do:
    people.cs.clem...
    persist.cs.clem...
    ***
    Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers.
    About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab.
    More about me and what I do:
    www.jacobsorbe...
    people.cs.clem...
    persist.cs.clem...
    To Support the Channel:
    like, subscribe, spread the word
    contribute via Patreon --- [ / jacobsorber ]
    rep the channel with nerdy merch --- [teespring.com/...]
    Source code is also available to Patreon supporters. --- [jsorber-youtub...]
    Want me to review your code?
    Email the code to js.reviews.code@gmail.com. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos."
    You can also find more info about code reviews here.
    • I want to review your ...

ความคิดเห็น • 36

  • @GaussianBluff
    @GaussianBluff 6 ปีที่แล้ว +37

    I really like the format of these videos. It's naturally easier to get into as a viewer than a full 1h+ tutorial, but I'm still sometimes surprised how much content you manage to get across in 3-5min without me having to rewatch it.

    • @JacobSorber
      @JacobSorber  6 ปีที่แล้ว +6

      I do what I can. Glad you enjoyed it.

  • @saicharan3650
    @saicharan3650 5 ปีที่แล้ว +2

    man you are just awesome. I am struggling with my Operating System lab problems and now you have made it all easy.

  • @abdelazizsaad7676
    @abdelazizsaad7676 3 ปีที่แล้ว

    This is a very amazing video, please keep such videos coming up.
    The format is just amazing. Easier to get the idea.

  • @TheSRONIX
    @TheSRONIX 4 ปีที่แล้ว

    Great production! Really appreciate the quality

  • @ushnakhan198
    @ushnakhan198 4 ปีที่แล้ว +5

    This teacher is so amazing ❤️❤️ and so cool love from india

  • @youthfull3616
    @youthfull3616 ปีที่แล้ว

    very good and precise. love it

  • @yjc149
    @yjc149 2 ปีที่แล้ว

    you are the star!

  • @rishikeshkumar490
    @rishikeshkumar490 3 ปีที่แล้ว +1

    This video was really nice and informative .
    It would be better if you explain what is Mutex, Semaphore, Deadlock, Race Conditions , Critical Section with a muti-threaded program in C++. How to debug muti-threaded program in a single video for Interview Preparation.

  • @hashincludetravel3766
    @hashincludetravel3766 5 ปีที่แล้ว +1

    watch point used at 3:22 will make the execution quite slow..we can use conditional breakpoint
    watch point definitely has its own use which you explained later.

  • @fsaforosaforo6338
    @fsaforosaforo6338 ปีที่แล้ว

    Excellent video on the subject matter of debugging. I see why my school used your video for our class. Thanks for sharing. One question...did you do this Ubutu?

  • @shushens
    @shushens 4 ปีที่แล้ว

    Super useful as always. I have a question. Debugging multi-threaded programs is of course a challenge, but it is a challenge people have had the chance to discuss for quite some time now. One thing that is relatively less discussed is what to do when you are debugging a process that creates many inferiors, some of which might also become interesting to you. Trying to find them and attaching new instances to them can quickly go out of hand. GDB9.1 claims to have gained new multiprocess debugging capabilities. It would be super interesting to see something in this area. It is not like I am proposing that you demonstrate something that I already know. I am struggling to find information on this, and perhaps you will have better luck than I did :)

  • @shrek1412
    @shrek1412 4 ปีที่แล้ว +1

    thanks, it is very helpful, but what if you work with embedded linux and you don’t have gdb, how do you debug?

  • @951784623
    @951784623 2 ปีที่แล้ว

    Sometimes when I am debugging multiple threads when the threads are being created it lists them all and then the prompt breaks. How can I get the prompt back in this case?

  • @youdy3000
    @youdy3000 5 ปีที่แล้ว

    Beautiful videos.
    Did you consider an example / video on debugging multi threaded program that paused a specific thread so you could clearly see the other thread complete?

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว

      Thanks, Robert. I'll put it on the list and see what I can do.

    • @youdy3000
      @youdy3000 5 ปีที่แล้ว

      @@JacobSorber Thanks, Jacob. This is how you achieve that with `lldb`.. stackoverflow.com/questions/56171638/lldb-pause-a-thread-while-other-threads-continue/56174578#56174578

  • @madteen2507
    @madteen2507 3 ปีที่แล้ว

    Which OS are u using?

  • @ymi_yugy3133
    @ymi_yugy3133 4 ปีที่แล้ว

    Is there a way to do the same with multi process programs?

  • @vishalggupta
    @vishalggupta 3 ปีที่แล้ว

    Can debugger sleep a thread for a while and other threads keep running in the background?

    • @JacobSorber
      @JacobSorber  3 ปีที่แล้ว +1

      Sort of. You can set the scheduler locking mode to restrict thread progress, but I believe it only works while step-debugging. As soon as you continue execution, then I believe everything is running again. ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_39.html

  • @abhisheksa6635
    @abhisheksa6635 ปีที่แล้ว

    just wow

  • @ihamzaiqbal
    @ihamzaiqbal 5 ปีที่แล้ว

    I am trying to make a simple game using C that uses threads it's a "DRAGON JUMP" game that we can play on chrome when we haven't access INTERNET. I am using 2 characters one is jumping and the second one is horizontally moving but the problem is that when one jumps the second one disappears and when one moves horizontally jumping one disappears.I want both of them to present there.

    • @JacobSorber
      @JacobSorber  5 ปีที่แล้ว +1

      Sounds like a fun project. I don't have enough information to know what's going wrong, but I wish you all the best as you try to figure it out.

    • @kiwi_wolf2805
      @kiwi_wolf2805 5 ปีที่แล้ว

      Maybe one of the threads gets locked?

  • @desiganpang5324
    @desiganpang5324 6 ปีที่แล้ว

    how can i setup the pthreads lib ? i couldnt find any related info on this matter. im using ubuntu on vm

    • @JacobSorber
      @JacobSorber  6 ปีที่แล้ว +1

      You shouldn't really have to set anything up. Just compile as usual (but link with the library "-lpthread" - not necessary on some machines, but I think on Linux it is). Also, if you look back in my videos a I have a basic intro on creating threads that might help.

    • @desiganpang5324
      @desiganpang5324 6 ปีที่แล้ว

      @@JacobSorber i copy your code and try to run it, but the system said pthreads is not found, i dont remember the exact error, i also try installing it from sourceforge for window but its the same result

    • @JacobSorber
      @JacobSorber  6 ปีที่แล้ว

      Did you add "-lpthread" to the compile line (something like... "clang test.c -lpthread")? Try running the command "locate pthread.h". It should find a file at /usr/include/pthread.h. For me, this was all just there when I installed ubuntu.

    • @desiganpang5324
      @desiganpang5324 6 ปีที่แล้ว +1

      turn out i had a typo in my code where i wrote include, after i remove the s and include the pthread lib in the compile line I was able to run the code. thank you for all your help

  • @cyrilanisimov
    @cyrilanisimov 4 ปีที่แล้ว +5

    1 dislike))) Who was that guy? Java developer?))))

  • @danielkrajnik3817
    @danielkrajnik3817 3 ปีที่แล้ว

    the only 2 dislikes were from functional programmers

  • @eddaly4160
    @eddaly4160 2 ปีที่แล้ว

    Yikes...get an IDE...great video's...I have been watching many of them

    • @wertigon
      @wertigon ปีที่แล้ว

      Once you really understand the "behind the scenes" and how vim works, IDEs tend to slow you down more than anything else.
      That said, Visual Code is a really, really, reeeeeeaaaaally nice editor once you figure out how to install support for the vim language... :)