As TazMainiac said, scheduler-locking is useful for single stepping, but the “mode” must be set to “step”.
set scheduler-locking step
You can refer the link provided by TazMainiac which mentions the same:
http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_39.html
The step mode optimizes for single-stepping. It stops other threads
from “seizing the prompt” by preempting the current thread while you
are stepping.