linux - 使用 -finstrument-functions 构建 glibc

标签 linux gcc makefile glibc instrumentation

我正在尝试记录应用程序在崩溃前发出的调用,包括 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/

相关文章:

makefile - 为什么 Makefile 中的 basename 不能按预期工作?

linux - 处理二进制文件时获得与 cat 类似的输出

python - 脚本适用于 Windows,但不适用于 Linux(语法错误)

python - 在 Python 2 中指定自定义日志记录 Linux 文件路径

c++ - 使用 gcc 编译错误 - strprintf ("%"PRId64, n)

c++ - -L 选项不适用于 mingw gcc

c - & 运算符在函数指针赋值中可选

c++ - 加速 C++ : compiling the programs in chapter 4

c++ - default_random_engine’ 没有命名类型

java - 设置 Elasticsearch 问题