This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RFE: dl_iterate_phdr, r_debug.r_brk usability for introspection
- From: John Reiser <jreiser at bitwagon dot com>
- To: libc-alpha at sourceware dot org
- Date: Sun, 13 Sep 2015 09:45:22 -0700
- Subject: RFE: dl_iterate_phdr, r_debug.r_brk usability for introspection
- Authentication-results: sourceware.org; auth=none
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.)