c++filt

原创 2011年09月14日 11:15:14
c++filt decodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing.

You may use c++filt to demangle the symbols.

$ c++filt _ZNSt8ios_base4InitD1Ev
std::ios_base::Init::~Init()

You may try adding -lstdc++ to your link command to resolve the issue.

c++filt
  
     c++filt [-_|--strip-underscores]
             [-j|--java]
             [-n|--no-strip-underscores]
             [-p|--no-params]
             [-s format|--format=format]
             [--help]  [--version]  [symbol...]
     

The C++ and Java languages provides function overloading, which means that you can write many functions with the same name (providing each takes parameters of different types). All C++ and Java function names are encoded into a low-level assembly label (this process is known as mangling). The c++filt 1 program does the inverse mapping: it decodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing.

Every alphanumeric word (consisting of letters, digits, underscores, dollars, or periods) seen in the input is a potential label. If the label decodes into a C++ name, the C++ name replaces the low-level name in the output.

You can use c++filt to decipher individual symbols:

     c++filt symbol
     

If no symbol arguments are given, c++filt reads symbol names from the standard input and writes the demangled names to the standard output. All results are printed on the standard output.

-_
--strip-underscores
On some systems, both the C and C++ compilers put an underscore in front of every name. For example, the C name foo gets the low-level name _foo. This option removes the initial underscore. Whether c++filt removes the underscore by default is target dependent. 
-j
--java
Prints demangled names using Java syntax. The default is to use C++ syntax. 
-n
--no-strip-underscores
Do not remove the initial underscore. 
-p
--no-params
When demangling the name of a function, do not display the types of the function's parameters. 
-s format
--format=format
c++filt can decode various methods of mangling, used by different compilers. The argument to this option selects which method it uses:
auto
Automatic selection based on executable (the default method) 
gnu
the one used by the GNU C++ compiler (g++) 
lucid
the one used by the Lucid compiler (lcc) 
arm
the one specified by the C++ Annotated Reference Manual 
hp
the one used by the HP compiler (aCC) 
edg
the one used by the EDG compiler 
gnu-v3
the one used by the GNU C++ compiler (g++) with the V3 ABI. 
java
the one used by the GNU Java compiler (gcj) 
gnat
the one used by the GNU Ada compiler (GNAT).

--help
Print a summary of the options to c++filt and exit. 
--version
Print the version number of c++filt and exit.
Warning: c++filt is a new utility, and the details of its user interface are subject to change in future releases. In particular, a command-line option may be required in the the future to decode a name passed as an argument on the command line; in other words,
          c++filt symbol
          

may in a future release become

          c++filt option symbol
          

Footnotes

  1. MS-DOS does not allow + characters in file names, so on MS-DOS this program is named cxxfilt.



相见恨晚:linux下的c++filt 命令

一个简单的linux命令, 确实不值得大费周折, 但是, 如果能与实际开发工作联系起来, 解决实际开发中的困惑, 在生动的实际场景中学习命令, 那无疑是棒棒哒的感觉。 最近刚好用c++filt解决了相...
  • stpeace
  • stpeace
  • 2016-05-15 11:42:45
  • 6987

c++filt看函数名

gdb查看寄存器 i r   查看有意义的信息 函数后面的+num(行数) 然后在gdb中用反汇编指令disassemble 在指定行下看编译信息 _ZN6apsara5pangu15ScopedCh...
  • jimmy1357
  • jimmy1357
  • 2015-07-09 18:35:50
  • 3755

Linux命令c++filt

一个简单的linux命令, 确实不值得大费周折, 但是, 在实际的开发过程中,却帮助很大,在编译cgi,修改函数的调用之后获得函数的符号名,就可以看到这个函数的定义。 C/C++语言在编译以后...
  • a2796749
  • a2796749
  • 2016-08-31 00:27:55
  • 494

linux下c++filter查看函数修饰名

c++函数在编译之后会变成类似下面的样子: _ZNK4Json5ValueixEPKc   在linux命令行使用c++filter: root@SSDEV016:~ $ c++filt _ZNK4J...
  • yufei_email
  • yufei_email
  • 2014-07-11 10:31:46
  • 4691

GDB十分钟教程

GDB十分钟教程作者: liigo原文链接: http://blog.csdn.net/liigo/archive/2006/01/17/582231.aspx日期: 2006年1月16日本文写给主要...
  • liigo
  • liigo
  • 2006-01-17 18:28:00
  • 313977

固件提取

说明:Binwalk v2.1.2b Craig Heffner, http://www.binwalk.org Usage: binwalk [OPTIONS] [FILE1] [FI...
  • u011672712
  • u011672712
  • 2018-03-01 10:37:32
  • 96

使用C++filt工具去除C++的名称转义

由于C++的name mangling机制,在使用pstack或ldd等输出C++函数名时 和源代码中的函数名并不是对应的。解决方法很简单:pstack -p 123 | c++filt...
  • iamoyjj
  • iamoyjj
  • 2017-05-01 10:20:15
  • 3254

c++filt address2line GDB栈跟踪

http://www.wuzesheng.com/?p=1804    前几天帮同事跟踪的一个程序莫名退出,没有core dump(当然ulimit是打开的)的问题。我们知道,正常情况下,如果程序...
  • tycoon1988
  • tycoon1988
  • 2014-08-28 16:03:56
  • 665

双语不用教 下载地址!!!

ed2k://|file|英语一点通DVD1-1.(ED2000.COM).VOB|1073739776|17812ce7ba84d62a868204c3aa35f312|h=ctnccbz52k5i...
  • allenlinc
  • allenlinc
  • 2011-07-18 13:47:49
  • 37168

解决V<em>C++</em>6.0的open死机问题+filetool.dll与.exe及操作说明

V<em>C%2B%2B</em>6.0助手[Visual Assist X v10.0.1233.0 破解版(Cracked)]... 时间:2018-3-21c<em>+c%2B%2B</em>程序员面试宝典 时间:2018-3-23 ...
  • 2018年03月27日 00:00
收藏助手
不良信息举报
您举报文章:c++filt
举报原因:
原因补充:

(最多只允许输入30个字)