From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21594 invoked by alias); 18 Jun 2009 23:03:49 -0000 Received: (qmail 21582 invoked by uid 22791); 18 Jun 2009 23:03:48 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Jun 2009 23:03:41 +0000 Received: (qmail 25989 invoked from network); 18 Jun 2009 23:03:39 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Jun 2009 23:03:39 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch] solib-svr4.c - allow reading linkmap info from core without executable Date: Thu, 18 Jun 2009 23:03:00 -0000 User-Agent: KMail/1.9.10 Cc: Aleksandar Ristovski References: <200906102308.29638.pedro@codesourcery.com> <4A310906.4030603@qnx.com> In-Reply-To: <4A310906.4030603@qnx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906190004.23937.pedro@codesourcery.com> X-IsSubscribed: yes 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: 2009-06/txt/msg00491.txt.bz2 On Thursday 11 June 2009 14:39:18, Aleksandar Ristovski wrote: > Pedro Alves wrote: > >> if (info->debug_base == 0 && svr4_have_link_map_offsets ()) > >> { > >> - if (exec_bfd != NULL > >> + if ((exec_bfd != NULL > >> && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour) > >> + || (core_bfd != NULL > >> + && bfd_get_flavour (core_bfd) == bfd_target_elf_flavour)) > >> info->debug_base = elf_locate_base (); > >> } > > > > Are there live debugging cases (archs?, PIE?) (e.g., "target remote" > > without specifying an executable) where letting elf_locate_base > > try to read the debug base from the target's auxv (scan_dyntag_auxv) > > will work? It would mean that removing the exec_bfd checks instead > > of adding core_bfd checks, would still improve your case, while > > letting other cases benefit as well. > > > > Yes, in theory it should work as long as target_ops in > question know how to read auxv (that is, as long as > to_xfer_partial(ops, TARGET_OBJECT_AUXV,...) knows how to do > it.) > > I had internally made this change: > > { > - if (exec_bfd != NULL > + if ((exec_bfd != NULL > && bfd_get_flavour (exec_bfd) == > bfd_target_elf_flavour) > + || exec_bfd == NULL) > debug_base = elf_locate_base (); > } > return (debug_base); > > > But wanted to be more conservative for FSF, since I do not > quite understand under which circumstances could we end up > in solib-svr4, and not have "bfd_target_elf_flavour". I was thinking on pushing the elf check a bit down instead, like the below. However, having now tested this, I see that this doesn't work in most of the cores I have here (x86_64-linux). In most cases I see, the segment that would contain the program headers, as indicated by auxv info, isn't included in the core... (objdump -h) Idx Name Size VMA LMA File off Algn : 6 load1 00000000 0000000000400000 0000000000000000 000008f8 2**0 ALLOC, READONLY, CODE : -- Pedro Alves --- gdb/solib-svr4.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) Index: src/gdb/solib-svr4.c =================================================================== --- src.orig/gdb/solib-svr4.c 2009-06-18 20:55:50.000000000 +0100 +++ src/gdb/solib-svr4.c 2009-06-18 22:25:11.000000000 +0100 @@ -266,7 +266,7 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_l /* Assume that everything is a library if the dynamic loader was loaded late by a static executable. */ - if (bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL) + if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL) return 0; return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset, @@ -600,9 +600,13 @@ scan_dyntag (int dyntag, bfd *abfd, CORE if (abfd == NULL) return 0; + + if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) + return 0; + arch_size = bfd_get_arch_size (abfd); if (arch_size == -1) - return 0; + return 0; /* Find the start address of the .dynamic section. */ sect = bfd_get_section_by_name (abfd, ".dynamic"); @@ -825,11 +829,7 @@ locate_base (struct svr4_info *info) though if we don't have some link map offsets to work with. */ if (info->debug_base == 0 && svr4_have_link_map_offsets ()) - { - if (exec_bfd != NULL - && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour) - info->debug_base = elf_locate_base (); - } + info->debug_base = elf_locate_base (); return info->debug_base; }