public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] linux_nat_target::xfer_partial: Fallback to ptrace
Date: Tue, 24 May 2022 11:56:40 -0700	[thread overview]
Message-ID: <7cca96e8-bd52-0c6c-8a90-582c0abd80a9@redhat.com> (raw)
In-Reply-To: <23154482-133e-8bfe-6d14-17f7e79b716b@palves.net>

On 5/20/22 11:51, Pedro Alves wrote:
> On 2022-05-12 19:15, Keith Seitz via Gdb-patches wrote:
>> Commit 05c06f318fd9a112529dfc313e6512b399a645e4 enabled GDB
>> to access memory while threads are running. It did this by accessing
>> /proc/PID/task/LWP/mem.
>>
>> Unfortunatley, this interface is not implemented for writing in older kernels
> 
> Unfortunatley -> Unfortunately

Fixed.

> Oh man.  I thought such kernels were already older than the oldest version
> we support, but looks like not.  :-/  I don't suppose you could instead
> convince the kernel team to backport the patches that made /proc/pid/mem
> writable (https://lore.kernel.org/lkml/20110314151320.GG21770@outflux.net/T/).. :-P

:-)

> Both gdb and gdbserver are now relying on this to access memory of running threads.
> This never worked for gdb, but it did for gdbserver, by stopping all threads temporarily.
> I would really-really-really prefer not to add that code back for ancient
> kernels...

I did not observe any issues with gdbserver. As to whether we need to support
kernels as old as RHEL6? I don't really know. I noticed problems when I was
running through some internal testing which still uses RHEL6.

I figured (maybe incorrectly) that the fallthrough was otherwise harmless.
I'm fine if we'd prefer not to include this patch, though. I honestly
haven't a clue how widespread RHEL6-vintage kernels are in the wild.

>> --- a/gdb/linux-nat.c
>> +++ b/gdb/linux-nat.c
>> @@ -3706,8 +3706,12 @@ linux_nat_target::xfer_partial (enum target_object object,
>>         if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
>>   	offset &= ((ULONGEST) 1 << addr_bit) - 1;
>>   
>> -      return linux_proc_xfer_memory_partial (readbuf, writebuf,
>> -					     offset, len, xfered_len);
>> +      enum target_xfer_status xfer
>> +	= linux_proc_xfer_memory_partial (readbuf, writebuf,
>> +					  offset, len, xfered_len);
>> +      if (xfer != TARGET_XFER_EOF)
>> +	return xfer;
>> +      /* Fallthrough to ptrace.  */
> 
> Seems fine, but I'd like a comment here giving a hint that we'll be able to
> remove this once we stop supporting such old kernels.  Something like:
> 
>        /* Fallthrough to ptrace.  /proc/pid/mem wasn't writable before Linux 2.6.39.  */
> 
> I got that number by finding commit 198214a7ee50, and looking at git tag --contains 198214a7ee50.

I've updated that comment.

> AFAICT, RHEL 6 is on 2.6.32.

As far as I can tell, that is correct.

I will wait before pushing this to give others the opportunity to chime in.

Thank you for taking a look at this,
Keith


  reply	other threads:[~2022-05-24 18:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 18:15 Keith Seitz
2022-05-20 18:51 ` Pedro Alves
2022-05-24 18:56   ` Keith Seitz [this message]
2022-05-25 13:41     ` Pedro Alves
2022-06-03 15:18 Keith Seitz
2022-07-21 15:03 ` Keith Seitz
2022-07-21 20:07   ` Pedro Alves
2022-07-26 17:24     ` Keith Seitz
2022-07-26 19:16       ` Pedro Alves

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=7cca96e8-bd52-0c6c-8a90-582c0abd80a9@redhat.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).