Re: [patch] Speed up find_pc_section

Ulrich Weigand
2009-08-17T19:28:01Z

Paul Pluzhnikov wrote:

> 2009-08-08 Paul Pluzhnikov <ppluzhnikov@google.com>
>
> * objfiles.c (qsort_cmp): Remove assert.
> (preferred_obj_section): New function.
> (update_section_map): Filter duplicates.

This patch breaks overlay support:

+static struct obj_section *
+preferred_obj_section (struct obj_section *a, struct obj_section *b)
+{
+ gdb_assert (obj_section_addr (a) == obj_section_addr (b));
+ gdb_assert ((a->objfile->separate_debug_objfile == b->objfile)
+ || (b->objfile->separate_debug_objfile == a->objfile));
+ gdb_assert ((a->objfile->separate_debug_objfile_backlink == b->objfile)
+ || (b->objfile->separate_debug_objfile_backlink == a->objfile));
+
+ if (a->objfile->separate_debug_objfile != NULL)
+ return a;
+ return b;
+}

+ /* With separate debuginfo files, we may have up to two (almost)
+ identical copies of some obj_sections in the map.
+ Filter out duplicates. */
+ for (i = 0, j = 0; i < map_size; ++i)
+ {
+ struct obj_section *sect1 = map[i];
+ struct obj_section *sect2 = (i + 1 < map_size) ? map[i + 1] : NULL;
+
+ if (sect2 == NULL
+ || obj_section_addr (sect1) != obj_section_addr (sect2))
+ map[j++] = sect1;
+ else
+ {
+ map[j++] = preferred_obj_section (sect1, sect2);
+ ++i;
+ }
+ }

The patch appears to assume that two sections with the same start
address must be from a separate debuginfo file. Of course, in the
presence of overlays, you may have multiple regular sections with
the same start address -- that's the point of overlays :-)

These now always run into the assert above.

Bye,
Ulrich

--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com