RFE: dl_iterate_phdr, r_debug.r_brk usability for introspection

John Reiser jreiser@bitwagon.com
Sun Sep 13 16:45:00 GMT 2015


Counting and reporting the number of calls to dlopen and dlclose
would enhance the usability of dl_iterate_phdr.  A related change
to r_debug.r_brk would make life easier for live introspection.

For dl_iterate_phdr: count the number of calls to dlopen and dlclose.
Report the counts to the callback function as new members of
struct dl_phdr_info.  Also tell the number of iterations remaining:
	unsigned dlpi_n_dlopen;   /* # calls in this process */
	unsigned dlpi_n_dlclose;  /* # calls in this process */
	unsigned dlpi_n_more;  /* # remaining link_map along .r_map */

By remembering .dlpi_n_dlopen and .dlpi_n_dlclose from the previous
invocation of dl_iterate_phdr, then the app can tell which kind of
changes, or determine quickly that there have been no changes.
The data member .dlpi_n_more enables effective planning for
resources which depend on the number of link_map instances.

In struct r_debug, change from
     ElfW(Addr) r_brk;
to
     int (*r_brk)(struct r_debug *, unsigned long);
and make .r_brk be a read+write member that is honored by ld-linux.
Instead of ld_linux always calling the same internal function
(with .r_brk being its address), have ld-linux call:
     (void) (*r_debug.r_brk)(&r_debug, 0ul);

ld-linux will initialize r_debug.r_brk, but also will use the
current value of .r_brk if an introspecting app changes .r_brk.
This is much more usable because breakpointing is not required
(but still works.)




More information about the Libc-alpha mailing list