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

Kamil Rytarowski
2020-09-18T17:44:08Z

[-- Attachment #1.1: Type: text/plain, Size: 1207 bytes --]

On 16.09.2020 18:08, Tom Tromey wrote:
>>>>>> "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.
>

I see. It happens that WNOHANG is equal to TARGET_WNOHANG on NetBSD and
it went unnoticed.

> thanks,
> Tom
>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]