gdbserver: introduce scoped_restore_current_thread and switch_to_thread Introduce a class for restoring the current thread and a function to switch to the given thread. This is a preparation for a refactoring that aims to remove direct assignments to 'current_thread'.