From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5476 invoked by alias); 21 Jul 2010 13:30:33 -0000 Received: (qmail 5467 invoked by uid 22791); 21 Jul 2010 13:30:31 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Jul 2010 13:30:24 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4F3F7CB02FF; Wed, 21 Jul 2010 15:30:19 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vuk7v-wiLq7Q; Wed, 21 Jul 2010 15:30:19 +0200 (CEST) Received: from province.act-europe.fr (province.act-europe.fr [10.10.0.214]) by mel.act-europe.fr (Postfix) with ESMTP id 241E8CB02BB; Wed, 21 Jul 2010 15:30:19 +0200 (CEST) Received: by province.act-europe.fr (Postfix, from userid 560) id 0FB1C16489D; Wed, 21 Jul 2010 15:30:19 +0200 (CEST) Date: Wed, 21 Jul 2010 13:30:00 -0000 From: Jerome Guitton To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Nullified garbage-collected global variables Message-ID: <20100721133019.GA51363@adacore.com> References: <1278948088-15391-1-git-send-email-guitton@adacore.com> <20100720154223.GA80443@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) 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: 2010-07/txt/msg00330.txt.bz2 Tom Tromey (tromey@redhat.com): > >>>>> "Jerome" == Jerome Guitton 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;