我正在尝试记录应用程序在崩溃前发出的调用,包括 libc 调用。我在 gcc 中使用了 -finstrument-functions
支持和我自己的库,但我无法使用此工具构建 glibc。
我在 libc/configure 中将 -finstrument-functions
添加到 libc_extra_cflags
,但在链接 ld.so 时构建失败并显示“对 __libc_multiple_libcs 的 undefined reference ”。
仅运行 CFLAGS=-finstrument-functions ./configure
不起作用,因为配置测试失败,因为它们没有定义 __cyg_profile_func_enter/_exit
。
我目前正在尝试弄清楚如何为每个模块(stdlib、io、string 等)添加检测并查看 libc/foo/Makefile 应该可以使用例如CFLAGS_stdlib = -finstrument-functions
但标志不会出现在 gcc 命令中。
有没有办法将每个模块的标志添加到 glibc 构建中,或者 glibc 是否已知不能与 -finstrument-functions 一起使用?
最佳答案
I'm trying to log the calls made by an app prior to a crash, including libc calls.
您可以使用 ltrace跟踪应用程序对任何共享库(包括 GLIBC)所做的调用。
is glibc known not to work with -finstrument-functions
差不多。
如果你想一想,你的__cyg_profile_func_enter
要做什么?它不能调用 libc,否则你将以无限递归告终。可以使用直接系统调用,但这绝非易事。
关于linux - 使用 -finstrument-functions 构建 glibc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45879939/