Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA/commit/dwarf] Create partial symbols for nested subprograms
Date: Wed, 10 Sep 2008 20:20:00 -0000	[thread overview]
Message-ID: <20080910201959.GC10133@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]

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  <brobecker@adacore.com>

        * 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

[-- Attachment #2: 03-nested_psym.diff --]
[-- Type: text/plain, Size: 2747 bytes --]

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

             reply	other threads:[~2008-09-10 20:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-10 20:20 Joel Brobecker [this message]
2008-09-10 20:35 ` Daniel Jacobowitz
2008-09-10 21:38   ` Tom Tromey
2008-09-11  5:01     ` Joel Brobecker
2008-09-11 22:15       ` Tom Tromey
2008-09-11 22:28         ` Daniel Jacobowitz
2008-09-11 22:33           ` Tom Tromey
2008-09-12  4:19           ` Joel Brobecker
2008-09-11 17:55   ` Joel Brobecker
2008-09-11 18:38     ` Daniel Jacobowitz
2008-09-11 21:53       ` Joel Brobecker
2008-09-13 15:14         ` Daniel Jacobowitz
2008-09-13 22:21           ` Joel Brobecker
2008-09-11 22:44       ` Tom Tromey
2008-09-12  4:18         ` Joel Brobecker
2008-09-12 16:51           ` Tom Tromey
2008-09-12 16:56             ` Joel Brobecker
2008-09-12 17:19               ` Tom Tromey
2008-09-12 17:43                 ` Joel Brobecker
2008-09-12 18:08                   ` Tom Tromey
2008-09-12 18:43                   ` Frank Ch. Eigler
2008-09-12 20:31                     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080910201959.GC10133@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox