Re: [PATCH 02/23] Don't rely on inferior_ptid in record_full_wait

Tom Tromey
2020-08-01T20:46:10Z

Simon> I don't know if this makes sense: you tell the core of GDB that some
Simon> process was signalled (terminated by a signal), but you don't tell
Simon> what process it is. I am not sure what the core of GDB can do with
Simon> this information.

Simon> The contract that the `wait` implementations must respect is not
Simon> very well documented I believe, so it's not clear which value is
Simon> valid with which event.

Yeah. I think it would be good to fix this.

The reason I had it return minus_one_ptid is this text in
target/target.h:

Return pid of child, or -1 in case of error;
store status through argument pointer STATUS.

remote_target::wait does this as well, though perhaps not with this
target waitkind, e.g.:

status->kind = TARGET_WAITKIND_NO_RESUMED;
return minus_one_ptid;

or

if (status->kind == TARGET_WAITKIND_NO_RESUMED)
return minus_one_ptid;

... though not all returns set the kind.

Simon> Note that this waitpid call is blocking (and there's no async stuff in
Simon> inf-ptrace.c), so I presume that this is only used in sync targets.

Yeah. I found this because I was wondering what it would take to
convert the remaining sync targets, and have only target-async left.

I suspect the inf-ptrace targets can be converted by just lifting the
Linux code into in inf_ptrace_target. This comment in nbsd-nat.c is
worrying though:

/* The common code passes WNOHANG that leads to crashes, overwrite it. */

Other targets require a little more research. For Windows, Darwin, and
remote-sim, I thought perhaps we could put some of the current
resume/wait code into a separate thread. (Though in the case of the
sim, I think it would be better to move the sims to using the remote
protocol.)

Simon> Perhaps we could return TARGET_WAITKIND_NO_RESUMED in both cases?

remote.c does this in at least one case, though apparently not in all.

Tom