【发布时间】:2011-06-23 19:15:51
【问题描述】:
我以前,here,已经证明 C++ 函数不容易在汇编中表示。现在我有兴趣以一种或另一种方式阅读它们,因为作为 Valgrind 的一部分的 Callgrind 显示它们被破坏,而在组装时它们被显示为破坏。
所以我想要么破坏 Valgrind 函数输出,要么破坏函数的程序集名称。有人尝试过这样的事情吗?我正在查看website 并发现以下内容:
Code to implement demangling is part of the GNU Binutils package; see libiberty/cplus-dem.c and include/demangle.h.
有没有人尝试过这样的事情?我想在 C 中进行 demangle/mangle。
我的编译器是 gcc 4.x。
【问题讨论】:
-
我不明白您的问题 - 您已经发布了自己的答案,请使用 binutils 中的代码。其他工具链都有类似的库/代码sn-ps,那么问题出在哪里?
-
IIRC 然后 valgrind 已经有一个 --demangle=yes 选项来对输出上的 C++ 符号进行去角化。那么callgrind可以叫
valgrind --tool=callgrind --demangle=yes不是吗? -
@Luther:我打开了另一个论坛来检查我是否对 vallgrind stackoverflow.com/questions/4846411/de-mangeling-in-callgrind 进行了 demangle,但没有人回复。我查看了 linux 手册以解开它没有提供任何东西!你的建议奏效了。谢谢
-
以下答案仅涵盖 demangle 情况。 mangle 案例是 c++ - Is it possible to mangle typename at runtime? - Stack Overflow(note 请参阅此问题链接的问题,以及 that 问题链接的问题)
-
对于 Python,请参阅 stackoverflow.com/questions/6526500/…
标签: c++ c function assembly name-mangling