Make target_wait options use enum flags

Message ID 20200727173526.2186755-1-tromey@adacore.com
State New
Headers show
Series
  • Make target_wait options use enum flags
Related show

Commit Message

Tom Tromey July 27, 2020, 5:35 p.m.
This changes TARGET_WNOHANG to be a member of an enum, rather than a
define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it
changes target_wait and the various target wait methods to use this
type rather than "int".

This didn't catch any bugs, but it seems like a decent cleanup
nevertheless.

I did not change deprecated_target_wait_hook, since that's only used
out-of-tree (by Insight), and there didn't seem to be a need.

I can't build some of these targets, so I modified them on a
best-effort basis.  I don't think this patch should go in before the
release branch is made.

gdb/ChangeLog
2020-07-27  Tom Tromey  <tromey@adacore.com>

	* windows-nat.c (struct windows_nat_target) <wait>: Update.
	(windows_nat_target::wait): Update.
	* target/wait.h (enum target_wait_flag): New.  Use
	DEF_ENUM_FLAGS_TYPE.
	* target/target.h (target_wait): Change type of options.
	* target.h (target_options_to_string, default_target_wait):
	Update.
	(struct target_ops) <wait>: Change type of options.
	* target.c (target_wait, default_target_wait, do_option): Change
	type of "options".
	(target_options_to_string): Likewise.
	* target-delegates.c: Rebuild.
	* target-debug.h (target_debug_print_target_wait_flags): Rename
	from target_debug_print_options.
	* sol-thread.c (class sol_thread_target) <wait>: Update.
	(sol_thread_target::wait): Update.
	* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
	(rs6000_nat_target::wait): Update.
	* remote.c (class remote_target) <wait, wait_ns, wait_as>:
	Update.
	(remote_target::wait_ns, remote_target::wait_as): Change type of
	"options".
	(remote_target::wait): Update.
	* remote-sim.c (struct gdbsim_target) <wait>: Update.
	(gdbsim_target::wait): Update.
	* record-full.c (class record_full_base_target) <wait>: Update.
	(record_full_wait_1): Change type of "options".
	(record_full_base_target::wait): Update.
	* record-btrace.c (class record_btrace_target) <wait>: Update.
	(record_btrace_target::wait): Update.
	* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
	Update.
	(ravenscar_thread_target::wait): Update.
	* procfs.c (class procfs_target) <wait>: Update.
	(procfs_target::wait): Update.
	* obsd-nat.h (class obsd_nat_target) <wait>: Update.
	* obsd-nat.c (obsd_nat_target::wait): Update.
	* nto-procfs.c (struct nto_procfs_target) <wait>: Update.
	(nto_procfs_target::wait): Update.
	* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
	* nbsd-nat.c (nbsd_wait): Change type of "options".
	(nbsd_nat_target::wait): Update.
	* linux-thread-db.c (class thread_db_target) <wait>: Update.
	(thread_db_target::wait): Update.
	* linux-nat.h (class linux_nat_target) <wait>: Update.
	* linux-nat.c (linux_nat_target::wait): Update.
	* infrun.c (do_target_wait_1, do_target_wait): Change type of
	"options".
	* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
	* inf-ptrace.c (inf_ptrace_target::wait): Update.
	* go32-nat.c (struct go32_nat_target) <wait>: Update.
	(go32_nat_target::wait): Update.
	* gnu-nat.h (struct gnu_nat_target) <wait>: Update.
	* gnu-nat.c (gnu_nat_target::wait): Update.
	* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
	* fbsd-nat.c (fbsd_nat_target::wait): Update.
	* darwin-nat.h (class darwin_nat_target) <wait>: Update.
	* darwin-nat.c (darwin_nat_target::wait): Update.
	* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
	(bsd_uthread_target::wait): Update.
	* aix-thread.c (class aix_thread_target) <wait>: Update.
	(aix_thread_target::wait): Update.

gdbserver/ChangeLog
2020-07-27  Tom Tromey  <tromey@adacore.com>

	* win32-low.h (class win32_process_target) <wait>: Update.
	* win32-low.cc (win32_process_target::wait): Update.
	* target.h (class process_stratum_target) <wait>: Update.
	(mywait): Update.
	* target.cc (mywait, target_wait): Change type of "options".
	* linux-low.h (class linux_process_target) <wait>: Update.
	* linux-low.cc (linux_process_target::wait): Update.
---
 gdb/ChangeLog          | 65 ++++++++++++++++++++++++++++++++++++++++++
 gdb/aix-thread.c       |  4 +--
 gdb/bsd-uthread.c      |  4 +--
 gdb/darwin-nat.c       |  2 +-
 gdb/darwin-nat.h       |  2 +-
 gdb/fbsd-nat.c         |  2 +-
 gdb/fbsd-nat.h         |  2 +-
 gdb/gnu-nat.c          |  2 +-
 gdb/gnu-nat.h          |  2 +-
 gdb/go32-nat.c         |  4 +--
 gdb/inf-ptrace.c       |  2 +-
 gdb/inf-ptrace.h       |  2 +-
 gdb/infrun.c           |  5 ++--
 gdb/linux-nat.c        |  2 +-
 gdb/linux-nat.h        |  2 +-
 gdb/linux-thread-db.c  |  4 +--
 gdb/nbsd-nat.c         |  5 ++--
 gdb/nbsd-nat.h         |  2 +-
 gdb/nto-procfs.c       |  4 +--
 gdb/obsd-nat.c         |  2 +-
 gdb/obsd-nat.h         |  2 +-
 gdb/procfs.c           |  4 +--
 gdb/ravenscar-thread.c |  4 +--
 gdb/record-btrace.c    |  7 +++--
 gdb/record-full.c      |  6 ++--
 gdb/remote-sim.c       |  5 ++--
 gdb/remote.c           | 15 ++++++----
 gdb/rs6000-nat.c       |  4 +--
 gdb/sol-thread.c       |  4 +--
 gdb/target-debug.h     |  2 +-
 gdb/target-delegates.c | 12 ++++----
 gdb/target.c           | 11 +++----
 gdb/target.h           |  6 ++--
 gdb/target/target.h    |  4 ++-
 gdb/target/wait.h      | 15 +++++++---
 gdb/windows-nat.c      |  4 +--
 gdbserver/ChangeLog    | 10 +++++++
 gdbserver/linux-low.cc |  2 +-
 gdbserver/linux-low.h  |  2 +-
 gdbserver/target.cc    |  7 +++--
 gdbserver/target.h     |  6 ++--
 gdbserver/win32-low.cc |  2 +-
 gdbserver/win32-low.h  |  2 +-
 43 files changed, 174 insertions(+), 81 deletions(-)

-- 
2.26.2

Comments

Simon Marchi July 28, 2020, 1:31 p.m. | #1
On 2020-07-27 1:35 p.m., Tom Tromey wrote:
> This changes TARGET_WNOHANG to be a member of an enum, rather than a

> define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it

> changes target_wait and the various target wait methods to use this

> type rather than "int".

> 

> This didn't catch any bugs, but it seems like a decent cleanup

> nevertheless.

> 

> I did not change deprecated_target_wait_hook, since that's only used

> out-of-tree (by Insight), and there didn't seem to be a need.

> 

> I can't build some of these targets, so I modified them on a

> best-effort basis.  I don't think this patch should go in before the

> release branch is made.

> 

> gdb/ChangeLog

> 2020-07-27  Tom Tromey  <tromey@adacore.com>

> 

> 	* windows-nat.c (struct windows_nat_target) <wait>: Update.

> 	(windows_nat_target::wait): Update.

> 	* target/wait.h (enum target_wait_flag): New.  Use

> 	DEF_ENUM_FLAGS_TYPE.

> 	* target/target.h (target_wait): Change type of options.

> 	* target.h (target_options_to_string, default_target_wait):

> 	Update.

> 	(struct target_ops) <wait>: Change type of options.

> 	* target.c (target_wait, default_target_wait, do_option): Change

> 	type of "options".

> 	(target_options_to_string): Likewise.

> 	* target-delegates.c: Rebuild.

> 	* target-debug.h (target_debug_print_target_wait_flags): Rename

> 	from target_debug_print_options.

> 	* sol-thread.c (class sol_thread_target) <wait>: Update.

> 	(sol_thread_target::wait): Update.

> 	* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.

> 	(rs6000_nat_target::wait): Update.

> 	* remote.c (class remote_target) <wait, wait_ns, wait_as>:

> 	Update.

> 	(remote_target::wait_ns, remote_target::wait_as): Change type of

> 	"options".

> 	(remote_target::wait): Update.

> 	* remote-sim.c (struct gdbsim_target) <wait>: Update.

> 	(gdbsim_target::wait): Update.

> 	* record-full.c (class record_full_base_target) <wait>: Update.

> 	(record_full_wait_1): Change type of "options".

> 	(record_full_base_target::wait): Update.

> 	* record-btrace.c (class record_btrace_target) <wait>: Update.

> 	(record_btrace_target::wait): Update.

> 	* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:

> 	Update.

> 	(ravenscar_thread_target::wait): Update.

> 	* procfs.c (class procfs_target) <wait>: Update.

> 	(procfs_target::wait): Update.

> 	* obsd-nat.h (class obsd_nat_target) <wait>: Update.

> 	* obsd-nat.c (obsd_nat_target::wait): Update.

> 	* nto-procfs.c (struct nto_procfs_target) <wait>: Update.

> 	(nto_procfs_target::wait): Update.

> 	* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.

> 	* nbsd-nat.c (nbsd_wait): Change type of "options".

> 	(nbsd_nat_target::wait): Update.

> 	* linux-thread-db.c (class thread_db_target) <wait>: Update.

> 	(thread_db_target::wait): Update.

> 	* linux-nat.h (class linux_nat_target) <wait>: Update.

> 	* linux-nat.c (linux_nat_target::wait): Update.

> 	* infrun.c (do_target_wait_1, do_target_wait): Change type of

> 	"options".

> 	* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.

> 	* inf-ptrace.c (inf_ptrace_target::wait): Update.

> 	* go32-nat.c (struct go32_nat_target) <wait>: Update.

> 	(go32_nat_target::wait): Update.

> 	* gnu-nat.h (struct gnu_nat_target) <wait>: Update.

> 	* gnu-nat.c (gnu_nat_target::wait): Update.

> 	* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.

> 	* fbsd-nat.c (fbsd_nat_target::wait): Update.

> 	* darwin-nat.h (class darwin_nat_target) <wait>: Update.

> 	* darwin-nat.c (darwin_nat_target::wait): Update.

> 	* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.

> 	(bsd_uthread_target::wait): Update.

> 	* aix-thread.c (class aix_thread_target) <wait>: Update.

> 	(aix_thread_target::wait): Update.

> 

> gdbserver/ChangeLog

> 2020-07-27  Tom Tromey  <tromey@adacore.com>

> 

> 	* win32-low.h (class win32_process_target) <wait>: Update.

> 	* win32-low.cc (win32_process_target::wait): Update.

> 	* target.h (class process_stratum_target) <wait>: Update.

> 	(mywait): Update.

> 	* target.cc (mywait, target_wait): Change type of "options".

> 	* linux-low.h (class linux_process_target) <wait>: Update.

> 	* linux-low.cc (linux_process_target::wait): Update.


Good idea thanks.

For mostly mechanical changes across the code base like this, I think it should be fine
to have a short ChangeLog entry that says "Update all users" or "Update all extenders".
Otherwise, writing the ChangeLog entry really becomes a demotivation for making good code
cleanups that have concrete positive impacts on the technical debt.

Simon
Tom Tromey Sept. 16, 2020, 3:48 p.m. | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:


>> This changes TARGET_WNOHANG to be a member of an enum, rather than a

>> define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it

>> changes target_wait and the various target wait methods to use this

>> type rather than "int".

[...]

Simon> Good idea thanks.

I'm going to check this in.

Note that, as I mentioned earlier, I couldn't build all targets -- I
made a best effort, but maybe I've introduced an error.  Let me know if
you hit one and I will try to fix it.

thanks,
Tom
Tom Tromey Sept. 16, 2020, 4:02 p.m. | #3
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:


Simon> Good idea thanks.

Tom> I'm going to check this in.

Actually, I'm not yet -- the enum flags update pointed out a couple more
spots to fix, and then while grepping to see if any other targets needed
the same treatment, I found some other problems.  So, this patch did end
up catching bugs after all :)

I'll send separate email about the problem I found.

Tom
Tom Tromey Sept. 16, 2020, 5:58 p.m. | #4
Tom> Actually, I'm not yet -- the enum flags update pointed out a couple more
Tom> spots to fix, and then while grepping to see if any other targets needed
Tom> the same treatment, I found some other problems.  So, this patch did end
Tom> up catching bugs after all :)

Here's the updated patch.

Kamil, could you check the NetBSD changes?

thanks,
Tom

commit b9bbce754075de503869d44fcd7ee636888dfb7a
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Sep 16 09:51:59 2020 -0600

    Make target_wait options use enum flags
    
    This changes TARGET_WNOHANG to be a member of an enum, rather than a
    define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it
    changes target_wait and the various target wait methods to use this
    type rather than "int".
    
    This didn't catch any bugs, but it seems like a decent cleanup
    nevertheless.
    
    I did not change deprecated_target_wait_hook, since that's only used
    out-of-tree (by Insight), and there didn't seem to be a need.
    
    I can't build some of these targets, so I modified them on a
    best-effort basis.  I don't think this patch should go in before the
    release branch is made.
    
    gdb/ChangeLog
    2020-09-16  Tom Tromey  <tromey@adacore.com>
    
            * windows-nat.c (struct windows_nat_target) <wait>: Update.
            (windows_nat_target::wait): Update.
            * target/wait.h (enum target_wait_flag): New.  Use
            DEF_ENUM_FLAGS_TYPE.
            * target/target.h (target_wait): Change type of options.
            * target.h (target_options_to_string, default_target_wait):
            Update.
            (struct target_ops) <wait>: Change type of options.
            * target.c (target_wait, default_target_wait, do_option): Change
            type of "options".
            (target_options_to_string): Likewise.
            * target-delegates.c: Rebuild.
            * target-debug.h (target_debug_print_target_wait_flags): Rename
            from target_debug_print_options.
            * sol-thread.c (class sol_thread_target) <wait>: Update.
            (sol_thread_target::wait): Update.
            * rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
            (rs6000_nat_target::wait): Update.
            * remote.c (class remote_target) <wait, wait_ns, wait_as>:
            Update.
            (remote_target::wait_ns, remote_target::wait_as): Change type of
            "options".
            (remote_target::wait): Update.
            * remote-sim.c (struct gdbsim_target) <wait>: Update.
            (gdbsim_target::wait): Update.
            * record-full.c (class record_full_base_target) <wait>: Update.
            (record_full_wait_1): Change type of "options".
            (record_full_base_target::wait): Update.
            * record-btrace.c (class record_btrace_target) <wait>: Update.
            (record_btrace_target::wait): Update.
            * ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
            Update.
            (ravenscar_thread_target::wait): Update.
            * procfs.c (class procfs_target) <wait>: Update.
            (procfs_target::wait): Update.
            * obsd-nat.h (class obsd_nat_target) <wait>: Update.
            * obsd-nat.c (obsd_nat_target::wait): Update.
            * nto-procfs.c (struct nto_procfs_target) <wait>: Update.
            (nto_procfs_target::wait): Update.
            * nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
            * nbsd-nat.c (nbsd_wait): Change type of "options".
            (nbsd_nat_target::wait): Update.
            * linux-thread-db.c (class thread_db_target) <wait>: Update.
            (thread_db_target::wait): Update.
            * linux-nat.h (class linux_nat_target) <wait>: Update.
            * linux-nat.c (linux_nat_target::wait): Update.
            (linux_nat_wait_1): Update.
            * infrun.c (do_target_wait_1, do_target_wait): Change type of
            "options".
            * inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
            * inf-ptrace.c (inf_ptrace_target::wait): Update.
            * go32-nat.c (struct go32_nat_target) <wait>: Update.
            (go32_nat_target::wait): Update.
            * gnu-nat.h (struct gnu_nat_target) <wait>: Update.
            * gnu-nat.c (gnu_nat_target::wait): Update.
            * fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
            * fbsd-nat.c (fbsd_nat_target::wait): Update.
            * darwin-nat.h (class darwin_nat_target) <wait>: Update.
            * darwin-nat.c (darwin_nat_target::wait): Update.
            * bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
            (bsd_uthread_target::wait): Update.
            * aix-thread.c (class aix_thread_target) <wait>: Update.
            (aix_thread_target::wait): Update.
    
    gdbserver/ChangeLog
    2020-09-16  Tom Tromey  <tromey@adacore.com>
    
            * netbsd-low.h (class netbsd_process_target) <wait>: Update.
            * netbsd-low.cc (netbsd_waitpid, netbsd_wait)
            (netbsd_process_target::wait): Change type of target_options.
            * win32-low.h (class win32_process_target) <wait>: Update.
            * win32-low.cc (win32_process_target::wait): Update.
            * target.h (class process_stratum_target) <wait>: Update.
            (mywait): Update.
            * target.cc (mywait, target_wait): Change type of "options".
            * linux-low.h (class linux_process_target) <wait, wait_1>:
            Update.
            * linux-low.cc (linux_process_target::wait)
            (linux_process_target::wait_1): Update.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 85c733e203f..091b5da65d2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,69 @@
+2020-09-16  Tom Tromey  <tromey@adacore.com>
+
+	* windows-nat.c (struct windows_nat_target) <wait>: Update.
+	(windows_nat_target::wait): Update.
+	* target/wait.h (enum target_wait_flag): New.  Use
+	DEF_ENUM_FLAGS_TYPE.
+	* target/target.h (target_wait): Change type of options.
+	* target.h (target_options_to_string, default_target_wait):
+	Update.
+	(struct target_ops) <wait>: Change type of options.
+	* target.c (target_wait, default_target_wait, do_option): Change
+	type of "options".
+	(target_options_to_string): Likewise.
+	* target-delegates.c: Rebuild.
+	* target-debug.h (target_debug_print_target_wait_flags): Rename
+	from target_debug_print_options.
+	* sol-thread.c (class sol_thread_target) <wait>: Update.
+	(sol_thread_target::wait): Update.
+	* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.
+	(rs6000_nat_target::wait): Update.
+	* remote.c (class remote_target) <wait, wait_ns, wait_as>:
+	Update.
+	(remote_target::wait_ns, remote_target::wait_as): Change type of
+	"options".
+	(remote_target::wait): Update.
+	* remote-sim.c (struct gdbsim_target) <wait>: Update.
+	(gdbsim_target::wait): Update.
+	* record-full.c (class record_full_base_target) <wait>: Update.
+	(record_full_wait_1): Change type of "options".
+	(record_full_base_target::wait): Update.
+	* record-btrace.c (class record_btrace_target) <wait>: Update.
+	(record_btrace_target::wait): Update.
+	* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:
+	Update.
+	(ravenscar_thread_target::wait): Update.
+	* procfs.c (class procfs_target) <wait>: Update.
+	(procfs_target::wait): Update.
+	* obsd-nat.h (class obsd_nat_target) <wait>: Update.
+	* obsd-nat.c (obsd_nat_target::wait): Update.
+	* nto-procfs.c (struct nto_procfs_target) <wait>: Update.
+	(nto_procfs_target::wait): Update.
+	* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.
+	* nbsd-nat.c (nbsd_wait): Change type of "options".
+	(nbsd_nat_target::wait): Update.
+	* linux-thread-db.c (class thread_db_target) <wait>: Update.
+	(thread_db_target::wait): Update.
+	* linux-nat.h (class linux_nat_target) <wait>: Update.
+	* linux-nat.c (linux_nat_target::wait): Update.
+	(linux_nat_wait_1): Update.
+	* infrun.c (do_target_wait_1, do_target_wait): Change type of
+	"options".
+	* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.
+	* inf-ptrace.c (inf_ptrace_target::wait): Update.
+	* go32-nat.c (struct go32_nat_target) <wait>: Update.
+	(go32_nat_target::wait): Update.
+	* gnu-nat.h (struct gnu_nat_target) <wait>: Update.
+	* gnu-nat.c (gnu_nat_target::wait): Update.
+	* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.
+	* fbsd-nat.c (fbsd_nat_target::wait): Update.
+	* darwin-nat.h (class darwin_nat_target) <wait>: Update.
+	* darwin-nat.c (darwin_nat_target::wait): Update.
+	* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.
+	(bsd_uthread_target::wait): Update.
+	* aix-thread.c (class aix_thread_target) <wait>: Update.
+	(aix_thread_target::wait): Update.
+
 2020-09-16  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
 	* breakpoint.c (commands_command_1): Make a copy of the 'arg'
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 3963a08c840..ed30df5f3f6 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -124,7 +124,7 @@ class aix_thread_target final : public target_ops
 
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -1077,7 +1077,7 @@ aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
 ptid_t
 aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			 int options)
+			 target_wait_flags options)
 {
   {
     scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 11ce0f439bf..144e8b920fa 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -53,7 +53,7 @@ struct bsd_uthread_target final : public target_ops
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   bool thread_alive (ptid_t ptid) override;
@@ -377,7 +377,7 @@ bsd_uthread_target::store_registers (struct regcache *regcache, int regnum)
 
 ptid_t
 bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			  int options)
+			  target_wait_flags options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR addr;
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0d7b028e39c..76d0fe87a85 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1285,7 +1285,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
 
 ptid_t
 darwin_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			 int options)
+			 target_wait_flags options)
 {
   return wait_1 (ptid, status);
 }
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 86bb3389212..8a84cdc83dd 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -86,7 +86,7 @@ class darwin_nat_target : public inf_child_target
 
   void detach (inferior *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void mourn_inferior () override;
 
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index a355ebe4382..29c30623d09 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1295,7 +1295,7 @@ fbsd_handle_debug_trap (fbsd_nat_target *target, ptid_t ptid,
 
 ptid_t
 fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int target_options)
+		       target_wait_flags target_options)
 {
   ptid_t wptid;
 
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 1b1e043dae7..58bea352c88 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -70,7 +70,7 @@ class fbsd_nat_target : public inf_ptrace_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void post_startup_inferior (ptid_t) override;
   void post_attach (int) override;
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 3cee06dc4db..32af0bf3192 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1436,7 +1436,7 @@ static struct inf *waiting_inf;
 
 ptid_t
 gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		      int options)
+		      target_wait_flags options)
 {
   struct msg
     {
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 0e7ff8d5aa9..28c08108265 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -124,7 +124,7 @@ struct gnu_nat_target : public inf_child_target
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   enum target_xfer_status xfer_partial (enum target_object object,
 					const char *annex,
 					gdb_byte *readbuf,
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 8ffd28985ab..4ea2dd8714f 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -342,7 +342,7 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target>
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -419,7 +419,7 @@ static char child_cwd[FILENAME_MAX];
 
 ptid_t
 go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		       int options)
+		       target_wait_flags options)
 {
   int i;
   unsigned char saved_opcode;
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index ae0b0f7ff0d..d5a062163c7 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -316,7 +316,7 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 
 ptid_t
 inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index e2079faee3d..d3c59e6d46a 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -35,7 +35,7 @@ struct inf_ptrace_target : public inf_child_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void files_info () override;
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5773fd03951..3e49cb4c641 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3423,7 +3423,7 @@ random_pending_event_thread (inferior *inf, ptid_t waiton_ptid)
 
 static ptid_t
 do_target_wait_1 (inferior *inf, ptid_t ptid,
-		  target_waitstatus *status, int options)
+		  target_waitstatus *status, target_wait_flags options)
 {
   ptid_t event_ptid;
   struct thread_info *tp;
@@ -3546,7 +3546,8 @@ do_target_wait_1 (inferior *inf, ptid_t ptid,
    more events.  Polls for events from all inferiors/targets.  */
 
 static bool
-do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, int options)
+do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,
+		target_wait_flags options)
 {
   int num_inferiors = 0;
   int random_selector;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 4f53670da5e..44b59485d7b 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3131,7 +3131,7 @@ filter_exit_event (struct lwp_info *event_child,
 
 static ptid_t
 linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,
-		  int target_options)
+		  target_wait_flags target_options)
 {
   sigset_t prev_mask;
   enum resume_kind last_resume_kind;
@@ -3411,7 +3411,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
 
 ptid_t
 linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			int target_options)
+			target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 1af9e830c83..caaeff85207 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -46,7 +46,7 @@ class linux_nat_target : public inf_ptrace_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void pass_signals (gdb::array_view<const unsigned char>) override;
 
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index b3cda05cd6e..fbddfed3c59 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -92,7 +92,7 @@ class thread_db_target final : public target_ops
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   void update_thread_list () override;
@@ -1379,7 +1379,7 @@ thread_db_target::detach (inferior *inf, int from_tty)
 
 ptid_t
 thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			int options)
+			target_wait_flags options)
 {
   struct thread_db_info *info;
 
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index b12d86e8256..7a07fbf6d8a 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -540,7 +540,8 @@ nbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 /* Implement a safe wrapper around waitpid().  */
 
 static pid_t
-nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	   target_wait_flags options)
 {
   pid_t pid;
   int status;
@@ -569,7 +570,7 @@ nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
 
 ptid_t
 nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int target_options)
