c++ - sprof 平面配置文件名称列的格式很难看

标签 c++ shared-libraries profiling name-mangling sprof

我尝试使用 sprof 分析共享库提供的函数。 分析有效,但包含函数名称的列的格式非常难看。例如,我正在使用 boost 提供的 unordered_map。平面配置文件中的关联条目是:

Each sample counts as 0.01 seconds.
%   cumulative   self              self     total
time   seconds   seconds    calls  us/call  us/call  name
[...]
0.12     78.47     0.10   232327     0.43            _ZN5boost9unordered13unordered_mapIN4BALL6StringES3_NS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S3_EEEC1ERKSC_
[...]

我使用了与 sprof 中描述的相同命令手册页。我只是改变了路径。 整个配置文件难以阅读,因为人们看不清命名空间、类名、函数名等。

我尝试了 sprof 的小例子手册页,效果很好。

有谁知道为什么这里的名称列格式如此难看?

最佳答案

名称如“_ZN5boost9unordered13unordered_mapIN4BALL6StringES3_NS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S3_EEEC1ERKSC_” 来自 C++ name mangling .名称中记录了命名空间、类名、模板参数、函数名、函数参数类型。通过 mangling,C++ 有一些额外的功能,例如为不同的参数和模板重载方法以生成特定于类型的代码。

您可以使用 c++filt 程序过滤输出,该程序将大多数 C++ 符号名称分解为类似 C++ 代码的格式,可供人类阅读。

也有在线服务来分解名称:https://demangler.com/ 它将您的符号分解为:

boost::unordered::unordered_map<BALL::String, BALL::String, boost::hash<BALL::String>, std::equal_to<BALL::String>, std::allocator<std::pair<BALL::String const, BALL::String> > >::unordered_map(boost::unordered::unordered_map<BALL::String, BALL::String, boost::hash<BALL::String>, std::equal_to<BALL::String>, std::allocator<std::pair<BALL::String const, BALL::String> > > const&)

或者,如果我们重写它:

boost::unordered_map<BALL::String, BALL::String...>::
 unordered_map(boost::unordered::unordered_map<BALL::String, BALL::String...> const&)

或者最后 - 它是 copy constructor

unordered_map<String, String...>::unordered_map( unordered_map<String, String...> const&)

关于c++ - sprof 平面配置文件名称列的格式很难看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38251845/

相关文章:

c++查找一组点中最近的四个

c++ - 如何用mingw在windows上编译rtaudio?

头文件中的 C++ 空接口(interface)析构函数

c# - 实现行级分析

java - 无法理解Intellij IDEA的内存使用和管理

linux - 性能分析器中的调用堆栈

c++ - 为什么 Shell_NotifyIcon 气球提示不起作用?

python - OSError : libtest. 所以: undefined symbol :g_tree_new

php - 从 php 调用 .so 共享库对象

c++ - 是否可以从库连接到mysql?