Re: [patch] Speed up find_pc_section

Paul Pluzhnikov
2009-09-14T18:10:47Z

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

On Mon, Sep 14, 2009 at 10:35 AM, Joel Brobecker <brobecker@adacore.com> wrote:
>> I've just checked in both patches. Hopefully this thread will end here,
>> it's been long enough :-)
>
> There is still the OBJF_NOT_MAPPED patch.

Given this subthread:

http://sourceware.org/ml/gdb-patches/2009-09/msg00307.html

I don't believe OBJF_NOT_MAPPED is the right way to go.

I agree with Tristan that we should separate the 'read objfile for symbols,
sections, etc.' from read an object file just for its debug bits.

This would allow:
- Darwin "dwarf debug is found in the separate *.o files",
- Solaris cc/CC without '-xs' (dwarf or stabs debug is found in original
*.o files -- very similar to Darwin),
- We could then use the same on Linux and drop the
separate_debug_objfile/separate_debug_objfile_backlink objfile members,
as well as filter_debuginfo_sections().

Note that current checked in code on Darwin does not fail any asserts,
it just doesn't work correctly and issues bazillion of complaints.

Given above, I don't think committing/testing the OBJF_NOT_MAPPED patch
is the right way to go -- it's more of a hack then a solution.

However, if someone needs a hack, attached is the current state of the
patch. Christian Thalinger tested essentially this version on his Darwin/Java
build, and reported success.

Cheers,
--
Paul Pluzhnikov

2009-09-14 Paul Pluzhnikov <ppluzhnikov@google.com>

* objfiles.h (OBJF_NOT_MAPPED): New define.
* objfiles.c (update_section_map): Ignore not mapped objfiles.
* machoread.c (macho_oso_symfile, macho_oso_symfile): Adjust.

[-- Attachment #2: gdb-macho-bp-reset-20090914.txt --]
[-- Type: text/plain, Size: 3113 bytes --]

Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.64
diff -u -p -u -r1.64 objfiles.h
--- objfiles.h 11 Sep 2009 18:51:31 -0000 1.64
+++ objfiles.h 14 Sep 2009 18:04:54 -0000
@@ -414,6 +414,12 @@ struct objfile

#define OBJF_USERLOADED (1 << 3) /* User loaded */

+/* This objfile is not mapped into the process address space. We only have it
+ for its debug bits. One example is MACH-O ("other source") object
+ files. */
+
+#define OBJF_NOT_MAPPED (1 << 4) /* Not mapped */
+
/* The object file that the main symbol table was loaded from (e.g. the
argument to the "symbol-file" or "file" command). */

Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.96
diff -u -p -u -r1.96 objfiles.c
--- objfiles.c 14 Sep 2009 17:12:07 -0000 1.96
+++ objfiles.c 14 Sep 2009 18:04:54 -0000
@@ -1041,16 +1041,21 @@ update_section_map (struct obj_section *
xfree (map);

alloc_size = 0;
- ALL_OBJSECTIONS (objfile, s)
- if (insert_section_p (objfile->obfd, s->the_bfd_section))
- alloc_size += 1;
+
+ ALL_OBJFILES (objfile)
+ if ((objfile->flags & OBJF_NOT_MAPPED) == 0)
+ ALL_OBJFILE_OSECTIONS (objfile, s)
+ if (insert_section_p (objfile->obfd, s->the_bfd_section))
+ alloc_size += 1;

map = xmalloc (alloc_size * sizeof (*map));

i = 0;
- ALL_OBJSECTIONS (objfile, s)
- if (insert_section_p (objfile->obfd, s->the_bfd_section))
- map[i++] = s;
+ ALL_OBJFILES (objfile)
+ if ((objfile->flags & OBJF_NOT_MAPPED) == 0)
+ ALL_OBJFILE_OSECTIONS (objfile, s)
+ if (insert_section_p (objfile->obfd, s->the_bfd_section))
+ map[i++] = s;

qsort (map, alloc_size, sizeof (*map), qsort_cmp);
map_size = filter_debuginfo_sections(map, alloc_size);
Index: machoread.c
===================================================================
RCS file: /cvs/src/src/gdb/machoread.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 machoread.c
--- machoread.c 19 Jun 2009 14:30:30 -0000 1.5
+++ machoread.c 14 Sep 2009 18:04:54 -0000
@@ -406,7 +406,8 @@ macho_oso_symfile (struct objfile *main_
bfd_close (member_bfd);
}
else
- symbol_file_add_from_bfd (member_bfd, 0, addrs, 0);
+ symbol_file_add_from_bfd (member_bfd, SYMFILE_DEFER_BP_RESET,
+ addrs, OBJF_NOT_MAPPED);
}
else
{
@@ -429,7 +430,8 @@ macho_oso_symfile (struct objfile *main_
continue;
}

- symbol_file_add_from_bfd (abfd, 0, addrs, 0);
+ symbol_file_add_from_bfd (abfd, SYMFILE_DEFER_BP_RESET, addrs,
+ OBJF_NOT_MAPPED);
}
xfree (oso->symbols);
xfree (oso->offsets);
@@ -592,7 +594,7 @@ macho_symfile_read (struct objfile *objf
oso_vector = NULL;

/* Now recurse: read dwarf from dsym. */
- symbol_file_add_from_bfd (dsym_bfd, 0, NULL, 0);
+ symbol_file_add_from_bfd (dsym_bfd, 0, NULL, OBJF_NOT_MAPPED);

/* Don't try to read dwarf2 from main file or shared libraries. */
return;