+		       target_wait_flags target_options)
 {
   pid_t pid = nbsd_wait (ptid, ourstatus, target_options);
   ptid_t wptid = ptid_t (pid);
diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h
index b09d5b1e3bb..7461667cefb 100644
--- a/gdb/nbsd-nat.h
+++ b/gdb/nbsd-nat.h
@@ -41,7 +41,7 @@ struct nbsd_nat_target : public inf_ptrace_target
   bool info_proc (const char *, enum info_proc_what) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   int insert_exec_catchpoint (int pid) override;
   int remove_exec_catchpoint (int pid) override;
   int set_syscall_catchpoint (int pid, bool needed, int any_count,
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 91d2cc5914d..ef1615df3e2 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -69,7 +69,7 @@ struct nto_procfs_target : public inf_child_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -795,7 +795,7 @@ nto_handle_sigint (int signo)
 
 sptid_t
 nto_procfs_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   sigset_t set;
   siginfo_t info;
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index 6667a0add7f..310e2b72fcd 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -74,7 +74,7 @@ obsd_nat_target::update_thread_list ()
 
 ptid_t
 obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int options)
+		       target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index e5962004d4c..3d3e50c57ec 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -27,7 +27,7 @@ class obsd_nat_target : public inf_ptrace_target
   /* Override some methods to support threads.  */
   std::string pid_to_str (ptid_t) override;
   void update_thread_list () override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 #ifdef PT_GET_PROCESS_STATE
   bool follow_fork (bool, bool) override;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index b628c2d0355..a06f0357ec3 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -105,7 +105,7 @@ class procfs_target final : public inf_child_target
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -2033,7 +2033,7 @@ procfs_target::store_registers (struct regcache *regcache, int regnum)
 
 ptid_t
 procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		     int options)
+		     target_wait_flags options)
 {
   /* First cut: loosely based on original version 2.1.  */
   procinfo *pi;
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 387ebcb32e9..cc94ff8e1ea 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -87,7 +87,7 @@ struct ravenscar_thread_target final : public target_ops
 
   strata stratum () const override { return thread_stratum; }
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   void fetch_registers (struct regcache *, int) override;
@@ -385,7 +385,7 @@ ravenscar_thread_target::resume (ptid_t ptid, int step,
 ptid_t
 ravenscar_thread_target::wait (ptid_t ptid,
 			       struct target_waitstatus *status,
-			       int options)
+			       target_wait_flags options)
 {
   process_stratum_target *beneath
     = as_process_stratum_target (this->beneath ());
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index fd0d13fb258..c1430e9b533 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -118,7 +118,7 @@ class record_btrace_target final : public target_ops
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void stop (ptid_t) override;
   void update_thread_list () override;
@@ -2537,12 +2537,13 @@ record_btrace_maybe_mark_async_event
 
 ptid_t
 record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			    int options)
+			    target_wait_flags options)
 {
   std::vector<thread_info *> moving;
   std::vector<thread_info *> no_history;
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);
+  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),
+	 (unsigned) options);
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 1d8f1930a5b..1c8b791ffb9 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -225,7 +225,7 @@ class record_full_base_target : public target_ops
 
   void close () override;
   void async (int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   bool stopped_by_watchpoint () override;
   bool stopped_data_address (CORE_ADDR *) override;
 
@@ -1155,7 +1155,7 @@ record_full_sig_handler (int signo)
 static ptid_t
 record_full_wait_1 (struct target_ops *ops,
 		    ptid_t ptid, struct target_waitstatus *status,
-		    int options)
+		    target_wait_flags options)
 {
   scoped_restore restore_operation_disable
     = record_full_gdb_operation_disable_set ();
@@ -1468,7 +1468,7 @@ record_full_wait_1 (struct target_ops *ops,
 
 ptid_t
 record_full_base_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			       int options)
+			       target_wait_flags options)
 {
   ptid_t return_ptid;
 
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 9af6486bca8..9e1c2b151c8 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -131,7 +131,7 @@ struct gdbsim_target final
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -927,7 +927,8 @@ gdbsim_cntrl_c (int signo)
 }
 
 ptid_t
-gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status,
+		     target_wait_flags options)
 {
   struct sim_inferior_data *sim_data;
   static sighandler_t prev_sigint;
diff --git a/gdb/remote.c b/gdb/remote.c
index 59075cb09f2..5fc80ebc8f7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -422,7 +422,7 @@ class remote_target : public process_stratum_target
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -739,9 +739,9 @@ class remote_target : public process_stratum_target
   void add_current_inferior_and_thread (char *wait_status);
 
   ptid_t wait_ns (ptid_t ptid, struct target_waitstatus *status,
-		  int options);
+		  target_wait_flags options);
   ptid_t wait_as (ptid_t ptid, target_waitstatus *status,
-		  int options);
+		  target_wait_flags options);
 
   ptid_t process_stop_reply (struct stop_reply *stop_reply,
 			     target_waitstatus *status);
@@ -7771,7 +7771,8 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,
 /* The non-stop mode version of target_wait.  */
 
 ptid_t
-remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status,
+			target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   struct stop_reply *stop_reply;
@@ -7839,7 +7840,8 @@ first_remote_resumed_thread (remote_target *target)
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)
+remote_target::wait_as (ptid_t ptid, target_waitstatus *status,
+			target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   ptid_t event_ptid = null_ptid;
@@ -7992,7 +7994,8 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait (ptid_t ptid, struct target_waitstatus *status,
+		     target_wait_flags options)
 {
   ptid_t event_ptid;
 
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 654e06e3e4b..29154cfc2e7 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -90,7 +90,7 @@ class rs6000_nat_target final : public inf_ptrace_target
   void create_inferior (const char *, const std::string &,
 			char **, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 private:
   enum target_xfer_status
@@ -495,7 +495,7 @@ rs6000_nat_target::xfer_partial (enum target_object object,
 
 ptid_t
 rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index a24d51d1db2..bb33a20ea52 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -84,7 +84,7 @@ class sol_thread_target final : public target_ops
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   std::string pid_to_str (ptid_t) override;
@@ -425,7 +425,7 @@ sol_thread_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 
 ptid_t
 sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   if (ptid.pid () != -1)
     {
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 46d17a359d9..1b2feb2c7fb 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -205,7 +205,7 @@ target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
   target_debug_do_print ((X) ? "step" : "continue")
 
 static void
-target_debug_print_options (int options)
+target_debug_print_target_wait_flags (target_wait_flags options)
 {
   std::string str = target_options_to_string (options);
 
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 15f441edf28..c0968e2040e 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -15,7 +15,7 @@ struct dummy_target : public target_ops
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
@@ -186,7 +186,7 @@ struct debug_target : public target_ops
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
@@ -461,19 +461,19 @@ debug_target::commit_resume ()
 }
 
 ptid_t
-target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return this->beneath ()->wait (arg0, arg1, arg2);
 }
 
 ptid_t
-dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return default_target_wait (this, arg0, arg1, arg2);
 }
 
 ptid_t
-debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   ptid_t result;
   fprintf_unfiltered (gdb_stdlog, "-> %s->wait (...)\n", this->beneath ()->shortname ());
@@ -483,7 +483,7 @@ debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_struct_target_waitstatus_p (arg1);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_options (arg2);
+  target_debug_print_target_wait_flags (arg2);
   fputs_unfiltered (") = ", gdb_stdlog);
   target_debug_print_ptid_t (result);
   fputs_unfiltered ("\n", gdb_stdlog);
diff --git a/gdb/target.c b/gdb/target.c
index 58189e62024..9fd6b4ba9e1 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2007,7 +2007,8 @@ target_disconnect (const char *args, int from_tty)
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+	     target_wait_flags options)
 {
   return current_top_target ()->wait (ptid, status, options);
 }
@@ -2017,7 +2018,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 ptid_t
 default_target_wait (struct target_ops *ops,
 		     ptid_t ptid, struct target_waitstatus *status,
-		     int options)
+		     target_wait_flags options)
 {
   status->kind = TARGET_WAITKIND_IGNORE;
   return minus_one_ptid;
@@ -3360,8 +3361,8 @@ str_comma_list_concat_elem (std::string *list, const char *elem)
    OPT is removed from TARGET_OPTIONS.  */
 
 static void
-do_option (int *target_options, std::string *ret,
-	   int opt, const char *opt_str)
+do_option (target_wait_flags *target_options, std::string *ret,
+	   target_wait_flag opt, const char *opt_str)
 {
   if ((*target_options & opt) != 0)
     {
@@ -3373,7 +3374,7 @@ do_option (int *target_options, std::string *ret,
 /* See target.h.  */
 
 std::string
-target_options_to_string (int target_options)
+target_options_to_string (target_wait_flags target_options)
 {
   std::string ret;
 
diff --git a/gdb/target.h b/gdb/target.h
index 71d575f2917..0cb92fa8ea8 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -117,7 +117,7 @@ struct syscall
   };
 
 /* Return a pretty printed form of TARGET_OPTIONS.  */
-extern std::string target_options_to_string (int target_options);
+extern std::string target_options_to_string (target_wait_flags target_options);
 
 /* Possible types of events that the inferior handler will have to
    deal with.  */
@@ -488,7 +488,7 @@ struct target_ops
        current target.  inferior_ptid may also be null_ptid on
        entry.  */
     virtual ptid_t wait (ptid_t, struct target_waitstatus *,
-			 int TARGET_DEBUG_PRINTER (target_debug_print_options))
+			 target_wait_flags options)
       TARGET_DEFAULT_FUNC (default_target_wait);
     virtual void fetch_registers (struct regcache *, int)
       TARGET_DEFAULT_IGNORE ();
@@ -1456,7 +1456,7 @@ extern scoped_restore_tmpl<int> make_scoped_defer_target_commit_resume ();
 extern ptid_t default_target_wait (struct target_ops *ops,
 				   ptid_t ptid,
 				   struct target_waitstatus *status,
-				   int options);
+				   target_wait_flags options);
 
 /* Fetch at least register REGNO, or all regs if regno == -1.  No result.  */
 
diff --git a/gdb/target/target.h b/gdb/target/target.h
index a66459c2469..393272b3273 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -21,6 +21,8 @@
 #define TARGET_TARGET_H
 
 #include "target/waitstatus.h"
+#include "target/wait.h"
+
 /* This header is a stopgap until more code is shared.  */
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
@@ -84,7 +86,7 @@ extern void target_continue (ptid_t ptid, enum gdb_signal signal);
    options.  */
 
 extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
-			   int options);
+			   target_wait_flags options);
 
 /* The inferior process has died.  Do what is right.  */
 
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index d23b892700f..ee623bb7310 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -20,11 +20,18 @@
 #ifndef TARGET_WAIT_H
 #define TARGET_WAIT_H
 
+#include "gdbsupport/enum-flags.h"
+
 /* Options that can be passed to target_wait.  */
 
-/* Return immediately if there's no event already queued.  If this
-   options is not requested, target_wait blocks waiting for an
-   event.  */
-#define TARGET_WNOHANG 1
+enum target_wait_flag : unsigned
+{
+  /* Return immediately if there's no event already queued.  If this
+     options is not requested, target_wait blocks waiting for an
+     event.  */
+  TARGET_WNOHANG = 1,
+};
+
+DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
 #endif /* TARGET_WAIT_H */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 188a920cbb0..b13129336ab 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -310,7 +310,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
 
   void resume (ptid_t, int , enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -1774,7 +1774,7 @@ windows_nat_target::get_windows_debug_event (int pid,
 /* Wait for interesting events to occur in the target process.  */
 ptid_t
 windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			  int options)
+			  target_wait_flags options)
 {
   int pid = -1;
 
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 576c96e93b8..74e6f5cb03c 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,18 @@
+2020-09-16  Tom Tromey  <tromey@adacore.com>
+
+	* netbsd-low.h (class netbsd_process_target) <wait>: Update.
+	* netbsd-low.cc (netbsd_waitpid, netbsd_wait)
+	(netbsd_process_target::wait): Change type of target_options.
+	* win32-low.h (class win32_process_target) <wait>: Update.
+	* win32-low.cc (win32_process_target::wait): Update.
+	* target.h (class process_stratum_target) <wait>: Update.
+	(mywait): Update.
+	* target.cc (mywait, target_wait): Change type of "options".
+	* linux-low.h (class linux_process_target) <wait, wait_1>:
+	Update.
+	* linux-low.cc (linux_process_target::wait)
+	(linux_process_target::wait_1): Update.
+
 2020-09-15  Tom Tromey  <tromey@adacore.com>
 
 	* linux-x86-low.cc (xmltarget_i386_linux_no_xml)
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e45493339d2..70d5521d442 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -2948,7 +2948,7 @@ linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)
 
 ptid_t
 linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
-			      int target_options)
+			      target_wait_flags target_options)
 {
   client_state &cs = get_client_state ();
   int w;
@@ -3710,7 +3710,7 @@ async_file_mark (void)
 ptid_t
 linux_process_target::wait (ptid_t ptid,
 			    target_waitstatus *ourstatus,
-			    int target_options)
+			    target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 0ef659fb0f0..56c353319c2 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -157,7 +157,7 @@ class linux_process_target : public process_stratum_target
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-	       int options) override;
+	       target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
 
@@ -356,7 +356,7 @@ class linux_process_target : public process_stratum_target
 
   /* Wait for process, returns status.  */
   ptid_t wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
-		 int target_options);
+		 target_wait_flags target_options);
 
   /* Stop all lwps that aren't stopped yet, except EXCEPT, if not NULL.
      If SUSPEND, then also increase the suspend count of every LWP,
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 8b13b6741e9..3eb2c0f25f6 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -236,9 +236,11 @@ netbsd_store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
 /* Implement a safe wrapper around waitpid().  */
 
 static pid_t
-netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,
+		target_wait_flags target_options)
 {
   int status;
+  int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;
 
   pid_t pid
     = gdb::handle_eintr<int> (-1, ::waitpid, ptid.pid (), &status, options);
@@ -259,7 +261,7 @@ netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
 
 static ptid_t
 netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-	     int target_options)
+	     target_wait_flags target_options)
 {
   pid_t pid = netbsd_waitpid (ptid, ourstatus, target_options);
   ptid_t wptid = ptid_t (pid);
@@ -398,7 +400,7 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 
 ptid_t
 netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			     int target_options)
+			     target_wait_flags target_options)
 {
   while (true)
     {
diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h
index 3d2ec345a41..96ad6d92474 100644
--- a/gdbserver/netbsd-low.h
+++ b/gdbserver/netbsd-low.h
@@ -76,7 +76,7 @@ class netbsd_process_target : public process_stratum_target
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-	       int options) override;
+	       target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 87f62a0b555..921d26fcf79 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -160,8 +160,8 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 }
 
 ptid_t
-mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-	int connected_wait)
+mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	target_wait_flags options, int connected_wait)
 {
   ptid_t ret;
 
@@ -220,7 +220,8 @@ target_stop_and_wait (ptid_t ptid)
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+	     target_wait_flags options)
 {
   return the_target->wait (ptid, status, options);
 }
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 13f069f7729..c2245ebfe85 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -128,7 +128,7 @@ class process_stratum_target
      no child stop to report, return is
      null_ptid/TARGET_WAITKIND_IGNORE.  */
   virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
-		       int options) = 0;
+		       target_wait_flags options) = 0;
 
   /* Fetch registers from the inferior process.
 
@@ -663,8 +663,8 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
 #define target_supports_software_single_step() \
   the_target->supports_software_single_step ()
 
-ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-	       int connected_wait);
+ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	       target_wait_flags options, int connected_wait);
 
 /* Prepare to read or write memory from the inferior process.  See the
    corresponding process_stratum_target methods for more details.  */
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a11cc740925..9980986c739 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1610,7 +1610,7 @@ get_child_debug_event (DWORD *continue_status,
    Returns the signal which caused the process to stop. */
 ptid_t
 win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
-			    int options)
+			    target_wait_flags options)
 {
   if (cached_status.kind != TARGET_WAITKIND_IGNORE)
     {
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index f3b44776ae1..d4ad5d83d29 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -116,7 +116,7 @@ class win32_process_target : public process_stratum_target
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-	       int options) override;
+	       target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
Kamil Rytarowski Sept. 18, 2020, 6:18 p.m. | #5
On 16.09.2020 19:58, Tom Tromey wrote:
> Tom> Actually, I'm not yet -- the enum flags update pointed out a couple more

> Tom> spots to fix, and then while grepping to see if any other targets needed

> Tom> the same treatment, I found some other problems.  So, this patch did end

> Tom> up catching bugs after all :)

> 

> Here's the updated patch.

> 

> Kamil, could you check the NetBSD changes?

> 


I've checked this patch (on top of "6e25f88828f (upstream/master) bpf:
xBPF SDIV, SMOD instructions") and the NetBSD gdbserver still works.

> thanks,

> Tom

> 

> commit b9bbce754075de503869d44fcd7ee636888dfb7a

> Author: Tom Tromey <tromey@adacore.com>

> Date:   Wed Sep 16 09:51:59 2020 -0600

> 

>     Make target_wait options use enum flags

>     

>     This changes TARGET_WNOHANG to be a member of an enum, rather than a

>     define, and also adds a DEF_ENUM_FLAGS_TYPE for this type.  Then, it

>     changes target_wait and the various target wait methods to use this

>     type rather than "int".

>     

>     This didn't catch any bugs, but it seems like a decent cleanup

>     nevertheless.

>     

>     I did not change deprecated_target_wait_hook, since that's only used

>     out-of-tree (by Insight), and there didn't seem to be a need.

>     

>     I can't build some of these targets, so I modified them on a

>     best-effort basis.  I don't think this patch should go in before the

>     release branch is made.

>     

>     gdb/ChangeLog

>     2020-09-16  Tom Tromey  <tromey@adacore.com>

>     

>             * windows-nat.c (struct windows_nat_target) <wait>: Update.

>             (windows_nat_target::wait): Update.

>             * target/wait.h (enum target_wait_flag): New.  Use

>             DEF_ENUM_FLAGS_TYPE.

>             * target/target.h (target_wait): Change type of options.

>             * target.h (target_options_to_string, default_target_wait):

>             Update.

>             (struct target_ops) <wait>: Change type of options.

>             * target.c (target_wait, default_target_wait, do_option): Change

>             type of "options".

>             (target_options_to_string): Likewise.

>             * target-delegates.c: Rebuild.

>             * target-debug.h (target_debug_print_target_wait_flags): Rename

>             from target_debug_print_options.

>             * sol-thread.c (class sol_thread_target) <wait>: Update.

>             (sol_thread_target::wait): Update.

>             * rs6000-nat.c (class rs6000_nat_target) <wait>: Update.

>             (rs6000_nat_target::wait): Update.

>             * remote.c (class remote_target) <wait, wait_ns, wait_as>:

>             Update.

>             (remote_target::wait_ns, remote_target::wait_as): Change type of

>             "options".

>             (remote_target::wait): Update.

>             * remote-sim.c (struct gdbsim_target) <wait>: Update.

>             (gdbsim_target::wait): Update.

>             * record-full.c (class record_full_base_target) <wait>: Update.

>             (record_full_wait_1): Change type of "options".

>             (record_full_base_target::wait): Update.

>             * record-btrace.c (class record_btrace_target) <wait>: Update.

>             (record_btrace_target::wait): Update.

>             * ravenscar-thread.c (struct ravenscar_thread_target) <wait>:

>             Update.

>             (ravenscar_thread_target::wait): Update.

>             * procfs.c (class procfs_target) <wait>: Update.

>             (procfs_target::wait): Update.

>             * obsd-nat.h (class obsd_nat_target) <wait>: Update.

>             * obsd-nat.c (obsd_nat_target::wait): Update.

>             * nto-procfs.c (struct nto_procfs_target) <wait>: Update.

>             (nto_procfs_target::wait): Update.

>             * nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.

>             * nbsd-nat.c (nbsd_wait): Change type of "options".

>             (nbsd_nat_target::wait): Update.

>             * linux-thread-db.c (class thread_db_target) <wait>: Update.

>             (thread_db_target::wait): Update.

>             * linux-nat.h (class linux_nat_target) <wait>: Update.

>             * linux-nat.c (linux_nat_target::wait): Update.

>             (linux_nat_wait_1): Update.

>             * infrun.c (do_target_wait_1, do_target_wait): Change type of

>             "options".

>             * inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.

>             * inf-ptrace.c (inf_ptrace_target::wait): Update.

>             * go32-nat.c (struct go32_nat_target) <wait>: Update.

>             (go32_nat_target::wait): Update.

>             * gnu-nat.h (struct gnu_nat_target) <wait>: Update.

>             * gnu-nat.c (gnu_nat_target::wait): Update.

>             * fbsd-nat.h (class fbsd_nat_target) <wait>: Update.

>             * fbsd-nat.c (fbsd_nat_target::wait): Update.

>             * darwin-nat.h (class darwin_nat_target) <wait>: Update.

>             * darwin-nat.c (darwin_nat_target::wait): Update.

>             * bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.

>             (bsd_uthread_target::wait): Update.

>             * aix-thread.c (class aix_thread_target) <wait>: Update.

>             (aix_thread_target::wait): Update.

>     

>     gdbserver/ChangeLog

>     2020-09-16  Tom Tromey  <tromey@adacore.com>

>     

>             * netbsd-low.h (class netbsd_process_target) <wait>: Update.

>             * netbsd-low.cc (netbsd_waitpid, netbsd_wait)

>             (netbsd_process_target::wait): Change type of target_options.

>             * win32-low.h (class win32_process_target) <wait>: Update.

>             * win32-low.cc (win32_process_target::wait): Update.

>             * target.h (class process_stratum_target) <wait>: Update.

>             (mywait): Update.

>             * target.cc (mywait, target_wait): Change type of "options".

>             * linux-low.h (class linux_process_target) <wait, wait_1>:

>             Update.

>             * linux-low.cc (linux_process_target::wait)

>             (linux_process_target::wait_1): Update.

> 

> diff --git a/gdb/ChangeLog b/gdb/ChangeLog

> index 85c733e203f..091b5da65d2 100644

> --- a/gdb/ChangeLog

> +++ b/gdb/ChangeLog

> @@ -1,3 +1,69 @@

> +2020-09-16  Tom Tromey  <tromey@adacore.com>

> +

> +	* windows-nat.c (struct windows_nat_target) <wait>: Update.

> +	(windows_nat_target::wait): Update.

> +	* target/wait.h (enum target_wait_flag): New.  Use

> +	DEF_ENUM_FLAGS_TYPE.

> +	* target/target.h (target_wait): Change type of options.

> +	* target.h (target_options_to_string, default_target_wait):

> +	Update.

> +	(struct target_ops) <wait>: Change type of options.

> +	* target.c (target_wait, default_target_wait, do_option): Change

> +	type of "options".

> +	(target_options_to_string): Likewise.

> +	* target-delegates.c: Rebuild.

> +	* target-debug.h (target_debug_print_target_wait_flags): Rename

> +	from target_debug_print_options.

> +	* sol-thread.c (class sol_thread_target) <wait>: Update.

> +	(sol_thread_target::wait): Update.

> +	* rs6000-nat.c (class rs6000_nat_target) <wait>: Update.

> +	(rs6000_nat_target::wait): Update.

> +	* remote.c (class remote_target) <wait, wait_ns, wait_as>:

> +	Update.

> +	(remote_target::wait_ns, remote_target::wait_as): Change type of

> +	"options".

> +	(remote_target::wait): Update.

> +	* remote-sim.c (struct gdbsim_target) <wait>: Update.

> +	(gdbsim_target::wait): Update.

> +	* record-full.c (class record_full_base_target) <wait>: Update.

> +	(record_full_wait_1): Change type of "options".

> +	(record_full_base_target::wait): Update.

> +	* record-btrace.c (class record_btrace_target) <wait>: Update.

> +	(record_btrace_target::wait): Update.

> +	* ravenscar-thread.c (struct ravenscar_thread_target) <wait>:

> +	Update.

> +	(ravenscar_thread_target::wait): Update.

> +	* procfs.c (class procfs_target) <wait>: Update.

> +	(procfs_target::wait): Update.

> +	* obsd-nat.h (class obsd_nat_target) <wait>: Update.

> +	* obsd-nat.c (obsd_nat_target::wait): Update.

> +	* nto-procfs.c (struct nto_procfs_target) <wait>: Update.

> +	(nto_procfs_target::wait): Update.

> +	* nbsd-nat.h (struct nbsd_nat_target) <wait>: Update.

> +	* nbsd-nat.c (nbsd_wait): Change type of "options".

> +	(nbsd_nat_target::wait): Update.

> +	* linux-thread-db.c (class thread_db_target) <wait>: Update.

> +	(thread_db_target::wait): Update.

> +	* linux-nat.h (class linux_nat_target) <wait>: Update.

> +	* linux-nat.c (linux_nat_target::wait): Update.

> +	(linux_nat_wait_1): Update.

> +	* infrun.c (do_target_wait_1, do_target_wait): Change type of

> +	"options".

> +	* inf-ptrace.h (struct inf_ptrace_target) <wait>: Update.

> +	* inf-ptrace.c (inf_ptrace_target::wait): Update.

> +	* go32-nat.c (struct go32_nat_target) <wait>: Update.

> +	(go32_nat_target::wait): Update.

> +	* gnu-nat.h (struct gnu_nat_target) <wait>: Update.

> +	* gnu-nat.c (gnu_nat_target::wait): Update.

> +	* fbsd-nat.h (class fbsd_nat_target) <wait>: Update.

> +	* fbsd-nat.c (fbsd_nat_target::wait): Update.

> +	* darwin-nat.h (class darwin_nat_target) <wait>: Update.

> +	* darwin-nat.c (darwin_nat_target::wait): Update.

> +	* bsd-uthread.c (struct bsd_uthread_target) <wait>: Update.

> +	(bsd_uthread_target::wait): Update.

> +	* aix-thread.c (class aix_thread_target) <wait>: Update.

> +	(aix_thread_target::wait): Update.

> +

>  2020-09-16  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

>  

>  	* breakpoint.c (commands_command_1): Make a copy of the 'arg'

> diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c

> index 3963a08c840..ed30df5f3f6 100644

> --- a/gdb/aix-thread.c

> +++ b/gdb/aix-thread.c

> @@ -124,7 +124,7 @@ class aix_thread_target final : public target_ops

>  

>    void detach (inferior *, int) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -1077,7 +1077,7 @@ aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)

>  

>  ptid_t

>  aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    {

>      scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);

> diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c

> index 11ce0f439bf..144e8b920fa 100644

> --- a/gdb/bsd-uthread.c

> +++ b/gdb/bsd-uthread.c

