From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19569 invoked by alias); 10 Jan 2010 23:34:57 -0000 Received: (qmail 19560 invoked by uid 22791); 10 Jan 2010 23:34:56 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS 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; Sun, 10 Jan 2010 23:34:51 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0ANYoPZ029155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 10 Jan 2010 18:34:50 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0ANYHaC005111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 10 Jan 2010 18:34:49 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o0ANYEGi006257 for ; Mon, 11 Jan 2010 00:34:14 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o0ANYAhw006255 for gdb-patches@sourceware.org; Mon, 11 Jan 2010 00:34:10 +0100 Date: Sun, 10 Jan 2010 23:34:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] objfile_relocate: Call breakpoint_re_set on-demand Message-ID: <20100110233410.GC1435@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-01/txt/msg00237.txt.bz2 Hi, this is just a performance optimization to avoid some needless calls. I created the patch as a safety against regressions on non-PIE (normal) executables by the PIE patch if breakpoint_re_set would hurt some time. But it is true there can be a risk of regression for current (rare) users of objfile_relocate (IMO incorrectly) expecting breakpoint_re_set gets called. Briefly checked the callers without seeing such expectations. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan 2010-01-11 Jan Kratochvil * objfiles.c (objfile_relocate1): Change the return type to int. Describe the new return value. Return non-zero if data changed. (objfile_relocate): New variable changed. Set it. Call breakpoint_re_set depending on CHANGED. --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -693,9 +693,10 @@ free_all_objfiles (void) } /* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS - entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here. */ + entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here. + Return non-zero iff any change happened. */ -static void +static int objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) { struct obj_section *s; @@ -714,7 +715,7 @@ objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) something_changed = 1; } if (!something_changed) - return; + return 0; } /* OK, get all the symtabs. */ @@ -850,6 +851,9 @@ objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) exec_set_section_address (bfd_get_filename (objfile->obfd), idx, obj_section_addr (s)); } + + /* Data changed. */ + return 1; } /* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS @@ -865,8 +869,9 @@ void objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) { struct objfile *debug_objfile; + int changed = 0; - objfile_relocate1 (objfile, new_offsets); + changed |= objfile_relocate1 (objfile, new_offsets); for (debug_objfile = objfile->separate_debug_objfile; debug_objfile; @@ -894,13 +899,14 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) debug_objfile->num_sections, objfile_addrs); - objfile_relocate1 (debug_objfile, new_debug_offsets); + changed |= objfile_relocate1 (debug_objfile, new_debug_offsets); do_cleanups (my_cleanups); } /* Relocate breakpoints as necessary, after things are relocated. */ - breakpoint_re_set (); + if (changed) + breakpoint_re_set (); } /* Return non-zero if OBJFILE has partial symbols. */