From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7663 invoked by alias); 10 Sep 2008 20:20:44 -0000 Received: (qmail 7655 invoked by uid 22791); 10 Sep 2008 20:20:43 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 10 Sep 2008 20:20:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5C6D02A966A for ; Wed, 10 Sep 2008 16:20:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KD6GKfd1eBfg for ; Wed, 10 Sep 2008 16:20:04 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id B81942A9667 for ; Wed, 10 Sep 2008 16:20:03 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id BA86DE7ACD; Wed, 10 Sep 2008 22:19:59 +0200 (CEST) Date: Wed, 10 Sep 2008 20:20:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/commit/dwarf] Create partial symbols for nested subprograms Message-ID: <20080910201959.GC10133@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5G06lTa6Jq83wMTw" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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: 2008-09/txt/msg00224.txt.bz2 --5G06lTa6Jq83wMTw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1349 Hello, I just realized that we are missing the nested subprograms in our partial symbol list. Normally, this should cause us to fail when trying to break on a nested procedure until we have loaded the full symbols for that unit. But there is in fact a bit of code that I couldn't understand in ada_lookup_symbol_list which works around this issue: It searches the minimal symbols for a match, derives the associated symbol address, then determines the associated psymtab, converts the psymtab into a symtab; Contrary to the partial symtab, the full symtab does contain a symbol for our nested procedure, and thus the lookup succeeds. I stumbled on this because I am about to remove the piece of code mentioned above (in ada_lookup_symbol_list), as it introduces a pretty significant performance penalty - I will post a separate patch with more details later on. But at the same time, I think it is important by itself, as I want the partial symtab and full symtab to be consistent. 2008-09-10 Joel Brobecker * dwarf2read.c (add_partial_subprogram): New procedure. (scan_partial_symbols): Use it. (load_partial_dies): Read in children of subprogram and lexical blocks. Tested on x86-linux. No regression. I would like to commit in a week if there are no objections. Thanks, -- Joel --5G06lTa6Jq83wMTw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="03-nested_psym.diff" Content-length: 2747 diff -r d71d6b13aae1 -r ad68e435fc43 gdb/dwarf2read.c --- a/gdb/dwarf2read.c Wed Sep 10 12:23:56 2008 -0700 +++ b/gdb/dwarf2read.c Wed Sep 10 12:24:48 2008 -0700 @@ -766,6 +766,10 @@ static void add_partial_enumeration (struct partial_die_info *enum_pdi, struct dwarf2_cu *cu); + +static void add_partial_subprogram (struct partial_die_info *pdi, + CORE_ADDR *lowpc, CORE_ADDR *highpc, + struct dwarf2_cu *cu); static gdb_byte *locate_pdi_sibling (struct partial_die_info *orig_pdi, gdb_byte *info_ptr, @@ -1783,21 +1787,7 @@ switch (pdi->tag) { case DW_TAG_subprogram: - if (pdi->has_pc_info) - { - if (pdi->lowpc < *lowpc) - { - *lowpc = pdi->lowpc; - } - if (pdi->highpc > *highpc) - { - *highpc = pdi->highpc; - } - if (!pdi->is_declaration) - { - add_partial_symbol (pdi, cu); - } - } + add_partial_subprogram (pdi, lowpc, highpc, cu); break; case DW_TAG_variable: case DW_TAG_typedef: @@ -2145,6 +2135,45 @@ if (pdi->has_children) scan_partial_symbols (pdi->die_child, lowpc, highpc, cu); +} + +/* Read a partial die corresponding to a subprogram and create a partial + symbol for that subprogram. Also define a partial symbol for each + nested subprogram defined inside it. + + DIE my also be a lexical block, in which case we simply search + recursively for suprograms defined inside that lexical block. */ + +static void +add_partial_subprogram (struct partial_die_info *pdi, + CORE_ADDR *lowpc, CORE_ADDR *highpc, + struct dwarf2_cu *cu) +{ + if (pdi->tag == DW_TAG_subprogram) + { + if (pdi->has_pc_info) + { + if (pdi->lowpc < *lowpc) + *lowpc = pdi->lowpc; + if (pdi->highpc > *highpc) + *highpc = pdi->highpc; + if (!pdi->is_declaration) + add_partial_symbol (pdi, cu); + } + } + + if (! pdi->has_children) + return; + + pdi = pdi->die_child; + while (pdi != NULL) + { + fixup_partial_die (pdi, cu); + if (pdi->tag == DW_TAG_subprogram + || pdi->tag == DW_TAG_lexical_block) + add_partial_subprogram (pdi, lowpc, highpc, cu); + pdi = pdi->die_sibling; + } } /* See if we can figure out if the class lives in a namespace. We do @@ -5696,6 +5725,8 @@ && (load_all || last_die->tag == DW_TAG_namespace || last_die->tag == DW_TAG_enumeration_type + || last_die->tag == DW_TAG_subprogram + || last_die->tag == DW_TAG_lexical_block || (cu->language != language_c && (last_die->tag == DW_TAG_class_type || last_die->tag == DW_TAG_interface_type --5G06lTa6Jq83wMTw--