Bug 10952 - Single Stepping into functions is very slow when not setting LD_BIND_NOW env variable
Summary: Single Stepping into functions is very slow when not setting LD_BIND_NOW env ...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 7.5
Assignee: Pedro Alves
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-13 14:32 UTC by Benjamin Schindler
Modified: 2012-05-07 11:00 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2012-05-03 00:00:00


Attachments
Install gdbarch_skip_solib_resolver on amd64 GNU/Linux (573 bytes, patch)
2012-05-02 09:54 UTC, Pedro Alves
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Schindler 2009-11-13 14:32:17 UTC
(I'm not sure which values to fill out above (host, target and build triplet, so
I'll describe below)

I'm currently debugging paraview and very often, single stepping will cause gdb
to stall for multiple seconds when stepping into a function call. Googling a bit
revealed that setting LD_BIND_NOW can solve these problems. And here it did
solve them 

I'm on a modern 8-core x86-64 system with more than enough ram. Kernel and
user-space software is all in x86-64.
Distribution is gentoo (no excessive flags)

If there is anything I can do just let me know
Comment 1 Benjamin Schindler 2009-11-13 15:05:43 UTC
Thanks to some help from pholklore___ on #gdb on freenode, I was able to produce
some output. 

I enabled:
 set debug infrun 1

And the output is like this (the last 100 lines, there were way more than this,
but they were all the same)

infrun: stop_pc = 0x7ffff7deecb6                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecb9                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecbd                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecc4                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecc7                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecc9                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecce                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecd2                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecd3                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7deecd4                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45a2                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45a5                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45aa                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45af                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45b4                                               
                                                                               
                                         
infrun: stepped into dynsym resolve code                                       
                                                                               
                                         
infrun: resume (step=1, signal=0), trap_expected=0                             
                                                                               
                                         
infrun: prepare_to_wait                                                        
                                                                               
                                         
infrun: target_wait (-1, status) =                                             
                                                                               
                                         
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],                             
                                                                               
                                         
infrun:   status->kind = stopped, signal = SIGTRAP                             
                                                                               
                                         
infrun: infwait_normal_state                                                   
                                                                               
                                         
infrun: TARGET_WAITKIND_STOPPED                                                
                                                                               
                                         
infrun: stop_pc = 0x7ffff7df45b9
infrun: stepped into dynsym resolve code
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7ffff7df45be
infrun: stepped into dynsym resolve code
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7ffff7df45c3
infrun: stepped into dynsym resolve code
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7ffff7df45c7
infrun: stepped into dynsym resolve code
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7ffff7df45cb
infrun: stepped into dynsym resolve code
infrun: resume (step=1, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7fffe7b8afd4
infrun: stepped into subroutine
infrun: inserting step-resume breakpoint at 0x7fffe7b8afe0
infrun: resume (step=0, signal=0), trap_expected=0
infrun: prepare_to_wait
infrun: target_wait (-1, status) =
infrun:   1703 [Thread 0x7ffff7e977c0 (LWP 1703)],
infrun:   status->kind = stopped, signal = SIGTRAP
infrun: infwait_normal_state
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x7fffe7b8afe0
infrun: BPSTAT_WHAT_STEP_RESUME
infrun: stepped into subroutine
infrun: stop_stepping
Comment 2 dje 2012-05-01 17:06:43 UTC
Data point: This is still an issue.  One exampoe here took 30 seconds to get through 1800 insns of dynsym resolving code.
Comment 3 dje 2012-05-01 17:48:45 UTC
Some profiling data for the 30 seconds to step 1800 insns of dynsym resolving code case.
gdb compiled with -g -pg -ftest-coverage -fprofile-arc.
This is with gdb 7.4.

gprof output:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 35.22      6.97     6.97    18756     0.37     0.37  find_pc_sect_psymtab
  8.84      8.72     1.75     1925     0.91     0.91  find_pc_sect_symtab
  7.38     10.18     1.46    29385     0.05     0.12  dwarf2_read_abbrevs
  7.33     11.63     1.45 167485647     0.00     0.00  read_unsigned_leb128
  4.40     12.50     0.87   358406     0.00     0.00  cpname_parse
  3.59     13.21     0.71  5015596     0.00     0.00  hash_continue
  2.68     13.74     0.53   762409     0.00     0.00  strcmp_iw_ordered
  2.27     14.19     0.45 15061184     0.00     0.00  dwarf2_lookup_abbrev
  2.12     14.61     0.42  5946084     0.00     0.00  cpname_lex
  1.54     14.92     0.31                             d_print_comp
  1.52     15.22     0.30 12193270     0.00     0.00  read_attribute_value
  1.41     15.50     0.28  2013893     0.00     0.00  read_partial_die
  1.16     15.73     0.23 10510160     0.00     0.00  dwarf_alloc_abbrev
  1.06     15.94     0.21    29094     0.01     0.12  load_partial_dies
  1.06     16.15     0.21   152021     0.00     0.00  msymbol_hash_iw

For find_pc_sect_psymtab, gcov shows this interesting tidbit:

 85699863:  364:  ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
148591017:  365:    if (!pst->psymtabs_addrmap_supported
 62909784:  366:	&& pc >= pst->textlow && pc < pst->texthigh)
Comment 4 dje 2012-05-01 18:08:49 UTC
Another data point for the same example:

gcov for symtab.c, find_pc_sect_symtab has this:

 32582676: 1968:  ALL_PRIMARY_SYMTABS (objfile, s)
        -: 1969:  {
   206414: 1970:    bv = BLOCKVECTOR (s);
   206414: 1971:    b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);

A case for having a list of the symtabs with block vectors not polluted by symtabs without block vectors (or rather share theirs with the primary - the include files) ?
Comment 5 Pedro Alves 2012-05-02 09:54:38 UTC
Created attachment 6384 [details]
Install gdbarch_skip_solib_resolver on amd64 GNU/Linux

Looks like I'm sitting on this for 3 years already...  (I'm pholklore)

Try this patch.  For some reason, which I couldn't determine from looking at the archives/history, amd64 doesn't install glibc_skip_solib_resolver.  Looks like an oversight.  This short circuits a bunch of single-steps while resolving plts.
Comment 6 dje 2012-05-02 16:53:32 UTC
Pedro, righto.
[Yes, I know you're pholkore. :-)]

Seems like an oversight to me.
Comment 8 Sourceware Commits 2012-05-07 10:59:30 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	palves@sourceware.org	2012-05-07 10:59:26

Modified files:
	gdb            : ChangeLog 

Log message:
	Add PR number to ChangeLog entry.
	
	2012-05-07  Pedro Alves  <palves@redhat.com>
	
	PR gdb/10952
	
	* amd64-linux-tdep.c: Include glibc-tdep.h.
	(amd64_linux_init_abi): Install glibc_skip_solib_resolver as
	gdbarch_skip_solib_resolver callback.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14213&r2=1.14214
Comment 9 Pedro Alves 2012-05-07 11:00:59 UTC
Patch checked in.