Re: [PATCH 10/10] Add minimal and functional NetBSD/amd64 gdbserver

Tom Tromey
2020-09-16T16:08:30Z

>>>>> "Kamil" == Kamil Rytarowski <n54@gmx.com> writes:

While switching the target wait flags to be a flag enum type, I found a
small problem in the new NetBSD gdbserver work.

Kamil> +/* Implement a safe wrapper around waitpid(). */
Kamil> +
Kamil> +static pid_t
Kamil> +netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus, int options)

Here options is either 0 or:

#define TARGET_WNOHANG 1

Kamil> +{
Kamil> + int status;
Kamil> +
Kamil> + pid_t pid = gdb::handle_eintr (::waitpid, ptid.pid (), &status, options);

... but it is passed directly to ::waitpid. This is fine for now if the
system WNOHANG happens to be 1. However, I think it would be better not
to rely on this. For one thing, there's no guarantee that the value of
TARGET_WNOHANG will never change.

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

Here's a spot making the call; this shows that the target option is
being passed untranslated.

thanks,
Tom