diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-04-03 14:52:05 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-04-17 13:47:13 -0400 |
commit | 348da4565b5c901e9320c3e2d7f5b62793b48a38 (patch) | |
tree | 494850c0621b85dd9ef473e0ecfb65e2c6bb7ea1 /gdb/inferior.h | |
parent | 2b214d3e3b51b9a6544ffbcf0a1554376c3ce9c5 (diff) | |
download | fsf-binutils-gdb-348da4565b5c901e9320c3e2d7f5b62793b48a38.zip fsf-binutils-gdb-348da4565b5c901e9320c3e2d7f5b62793b48a38.tar.gz fsf-binutils-gdb-348da4565b5c901e9320c3e2d7f5b62793b48a38.tar.bz2 |
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>
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index 633916e..613ef28 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -340,6 +340,13 @@ extern void set_current_inferior (inferior *); selected. */ extern void switch_to_inferior_no_thread (inferior *inf); +/* Ensure INF is the current inferior. + + If the current inferior was changed, return an RAII object that will + restore the original current context. */ +extern gdb::optional<scoped_restore_current_thread> maybe_switch_inferior + (inferior *inf); + /* Info about an inferior's target description. There's one of these for each inferior. */ |