3

我正在尝试perf在 Ubuntu 20.04 上进行分析,但问题是其中没有出现许多函数(可能是因为它们是内联的),或者只出现了它们的地址(没有名称等)。我正在使用 CMake 的RelWithDebInfo构建。但是有一些模板函数我不知道如何将它们带到分析器结果中。我认为noinline如果这在 C++ 中对于模板函数是合法的,那么标记它们可能会有所帮助,但这会破坏代码库并且需要按函数完成。有什么建议可以noinline一次完成所有功能吗?

4

1 回答 1

3

您可以添加-fno-inlineCMAKE_CXX_FLAGS.

GCC 手册页

-fno-inline
      Do not expand any functions inline apart from those marked
      with the "always_inline" attribute.  This is the default when
      not optimizing.

      Single functions can be exempted from inlining by marking
      them with the "noinline" attribute.
于 2021-12-03T11:53:36.150 回答