From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14870 invoked by alias); 1 Oct 2008 01:16:15 -0000 Received: (qmail 14859 invoked by uid 22791); 1 Oct 2008 01:16:14 -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, 01 Oct 2008 01:15:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id AB8C32A9677; Tue, 30 Sep 2008 21:15:37 -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 1zakbxOjfNjw; Tue, 30 Sep 2008 21:15:37 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 4CC562A9654; Tue, 30 Sep 2008 21:15:37 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id C0719E7ACD; Tue, 30 Sep 2008 18:15:34 -0700 (PDT) Date: Wed, 01 Oct 2008 01:16:00 -0000 From: Joel Brobecker To: Pierre Muller , gdb-patches@sourceware.org Subject: Re: [RFA/DWARF2] Handle nested subprograms in CU pc bound calculation Message-ID: <20081001011534.GA3665@adacore.com> References: <20080930152757.GC23135@adacore.com> <002601c92313$27d06790$777136b0$@u-strasbg.fr> <20080930170648.GI3811@adacore.com> <20080930173837.GA959@caradoc.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" Content-Disposition: inline In-Reply-To: <20080930173837.GA959@caradoc.them.org> 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-10/txt/msg00000.txt.bz2 --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1657 > > Actually, now that I think of it, a slightly cleaner approach would > > probably be to extend the language vector to add a flag set to non-zero > > for the languages that want nested-subprogram handling. The only slight > > issue is that the CU references the language enum, which means we need > > to go from that enum to the language_defn to get access to the flag. > > I think you should stick with a language test in the DWARF reader. OK. Would the following kind of patch be what you have in mind? Or would you prefer that the function simply take a language, rather than a CU. Or actually no function at all? 2008-09-30 Joel Brobecker * dwarf2read.c (dwarf2_handle_nested_subprograms_p): New function. (add_partial_subprogram): Replace check of Ada language by call to dwarf2_handle_nested_subprograms_p. (dwarf2_get_subprogram_pc_bounds, load_partial_dies): Likewise. This is only just for comments, as there is still one question open: For Ada, we store the symbols for nested subprograms in the global context. This allows us to break on these functions even when these functions are not defined in the current context. Do we want to do the same with Pascal? Right now, I left this functionality out... In Ada, we have found it to be extremely convenient to not have to be inside the enclosing function before we can insert the breakpoint. When there are ambiguities (say two functions have a nested subprogram with the same name), the ambiguity can be resolved using the fully qualified name. Tested on x86-linux, no regression (but I don't have a Pascal compiler). -- Joel --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pascal-nested.diff" Content-length: 1796 diff -r 5c068b86064f dwarf2read.c --- a/dwarf2read.c Tue Sep 30 15:08:26 2008 -0700 +++ b/dwarf2read.c Tue Sep 30 18:09:41 2008 -0700 @@ -1217,6 +1217,19 @@ dwarf2_resize_section (asection *sectp, sectp->name); } +/* Return non-zero if the given CU may contains some nested subprograms + (in other words, subprograms defined inside another subprogram or + inside a lexical block). + + The result is currently purely based on the compilation unit language, + and thus the content of the compilation unit itself is not checked. */ + +static int +dwarf2_handle_nested_subprograms_p (struct dwarf2_cu *cu) +{ + return (cu->language == language_ada || cu->language == language_pascal); +} + /* Build a partial symbol table. */ void @@ -2163,7 +2176,7 @@ add_partial_subprogram (struct partial_d if (! pdi->has_children) return; - if (cu->language == language_ada) + if (dwarf2_handle_nested_subprograms_p (cu)) { pdi = pdi->die_child; while (pdi != NULL) @@ -3345,7 +3358,7 @@ dwarf2_get_subprogram_pc_bounds (struct /* If the language does not allow nested subprograms (either inside subprograms or lexical blocks), we're done. */ - if (cu->language != language_ada) + if (!dwarf2_handle_nested_subprograms_p (cu)) return; /* Check all the children of the given DIE. If it contains nested @@ -5770,7 +5783,7 @@ load_partial_dies (bfd *abfd, gdb_byte * || last_die->tag == DW_TAG_interface_type || last_die->tag == DW_TAG_structure_type || last_die->tag == DW_TAG_union_type)) - || (cu->language == language_ada + || (dwarf2_handle_nested_subprograms_p (cu) && (last_die->tag == DW_TAG_subprogram || last_die->tag == DW_TAG_lexical_block)))) { --5vNYLRcllDrimb99--