Bug 11198

Summary: Performance problem in find_minsym_and_objfile
Product: gdb Reporter: Andre' <andre.poenitz>
Component: symtabAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gdb-prs, tromey
Priority: P2    
Version: 7.0   
Target Milestone: 7.1   
Host: i486-linux-gnu Target: i486-linux-gnu
Build: i486-linux-gnu Last reconfirmed:
Attachments: proposed patch

Description Andre' 2010-01-20 16:10:16 UTC
Each time I step the first time into code belonging to some library like QtCore
or QtGui, gdb goes to 100% CPU for 10-20 seconds. That time is spent almost
entirely in find_minsym_and_objfile (char *name, struct objfile **objfile_p) in
glibc-tdep.c. The change below removes the delay and does not seem to have ill
side-effects for me.

--- glibc-tdep.c.orig   2010-01-20 16:00:22.000000000 +0100
+++ glibc-tdep.c        2010-01-20 17:04:41.000000000 +0100
@@ -41,15 +41,12 @@
   ALL_OBJFILES (objfile)
     {
         struct minimal_symbol *msym;
-      ALL_OBJFILE_MSYMBOLS (objfile, msym)
-       {
-         if (SYMBOL_LINKAGE_NAME (msym)
-             && strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
-           {
+        msym = lookup_minimal_symbol (name, NULL, objfile);
+        if ( msym ) 
+         {
              *objfile_p = objfile;
              return msym;
-           }
-       }
+         }
     }
Comment 1 Tom Tromey 2010-01-20 19:00:44 UTC
Created attachment 4543 [details]
proposed patch

Please try this patch.
If it works for you, I will check it in.
Thanks.
Comment 2 Andre' 2010-01-21 14:45:30 UTC
Yes, it solves the performance problem. 

Time for the initial step into  libQtCore.so is down to 0.4 seconds from 10.2
seconds, both "real" time averaged over four "warm" runs.
Comment 3 Sourceware Commits 2010-01-21 17:12:38 UTC
Subject: Bug 11198

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-01-21 17:12:19

Modified files:
	gdb            : ChangeLog minsyms.c symtab.h glibc-tdep.c 

Log message:
	PR symtab/11198:
	* symtab.h (lookup_minimal_symbol_and_objfile): Declare.
	* minsyms.c (lookup_minimal_symbol_and_objfile): New function.
	* glibc-tdep.c (find_minsym_and_objfile): Remove.
	(glibc_skip_solib_resolver): Use
	lookup_minimal_symbol_and_objfile.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11284&r2=1.11285
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/minsyms.c.diff?cvsroot=src&r1=1.70&r2=1.71
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/symtab.h.diff?cvsroot=src&r1=1.144&r2=1.145
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/glibc-tdep.c.diff?cvsroot=src&r1=1.12&r2=1.13

Comment 4 Tom Tromey 2010-01-21 17:15:30 UTC
Thanks for trying this.
I've checked in the fix.