Re: [patch] Speed up find_pc_section

Paul Pluzhnikov
2009-08-23T22:48:52Z

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

On Fri, Aug 21, 2009 at 4:30 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:

> (A cleaner fix might be to fix all callers to never pass in a NULL
> section argument --most already don't-- and simply rely on it.)

Attached patch does that ...
Not tested (I still haven't figured out how to test overlays).

> I'm still not completely happy about the assertions you added.  An
> assertion failure is supposed to be an indication of a bug in GDB
> -- it should never be possible to trigger the assertion just by
> providing particular user input (this includes the binary file).

I am still working on fixing that part...

Thanks,
--
Paul Pluzhnikov

2009-08-23 Paul Pluzhnikov <ppluzhnikov@google.com>

* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Assume
non-NULL section.
(lookup_minimal_symbol_by_pc_section): Check for NULL section.
(lookup_minimal_symbol_by_pc): Adjust.

[-- Attachment #2: gdb-overlay-fix-20090823.txt --]
[-- Type: text/plain, Size: 2082 bytes --]

Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.66
diff -u -p -u -r1.66 minsyms.c
--- minsyms.c 28 Jun 2009 00:20:22 -0000 1.66
+++ minsyms.c 22 Aug 2009 18:01:37 -0000
@@ -457,18 +457,10 @@ lookup_minimal_symbol_by_pc_section_1 (C
struct objfile *objfile;
struct minimal_symbol *msymbol;
struct minimal_symbol *best_symbol = NULL;
- struct obj_section *pc_section;
enum minimal_symbol_type want_type, other_type;

want_type = want_trampoline ? mst_solib_trampoline : mst_text;
other_type = want_trampoline ? mst_text : mst_solib_trampoline;
-
- /* PC has to be in a known section. This ensures that anything
- beyond the end of the last segment doesn't appear to be part of
- the last function in the last segment. */
- pc_section = find_pc_section (pc);
- if (pc_section == NULL)
- return NULL;

/* 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
@@ -479,7 +471,7 @@ lookup_minimal_symbol_by_pc_section_1 (C
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;
+ objfile = section->objfile;
if (objfile->separate_debug_objfile)
objfile = objfile->separate_debug_objfile;

@@ -680,6 +672,12 @@ lookup_minimal_symbol_by_pc_section_1 (C
struct minimal_symbol *
lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section)
{
+ if (section == NULL)
+ {
+ section = find_pc_section (pc);
+ if (section == NULL)
+ return NULL;
+ }
return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0);
}

@@ -695,7 +693,7 @@ lookup_minimal_symbol_by_pc (CORE_ADDR p
struct obj_section *section = find_pc_section (pc);
if (section == NULL)
return NULL;
- return lookup_minimal_symbol_by_pc_section (pc, section);
+ return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0);
}
\f