1<html lang="en"> 2<head> 3<title>c++filt - GNU Binary Utilities</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="GNU Binary Utilities"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="prev" href="elfedit.html#elfedit" title="elfedit"> 9<link rel="next" href="addr2line.html#addr2line" title="addr2line"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 132000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 14Free Software Foundation, Inc. 15 16Permission is granted to copy, distribute and/or modify this document 17under the terms of the GNU Free Documentation License, Version 1.3 18or any later version published by the Free Software Foundation; 19with no Invariant Sections, with no Front-Cover Texts, and with no 20Back-Cover Texts. A copy of the license is included in the 21section entitled ``GNU Free Documentation License''. 22 23--> 24<meta http-equiv="Content-Style-Type" content="text/css"> 25<style type="text/css"><!-- 26 pre.display { font-family:inherit } 27 pre.format { font-family:inherit } 28 pre.smalldisplay { font-family:inherit; font-size:smaller } 29 pre.smallformat { font-family:inherit; font-size:smaller } 30 pre.smallexample { font-size:smaller } 31 pre.smalllisp { font-size:smaller } 32 span.sc { font-variant:small-caps } 33 span.roman { font-family:serif; font-weight:normal; } 34 span.sansserif { font-family:sans-serif; font-weight:normal; } 35--></style> 36<link rel="stylesheet" type="text/css" href="../cs.css"> 37</head> 38<body> 39<div class="node"> 40<a name="c++filt"></a> 41<a name="c_002b_002bfilt"></a> 42<p> 43Next: <a rel="next" accesskey="n" href="addr2line.html#addr2line">addr2line</a>, 44Previous: <a rel="previous" accesskey="p" href="elfedit.html#elfedit">elfedit</a>, 45Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> 46<hr> 47</div> 48 49<h2 class="chapter">9 c++filt</h2> 50 51<p><a name="index-c_002b_002bfilt-121"></a><a name="index-demangling-C_002b_002b-symbols-122"></a> 52<!-- man title cxxfilt Demangle C++ and Java symbols. --> 53 54<pre class="smallexample"> <!-- man begin SYNOPSIS cxxfilt --> 55 c++filt [<samp><span class="option">-_</span></samp>|<samp><span class="option">--strip-underscores</span></samp>] 56 [<samp><span class="option">-n</span></samp>|<samp><span class="option">--no-strip-underscores</span></samp>] 57 [<samp><span class="option">-p</span></samp>|<samp><span class="option">--no-params</span></samp>] 58 [<samp><span class="option">-t</span></samp>|<samp><span class="option">--types</span></samp>] 59 [<samp><span class="option">-i</span></samp>|<samp><span class="option">--no-verbose</span></samp>] 60 [<samp><span class="option">-s</span></samp> <var>format</var>|<samp><span class="option">--format=</span></samp><var>format</var>] 61 [<samp><span class="option">--help</span></samp>] [<samp><span class="option">--version</span></samp>] [<var>symbol</var>...] 62 <!-- man end --> 63</pre> 64 <!-- man begin DESCRIPTION cxxfilt --> 65 <p><a name="index-cxxfilt-123"></a>The C++ and Java languages provide function overloading, which means 66that you can write many functions with the same name, providing that 67each function takes parameters of different types. In order to be 68able to distinguish these similarly named functions C++ and Java 69encode them into a low-level assembler name which uniquely identifies 70each different version. This process is known as <dfn>mangling</dfn>. The 71<samp><span class="command">c++filt</span></samp> 72<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> 73program does the inverse mapping: it decodes (<dfn>demangles</dfn>) low-level 74names into user-level names so that they can be read. 75 76 <p>Every alphanumeric word (consisting of letters, digits, underscores, 77dollars, or periods) seen in the input is a potential mangled name. 78If the name decodes into a C++ name, the C++ name replaces the 79low-level name in the output, otherwise the original word is output. 80In this way you can pass an entire assembler source file, containing 81mangled names, through <samp><span class="command">c++filt</span></samp> and see the same source file 82containing demangled names. 83 84 <p>You can also use <samp><span class="command">c++filt</span></samp> to decipher individual symbols by 85passing them on the command line: 86 87<pre class="example"> c++filt <var>symbol</var> 88</pre> 89 <p>If no <var>symbol</var> arguments are given, <samp><span class="command">c++filt</span></samp> reads symbol 90names from the standard input instead. All the results are printed on 91the standard output. The difference between reading names from the 92command line versus reading names from the standard input is that 93command line arguments are expected to be just mangled names and no 94checking is performed to separate them from surrounding text. Thus 95for example: 96 97<pre class="smallexample"> c++filt -n _Z1fv 98</pre> 99 <p>will work and demangle the name to “f()” whereas: 100 101<pre class="smallexample"> c++filt -n _Z1fv, 102</pre> 103 <p>will not work. (Note the extra comma at the end of the mangled 104name which makes it invalid). This command however will work: 105 106<pre class="smallexample"> echo _Z1fv, | c++filt -n 107</pre> 108 <p>and will display “f(),”, i.e., the demangled name followed by a 109trailing comma. This behaviour is because when the names are read 110from the standard input it is expected that they might be part of an 111assembler source file where there might be extra, extraneous 112characters trailing after a mangled name. For example: 113 114<pre class="smallexample"> .type _Z1fv, @function 115</pre> 116 <!-- man end --> 117<!-- man begin OPTIONS cxxfilt --> 118 <dl> 119<dt><samp><span class="env">-_</span></samp><dt><samp><span class="env">--strip-underscores</span></samp><dd>On some systems, both the C and C++ compilers put an underscore in front 120of every name. For example, the C name <code>foo</code> gets the low-level 121name <code>_foo</code>. This option removes the initial underscore. Whether 122<samp><span class="command">c++filt</span></samp> removes the underscore by default is target dependent. 123 124 <br><dt><samp><span class="env">-n</span></samp><dt><samp><span class="env">--no-strip-underscores</span></samp><dd>Do not remove the initial underscore. 125 126 <br><dt><samp><span class="env">-p</span></samp><dt><samp><span class="env">--no-params</span></samp><dd>When demangling the name of a function, do not display the types of 127the function's parameters. 128 129 <br><dt><samp><span class="env">-t</span></samp><dt><samp><span class="env">--types</span></samp><dd>Attempt to demangle types as well as function names. This is disabled 130by default since mangled types are normally only used internally in 131the compiler, and they can be confused with non-mangled names. For example, 132a function called “a” treated as a mangled type name would be 133demangled to “signed char”. 134 135 <br><dt><samp><span class="env">-i</span></samp><dt><samp><span class="env">--no-verbose</span></samp><dd>Do not include implementation details (if any) in the demangled 136output. 137 138 <br><dt><samp><span class="env">-s </span><var>format</var></samp><dt><samp><span class="env">--format=</span><var>format</var></samp><dd><samp><span class="command">c++filt</span></samp> can decode various methods of mangling, used by 139different compilers. The argument to this option selects which 140method it uses: 141 142 <dl> 143<dt><code>auto</code><dd>Automatic selection based on executable (the default method) 144<br><dt><code>gnu</code><dd>the one used by the <span class="sc">gnu</span> C++ compiler (g++) 145<br><dt><code>lucid</code><dd>the one used by the Lucid compiler (lcc) 146<br><dt><code>arm</code><dd>the one specified by the C++ Annotated Reference Manual 147<br><dt><code>hp</code><dd>the one used by the HP compiler (aCC) 148<br><dt><code>edg</code><dd>the one used by the EDG compiler 149<br><dt><code>gnu-v3</code><dd>the one used by the <span class="sc">gnu</span> C++ compiler (g++) with the V3 ABI. 150<br><dt><code>java</code><dd>the one used by the <span class="sc">gnu</span> Java compiler (gcj) 151<br><dt><code>gnat</code><dd>the one used by the <span class="sc">gnu</span> Ada compiler (GNAT). 152</dl> 153 154 <br><dt><samp><span class="env">--help</span></samp><dd>Print a summary of the options to <samp><span class="command">c++filt</span></samp> and exit. 155 156 <br><dt><samp><span class="env">--version</span></samp><dd>Print the version number of <samp><span class="command">c++filt</span></samp> and exit. 157</dl> 158 159<!-- man end --> 160 <blockquote> 161<em>Warning:</em> <samp><span class="command">c++filt</span></samp> is a new utility, and the details of its 162user interface are subject to change in future releases. In particular, 163a command-line option may be required in the future to decode a name 164passed as an argument on the command line; in other words, 165 166<pre class="example"> c++filt <var>symbol</var> 167</pre> 168 <p class="noindent">may in a future release become 169 170<pre class="example"> c++filt <var>option</var> <var>symbol</var> 171</pre> 172 </blockquote> 173 174 <div class="footnote"> 175<hr> 176<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> MS-DOS does not allow <kbd>+</kbd> characters in file names, so on 177MS-DOS this program is named <samp><span class="command">CXXFILT</span></samp>.</p> 178 179 <hr></div> 180 181 </body></html> 182 183