> @@ -53,7 +53,7 @@ struct bsd_uthread_target final : public target_ops

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

>    bool thread_alive (ptid_t ptid) override;

> @@ -377,7 +377,7 @@ bsd_uthread_target::store_registers (struct regcache *regcache, int regnum)

>  

>  ptid_t

>  bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -			  int options)

> +			  target_wait_flags options)

>  {

>    enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());

>    CORE_ADDR addr;

> diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c

> index 0d7b028e39c..76d0fe87a85 100644

> --- a/gdb/darwin-nat.c

> +++ b/gdb/darwin-nat.c

> @@ -1285,7 +1285,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)

>  

>  ptid_t

>  darwin_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    return wait_1 (ptid, status);

>  }

> diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h

> index 86bb3389212..8a84cdc83dd 100644

> --- a/gdb/darwin-nat.h

> +++ b/gdb/darwin-nat.h

> @@ -86,7 +86,7 @@ class darwin_nat_target : public inf_child_target

>  

>    void detach (inferior *, int) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void mourn_inferior () override;

>  

> diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c

> index a355ebe4382..29c30623d09 100644

> --- a/gdb/fbsd-nat.c

> +++ b/gdb/fbsd-nat.c

> @@ -1295,7 +1295,7 @@ fbsd_handle_debug_trap (fbsd_nat_target *target, ptid_t ptid,

>  

>  ptid_t

>  fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -		       int target_options)

> +		       target_wait_flags target_options)

>  {

>    ptid_t wptid;

>  

> diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h

> index 1b1e043dae7..58bea352c88 100644

> --- a/gdb/fbsd-nat.h

> +++ b/gdb/fbsd-nat.h

> @@ -70,7 +70,7 @@ class fbsd_nat_target : public inf_ptrace_target

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void post_startup_inferior (ptid_t) override;

>    void post_attach (int) override;

> diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c

> index 3cee06dc4db..32af0bf3192 100644

> --- a/gdb/gnu-nat.c

> +++ b/gdb/gnu-nat.c

> @@ -1436,7 +1436,7 @@ static struct inf *waiting_inf;

>  

>  ptid_t

>  gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -		      int options)

> +		      target_wait_flags options)

>  {

>    struct msg

>      {

> diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h

> index 0e7ff8d5aa9..28c08108265 100644

> --- a/gdb/gnu-nat.h

> +++ b/gdb/gnu-nat.h

> @@ -124,7 +124,7 @@ struct gnu_nat_target : public inf_child_target

>    void detach (inferior *, int) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    enum target_xfer_status xfer_partial (enum target_object object,

>  					const char *annex,

>  					gdb_byte *readbuf,

> diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c

> index 8ffd28985ab..4ea2dd8714f 100644

> --- a/gdb/go32-nat.c

> +++ b/gdb/go32-nat.c

> @@ -342,7 +342,7 @@ struct go32_nat_target final : public x86_nat_target<inf_child_target>

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -419,7 +419,7 @@ static char child_cwd[FILENAME_MAX];

>  

>  ptid_t

>  go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -		       int options)

> +		       target_wait_flags options)

>  {

>    int i;

>    unsigned char saved_opcode;

> diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c

> index ae0b0f7ff0d..d5a062163c7 100644

> --- a/gdb/inf-ptrace.c

> +++ b/gdb/inf-ptrace.c

> @@ -316,7 +316,7 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)

>  

>  ptid_t

>  inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    pid_t pid;

>    int status, save_errno;

> diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h

> index e2079faee3d..d3c59e6d46a 100644

> --- a/gdb/inf-ptrace.h

> +++ b/gdb/inf-ptrace.h

> @@ -35,7 +35,7 @@ struct inf_ptrace_target : public inf_child_target

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void files_info () override;

>  

> diff --git a/gdb/infrun.c b/gdb/infrun.c

> index 5773fd03951..3e49cb4c641 100644

> --- a/gdb/infrun.c

> +++ b/gdb/infrun.c

> @@ -3423,7 +3423,7 @@ random_pending_event_thread (inferior *inf, ptid_t waiton_ptid)

>  

>  static ptid_t

>  do_target_wait_1 (inferior *inf, ptid_t ptid,

> -		  target_waitstatus *status, int options)

> +		  target_waitstatus *status, target_wait_flags options)

>  {

>    ptid_t event_ptid;

>    struct thread_info *tp;

> @@ -3546,7 +3546,8 @@ do_target_wait_1 (inferior *inf, ptid_t ptid,

>     more events.  Polls for events from all inferiors/targets.  */

>  

>  static bool

> -do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, int options)

> +do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,

> +		target_wait_flags options)

>  {

>    int num_inferiors = 0;

>    int random_selector;

> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c

> index 4f53670da5e..44b59485d7b 100644

> --- a/gdb/linux-nat.c

> +++ b/gdb/linux-nat.c

> @@ -3131,7 +3131,7 @@ filter_exit_event (struct lwp_info *event_child,

>  

>  static ptid_t

>  linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus,

> -		  int target_options)

> +		  target_wait_flags target_options)

>  {

>    sigset_t prev_mask;

>    enum resume_kind last_resume_kind;

> @@ -3411,7 +3411,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)

>  

>  ptid_t

>  linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			int target_options)

> +			target_wait_flags target_options)

>  {

>    ptid_t event_ptid;

>  

> diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h

> index 1af9e830c83..caaeff85207 100644

> --- a/gdb/linux-nat.h

> +++ b/gdb/linux-nat.h

> @@ -46,7 +46,7 @@ class linux_nat_target : public inf_ptrace_target

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void pass_signals (gdb::array_view<const unsigned char>) override;

>  

> diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c

> index b3cda05cd6e..fbddfed3c59 100644

> --- a/gdb/linux-thread-db.c

> +++ b/gdb/linux-thread-db.c

> @@ -92,7 +92,7 @@ class thread_db_target final : public target_ops

>    strata stratum () const override { return thread_stratum; }

>  

>    void detach (inferior *, int) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

>    void mourn_inferior () override;

>    void update_thread_list () override;

> @@ -1379,7 +1379,7 @@ thread_db_target::detach (inferior *inf, int from_tty)

>  

>  ptid_t

>  thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			int options)

> +			target_wait_flags options)

>  {

>    struct thread_db_info *info;

>  

> diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c

> index b12d86e8256..7a07fbf6d8a 100644

> --- a/gdb/nbsd-nat.c

> +++ b/gdb/nbsd-nat.c

> @@ -540,7 +540,8 @@ nbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)

>  /* Implement a safe wrapper around waitpid().  */

>  

>  static pid_t

> -nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)

> +nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> +	   target_wait_flags options)

>  {

>    pid_t pid;

>    int status;

> @@ -569,7 +570,7 @@ nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)

>  

>  ptid_t

>  nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -		       int target_options)

> +		       target_wait_flags target_options)

>  {

>    pid_t pid = nbsd_wait (ptid, ourstatus, target_options);

>    ptid_t wptid = ptid_t (pid);

> diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h

> index b09d5b1e3bb..7461667cefb 100644

> --- a/gdb/nbsd-nat.h

> +++ b/gdb/nbsd-nat.h

> @@ -41,7 +41,7 @@ struct nbsd_nat_target : public inf_ptrace_target

>    bool info_proc (const char *, enum info_proc_what) override;

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    int insert_exec_catchpoint (int pid) override;

>    int remove_exec_catchpoint (int pid) override;

>    int set_syscall_catchpoint (int pid, bool needed, int any_count,

> diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c

> index 91d2cc5914d..ef1615df3e2 100644

> --- a/gdb/nto-procfs.c

> +++ b/gdb/nto-procfs.c

> @@ -69,7 +69,7 @@ struct nto_procfs_target : public inf_child_target

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -795,7 +795,7 @@ nto_handle_sigint (int signo)

>  

>  sptid_t

>  nto_procfs_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    sigset_t set;

>    siginfo_t info;

> diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c

> index 6667a0add7f..310e2b72fcd 100644

> --- a/gdb/obsd-nat.c

> +++ b/gdb/obsd-nat.c

> @@ -74,7 +74,7 @@ obsd_nat_target::update_thread_list ()

>  

>  ptid_t

>  obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -		       int options)

> +		       target_wait_flags options)

>  {

>    pid_t pid;

>    int status, save_errno;

> diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h

> index e5962004d4c..3d3e50c57ec 100644

> --- a/gdb/obsd-nat.h

> +++ b/gdb/obsd-nat.h

> @@ -27,7 +27,7 @@ class obsd_nat_target : public inf_ptrace_target

>    /* Override some methods to support threads.  */

>    std::string pid_to_str (ptid_t) override;

>    void update_thread_list () override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>  #ifdef PT_GET_PROCESS_STATE

>    bool follow_fork (bool, bool) override;

> diff --git a/gdb/procfs.c b/gdb/procfs.c

> index b628c2d0355..a06f0357ec3 100644

> --- a/gdb/procfs.c

> +++ b/gdb/procfs.c

> @@ -105,7 +105,7 @@ class procfs_target final : public inf_child_target

>    void detach (inferior *inf, int) override;

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -2033,7 +2033,7 @@ procfs_target::store_registers (struct regcache *regcache, int regnum)

>  

>  ptid_t

>  procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -		     int options)

> +		     target_wait_flags options)

>  {

>    /* First cut: loosely based on original version 2.1.  */

>    procinfo *pi;

> diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c

> index 387ebcb32e9..cc94ff8e1ea 100644

> --- a/gdb/ravenscar-thread.c

> +++ b/gdb/ravenscar-thread.c

> @@ -87,7 +87,7 @@ struct ravenscar_thread_target final : public target_ops

>  

>    strata stratum () const override { return thread_stratum; }

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

>  

>    void fetch_registers (struct regcache *, int) override;

> @@ -385,7 +385,7 @@ ravenscar_thread_target::resume (ptid_t ptid, int step,

>  ptid_t

>  ravenscar_thread_target::wait (ptid_t ptid,

>  			       struct target_waitstatus *status,

> -			       int options)

> +			       target_wait_flags options)

>  {

>    process_stratum_target *beneath

>      = as_process_stratum_target (this->beneath ());

> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c

> index fd0d13fb258..c1430e9b533 100644

> --- a/gdb/record-btrace.c

> +++ b/gdb/record-btrace.c

> @@ -118,7 +118,7 @@ class record_btrace_target final : public target_ops

>  

>    void commit_resume () override;

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void stop (ptid_t) override;

>    void update_thread_list () override;

> @@ -2537,12 +2537,13 @@ record_btrace_maybe_mark_async_event

>  

>  ptid_t

>  record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -			    int options)

> +			    target_wait_flags options)

>  {

>    std::vector<thread_info *> moving;

>    std::vector<thread_info *> no_history;

>  

> -  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);

> +  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),

> +	 (unsigned) options);

>  

>    /* As long as we're not replaying, just forward the request.  */

>    if ((::execution_direction != EXEC_REVERSE)

> diff --git a/gdb/record-full.c b/gdb/record-full.c

> index 1d8f1930a5b..1c8b791ffb9 100644

> --- a/gdb/record-full.c

> +++ b/gdb/record-full.c

> @@ -225,7 +225,7 @@ class record_full_base_target : public target_ops

>  

>    void close () override;

>    void async (int) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    bool stopped_by_watchpoint () override;

>    bool stopped_data_address (CORE_ADDR *) override;

>  

> @@ -1155,7 +1155,7 @@ record_full_sig_handler (int signo)

>  static ptid_t

>  record_full_wait_1 (struct target_ops *ops,

>  		    ptid_t ptid, struct target_waitstatus *status,

> -		    int options)

> +		    target_wait_flags options)

>  {

>    scoped_restore restore_operation_disable

>      = record_full_gdb_operation_disable_set ();

> @@ -1468,7 +1468,7 @@ record_full_wait_1 (struct target_ops *ops,

>  

>  ptid_t

>  record_full_base_target::wait (ptid_t ptid, struct target_waitstatus *status,

> -			       int options)

> +			       target_wait_flags options)

>  {

>    ptid_t return_ptid;

>  

> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c

> index 9af6486bca8..9e1c2b151c8 100644

> --- a/gdb/remote-sim.c

> +++ b/gdb/remote-sim.c

> @@ -131,7 +131,7 @@ struct gdbsim_target final

>    void detach (inferior *inf, int) override;

>  

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -927,7 +927,8 @@ gdbsim_cntrl_c (int signo)

>  }

>  

>  ptid_t

> -gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)

> +gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status,

> +		     target_wait_flags options)

>  {

>    struct sim_inferior_data *sim_data;

>    static sighandler_t prev_sigint;

> diff --git a/gdb/remote.c b/gdb/remote.c

> index 59075cb09f2..5fc80ebc8f7 100644

> --- a/gdb/remote.c

> +++ b/gdb/remote.c

> @@ -422,7 +422,7 @@ class remote_target : public process_stratum_target

>  

>    void commit_resume () override;

>    void resume (ptid_t, int, enum gdb_signal) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -739,9 +739,9 @@ class remote_target : public process_stratum_target

>    void add_current_inferior_and_thread (char *wait_status);

>  

>    ptid_t wait_ns (ptid_t ptid, struct target_waitstatus *status,

> -		  int options);

> +		  target_wait_flags options);

