gpt4 book ai didi

c - 如何跟踪 C 中的特定函数/文件?

转载 作者:行者123 更新时间:2023-11-30 16:17:28 25 4
gpt4 key购买 nike

我已经知道GCC的参数-finstrument-functions可以 Hook 函数,参数-finstrument-functions-exclude-file(functions)-list可以排除一些要跟踪的文件/函数。

但是现在我有很多文件需要编译,只有其中一些需要跟踪。我想知道是否可以包含一些要跟踪的特定函数/文件,例如 -finstrument-functions-include-file(functions)-list

非常感谢!

最佳答案

GCC 不支持这种开箱即用的功能(这更像是构建系统的一项任务)。实现您想要的目标的一种常见方法是编写一个 shell 包装器来替换 GCC 并在需要时添加标志:

$ cat path/to/fake/gcc
#!/bin/sh
FLAGS=
if echo "$*" | grep -q 'myfile1.c'; then
FLAGS=-finstrument-functions
fi
exec /usr/bin/gcc "$@" $FLAGS
$ export PATH="path/to/fake:$PATH"

关于c - 如何跟踪 C 中的特定函数/文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56249509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com