17

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

sergico
  • 2,595
  • 2
  • 29
  • 40
  • 7
    **Apologies** a more accurate search on google let me found this link: (http://sourceware.org/gdb/onlinedocs/gdb/Non_002dStop-Mode.html#Non_002dStop-Mode) that seems to answer my question. Cheers – sergico Feb 02 '12 at 10:18
  • 5
    it is ok to post an answer to your question. please do. – Johan Lundberg Feb 02 '12 at 10:40
  • possible duplicate of [not stopping all threads in gdb](http://stackoverflow.com/questions/3666331/not-stopping-all-threads-in-gdb) – John Carter Feb 02 '12 at 20:22

3 Answers3

4

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

Adrian
  • 5,603
  • 8
  • 53
  • 85
0

You may use totalview debugger to do that

0

If that little variation is OK, you could send the thread a STOP signal (not as a gdb command the gdb - that the variation) and debug everything else running. Signal CONT lets the thread continue.

Jörg Beyer
  • 3,631
  • 21
  • 35