Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Linux/gdbserver: Fix memory read ptrace fallback issues
Date: Fri, 18 May 2012 20:11:00 -0000	[thread overview]
Message-ID: <4FB6ACEF.2030600@redhat.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1205181858370.11227@tp.orcam.me.uk>

On 05/18/2012 07:45 PM, Maciej W. Rozycki wrote:

>> > So how about just returning immediately if reading from /proc manages to
>> > read something?  From what you say, the PEEKTEXT fallback then won't just
>> > normally fail; it'll _always_ fail.  I suspect that'd make the code a bit
>> > simpler.
>  Maybe.  Question is, actually why it was written like this in the first 
> place.  And the only answer I could come up with was: to retrieve the 
> right error code for the caller to investigate.  You won't get that with 
> pread64/read if they succeed reading any data at all, even if the amount 
> is less than requested.  Hence I decided to preserve the original flow.  
> I do not feel comfortable with cooking up an artificial value of errno.


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.

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

>> > You shouldn't assume that "errno" is preserved across library
>> > calls (memcpy in this case).
>  Oh, that was an oversight rather than a deliberate assumption, sorry 
> about that.  Here's a trivial update that I have applied to my fix.


Thanks.  The whole patch is fine with me with this fix.

-- 
Pedro Alves


  reply	other threads:[~2012-05-18 20:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 22:57 Maciej W. Rozycki
2012-05-18 16:53 ` Pedro Alves
2012-05-18 18:46   ` Maciej W. Rozycki
2012-05-18 20:11     ` Pedro Alves [this message]
2012-05-22  0:05       ` Maciej W. Rozycki
2012-05-22  8:04         ` Regression for gdbserver [Re: [PATCH] Linux/gdbserver: Fix memory read ptrace fallback issues] Jan Kratochvil
2012-05-22 12:43           ` Maciej W. Rozycki
2012-05-22 19:35             ` [patch] " Jan Kratochvil
2012-05-22 20:06               ` Maciej W. Rozycki
2012-05-22 20:42                 ` Jan Kratochvil
2012-05-22 23:34                   ` Maciej W. Rozycki
2012-05-23  5:29                     ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FB6ACEF.2030600@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox