LIBC_PROBE宏实际上在Glibc中如何工作?

时间:2018-09-07 09:04:56

标签: c glibc

我试图了解mallopt()在glibc中的工作方式,但是无法理解函数LIBC_PROBE中使用的mallopt()宏的用法。 LIBC_PROBE的定义正在创建另一个宏LIBC_PROBE_1,并再次创建另一个STAP_PROBE##n。如果为mallopt(),则为STAP_PROBE3(a1, a2, a3)。之后,没有任何线索STAP_PROBE3会如何工作?
源文件:https://github.com/lattera/glibc/blob/master/malloc/malloc.c(行:5141)。

1 个答案:

答案 0 :(得分:2)

来自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.  */

所以:

  1. 不用担心-了解malloopt()的工作方式并不重要。
  2. 如果您真的很在意,请阅读上面引用的Wiki文章,并查看如何在SystemTap源代码中定义宏(SystemTap是与GLIBC完全独立的项目)。
相关问题