c_002b_002bfilt.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1991-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3
  6. or any later version published by the Free Software Foundation;
  7. with no Invariant Sections, with no Front-Cover Texts, and with no
  8. Back-Cover Texts. A copy of the license is included in the
  9. section entitled "GNU Free Documentation License".
  10. -->
  11. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  12. <head>
  13. <title>GNU Binary Utilities: c++filt</title>
  14. <meta name="description" content="GNU Binary Utilities: c++filt">
  15. <meta name="keywords" content="GNU Binary Utilities: c++filt">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="makeinfo">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <link href="index.html#Top" rel="start" title="Top">
  21. <link href="Binutils-Index.html#Binutils-Index" rel="index" title="Binutils Index">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="index.html#Top" rel="up" title="Top">
  24. <link href="addr2line.html#addr2line" rel="next" title="addr2line">
  25. <link href="strip.html#strip" rel="prev" title="strip">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.smallquotation {font-size: smaller}
  30. div.display {margin-left: 3.2em}
  31. div.example {margin-left: 3.2em}
  32. div.indentedblock {margin-left: 3.2em}
  33. div.lisp {margin-left: 3.2em}
  34. div.smalldisplay {margin-left: 3.2em}
  35. div.smallexample {margin-left: 3.2em}
  36. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  37. div.smalllisp {margin-left: 3.2em}
  38. kbd {font-style:oblique}
  39. pre.display {font-family: inherit}
  40. pre.format {font-family: inherit}
  41. pre.menu-comment {font-family: serif}
  42. pre.menu-preformatted {font-family: serif}
  43. pre.smalldisplay {font-family: inherit; font-size: smaller}
  44. pre.smallexample {font-size: smaller}
  45. pre.smallformat {font-family: inherit; font-size: smaller}
  46. pre.smalllisp {font-size: smaller}
  47. span.nocodebreak {white-space:nowrap}
  48. span.nolinebreak {white-space:nowrap}
  49. span.roman {font-family:serif; font-weight:normal}
  50. span.sansserif {font-family:sans-serif; font-weight:normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  56. <a name="c_002b_002bfilt"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="addr2line.html#addr2line" accesskey="n" rel="next">addr2line</a>, Previous: <a href="strip.html#strip" accesskey="p" rel="prev">strip</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="c_002b_002bfilt-1"></a>
  63. <h2 class="chapter">9 c++filt</h2>
  64. <a name="index-c_002b_002bfilt"></a>
  65. <a name="index-demangling-C_002b_002b-symbols"></a>
  66. <div class="smallexample">
  67. <pre class="smallexample">c++filt [<samp>-_</samp>|<samp>--strip-underscore</samp>]
  68. [<samp>-n</samp>|<samp>--no-strip-underscore</samp>]
  69. [<samp>-p</samp>|<samp>--no-params</samp>]
  70. [<samp>-t</samp>|<samp>--types</samp>]
  71. [<samp>-i</samp>|<samp>--no-verbose</samp>]
  72. [<samp>-s</samp> <var>format</var>|<samp>--format=</samp><var>format</var>]
  73. [<samp>--help</samp>] [<samp>--version</samp>] [<var>symbol</var>&hellip;]
  74. </pre></div>
  75. <a name="index-cxxfilt"></a>
  76. <p>The C++ and Java languages provide function overloading, which means
  77. that you can write many functions with the same name, providing that
  78. each function takes parameters of different types. In order to be
  79. able to distinguish these similarly named functions C++ and Java
  80. encode them into a low-level assembler name which uniquely identifies
  81. each different version. This process is known as <em>mangling</em>. The
  82. <code>c++filt</code>
  83. <a name="DOCF1" href="#FOOT1"><sup>1</sup></a>
  84. program does the inverse mapping: it decodes (<em>demangles</em>) low-level
  85. names into user-level names so that they can be read.
  86. </p>
  87. <p>Every alphanumeric word (consisting of letters, digits, underscores,
  88. dollars, or periods) seen in the input is a potential mangled name.
  89. If the name decodes into a C++ name, the C++ name replaces the
  90. low-level name in the output, otherwise the original word is output.
  91. In this way you can pass an entire assembler source file, containing
  92. mangled names, through <code>c++filt</code> and see the same source file
  93. containing demangled names.
  94. </p>
  95. <p>You can also use <code>c++filt</code> to decipher individual symbols by
  96. passing them on the command line:
  97. </p>
  98. <div class="example">
  99. <pre class="example">c++filt <var>symbol</var>
  100. </pre></div>
  101. <p>If no <var>symbol</var> arguments are given, <code>c++filt</code> reads symbol
  102. names from the standard input instead. All the results are printed on
  103. the standard output. The difference between reading names from the
  104. command line versus reading names from the standard input is that
  105. command line arguments are expected to be just mangled names and no
  106. checking is performed to separate them from surrounding text. Thus
  107. for example:
  108. </p>
  109. <div class="smallexample">
  110. <pre class="smallexample">c++filt -n _Z1fv
  111. </pre></div>
  112. <p>will work and demangle the name to &ldquo;f()&rdquo; whereas:
  113. </p>
  114. <div class="smallexample">
  115. <pre class="smallexample">c++filt -n _Z1fv,
  116. </pre></div>
  117. <p>will not work. (Note the extra comma at the end of the mangled
  118. name which makes it invalid). This command however will work:
  119. </p>
  120. <div class="smallexample">
  121. <pre class="smallexample">echo _Z1fv, | c++filt -n
  122. </pre></div>
  123. <p>and will display &ldquo;f(),&rdquo;, i.e., the demangled name followed by a
  124. trailing comma. This behaviour is because when the names are read
  125. from the standard input it is expected that they might be part of an
  126. assembler source file where there might be extra, extraneous
  127. characters trailing after a mangled name. For example:
  128. </p>
  129. <div class="smallexample">
  130. <pre class="smallexample"> .type _Z1fv, @function
  131. </pre></div>
  132. <dl compact="compact">
  133. <dt><code>-_</code></dt>
  134. <dt><code>--strip-underscore</code></dt>
  135. <dd><p>On some systems, both the C and C++ compilers put an underscore in front
  136. of every name. For example, the C name <code>foo</code> gets the low-level
  137. name <code>_foo</code>. This option removes the initial underscore. Whether
  138. <code>c++filt</code> removes the underscore by default is target dependent.
  139. </p>
  140. </dd>
  141. <dt><code>-n</code></dt>
  142. <dt><code>--no-strip-underscore</code></dt>
  143. <dd><p>Do not remove the initial underscore.
  144. </p>
  145. </dd>
  146. <dt><code>-p</code></dt>
  147. <dt><code>--no-params</code></dt>
  148. <dd><p>When demangling the name of a function, do not display the types of
  149. the function&rsquo;s parameters.
  150. </p>
  151. </dd>
  152. <dt><code>-t</code></dt>
  153. <dt><code>--types</code></dt>
  154. <dd><p>Attempt to demangle types as well as function names. This is disabled
  155. by default since mangled types are normally only used internally in
  156. the compiler, and they can be confused with non-mangled names. For example,
  157. a function called &ldquo;a&rdquo; treated as a mangled type name would be
  158. demangled to &ldquo;signed char&rdquo;.
  159. </p>
  160. </dd>
  161. <dt><code>-i</code></dt>
  162. <dt><code>--no-verbose</code></dt>
  163. <dd><p>Do not include implementation details (if any) in the demangled
  164. output.
  165. </p>
  166. </dd>
  167. <dt><code>-s <var>format</var></code></dt>
  168. <dt><code>--format=<var>format</var></code></dt>
  169. <dd><p><code>c++filt</code> can decode various methods of mangling, used by
  170. different compilers. The argument to this option selects which
  171. method it uses:
  172. </p>
  173. <dl compact="compact">
  174. <dt><code>auto</code></dt>
  175. <dd><p>Automatic selection based on executable (the default method)
  176. </p></dd>
  177. <dt><code>gnu</code></dt>
  178. <dd><p>the one used by the <small>GNU</small> C++ compiler (g++)
  179. </p></dd>
  180. <dt><code>lucid</code></dt>
  181. <dd><p>the one used by the Lucid compiler (lcc)
  182. </p></dd>
  183. <dt><code>arm</code></dt>
  184. <dd><p>the one specified by the C++ Annotated Reference Manual
  185. </p></dd>
  186. <dt><code>hp</code></dt>
  187. <dd><p>the one used by the HP compiler (aCC)
  188. </p></dd>
  189. <dt><code>edg</code></dt>
  190. <dd><p>the one used by the EDG compiler
  191. </p></dd>
  192. <dt><code>gnu-v3</code></dt>
  193. <dd><p>the one used by the <small>GNU</small> C++ compiler (g++) with the V3 ABI.
  194. </p></dd>
  195. <dt><code>java</code></dt>
  196. <dd><p>the one used by the <small>GNU</small> Java compiler (gcj)
  197. </p></dd>
  198. <dt><code>gnat</code></dt>
  199. <dd><p>the one used by the <small>GNU</small> Ada compiler (GNAT).
  200. </p></dd>
  201. </dl>
  202. </dd>
  203. <dt><code>--help</code></dt>
  204. <dd><p>Print a summary of the options to <code>c++filt</code> and exit.
  205. </p>
  206. </dd>
  207. <dt><code>--version</code></dt>
  208. <dd><p>Print the version number of <code>c++filt</code> and exit.
  209. </p></dd>
  210. </dl>
  211. <blockquote>
  212. <p><em>Warning:</em> <code>c++filt</code> is a new utility, and the details of its
  213. user interface are subject to change in future releases. In particular,
  214. a command-line option may be required in the future to decode a name
  215. passed as an argument on the command line; in other words,
  216. </p>
  217. <div class="example">
  218. <pre class="example">c++filt <var>symbol</var>
  219. </pre></div>
  220. <p>may in a future release become
  221. </p>
  222. <div class="example">
  223. <pre class="example">c++filt <var>option</var> <var>symbol</var>
  224. </pre></div>
  225. </blockquote>
  226. <div class="footnote">
  227. <hr>
  228. <h4 class="footnotes-heading">Footnotes</h4>
  229. <h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
  230. <p>MS-DOS does not allow <kbd>+</kbd> characters in file names, so on
  231. MS-DOS this program is named <code>CXXFILT</code>.</p>
  232. </div>
  233. <hr>
  234. <div class="header">
  235. <p>
  236. Next: <a href="addr2line.html#addr2line" accesskey="n" rel="next">addr2line</a>, Previous: <a href="strip.html#strip" accesskey="p" rel="prev">strip</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Binutils-Index.html#Binutils-Index" title="Index" rel="index">Index</a>]</p>
  237. </div>
  238. </body>
  239. </html>