From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2038 invoked by alias); 21 Dec 2011 09:30:39 -0000 Received: (qmail 2021 invoked by uid 22791); 21 Dec 2011 09:30:38 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Dec 2011 09:30:23 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBL9TvKd024660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2011 04:29:57 -0500 Received: from host2.jankratochvil.net (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBL9Tqfs010319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 21 Dec 2011 04:29:54 -0500 Date: Wed, 21 Dec 2011 11:46:00 -0000 From: Jan Kratochvil To: Ulrich Weigand Cc: gdb-patches@sourceware.org, Joel Brobecker , Pedro Alves Subject: [patch] reread_symbols observer_notify_new_objfile - fix ARM unwinding after reread [Re: [patch+7.4] reread.exp 7.3->7.4 regression] Message-ID: <20111221092951.GA22659@host2.jankratochvil.net> References: <20111218115343.GB22534@host2.jankratochvil.net> <201112191030.pBJAUsf4028428@d06av02.portsmouth.uk.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201112191030.pBJAUsf4028428@d06av02.portsmouth.uk.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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: 2011-12/txt/msg00714.txt.bz2 On Mon, 19 Dec 2011 11:30:54 +0100, Ulrich Weigand wrote: > In addition, we should probably call observer_notify_new_objfile so that new > tables can be built up for the re-read file ... Implemented. I have tested it really fixes the problem of ARM unwinding after reread on stripped GDB binary. Before this fix: ./gdb -nx ./test-gdb-strip -ex 'b gdb_do_one_event' -ex r -ex bt Breakpoint 1, 0x00372154 in gdb_do_one_event () #0 0x00372154 in gdb_do_one_event () #1 0x003722c8 in start_event_loop () #2 0x003741bc in cli_command_loop () #3 0x0036b9e0 in current_interp_command_loop () #4 0x0007a054 in ?? () #5 0x0036af08 in catch_errors () #6 0x0007b58c in ?? () #7 0x0036af08 in catch_errors () #8 0x0007b5c4 in gdb_main () #9 0x00079cd8 in main () (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y `/opt/jkratoch/redhat/archer-git/gdb/test-gdb-strip' has changed; re-reading symbols. (no debugging symbols found) [...] Breakpoint 1, 0x00372154 in gdb_do_one_event () (gdb) bt #0 0x00372154 in gdb_do_one_event () #1 0x003722c8 in start_event_loop () #2 0x003741bc in cli_command_loop () #3 0x0036b9e0 in current_interp_command_loop () #4 0x0007a054 in ?? () #5 0x0007a054 in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) After this fix both backtraces are the same. Testcase is not provided as I do not have some small enough ARM testcase which unwinds with .ARM.exidx but does not unwind without it. No regressions on {x86_64,x86_64-m32,i686}-fedora16-linux-gnu and on arm-fedora13beta-linux-gnueabi. Thanks, Jan gdb/ 2011-12-20 Jan Kratochvil * symfile.c (objfilep): New typedef and new DEF_VEC_P. (reread_symbols): Remove variable reread_one, new variables new_objfiles, all_cleanups and ix. Use new_objfiles instead of reread_one. Push changed objfiles to new_objfiles, call observer_notify_new_objfile for them later. --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2371,15 +2371,22 @@ add_symbol_file_command (char *args, int from_tty) } +typedef struct objfile *objfilep; + +DEF_VEC_P (objfilep); + /* Re-read symbols if a symbol-file has changed. */ void reread_symbols (void) { struct objfile *objfile; long new_modtime; - int reread_one = 0; struct stat new_statbuf; int res; + VEC (objfilep) *new_objfiles = NULL; + struct cleanup *all_cleanups; + + all_cleanups = make_cleanup (VEC_cleanup (objfilep), &new_objfiles); /* With the addition of shared libraries, this should be modified, the load time should be saved in the partial symbol tables, since @@ -2594,21 +2601,33 @@ reread_symbols (void) and now, we *want* this to be out of date, so don't call stat again now. */ objfile->mtime = new_modtime; - reread_one = 1; init_entry_point_info (objfile); + + VEC_safe_push (objfilep, new_objfiles, objfile); } } - if (reread_one) + if (new_objfiles) { + int ix; + /* Notify objfiles that we've modified objfile sections. */ objfiles_changed (); clear_symtab_users (0); + + /* clear_objfile_data for each objfile was called before freeing it and + observer_notify_new_objfile (NULL) has been called by + clear_symtab_users above. Notify the new files now. */ + for (ix = 0; VEC_iterate (objfilep, new_objfiles, ix, objfile); ix++) + observer_notify_new_objfile (objfile); + /* At least one objfile has changed, so we can consider that the executable we're debugging has changed too. */ observer_notify_executable_changed (); } + + do_cleanups (all_cleanups); }