This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] Search only one (well, two) objfiles for a minimal symbol
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Sun, 24 Jun 2007 14:59:52 -0400
- Subject: [rfc] Search only one (well, two) objfiles for a minimal symbol
lookup_minimal_symbol_by_pc_section already calls find_pc_section.
For reasons described by Andrew's 2004-01-27 comment, we don't require
the found symbol to be in that section. However, that objection
doesn't mean we have to ignore pc_section completely; I think it's
safe to require that we find the same objfile.
I have a simple testcase where this helps. It's nothing but "set
obj.z.y.x = 1" repeated a couple thousand times in a command file.
Before this patch, lookup_minimal_symbol_by_pc_section takes 17% of
execution time; after this patch it takes about 2%, and the slowest
part is now c_lex. That's because most of the minsyms were in
libc.so.6, which is clearly not the same objfile as the found section.
There's still room to speed things up, but not by a lot.
Any comments? Joel, do you think you could test this on IRIX for me?
Thanks!
--
Daniel Jacobowitz
CodeSourcery
2007-06-24 Daniel Jacobowitz <dan@codesourcery.com>
* minsyms.c (lookup_minimal_symbol_by_pc_section): Search fewer
objfiles.
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.50
diff -u -p -r1.50 minsyms.c
--- minsyms.c 15 Jun 2007 22:39:52 -0000 1.50
+++ minsyms.c 24 Jun 2007 18:44:08 -0000
@@ -387,20 +387,20 @@ lookup_minimal_symbol_by_pc_section (COR
if (pc_section == NULL)
return NULL;
- /* NOTE: cagney/2004-01-27: Removed code (added 2003-07-19) that was
- trying to force the PC into a valid section as returned by
- find_pc_section. It broke IRIX 6.5 mdebug which relies on this
- code returning an absolute symbol - the problem was that
- find_pc_section wasn't returning an absolute section and hence
- the code below would skip over absolute symbols. Since the
- original problem was with finding a frame's function, and that
- uses [indirectly] lookup_minimal_symbol_by_pc, the original
- problem has been fixed by having that function use
- find_pc_section. */
-
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ /* We can not require the symbol found to be in pc_section, because
+ e.g. IRIX 6.5 mdebug relies on this code returning an absolute
+ symbol - but find_pc_section won't return an absolute section and
+ hence the code below would skip over absolute symbols. We can
+ still take advantage of the call to find_pc_section, though - the
+ object file still must match. In case we have separate debug
+ files, search both the file and its separate debug file. There's
+ no telling which one will have the minimal symbols. */
+
+ objfile = pc_section->objfile;
+ if (objfile->separate_debug_objfile)
+ objfile = objfile->separate_debug_objfile;
+
+ for (; objfile != NULL; objfile = objfile->separate_debug_objfile_backlink)
{
/* If this objfile has a minimal symbol table, go search it using
a binary search. Note that a minimal symbol table always consists