This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Linux/gdbserver: Fix memory read ptrace fallback issues
On Fri, 18 May 2012, Pedro Alves wrote:
> Ah, right, we can't return immediately --- but if we loop pread64/read,
> handling partial reads (and EINTR, while at it), until it returns error
> would get us the errno we want, I'd think. I think the code would be
> more straightforward that way if it works, but anyway, just a suggestion;
> I'm super fine with your version.
You're correct, especially EINTR is worth getting right, interrupted
syscalls are always rare and unpredictable enough to make debugging their
consequences a nightmare.
> > Alternatively we could revamp the whole API to make
> > the_target->read_memory return the number of bytes actually read, just
> > like read and friends do. That would of course ask for a complementing
> > change to the_target->write_memory too. I even thought about it when I
> > finally tracked down what the cause of odd behaviour was, but I decided I
> > was too tired debugging this issue already to turn gdbserver upside down
> > at that stage.
>
>
> Yeah, certainly not worth the effort at this stage.
I think ultimately we should do it though. The /proc path is surely a
later addition and can explain the resulting unfit API that was originally
just fine with ptrace, but I think we should straighten it out and give an
advantage to the common case. Especially as it's not like the ptrace
fallback or platforms where it's the only choice are going to suffer from
such a read/write-like API.
I think the two choices in the Linux handlers should be factored out into
separate functions too.
> Thanks. The whole patch is fine with me with this fix.
Applied now, thanks for the review.
Maciej