Re: [patch] Speed up find_pc_section

Paul Pluzhnikov
2009-07-22T15:49:53Z

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

On Wed, Jul 22, 2009 at 7:25 AM, Tom Tromey<tromey@redhat.com> wrote:

> Paul, could you please either fix this ASAP, or revert the change while
> coming up with a fix?  Thanks.

Here is the fix for both issues.
Tested on Linux/x86_64, no regressions.

I'll work up a test case for add-symbol-file in a separate patch.
Not sure if I can make a test case for objfile_relocate though.

Thanks,
--
Paul Pluzhnikov

2009-07-22 Paul Pluzhnikov <ppluzhnikov@google.com>

* objfiles.c (objfile_relocate): Must rebuild section map.
(set_objfiles_updated_on_new_objfile): New observer.
(_initialize_objfiles): Register it.

[-- Attachment #2: gdb-find_pc_section-20090722.txt --]
[-- Type: text/plain, Size: 1354 bytes --]

Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.86
diff -u -p -u -r1.86 objfiles.c
--- objfiles.c 21 Jul 2009 20:54:30 -0000 1.86
+++ objfiles.c 22 Jul 2009 15:43:47 -0000
@@ -682,6 +682,7 @@ objfile_relocate (struct objfile *objfil

/* Relocate breakpoints as necessary, after things are relocated. */
breakpoint_re_set ();
+ objfiles_updated_p = 1; /* Rebuild section map next time we need it. */
}
\f
/* Many places in gdb want to test just to see if we have any partial
@@ -1007,10 +1008,20 @@ set_objfiles_updated_on_solib_activity (
objfiles_updated_p = 1; /* Rebuild section map next time we need it. */
}

+/* Set objfiles_updated_p so section map will be rebuilt next time it
+ is used. Called by new_objfile observer. */
+
+static void
+set_objfiles_updated_on_new_objfile (struct objfile *objfile)
+{
+ objfiles_updated_p = 1; /* Rebuild section map next time we need it. */
+}
+
void
_initialize_objfiles (void)
{
observer_attach_executable_changed (set_objfiles_updated_on_exe_change);
+ observer_attach_new_objfile (set_objfiles_updated_on_new_objfile);
observer_attach_solib_loaded (set_objfiles_updated_on_solib_activity);
observer_attach_solib_unloaded (set_objfiles_updated_on_solib_activity);
}