gdb: add maybe_switch_inferior function
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 3 Apr 2023 18:52:05 +0000 (14:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 17 Apr 2023 17:47:13 +0000 (13:47 -0400)
commit348da4565b5c901e9320c3e2d7f5b62793b48a38
tree494850c0621b85dd9ef473e0ecfb65e2c6bb7ea1
parent2b214d3e3b51b9a6544ffbcf0a1554376c3ce9c5
gdb: add maybe_switch_inferior function

Add the maybe_switch_inferior function, which ensures that the given
inferior is the current one.  Return an instantiated
scoped_restore_current_thread object only we actually needed to switch
inferior.

Returning a scoped_restore_current_thread requires it to be
move-constructible, so give it a move constructor.

Change-Id: I1231037102ed6166f2530399e8257ad937fb0569
Reviewed-By: Pedro Alves <pedro@palves.net>
gdb/gdbthread.h
gdb/inferior.c
gdb/inferior.h
gdb/thread.c