From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7028 invoked by alias); 5 Jun 2013 11:38:11 -0000 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 Received: (qmail 7015 invoked by uid 89); 5 Jun 2013 11:38:10 -0000 X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 05 Jun 2013 11:38:10 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r55Bc7j7011166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Jun 2013 07:38:07 -0400 Received: from host2.jankratochvil.net (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r55Bc0X7011600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 5 Jun 2013 07:38:03 -0400 Date: Wed, 05 Jun 2013 11:38:00 -0000 From: Jan Kratochvil To: Ben Cheng Cc: gdb-patches@sourceware.org Subject: [patchv2] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs Message-ID: <20130605113800.GA10973@host2.jankratochvil.net> References: <20130604180722.GA23588@host2.jankratochvil.net> <20130604202301.GA8999@host2.jankratochvil.net> <20130604205700.GA10677@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-06/txt/msg00077.txt.bz2 On Tue, 04 Jun 2013 23:21:36 +0200, Ben Cheng wrote: > If you don't mind I'll let you take care of it. :) I will check it in in some time. Regards, Jan gdb/gdbserver/ 2013-06-05 Jan Kratochvil Fix compatibility with Android Bionic. * linux-low.c (linux_qxfer_libraries_svr4): Ignore first entry even if it is not empty. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 03ac469..0f3e0f0 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5829,45 +5829,54 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, break; } - /* Not checking for error because reading may stop before - we've got PATH_MAX worth of characters. */ - libname[0] = '\0'; - linux_read_memory (l_name, libname, sizeof (libname) - 1); - libname[sizeof (libname) - 1] = '\0'; - if (libname[0] != '\0') + /* Ignore the first entry even if it has valid name as the first entry + corresponds to the main executable. The first entry should not be + skipped if the dynamic loader was loaded late by a static executable + (see solib-svr4.c parameter ignore_first). But in such case the main + executable does not have PT_DYNAMIC present and this function already + exited above due to failed get_r_debug. */ + if (lm_prev == 0) { - /* 6x the size for xml_escape_text below. */ - size_t len = 6 * strlen ((char *) libname); - char *name; - - if (!header_done) + sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); + p = p + strlen (p); + } + else + { + /* Not checking for error because reading may stop before + we've got PATH_MAX worth of characters. */ + libname[0] = '\0'; + linux_read_memory (l_name, libname, sizeof (libname) - 1); + libname[sizeof (libname) - 1] = '\0'; + if (libname[0] != '\0') { - /* Terminate `", - name, (unsigned long) lm_addr, - (unsigned long) l_addr, (unsigned long) l_ld); - free (name); - } - else if (lm_prev == 0) - { - sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr); - p = p + strlen (p); + document = xrealloc (document, 2 * allocated); + allocated *= 2; + p = document + document_len; + } + + name = xml_escape_text ((char *) libname); + p += sprintf (p, "", + name, (unsigned long) lm_addr, + (unsigned long) l_addr, (unsigned long) l_ld); + free (name); + } } lm_prev = lm_addr;