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

Tom Tromey tromey@adacore.com
Wed Sep 16 16:08:29 GMT 2020


>>>>> "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


More information about the Gdb-patches mailing list