Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch] objfile_relocate: Call breakpoint_re_set on-demand
Date: Sun, 10 Jan 2010 23:34:00 -0000	[thread overview]
Message-ID: <20100110233410.GC1435@host0.dyn.jankratochvil.net> (raw)

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  <jan.kratochvil@redhat.com>

	* 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)
 }
 \f
 /* 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 ();
 }
 \f
 /* Return non-zero if OBJFILE has partial symbols.  */


             reply	other threads:[~2010-01-10 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-10 23:34 Jan Kratochvil [this message]
2010-01-11 17:58 ` Tom Tromey
2010-01-11 18:16   ` Jan Kratochvil

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=20100110233410.GC1435@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.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