From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1666 invoked by alias); 3 Apr 2012 21:27:40 -0000 Received: (qmail 1656 invoked by uid 22791); 3 Apr 2012 21:27:39 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Apr 2012 21:27:19 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q33LRFkG030825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Apr 2012 17:27:15 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q33LRDE3010645; Tue, 3 Apr 2012 17:27:14 -0400 Message-ID: <4F7B6B31.3010203@redhat.com> Date: Tue, 03 Apr 2012 21:27:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120316 Thunderbird/11.0 MIME-Version: 1.0 To: "Maciej W. Rozycki" CC: gdb-patches@sourceware.org Subject: Re: [PATCH] gdbserver: Handle DT_MIPS_RLD_MAP dynamic tag References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00049.txt.bz2 Hi Maciej, On 04/03/2012 09:47 PM, Maciej W. Rozycki wrote: > While working on a test case for an unrelated issue I have noticed > single-stepping over system library calls is broken on the MIPS/Linux > target when `gdbserver' is used. On closer inspection I have observed > `gdbserver' reports no shared libraries loaded. Further investigation has > revealed that the newly-added support for the `qXfer:libraries-svr4:read' > packet does not handle the DT_MIPS_RLD_MAP dynamic tag and therefore > cannot locate the link map on the MIPS target. Yeah, I had noticed that on , but never got to propose a fix. Sorry about that. > gdb-gdbserver-rld-map.diff > Index: gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c > =================================================================== > --- gdb-fsf-trunk-quilt.orig/gdb/gdbserver/linux-low.c 2012-04-03 13:38:58.575561428 +0100 > +++ gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c 2012-04-03 13:39:17.315624148 +0100 > @@ -5419,7 +5419,9 @@ get_dynamic (const int pid, const int is > } > > /* Return &_r_debug in the inferior, or -1 if not present. Return value > - can be 0 if the inferior does not yet have the library list initialized. */ > + can be 0 if the inferior does not yet have the library list initialized. > + We look for DT_MIPS_RLD_MAP first. MIPS executables use this instead of > + DT_DEBUG, although they sometimes contain an unused DT_DEBUG entry too. */ > Can that "unused DT_DEBUG" entry ever appear before DT_MIPS_RLD_MAP in the tags list? With this patch, we'll stop looking if we see DT_DEBUG first, while solib-svr4.c in GDB first looks for DT_MIPS_RLD_MAP in all tags, and only if not found looks for DT_DEBUG (presumably, if there's no DT_MIPS_RLD_MAP, then there's no DT_DEBUG either; only if DT_MIPS_RLD_MAP exist might there be a DT_DEBUG). Do we need to worry about this? > static CORE_ADDR > get_r_debug (const int pid, const int is_elf64) > @@ -5437,6 +5439,21 @@ get_r_debug (const int pid, const int is > if (is_elf64) > { > Elf64_Dyn *const dyn = (Elf64_Dyn *) buf; > + union > + { > + Elf64_Xword map; > + unsigned char buf[sizeof (Elf64_Xword)]; > + } > + rld_map; > + > + if (dyn->d_tag == DT_MIPS_RLD_MAP) > + { > + if (linux_read_memory (dyn->d_un.d_val, > + rld_map.buf, sizeof (rld_map.buf)) == 0) > + return rld_map.map; > + else > + break; > + } > > if (dyn->d_tag == DT_DEBUG) > return dyn->d_un.d_val; > @@ -5447,6 +5464,21 @@ get_r_debug (const int pid, const int is > else > { > Elf32_Dyn *const dyn = (Elf32_Dyn *) buf; > + union > + { > + Elf32_Word map; > + unsigned char buf[sizeof (Elf32_Word)]; > + } > + rld_map; > + > + if (dyn->d_tag == DT_MIPS_RLD_MAP) > + { > + if (linux_read_memory (dyn->d_un.d_val, > + rld_map.buf, sizeof (rld_map.buf)) == 0) > + return rld_map.map; > + else > + break; > + } > > if (dyn->d_tag == DT_DEBUG) > return dyn->d_un.d_val; -- Pedro Alves