Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jerome Guitton <guitton@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Nullified garbage-collected global variables
Date: Wed, 21 Jul 2010 13:30:00 -0000	[thread overview]
Message-ID: <20100721133019.GA51363@adacore.com> (raw)
In-Reply-To: <m3aapmat60.fsf@fleche.redhat.com>

Tom Tromey (tromey@redhat.com):

> >>>>> "Jerome" == Jerome Guitton <guitton@adacore.com> writes:
> 
> Jerome> 	* dwarf2read.c (add_partial_symbol): Do not add a global variable if
> Jerome> 	its adress is null. Add comment to explain why.
> Jerome> 	(new_symbol): Ditto.
> 
> This is ok.  Thanks.

Thank you. I was actually polishing my tests when I realized that I was
missing a case (partial symbols for static variables). I've modified
my patch to handle it; it actually makes it cleaner, I think.

Unless you object, I will commit this new version.


gdb/ChangeLog:

	* dwarf2read.c (add_partial_symbol): Do not add a global variable if
	its adress is null. Add comment to explain why.
	(new_symbol): Ditto.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 288d777..80222c3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3421,7 +3421,19 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	}
       break;
     case DW_TAG_variable:
-      if (pdi->is_external)
+      if (pdi->locdesc)
+	addr = decode_locdesc (pdi->locdesc, cu);
+
+      if (pdi->locdesc
+	  && addr == 0
+	  && !dwarf2_per_objfile->has_section_at_zero)
+	{
+	  /* A global or static variable may also have been stripped
+	     out by the linker if unused, in which case its address
+	     will be nullified; do not add such variables into partial
+	     symbol table then.  */
+	}
+      else if (pdi->is_external)
 	{
 	  /* Global Variable.
 	     Don't enter into the minimal symbol tables as there is
@@ -3436,8 +3448,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	     used by GDB, but it comes in handy for debugging partial symbol
 	     table building.  */
 
-	  if (pdi->locdesc)
-	    addr = decode_locdesc (pdi->locdesc, cu);
 	  if (pdi->locdesc || pdi->has_type)
 	    psym = add_psymbol_to_list (actual_name, strlen (actual_name),
 					built_actual_name,
@@ -3455,7 +3465,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 		xfree (actual_name);
 	      return;
 	    }
-	  addr = decode_locdesc (pdi->locdesc, cu);
 	  /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
 	     mst_file_data, objfile); */
 	  psym = add_psymbol_to_list (actual_name, strlen (actual_name),
@@ -9860,7 +9869,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	    {
 	      var_decode_location (attr, sym, cu);
 	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
-	      if (attr2 && (DW_UNSND (attr2) != 0))
+	      if (SYMBOL_CLASS (sym) == LOC_STATIC
+		  && SYMBOL_VALUE_ADDRESS (sym) == 0
+		  && !dwarf2_per_objfile->has_section_at_zero)
+		{
+		  /* When a static variable is eliminated by the linker,
+		     the corresponding debug information is not stripped
+		     out, but the variable address is set to null;
+		     do not add such variables into symbol table.  */
+		}
+	      else if (attr2 && (DW_UNSND (attr2) != 0))
 		{
 		  struct pending **list_to_add;
 



  reply	other threads:[~2010-07-21 13:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-12 15:22 Jerome Guitton
2010-07-13 16:28 ` Tom Tromey
2010-07-15  9:22   ` Jerome Guitton
2010-07-20 15:44     ` Jerome Guitton
2010-07-20 15:42   ` Jerome Guitton
2010-07-20 18:46     ` Tom Tromey
2010-07-21 13:30       ` Jerome Guitton [this message]
2010-07-23 22:50         ` Tom Tromey
2010-07-26  9:33           ` Jerome Guitton

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=20100721133019.GA51363@adacore.com \
    --to=guitton@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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