Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to stop a single thread during debug in Linux?

What I'd like to know is if it is possible, inside a debugging session in Linux, (read: gdb :)) to stop the execution of a single thread, leaving the other threads to run.

If someone is curious to know why keep reading: I wrote a software watchdog C++ class (using Qt). I tested it with a simple multithreaded program, but I'd like to test the code once I integrate it inside the real application as well. If I could stop a thread from the debugger, that will simplify this testing phase. :)

Cheers Sergio

like image 397
sergico Avatar asked Feb 02 '12 10:02

sergico


1 Answers

Use this sequence of commands before you run or attach to your program:

  • Enable the async interface:
    set target-async 1

  • If using the CLI, pagination breaks non-stop:
    set pagination off

  • Turn it on:
    set non-stop on

Use these commands to manipulate the non-stop mode setting:

  • Enable selection of non-stop mode:
    set non-stop on

  • Disable selection of non-stop mode:
    set non-stop off

  • Show the current non-stop enabled setting:
    show non-stop

References:
http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html#Non_002dStop-Mode

like image 184
Adrian Avatar answered Oct 06 '22 00:10

Adrian