* [patch] objfile_relocate: Call breakpoint_re_set on-demand
@ 2010-01-10 23:34 Jan Kratochvil
2010-01-11 17:58 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-01-10 23:34 UTC (permalink / raw)
To: gdb-patches
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. */
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch] objfile_relocate: Call breakpoint_re_set on-demand
2010-01-10 23:34 [patch] objfile_relocate: Call breakpoint_re_set on-demand Jan Kratochvil
@ 2010-01-11 17:58 ` Tom Tromey
2010-01-11 18:16 ` Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-01-11 17:58 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> this is just a performance optimization to avoid some needless calls.
It seems reasonable enough to me.
Jan> 2010-01-11 Jan Kratochvil <jan.kratochvil@redhat.com>
Jan> * objfiles.c (objfile_relocate1): Change the return type to int.
Jan> Describe the new return value. Return non-zero if data changed.
Jan> (objfile_relocate): New variable changed. Set it. Call
Jan> breakpoint_re_set depending on CHANGED.
Ok.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] objfile_relocate: Call breakpoint_re_set on-demand
2010-01-11 17:58 ` Tom Tromey
@ 2010-01-11 18:16 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-01-11 18:16 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Mon, 11 Jan 2010 18:58:20 +0100, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> 2010-01-11 Jan Kratochvil <jan.kratochvil@redhat.com>
> Jan> * objfiles.c (objfile_relocate1): Change the return type to int.
> Jan> Describe the new return value. Return non-zero if data changed.
> Jan> (objfile_relocate): New variable changed. Set it. Call
> Jan> breakpoint_re_set depending on CHANGED.
>
> Ok.
Checked-in:
http://sourceware.org/ml/gdb-cvs/2010-01/msg00095.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-11 18:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-10 23:34 [patch] objfile_relocate: Call breakpoint_re_set on-demand Jan Kratochvil
2010-01-11 17:58 ` Tom Tromey
2010-01-11 18:16 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox