1
votes

I'm debugging a multithreaded C++ program with gdb. Here's the debugging flow I'd like to achieve:

  1. run until a breakpoint, then pause execution for all threads
  2. disable [breakpoints] with the disable command
  3. call a function (defined in my program) to print the state of a vector (while keeping the other threads paused)

However, when I make the call to the function that prints the state of the system multiple times, the values of the data structure change. Unless I have some sort of other bug, this must mean that the other threads are running while my printing function is running.

Questions:

  1. do other threads resume execution while a call command is executed in gdb?
  2. assuming so, is there a way to disable this such that I can keep threads paused while I introspect program state via call commands?
1
@KostasRim yes that's exactly what I needed; set scheduler-locking on does what I want - Kulluk007

1 Answers

1
votes

See @KostasRim's comment -- set scheduler-locking on achieves the desired behavior (https://sourceware.org/gdb/onlinedocs/gdb/All_002dStop-Mode.html). By default, other threads run during stepping, function calling, etc.