This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 0/7] Improved linker-debugger interface


Hi all,

This is an updated version of a patch series I posted last year
(I underestimated the disruption a baby can bring to your life!)
The series implements an improved interface between glibc and GDB
which significantly improves performance and fixes the following
bug:

  https://bugzilla.redhat.com/show_bug.cgi?id=658851
  http://sources.redhat.com/bugzilla/show_bug.cgi?id=2328
  "_dl_debug_state() RT_CONSISTENT called too early"

The existing linker-debugger interface has a structure (r_debug)
containing a list of loaded libraries, and an empty function
(_dl_debug_state) for debuggers to set breakpoints on and which
the linker calls both before and after modifying this list.
The problems with the current interface are as follows:

  - There is one place where glibc calls _dl_debug_state earlier than
    Solaris libc.  This is PR 2328.  The discrepancy means GDB reports
    libraries as loaded and ready before they really are.

  - There is also no provision for communicating what (if anything)
    has changed when _dl_debug_state is called.  GDB must therefore
    load the entire list of loaded libraries at every stop.  This
    hurts performance.

  - In normal use GDB only needs to stop _after_ the list is modified.
    Because _dl_debug_state is called both before and after changes,
    GDB stops twice as often as it needs to in most cases.  This also
    hurts performance.

glibc since 2.17 has named probes in the runtime linker, everywhere
that _dl_debug_state is called, and an extra pair surrounding
relocation events.  By using this probes-based interface this patch
series solves the above problems:

  - GDB can pick and choose which probes to set breakpoints on.
    By using the "relocation completed" probe instead of the one
    mirroring _dl_debug_state debuggers can stop after relocations
    have occurred, matching the behaviour of Solaris libc.

  - Probes adding new libraries supply the address of the link-map
    entry of the first newly added library.  This enables GDB to
    skip past libraries it has already seen.

  - When stop-on-solib-events is unset, GDB does not have to stop
    before changes are made, only after.  By disabling the "before"
    breakpoints the number of stops made can be halved.

This patch series modifies GDB to search for named probes in the
runtime linker, and to use them instead of _dl_debug_state if
found. If the probes are not found then GDB will fall back to its
previous behaviour.

I've regression tested this natively and using gdbserver on
RHEL 6.3 x86_64, with customized glibc rpms for the following
setups:

  - A glibc with no probes.

  - A glibc with probes as they are in glibc 2.17.

  - A glibc with a slightly different set of probes that were
    originally shipped in Fedora 17 and in RHEL 6 since 6.2.

A quick and dirty speed comparison yielded the following results:

  no of solibs      128     256     512     1024    2048    4096
  --------------------------------------------------------------
  old interface       0       1       4       12      47     185
  new interface       0       0	      2	       4      10      36
  (time in seconds)

If it's more convenient, you can find a tree with this series applied
in the gbenson/rtld-probes branch in archer git.

Thanks,
Gary

-- 
http://gbenson.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]