>    ptid_t wait_as (ptid_t ptid, target_waitstatus *status,

> -		  int options);

> +		  target_wait_flags options);

>  

>    ptid_t process_stop_reply (struct stop_reply *stop_reply,

>  			     target_waitstatus *status);

> @@ -7771,7 +7771,8 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,

>  /* The non-stop mode version of target_wait.  */

>  

>  ptid_t

> -remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)

> +remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status,

> +			target_wait_flags options)

>  {

>    struct remote_state *rs = get_remote_state ();

>    struct stop_reply *stop_reply;

> @@ -7839,7 +7840,8 @@ first_remote_resumed_thread (remote_target *target)

>     STATUS just as `wait' would.  */

>  

>  ptid_t

> -remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)

> +remote_target::wait_as (ptid_t ptid, target_waitstatus *status,

> +			target_wait_flags options)

>  {

>    struct remote_state *rs = get_remote_state ();

>    ptid_t event_ptid = null_ptid;

> @@ -7992,7 +7994,8 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)

>     STATUS just as `wait' would.  */

>  

>  ptid_t

> -remote_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)

> +remote_target::wait (ptid_t ptid, struct target_waitstatus *status,

> +		     target_wait_flags options)

>  {

>    ptid_t event_ptid;

>  

> diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c

> index 654e06e3e4b..29154cfc2e7 100644

> --- a/gdb/rs6000-nat.c

> +++ b/gdb/rs6000-nat.c

> @@ -90,7 +90,7 @@ class rs6000_nat_target final : public inf_ptrace_target

>    void create_inferior (const char *, const std::string &,

>  			char **, int) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>  private:

>    enum target_xfer_status

> @@ -495,7 +495,7 @@ rs6000_nat_target::xfer_partial (enum target_object object,

>  

>  ptid_t

>  rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    pid_t pid;

>    int status, save_errno;

> diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c

> index a24d51d1db2..bb33a20ea52 100644

> --- a/gdb/sol-thread.c

> +++ b/gdb/sol-thread.c

> @@ -84,7 +84,7 @@ class sol_thread_target final : public target_ops

>    strata stratum () const override { return thread_stratum; }

>  

>    void detach (inferior *, int) override;

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>    void resume (ptid_t, int, enum gdb_signal) override;

>    void mourn_inferior () override;

>    std::string pid_to_str (ptid_t) override;

> @@ -425,7 +425,7 @@ sol_thread_target::resume (ptid_t ptid, int step, enum gdb_signal signo)

>  

>  ptid_t

>  sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			 int options)

> +			 target_wait_flags options)

>  {

>    if (ptid.pid () != -1)

>      {

> diff --git a/gdb/target-debug.h b/gdb/target-debug.h

> index 46d17a359d9..1b2feb2c7fb 100644

> --- a/gdb/target-debug.h

> +++ b/gdb/target-debug.h

> @@ -205,7 +205,7 @@ target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)

>    target_debug_do_print ((X) ? "step" : "continue")

>  

>  static void

> -target_debug_print_options (int options)

> +target_debug_print_target_wait_flags (target_wait_flags options)

>  {

>    std::string str = target_options_to_string (options);

>  

> diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c

> index 15f441edf28..c0968e2040e 100644

> --- a/gdb/target-delegates.c

> +++ b/gdb/target-delegates.c

> @@ -15,7 +15,7 @@ struct dummy_target : public target_ops

>    void disconnect (const char *arg0, int arg1) override;

>    void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;

>    void commit_resume () override;

> -  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;

> +  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;

>    void fetch_registers (struct regcache *arg0, int arg1) override;

>    void store_registers (struct regcache *arg0, int arg1) override;

>    void prepare_to_store (struct regcache *arg0) override;

> @@ -186,7 +186,7 @@ struct debug_target : public target_ops

>    void disconnect (const char *arg0, int arg1) override;

>    void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;

>    void commit_resume () override;

> -  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;

> +  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;

>    void fetch_registers (struct regcache *arg0, int arg1) override;

>    void store_registers (struct regcache *arg0, int arg1) override;

>    void prepare_to_store (struct regcache *arg0) override;

> @@ -461,19 +461,19 @@ debug_target::commit_resume ()

>  }

>  

>  ptid_t

> -target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)

> +target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)

>  {

>    return this->beneath ()->wait (arg0, arg1, arg2);

>  }

>  

>  ptid_t

> -dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)

> +dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)

>  {

>    return default_target_wait (this, arg0, arg1, arg2);

>  }

>  

>  ptid_t

> -debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)

> +debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)

>  {

>    ptid_t result;

>    fprintf_unfiltered (gdb_stdlog, "-> %s->wait (...)\n", this->beneath ()->shortname ());

> @@ -483,7 +483,7 @@ debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)

>    fputs_unfiltered (", ", gdb_stdlog);

>    target_debug_print_struct_target_waitstatus_p (arg1);

>    fputs_unfiltered (", ", gdb_stdlog);

> -  target_debug_print_options (arg2);

> +  target_debug_print_target_wait_flags (arg2);

>    fputs_unfiltered (") = ", gdb_stdlog);

>    target_debug_print_ptid_t (result);

>    fputs_unfiltered ("\n", gdb_stdlog);

> diff --git a/gdb/target.c b/gdb/target.c

> index 58189e62024..9fd6b4ba9e1 100644

> --- a/gdb/target.c

> +++ b/gdb/target.c

> @@ -2007,7 +2007,8 @@ target_disconnect (const char *args, int from_tty)

>  /* See target/target.h.  */

>  

>  ptid_t

> -target_wait (ptid_t ptid, struct target_waitstatus *status, int options)

> +target_wait (ptid_t ptid, struct target_waitstatus *status,

> +	     target_wait_flags options)

>  {

>    return current_top_target ()->wait (ptid, status, options);

>  }

> @@ -2017,7 +2018,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)

>  ptid_t

>  default_target_wait (struct target_ops *ops,

>  		     ptid_t ptid, struct target_waitstatus *status,

> -		     int options)

> +		     target_wait_flags options)

>  {

>    status->kind = TARGET_WAITKIND_IGNORE;

>    return minus_one_ptid;

> @@ -3360,8 +3361,8 @@ str_comma_list_concat_elem (std::string *list, const char *elem)

>     OPT is removed from TARGET_OPTIONS.  */

>  

>  static void

> -do_option (int *target_options, std::string *ret,

> -	   int opt, const char *opt_str)

> +do_option (target_wait_flags *target_options, std::string *ret,

> +	   target_wait_flag opt, const char *opt_str)

>  {

>    if ((*target_options & opt) != 0)

>      {

> @@ -3373,7 +3374,7 @@ do_option (int *target_options, std::string *ret,

>  /* See target.h.  */

>  

>  std::string

> -target_options_to_string (int target_options)

> +target_options_to_string (target_wait_flags target_options)

>  {

>    std::string ret;

>  

> diff --git a/gdb/target.h b/gdb/target.h

> index 71d575f2917..0cb92fa8ea8 100644

> --- a/gdb/target.h

> +++ b/gdb/target.h

> @@ -117,7 +117,7 @@ struct syscall

>    };

>  

>  /* Return a pretty printed form of TARGET_OPTIONS.  */

> -extern std::string target_options_to_string (int target_options);

> +extern std::string target_options_to_string (target_wait_flags target_options);

>  

>  /* Possible types of events that the inferior handler will have to

>     deal with.  */

> @@ -488,7 +488,7 @@ struct target_ops

>         current target.  inferior_ptid may also be null_ptid on

>         entry.  */

>      virtual ptid_t wait (ptid_t, struct target_waitstatus *,

> -			 int TARGET_DEBUG_PRINTER (target_debug_print_options))

> +			 target_wait_flags options)

>        TARGET_DEFAULT_FUNC (default_target_wait);

>      virtual void fetch_registers (struct regcache *, int)

>        TARGET_DEFAULT_IGNORE ();

> @@ -1456,7 +1456,7 @@ extern scoped_restore_tmpl<int> make_scoped_defer_target_commit_resume ();

>  extern ptid_t default_target_wait (struct target_ops *ops,

>  				   ptid_t ptid,

>  				   struct target_waitstatus *status,

> -				   int options);

> +				   target_wait_flags options);

>  

>  /* Fetch at least register REGNO, or all regs if regno == -1.  No result.  */

>  

> diff --git a/gdb/target/target.h b/gdb/target/target.h

> index a66459c2469..393272b3273 100644

> --- a/gdb/target/target.h

> +++ b/gdb/target/target.h

> @@ -21,6 +21,8 @@

>  #define TARGET_TARGET_H

>  

>  #include "target/waitstatus.h"

> +#include "target/wait.h"

> +

>  /* This header is a stopgap until more code is shared.  */

>  

>  /* Read LEN bytes of target memory at address MEMADDR, placing the

> @@ -84,7 +86,7 @@ extern void target_continue (ptid_t ptid, enum gdb_signal signal);

>     options.  */

>  

>  extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,

> -			   int options);

> +			   target_wait_flags options);

>  

>  /* The inferior process has died.  Do what is right.  */

>  

> diff --git a/gdb/target/wait.h b/gdb/target/wait.h

> index d23b892700f..ee623bb7310 100644

> --- a/gdb/target/wait.h

> +++ b/gdb/target/wait.h

> @@ -20,11 +20,18 @@

>  #ifndef TARGET_WAIT_H

>  #define TARGET_WAIT_H

>  

> +#include "gdbsupport/enum-flags.h"

> +

>  /* Options that can be passed to target_wait.  */

>  

> -/* Return immediately if there's no event already queued.  If this

> -   options is not requested, target_wait blocks waiting for an

> -   event.  */

> -#define TARGET_WNOHANG 1

> +enum target_wait_flag : unsigned

> +{

> +  /* Return immediately if there's no event already queued.  If this

> +     options is not requested, target_wait blocks waiting for an

> +     event.  */

> +  TARGET_WNOHANG = 1,

> +};

> +

> +DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);

>  

>  #endif /* TARGET_WAIT_H */

> diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c

> index 188a920cbb0..b13129336ab 100644

> --- a/gdb/windows-nat.c

> +++ b/gdb/windows-nat.c

> @@ -310,7 +310,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>

>  

>    void resume (ptid_t, int , enum gdb_signal) override;

>  

> -  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;

> +  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;

>  

>    void fetch_registers (struct regcache *, int) override;

>    void store_registers (struct regcache *, int) override;

> @@ -1774,7 +1774,7 @@ windows_nat_target::get_windows_debug_event (int pid,

>  /* Wait for interesting events to occur in the target process.  */

>  ptid_t

>  windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			  int options)

> +			  target_wait_flags options)

>  {

>    int pid = -1;

>  

> diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog

> index 576c96e93b8..74e6f5cb03c 100644

> --- a/gdbserver/ChangeLog

> +++ b/gdbserver/ChangeLog

> @@ -1,3 +1,18 @@

> +2020-09-16  Tom Tromey  <tromey@adacore.com>

> +

> +	* netbsd-low.h (class netbsd_process_target) <wait>: Update.

> +	* netbsd-low.cc (netbsd_waitpid, netbsd_wait)

> +	(netbsd_process_target::wait): Change type of target_options.

> +	* win32-low.h (class win32_process_target) <wait>: Update.

> +	* win32-low.cc (win32_process_target::wait): Update.

> +	* target.h (class process_stratum_target) <wait>: Update.

> +	(mywait): Update.

> +	* target.cc (mywait, target_wait): Change type of "options".

> +	* linux-low.h (class linux_process_target) <wait, wait_1>:

> +	Update.

> +	* linux-low.cc (linux_process_target::wait)

> +	(linux_process_target::wait_1): Update.

> +

>  2020-09-15  Tom Tromey  <tromey@adacore.com>

>  

>  	* linux-x86-low.cc (xmltarget_i386_linux_no_xml)

> diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc

> index e45493339d2..70d5521d442 100644

> --- a/gdbserver/linux-low.cc

> +++ b/gdbserver/linux-low.cc

> @@ -2948,7 +2948,7 @@ linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)

>  

>  ptid_t

>  linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,

> -			      int target_options)

> +			      target_wait_flags target_options)

>  {

>    client_state &cs = get_client_state ();

>    int w;

> @@ -3710,7 +3710,7 @@ async_file_mark (void)

>  ptid_t

>  linux_process_target::wait (ptid_t ptid,

>  			    target_waitstatus *ourstatus,

> -			    int target_options)

> +			    target_wait_flags target_options)

>  {

>    ptid_t event_ptid;

>  

> diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h

> index 0ef659fb0f0..56c353319c2 100644

> --- a/gdbserver/linux-low.h

> +++ b/gdbserver/linux-low.h

> @@ -157,7 +157,7 @@ class linux_process_target : public process_stratum_target

>    void resume (thread_resume *resume_info, size_t n) override;

>  

>    ptid_t wait (ptid_t ptid, target_waitstatus *status,

> -	       int options) override;

> +	       target_wait_flags options) override;

>  

