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