I was trying to understand how mallopt()
works in glibc, but unable to understand the use of LIBC_PROBE
macro used in the function mallopt()
. The definition of LIBC_PROBE
is creating another macro LIBC_PROBE_1
and again it is creating another one STAP_PROBE##n
. In case of mallopt()
it is STAP_PROBE3(a1, a2, a3)
. After this there no clue how STAP_PROBE3
going to work ?
Source file: https://github.com/lattera/glibc/blob/master/malloc/malloc.c (line:5141).
From include/stap-probe.h
:
Without USE_STAP_PROBE, that does nothing but evaluates all
its arguments (to prevent bit rot, unlike e.g. assert).
Systemtap's header defines the macros STAP_PROBE (provider, name) and
STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
in MODULE_NAME (libc, libpthread, etc.) automagically.
The format of the arg parameters is discussed here:
https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
The precise details of how register names are specified is
architecture specific and can be found in the gdb and SystemTap
source code. */
So:
mallopt()
works.