【问题标题】:How does LIBC_PROBE macro actually work in Glibc?LIBC_PROBE 宏在 Glibc 中是如何实际工作的?
【发布时间】:2018-09-07 09:04:55
【问题描述】:

我试图了解 mallopt() 在 glibc 中的工作原理,但无法理解函数 mallopt() 中使用的 LIBC_PROBE 宏的使用。 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)。

【问题讨论】:

标签: c glibc


【解决方案1】:

来自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 的项目)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-30
    • 2021-01-21
    • 2011-09-27
    • 2021-12-16
    • 2013-03-14
    • 2021-03-23
    • 2011-02-11
    相关资源
    最近更新 更多