From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-5.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E54361F8C6 for ; Tue, 17 Aug 2021 13:18:43 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19142382BC20 for ; Tue, 17 Aug 2021 13:18:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19142382BC20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629206323; bh=95Zwtaf+ioshzWfU8YGRXJBqvJedm76/s+HNYFPMYt4=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BBYku51huRWyicr2L6khaR3P44fgNmVTbNg7KelQJNxPpTGYRpM2egHv8BOlS2+Ox hc9If6MCUrYe4jsKiln0vrm6HQIrUq93JdYlgtOt6M3H6DgKO4fjpiDIkCSRkG6jy0 KVsk+5ojYMkCY0GiIxB/zgDC1m1A4eeTTLMVd9Ro= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E56733853C31; Tue, 17 Aug 2021 13:17:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E56733853C31 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 17HDHeS2002226 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Aug 2021 09:17:45 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 17HDHeS2002226 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 9E1651EA7E; Tue, 17 Aug 2021 09:17:40 -0400 (EDT) Subject: Re: [PATCH v2] gdbserver: Check r_version < 1 for Linux debugger interface To: "H.J. Lu" , GNU C Library , GDB References: Message-ID: <9d4a8d15-b53b-fb14-1116-5981fa3274bf@polymtl.ca> Date: Tue, 17 Aug 2021 09:17:40 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 17 Aug 2021 13:17:40 +0000 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Libc-alpha Reply-To: Simon Marchi Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 2021-08-16 6:02 p.m., H.J. Lu wrote: > On Mon, Aug 16, 2021 at 1:30 PM H.J. Lu wrote: >> >> Update gdbserver to check r_version < 1 instead of r_version != 1 so >> that r_version can be bumped for a new field in the glibc debugger >> interface to support multiple namespaces. Since so far, the gdbserver >> only reads fields defined for r_version == 1, it is compatible with >> r_version >= 1. >> >> All future glibc debugger interface changes will be backward compatible. >> If there is ever the need for backward incompatible change to the glibc >> debugger interface, a new DT_XXX element will be provided to access the >> new incompatible interface. >> >> PR gdb/11839 >> * linux-low.cc (linux_process_target::qxfer_libraries_svr4): >> Check r_version < 1 instead of r_version != 1. >> --- >> gdbserver/linux-low.cc | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc >> index 5c6191d941c..fc7a995351d 100644 >> --- a/gdbserver/linux-low.cc >> +++ b/gdbserver/linux-low.cc >> @@ -6845,7 +6845,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex, >> if (linux_read_memory (priv->r_debug + lmo->r_version_offset, >> (unsigned char *) &r_version, >> sizeof (r_version)) != 0 >> - || r_version != 1) >> + || r_version < 1) >> { >> warning ("unexpected r_debug version %d", r_version); >> } >> -- >> 2.31.1 >> > > Set r_version == 2 breaks GDB due to > > static CORE_ADDR > solib_svr4_r_ldsomap (struct svr4_info *info) > { > struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); > struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; > enum bfd_endian byte_order = type_byte_order (ptr_type); > ULONGEST version = 0; > > try > { > /* Check version, and return zero if `struct r_debug' doesn't have > the r_ldsomap member. */ > version > = read_memory_unsigned_integer (info->debug_base + > lmo->r_version_offset, > lmo->r_version_size, byte_order); > } > catch (const gdb_exception_error &ex) > { > exception_print (gdb_stderr, ex); > } > > if (version < 2 || lmo->r_ldsomap_offset == -1) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > glibc doesn't have r_ldsomap. But r_ldsomap_offset is set > unconditionally. Shouldn't it be set only if the target debugger > interface has it? Ideally, I think that Solaris support would implement its own "solaris_{ilp32,lp64}_fetch_link_map_offsets", where it would set r_ldsomap_offset. And either there wouldn't be a generic svr4_{ilp32,lp64}_fetch_link_map_offsets (each OS support would provide its own, because things vary so much between OSes) or svr4_{ilp32,lp64}_fetch_link_map_offsets would just specify what's really the common denominator between all of them. I think that would allow remove that "version < 2" check that is a bit ugly. Simon