From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 843F638133F2 for ; Tue, 24 May 2022 18:56:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 843F638133F2 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-nTIRUqBkP5ijTqs-cuv6Ww-1; Tue, 24 May 2022 14:56:42 -0400 X-MC-Unique: nTIRUqBkP5ijTqs-cuv6Ww-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C12F83C0CD47; Tue, 24 May 2022 18:56:41 +0000 (UTC) Received: from [10.2.17.139] (unknown [10.2.17.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E3BCC27E8E; Tue, 24 May 2022 18:56:41 +0000 (UTC) Message-ID: <7cca96e8-bd52-0c6c-8a90-582c0abd80a9@redhat.com> Date: Tue, 24 May 2022 11:56:40 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] linux_nat_target::xfer_partial: Fallback to ptrace To: Pedro Alves , gdb-patches@sourceware.org References: <20220512181557.2093666-1-keiths@redhat.com> <23154482-133e-8bfe-6d14-17f7e79b716b@palves.net> From: Keith Seitz In-Reply-To: <23154482-133e-8bfe-6d14-17f7e79b716b@palves.net> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2022 18:56:47 -0000 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