>    void fetch_registers (regcache *regcache, int regno) override;

>  

> @@ -356,7 +356,7 @@ class linux_process_target : public process_stratum_target

>  

>    /* Wait for process, returns status.  */

>    ptid_t wait_1 (ptid_t ptid, target_waitstatus *ourstatus,

> -		 int target_options);

> +		 target_wait_flags target_options);

>  

>    /* Stop all lwps that aren't stopped yet, except EXCEPT, if not NULL.

>       If SUSPEND, then also increase the suspend count of every LWP,

> diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc

> index 8b13b6741e9..3eb2c0f25f6 100644

> --- a/gdbserver/netbsd-low.cc

> +++ b/gdbserver/netbsd-low.cc

> @@ -236,9 +236,11 @@ netbsd_store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)

>  /* Implement a safe wrapper around waitpid().  */

>  

>  static pid_t

> -netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)

> +netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,

> +		target_wait_flags target_options)

>  {

>    int status;

> +  int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;

>  

>    pid_t pid

>      = gdb::handle_eintr<int> (-1, ::waitpid, ptid.pid (), &status, options);

> @@ -259,7 +261,7 @@ netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)

>  

>  static ptid_t

>  netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -	     int target_options)

> +	     target_wait_flags target_options)

>  {

>    pid_t pid = netbsd_waitpid (ptid, ourstatus, target_options);

>    ptid_t wptid = ptid_t (pid);

> @@ -398,7 +400,7 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,

>  

>  ptid_t

>  netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,

> -			     int target_options)

> +			     target_wait_flags target_options)

>  {

>    while (true)

>      {

> diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h

> index 3d2ec345a41..96ad6d92474 100644

> --- a/gdbserver/netbsd-low.h

> +++ b/gdbserver/netbsd-low.h

> @@ -76,7 +76,7 @@ class netbsd_process_target : public process_stratum_target

>    void resume (thread_resume *resume_info, size_t n) override;

>  

>    ptid_t wait (ptid_t ptid, target_waitstatus *status,

> -	       int options) override;

> +	       target_wait_flags options) override;

>  

>    void fetch_registers (regcache *regcache, int regno) override;

>  

> diff --git a/gdbserver/target.cc b/gdbserver/target.cc

> index 87f62a0b555..921d26fcf79 100644

> --- a/gdbserver/target.cc

> +++ b/gdbserver/target.cc

> @@ -160,8 +160,8 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,

>  }

>  

>  ptid_t

> -mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,

> -	int connected_wait)

> +mywait (ptid_t ptid, struct target_waitstatus *ourstatus,

> +	target_wait_flags options, int connected_wait)

>  {

>    ptid_t ret;

>  

> @@ -220,7 +220,8 @@ target_stop_and_wait (ptid_t ptid)

>  /* See target/target.h.  */

>  

>  ptid_t

> -target_wait (ptid_t ptid, struct target_waitstatus *status, int options)

> +target_wait (ptid_t ptid, struct target_waitstatus *status,

> +	     target_wait_flags options)

>  {

>    return the_target->wait (ptid, status, options);

>  }

> diff --git a/gdbserver/target.h b/gdbserver/target.h

> index 13f069f7729..c2245ebfe85 100644

> --- a/gdbserver/target.h

> +++ b/gdbserver/target.h

> @@ -128,7 +128,7 @@ class process_stratum_target

>       no child stop to report, return is

>       null_ptid/TARGET_WAITKIND_IGNORE.  */

>    virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,

> -		       int options) = 0;

> +		       target_wait_flags options) = 0;

>  

>    /* Fetch registers from the inferior process.

>  

> @@ -663,8 +663,8 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,

>  #define target_supports_software_single_step() \

>    the_target->supports_software_single_step ()

>  

> -ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,

> -	       int connected_wait);

> +ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus,

> +	       target_wait_flags options, int connected_wait);

>  

>  /* Prepare to read or write memory from the inferior process.  See the

>     corresponding process_stratum_target methods for more details.  */

> diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc

> index a11cc740925..9980986c739 100644

> --- a/gdbserver/win32-low.cc

> +++ b/gdbserver/win32-low.cc

> @@ -1610,7 +1610,7 @@ get_child_debug_event (DWORD *continue_status,

>     Returns the signal which caused the process to stop. */

>  ptid_t

>  win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,

> -			    int options)

> +			    target_wait_flags options)

>  {

>    if (cached_status.kind != TARGET_WAITKIND_IGNORE)

>      {

> diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h

> index f3b44776ae1..d4ad5d83d29 100644

> --- a/gdbserver/win32-low.h

> +++ b/gdbserver/win32-low.h

> @@ -116,7 +116,7 @@ class win32_process_target : public process_stratum_target

>    void resume (thread_resume *resume_info, size_t n) override;

>  

>    ptid_t wait (ptid_t ptid, target_waitstatus *status,

> -	       int options) override;

> +	       target_wait_flags options) override;

>  

>    void fetch_registers (regcache *regcache, int regno) override;

>  

>
Tom Tromey Sept. 18, 2020, 8:20 p.m. | #6
>>>>> "Kamil" == Kamil Rytarowski <kamil@netbsd.org> writes:


>> Here's the updated patch.

>> 

>> Kamil, could you check the NetBSD changes?


Kamil> I've checked this patch (on top of "6e25f88828f (upstream/master) bpf:
Kamil> xBPF SDIV, SMOD instructions") and the NetBSD gdbserver still works.

Thank you.  I'm going to check this in soon.

As before, it's possible this breaks some target that I can't build.
If this happens, send me the errors and I will correct them.

Tom

Patch

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 3963a08c840..ed30df5f3f6 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -124,7 +124,7 @@  class aix_thread_target final : public target_ops
 
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -1077,7 +1077,7 @@  aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
 ptid_t
 aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			 int options)
+			 target_wait_flags options)
 {
   {
     scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 15d538c16db..d21ee7063c0 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -53,7 +53,7 @@  struct bsd_uthread_target final : public target_ops
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   bool thread_alive (ptid_t ptid) override;
@@ -377,7 +377,7 @@  bsd_uthread_target::store_registers (struct regcache *regcache, int regnum)
 
 ptid_t
 bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			  int options)
+			  target_wait_flags options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   CORE_ADDR addr;
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0d7b028e39c..76d0fe87a85 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1285,7 +1285,7 @@  darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
 
 ptid_t
 darwin_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			 int options)
+			 target_wait_flags options)
 {
   return wait_1 (ptid, status);
 }
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index 86bb3389212..8a84cdc83dd 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -86,7 +86,7 @@  class darwin_nat_target : public inf_child_target
 
   void detach (inferior *, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void mourn_inferior () override;
 
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index a355ebe4382..29c30623d09 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1295,7 +1295,7 @@  fbsd_handle_debug_trap (fbsd_nat_target *target, ptid_t ptid,
 
 ptid_t
 fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int target_options)
+		       target_wait_flags target_options)
 {
   ptid_t wptid;
 
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index b5a62b9212e..de952ef9306 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -64,7 +64,7 @@  class fbsd_nat_target : public inf_ptrace_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void post_startup_inferior (ptid_t) override;
   void post_attach (int) override;
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 3cee06dc4db..32af0bf3192 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1436,7 +1436,7 @@  static struct inf *waiting_inf;
 
 ptid_t
 gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		      int options)
+		      target_wait_flags options)
 {
   struct msg
     {
diff --git a/gdb/gnu-nat.h b/gdb/gnu-nat.h
index 0e7ff8d5aa9..28c08108265 100644
--- a/gdb/gnu-nat.h
+++ b/gdb/gnu-nat.h
@@ -124,7 +124,7 @@  struct gnu_nat_target : public inf_child_target
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   enum target_xfer_status xfer_partial (enum target_object object,
 					const char *annex,
 					gdb_byte *readbuf,
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 8ffd28985ab..4ea2dd8714f 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -342,7 +342,7 @@  struct go32_nat_target final : public x86_nat_target<inf_child_target>
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -419,7 +419,7 @@  static char child_cwd[FILENAME_MAX];
 
 ptid_t
 go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		       int options)
+		       target_wait_flags options)
 {
   int i;
   unsigned char saved_opcode;
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index ae0b0f7ff0d..d5a062163c7 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -316,7 +316,7 @@  inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 
 ptid_t
 inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
index e2079faee3d..d3c59e6d46a 100644
--- a/gdb/inf-ptrace.h
+++ b/gdb/inf-ptrace.h
@@ -35,7 +35,7 @@  struct inf_ptrace_target : public inf_child_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void files_info () override;
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index ca850f81c43..1c1462da2f5 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3469,7 +3469,7 @@  random_pending_event_thread (inferior *inf, ptid_t waiton_ptid)
 
 static ptid_t
 do_target_wait_1 (inferior *inf, ptid_t ptid,
-		  target_waitstatus *status, int options)
+		  target_waitstatus *status, target_wait_flags options)
 {
   ptid_t event_ptid;
   struct thread_info *tp;
@@ -3606,7 +3606,8 @@  do_target_wait_1 (inferior *inf, ptid_t ptid,
    more events.  Polls for events from all inferiors/targets.  */
 
 static bool
-do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, int options)
+do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,
+		target_wait_flags options)
 {
   int num_inferiors = 0;
   int random_selector;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 20b03bc2ba9..3eb8d9b1c1a 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3567,7 +3567,7 @@  resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
 
 ptid_t
 linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			int target_options)
+			target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 1af9e830c83..caaeff85207 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -46,7 +46,7 @@  class linux_nat_target : public inf_ptrace_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void pass_signals (gdb::array_view<const unsigned char>) override;
 
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index b3cda05cd6e..fbddfed3c59 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -92,7 +92,7 @@  class thread_db_target final : public target_ops
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   void update_thread_list () override;
@@ -1379,7 +1379,7 @@  thread_db_target::detach (inferior *inf, int from_tty)
 
 ptid_t
 thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			int options)
+			target_wait_flags options)
 {
   struct thread_db_info *info;
 
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index a9405ebf862..fedf4bd3c04 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -647,7 +647,8 @@  nbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 /* Implement a safe wrapper around waitpid().  */
 
 static pid_t
-nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	   target_wait_flags options)
 {
   pid_t pid;
   int status;
@@ -676,7 +677,7 @@  nbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
 
 ptid_t
 nbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int target_options)
+		       target_wait_flags target_options)
 {
   pid_t pid = nbsd_wait (ptid, ourstatus, target_options);
   ptid_t wptid = ptid_t (pid);
diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h
index 0a7048ecf35..172f189e44f 100644
--- a/gdb/nbsd-nat.h
+++ b/gdb/nbsd-nat.h
@@ -41,7 +41,7 @@  struct nbsd_nat_target : public inf_ptrace_target
   bool info_proc (const char *, enum info_proc_what) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   int insert_exec_catchpoint (int pid) override;
   int remove_exec_catchpoint (int pid) override;
   int set_syscall_catchpoint (int pid, bool needed, int any_count,
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 91d2cc5914d..ef1615df3e2 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -69,7 +69,7 @@  struct nto_procfs_target : public inf_child_target
 
   void resume (ptid_t, int, enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -795,7 +795,7 @@  nto_handle_sigint (int signo)
 
 sptid_t
 nto_procfs_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   sigset_t set;
   siginfo_t info;
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index 6667a0add7f..310e2b72fcd 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -74,7 +74,7 @@  obsd_nat_target::update_thread_list ()
 
 ptid_t
 obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-		       int options)
+		       target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/obsd-nat.h b/gdb/obsd-nat.h
index e5962004d4c..3d3e50c57ec 100644
--- a/gdb/obsd-nat.h
+++ b/gdb/obsd-nat.h
@@ -27,7 +27,7 @@  class obsd_nat_target : public inf_ptrace_target
   /* Override some methods to support threads.  */
   std::string pid_to_str (ptid_t) override;
   void update_thread_list () override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 #ifdef PT_GET_PROCESS_STATE
   bool follow_fork (bool, bool) override;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index d3085a20fce..071397b2253 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -107,7 +107,7 @@  class procfs_target final : public inf_child_target
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -2035,7 +2035,7 @@  procfs_target::store_registers (struct regcache *regcache, int regnum)
 
 ptid_t
 procfs_target::wait (ptid_t ptid, struct target_waitstatus *status,
-		     int options)
+		     target_wait_flags options)
 {
   /* First cut: loosely based on original version 2.1.  */
   procinfo *pi;
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 72253188c71..c52c1681f99 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -89,7 +89,7 @@  struct ravenscar_thread_target final : public target_ops
 
   strata stratum () const override { return thread_stratum; }
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
 
   void fetch_registers (struct regcache *, int) override;
@@ -339,7 +339,7 @@  ravenscar_thread_target::resume (ptid_t ptid, int step,
 ptid_t
 ravenscar_thread_target::wait (ptid_t ptid,
 			       struct target_waitstatus *status,
-			       int options)
+			       target_wait_flags options)
 {
   process_stratum_target *beneath
     = as_process_stratum_target (this->beneath ());
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 718de62f280..229e5c4be27 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -117,7 +117,7 @@  class record_btrace_target final : public target_ops
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void stop (ptid_t) override;
   void update_thread_list () override;
@@ -2536,12 +2536,13 @@  record_btrace_maybe_mark_async_event
 
 ptid_t
 record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			    int options)
+			    target_wait_flags options)
 {
   std::vector<thread_info *> moving;
   std::vector<thread_info *> no_history;
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);
+  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (),
+	 (unsigned) options);
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 1d8f1930a5b..1c8b791ffb9 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -225,7 +225,7 @@  class record_full_base_target : public target_ops
 
   void close () override;
   void async (int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   bool stopped_by_watchpoint () override;
   bool stopped_data_address (CORE_ADDR *) override;
 
@@ -1155,7 +1155,7 @@  record_full_sig_handler (int signo)
 static ptid_t
 record_full_wait_1 (struct target_ops *ops,
 		    ptid_t ptid, struct target_waitstatus *status,
-		    int options)
+		    target_wait_flags options)
 {
   scoped_restore restore_operation_disable
     = record_full_gdb_operation_disable_set ();
@@ -1468,7 +1468,7 @@  record_full_wait_1 (struct target_ops *ops,
 
 ptid_t
 record_full_base_target::wait (ptid_t ptid, struct target_waitstatus *status,
-			       int options)
+			       target_wait_flags options)
 {
   ptid_t return_ptid;
 
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 9af6486bca8..9e1c2b151c8 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -131,7 +131,7 @@  struct gdbsim_target final
   void detach (inferior *inf, int) override;
 
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -927,7 +927,8 @@  gdbsim_cntrl_c (int signo)
 }
 
 ptid_t
-gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status,
+		     target_wait_flags options)
 {
   struct sim_inferior_data *sim_data;
   static sighandler_t prev_sigint;
diff --git a/gdb/remote.c b/gdb/remote.c
index 59075cb09f2..5fc80ebc8f7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -422,7 +422,7 @@  class remote_target : public process_stratum_target
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -739,9 +739,9 @@  class remote_target : public process_stratum_target
   void add_current_inferior_and_thread (char *wait_status);
 
   ptid_t wait_ns (ptid_t ptid, struct target_waitstatus *status,
-		  int options);
+		  target_wait_flags options);
   ptid_t wait_as (ptid_t ptid, target_waitstatus *status,
-		  int options);
+		  target_wait_flags options);
 
   ptid_t process_stop_reply (struct stop_reply *stop_reply,
 			     target_waitstatus *status);
@@ -7771,7 +7771,8 @@  remote_target::process_stop_reply (struct stop_reply *stop_reply,
 /* The non-stop mode version of target_wait.  */
 
 ptid_t
-remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status,
+			target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   struct stop_reply *stop_reply;
@@ -7839,7 +7840,8 @@  first_remote_resumed_thread (remote_target *target)
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)
+remote_target::wait_as (ptid_t ptid, target_waitstatus *status,
+			target_wait_flags options)
 {
   struct remote_state *rs = get_remote_state ();
   ptid_t event_ptid = null_ptid;
@@ -7992,7 +7994,8 @@  remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options)
    STATUS just as `wait' would.  */
 
 ptid_t
-remote_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
+remote_target::wait (ptid_t ptid, struct target_waitstatus *status,
+		     target_wait_flags options)
 {
   ptid_t event_ptid;
 
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 654e06e3e4b..29154cfc2e7 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -90,7 +90,7 @@  class rs6000_nat_target final : public inf_ptrace_target
   void create_inferior (const char *, const std::string &,
 			char **, int) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
 private:
   enum target_xfer_status
@@ -495,7 +495,7 @@  rs6000_nat_target::xfer_partial (enum target_object object,
 
 ptid_t
 rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   pid_t pid;
   int status, save_errno;
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index a24d51d1db2..bb33a20ea52 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -84,7 +84,7 @@  class sol_thread_target final : public target_ops
   strata stratum () const override { return thread_stratum; }
 
   void detach (inferior *, int) override;
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
   void resume (ptid_t, int, enum gdb_signal) override;
   void mourn_inferior () override;
   std::string pid_to_str (ptid_t) override;
@@ -425,7 +425,7 @@  sol_thread_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 
 ptid_t
 sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			 int options)
+			 target_wait_flags options)
 {
   if (ptid.pid () != -1)
     {
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 46d17a359d9..1b2feb2c7fb 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -205,7 +205,7 @@  target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
   target_debug_do_print ((X) ? "step" : "continue")
 
 static void
-target_debug_print_options (int options)
+target_debug_print_target_wait_flags (target_wait_flags options)
 {
   std::string str = target_options_to_string (options);
 
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index c28af097183..a79444b1c06 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -15,7 +15,7 @@  struct dummy_target : public target_ops
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
@@ -184,7 +184,7 @@  struct debug_target : public target_ops
   void disconnect (const char *arg0, int arg1) override;
   void resume (ptid_t arg0, int arg1, enum gdb_signal arg2) override;
   void commit_resume () override;
-  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2) override;
+  ptid_t wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2) override;
   void fetch_registers (struct regcache *arg0, int arg1) override;
   void store_registers (struct regcache *arg0, int arg1) override;
   void prepare_to_store (struct regcache *arg0) override;
@@ -457,19 +457,19 @@  debug_target::commit_resume ()
 }
 
 ptid_t
-target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+target_ops::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return this->beneath ()->wait (arg0, arg1, arg2);
 }
 
 ptid_t
-dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+dummy_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   return default_target_wait (this, arg0, arg1, arg2);
 }
 
 ptid_t
-debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
+debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, target_wait_flags arg2)
 {
   ptid_t result;
   fprintf_unfiltered (gdb_stdlog, "-> %s->wait (...)\n", this->beneath ()->shortname ());
@@ -479,7 +479,7 @@  debug_target::wait (ptid_t arg0, struct target_waitstatus *arg1, int arg2)
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_struct_target_waitstatus_p (arg1);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_options (arg2);
+  target_debug_print_target_wait_flags (arg2);
   fputs_unfiltered (") = ", gdb_stdlog);
   target_debug_print_ptid_t (result);
   fputs_unfiltered ("\n", gdb_stdlog);
diff --git a/gdb/target.c b/gdb/target.c
index 58189e62024..9fd6b4ba9e1 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2007,7 +2007,8 @@  target_disconnect (const char *args, int from_tty)
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+	     target_wait_flags options)
 {
   return current_top_target ()->wait (ptid, status, options);
 }
@@ -2017,7 +2018,7 @@  target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 ptid_t
 default_target_wait (struct target_ops *ops,
 		     ptid_t ptid, struct target_waitstatus *status,
-		     int options)
+		     target_wait_flags options)
 {
   status->kind = TARGET_WAITKIND_IGNORE;
   return minus_one_ptid;
@@ -3360,8 +3361,8 @@  str_comma_list_concat_elem (std::string *list, const char *elem)
    OPT is removed from TARGET_OPTIONS.  */
 
 static void
-do_option (int *target_options, std::string *ret,
-	   int opt, const char *opt_str)
+do_option (target_wait_flags *target_options, std::string *ret,
+	   target_wait_flag opt, const char *opt_str)
 {
   if ((*target_options & opt) != 0)
     {
@@ -3373,7 +3374,7 @@  do_option (int *target_options, std::string *ret,
 /* See target.h.  */
 
 std::string
-target_options_to_string (int target_options)
+target_options_to_string (target_wait_flags target_options)
 {
   std::string ret;
 
diff --git a/gdb/target.h b/gdb/target.h
index 4e8d4cccd5c..3f432b14c44 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -117,7 +117,7 @@  struct syscall
   };
 
 /* Return a pretty printed form of TARGET_OPTIONS.  */
-extern std::string target_options_to_string (int target_options);
+extern std::string target_options_to_string (target_wait_flags target_options);
 
 /* Possible types of events that the inferior handler will have to
    deal with.  */
@@ -488,7 +488,7 @@  struct target_ops
        current target.  inferior_ptid may also be null_ptid on
        entry.  */
     virtual ptid_t wait (ptid_t, struct target_waitstatus *,
-			 int TARGET_DEBUG_PRINTER (target_debug_print_options))
+			 target_wait_flags options)
       TARGET_DEFAULT_FUNC (default_target_wait);
     virtual void fetch_registers (struct regcache *, int)
       TARGET_DEFAULT_IGNORE ();
@@ -1448,7 +1448,7 @@  extern scoped_restore_tmpl<int> make_scoped_defer_target_commit_resume ();
 extern ptid_t default_target_wait (struct target_ops *ops,
 				   ptid_t ptid,
 				   struct target_waitstatus *status,
-				   int options);
+				   target_wait_flags options);
 
 /* Fetch at least register REGNO, or all regs if regno == -1.  No result.  */
 
diff --git a/gdb/target/target.h b/gdb/target/target.h
index a66459c2469..393272b3273 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -21,6 +21,8 @@ 
 #define TARGET_TARGET_H
 
 #include "target/waitstatus.h"
+#include "target/wait.h"
+
 /* This header is a stopgap until more code is shared.  */
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
@@ -84,7 +86,7 @@  extern void target_continue (ptid_t ptid, enum gdb_signal signal);
    options.  */
 
 extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
-			   int options);
+			   target_wait_flags options);
 
 /* The inferior process has died.  Do what is right.  */
 
diff --git a/gdb/target/wait.h b/gdb/target/wait.h
index d23b892700f..ee623bb7310 100644
--- a/gdb/target/wait.h
+++ b/gdb/target/wait.h
@@ -20,11 +20,18 @@ 
 #ifndef TARGET_WAIT_H
 #define TARGET_WAIT_H
 
+#include "gdbsupport/enum-flags.h"
+
 /* Options that can be passed to target_wait.  */
 
-/* Return immediately if there's no event already queued.  If this
-   options is not requested, target_wait blocks waiting for an
-   event.  */
-#define TARGET_WNOHANG 1
+enum target_wait_flag : unsigned
+{
+  /* Return immediately if there's no event already queued.  If this
+     options is not requested, target_wait blocks waiting for an
+     event.  */
+  TARGET_WNOHANG = 1,
+};
+
+DEF_ENUM_FLAGS_TYPE (enum target_wait_flag, target_wait_flags);
 
 #endif /* TARGET_WAIT_H */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 188a920cbb0..b13129336ab 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -310,7 +310,7 @@  struct windows_nat_target final : public x86_nat_target<inf_child_target>
 
   void resume (ptid_t, int , enum gdb_signal) override;
 
-  ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
+  ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override;
 
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -1774,7 +1774,7 @@  windows_nat_target::get_windows_debug_event (int pid,
 /* Wait for interesting events to occur in the target process.  */
 ptid_t
 windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			  int options)
+			  target_wait_flags options)
 {
   int pid = -1;
 
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e45493339d2..1a3f13fa5e4 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -3710,7 +3710,7 @@  async_file_mark (void)
 ptid_t
 linux_process_target::wait (ptid_t ptid,
 			    target_waitstatus *ourstatus,
-			    int target_options)
+			    target_wait_flags target_options)
 {
   ptid_t event_ptid;
 
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 0ef659fb0f0..424745978da 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -157,7 +157,7 @@  class linux_process_target : public process_stratum_target
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-	       int options) override;
+	       target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 87f62a0b555..921d26fcf79 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -160,8 +160,8 @@  target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 }
 
 ptid_t
-mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-	int connected_wait)
+mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	target_wait_flags options, int connected_wait)
 {
   ptid_t ret;
 
@@ -220,7 +220,8 @@  target_stop_and_wait (ptid_t ptid)
 /* See target/target.h.  */
 
 ptid_t
-target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+target_wait (ptid_t ptid, struct target_waitstatus *status,
+	     target_wait_flags options)
 {
   return the_target->wait (ptid, status, options);
 }
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 13f069f7729..c2245ebfe85 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -128,7 +128,7 @@  class process_stratum_target
      no child stop to report, return is
      null_ptid/TARGET_WAITKIND_IGNORE.  */
   virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
-		       int options) = 0;
+		       target_wait_flags options) = 0;
 
   /* Fetch registers from the inferior process.
 
@@ -663,8 +663,8 @@  target_read_btrace_conf (struct btrace_target_info *tinfo,
 #define target_supports_software_single_step() \
   the_target->supports_software_single_step ()
 
-ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
-	       int connected_wait);
+ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus,
+	       target_wait_flags options, int connected_wait);
 
 /* Prepare to read or write memory from the inferior process.  See the
    corresponding process_stratum_target methods for more details.  */
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a11cc740925..9980986c739 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1610,7 +1610,7 @@  get_child_debug_event (DWORD *continue_status,
    Returns the signal which caused the process to stop. */
 ptid_t
 win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
-			    int options)
+			    target_wait_flags options)
 {
   if (cached_status.kind != TARGET_WAITKIND_IGNORE)
     {
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index f3b44776ae1..d4ad5d83d29 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -116,7 +116,7 @@  class win32_process_target : public process_stratum_target
   void resume (thread_resume *resume_info, size_t n) override;
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
-	       int options) override;
+	       target_wait_flags options) override;
 
   void fetch_registers (regcache *regcache, int regno) override;