Skip to content

Scheduler

lock_scheduler()

This context manager can be used to run GDB commands with threads scheduling being locked which means that other threads will be stopped during execution.

This is useful to prevent bugs where e.g.: gdb.parse_and_eval("(int)foo()") would execute foo() on the current debugee thread but would also unlock other threads for being executed and those other threads may for example hit a breakpoint we set previously which would be confusing for the user.

See also: https://sourceware.org/gdb/onlinedocs/gdb/All_002dStop-Mode.html

parse_and_eval_with_scheduler_lock(expr)