You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

c_002b_002bfilt.html 11KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  14. <title>c++filt (GNU Binary Utilities)</title>
  15. <meta name="description" content="c++filt (GNU Binary Utilities)">
  16. <meta name="keywords" content="c++filt (GNU Binary Utilities)">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  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.indentedblock {margin-right: 0em}
  30. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  48. span.roman {font-family: initial; font-weight: normal}
  49. span.sansserif {font-family: sans-serif; font-weight: normal}
  50. ul.no-bullet {list-style: none}
  51. -->
  52. </style>
  53. </head>
  54. <body lang="en">
  55. <a name="c_002b_002bfilt"></a>
  56. <div class="header">
  57. <p>
  58. 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>
  59. </div>
  60. <hr>
  61. <a name="c_002b_002bfilt-1"></a>
  62. <h2 class="chapter">9 c++filt</h2>
  63. <a name="index-c_002b_002bfilt"></a>
  64. <a name="index-demangling-C_002b_002b-symbols"></a>
  65. <div class="smallexample">
  66. <pre class="smallexample">c++filt [<samp>-_</samp>|<samp>--strip-underscore</samp>]
  67. [<samp>-n</samp>|<samp>--no-strip-underscore</samp>]
  68. [<samp>-p</samp>|<samp>--no-params</samp>]
  69. [<samp>-t</samp>|<samp>--types</samp>]
  70. [<samp>-i</samp>|<samp>--no-verbose</samp>]
  71. [<samp>-r</samp>|<samp>--no-recurse-limit</samp>]
  72. [<samp>-R</samp>|<samp>--recurse-limit</samp>]
  73. [<samp>-s</samp> <var>format</var>|<samp>--format=</samp><var>format</var>]
  74. [<samp>--help</samp>] [<samp>--version</samp>] [<var>symbol</var>&hellip;]
  75. </pre></div>
  76. <a name="index-cxxfilt"></a>
  77. <p>The C++ and Java languages provide function overloading, which means
  78. that you can write many functions with the same name, providing that
  79. each function takes parameters of different types. In order to be
  80. able to distinguish these similarly named functions C++ and Java
  81. encode them into a low-level assembler name which uniquely identifies
  82. each different version. This process is known as <em>mangling</em>. The
  83. <code>c++filt</code>
  84. <a name="DOCF1" href="#FOOT1"><sup>1</sup></a>
  85. program does the inverse mapping: it decodes (<em>demangles</em>) low-level
  86. names into user-level names so that they can be read.
  87. </p>
  88. <p>Every alphanumeric word (consisting of letters, digits, underscores,
  89. dollars, or periods) seen in the input is a potential mangled name.
  90. If the name decodes into a C++ name, the C++ name replaces the
  91. low-level name in the output, otherwise the original word is output.
  92. In this way you can pass an entire assembler source file, containing
  93. mangled names, through <code>c++filt</code> and see the same source file
  94. containing demangled names.
  95. </p>
  96. <p>You can also use <code>c++filt</code> to decipher individual symbols by
  97. passing them on the command line:
  98. </p>
  99. <div class="example">
  100. <pre class="example">c++filt <var>symbol</var>
  101. </pre></div>
  102. <p>If no <var>symbol</var> arguments are given, <code>c++filt</code> reads symbol
  103. names from the standard input instead. All the results are printed on
  104. the standard output. The difference between reading names from the
  105. command line versus reading names from the standard input is that
  106. command-line arguments are expected to be just mangled names and no
  107. checking is performed to separate them from surrounding text. Thus
  108. for example:
  109. </p>
  110. <div class="smallexample">
  111. <pre class="smallexample">c++filt -n _Z1fv
  112. </pre></div>
  113. <p>will work and demangle the name to &ldquo;f()&rdquo; whereas:
  114. </p>
  115. <div class="smallexample">
  116. <pre class="smallexample">c++filt -n _Z1fv,
  117. </pre></div>
  118. <p>will not work. (Note the extra comma at the end of the mangled
  119. name which makes it invalid). This command however will work:
  120. </p>
  121. <div class="smallexample">
  122. <pre class="smallexample">echo _Z1fv, | c++filt -n
  123. </pre></div>
  124. <p>and will display &ldquo;f(),&rdquo;, i.e., the demangled name followed by a
  125. trailing comma. This behaviour is because when the names are read
  126. from the standard input it is expected that they might be part of an
  127. assembler source file where there might be extra, extraneous
  128. characters trailing after a mangled name. For example:
  129. </p>
  130. <div class="smallexample">
  131. <pre class="smallexample"> .type _Z1fv, @function
  132. </pre></div>
  133. <dl compact="compact">
  134. <dt><code>-_</code></dt>
  135. <dt><code>--strip-underscore</code></dt>
  136. <dd><p>On some systems, both the C and C++ compilers put an underscore in front
  137. of every name. For example, the C name <code>foo</code> gets the low-level
  138. name <code>_foo</code>. This option removes the initial underscore. Whether
  139. <code>c++filt</code> removes the underscore by default is target dependent.
  140. </p>
  141. </dd>
  142. <dt><code>-n</code></dt>
  143. <dt><code>--no-strip-underscore</code></dt>
  144. <dd><p>Do not remove the initial underscore.
  145. </p>
  146. </dd>
  147. <dt><code>-p</code></dt>
  148. <dt><code>--no-params</code></dt>
  149. <dd><p>When demangling the name of a function, do not display the types of
  150. the function&rsquo;s parameters.
  151. </p>
  152. </dd>
  153. <dt><code>-t</code></dt>
  154. <dt><code>--types</code></dt>
  155. <dd><p>Attempt to demangle types as well as function names. This is disabled
  156. by default since mangled types are normally only used internally in
  157. the compiler, and they can be confused with non-mangled names. For example,
  158. a function called &ldquo;a&rdquo; treated as a mangled type name would be
  159. demangled to &ldquo;signed char&rdquo;.
  160. </p>
  161. </dd>
  162. <dt><code>-i</code></dt>
  163. <dt><code>--no-verbose</code></dt>
  164. <dd><p>Do not include implementation details (if any) in the demangled
  165. output.
  166. </p>
  167. </dd>
  168. <dt><code>-r</code></dt>
  169. <dt><code>-R</code></dt>
  170. <dt><code>--recurse-limit</code></dt>
  171. <dt><code>--no-recurse-limit</code></dt>
  172. <dt><code>--recursion-limit</code></dt>
  173. <dt><code>--no-recursion-limit</code></dt>
  174. <dd><p>Enables or disables a limit on the amount of recursion performed
  175. whilst demangling strings. Since the name mangling formats allow for
  176. an inifinite level of recursion it is possible to create strings whose
  177. decoding will exhaust the amount of stack space available on the host
  178. machine, triggering a memory fault. The limit tries to prevent this
  179. from happening by restricting recursion to 2048 levels of nesting.
  180. </p>
  181. <p>The default is for this limit to be enabled, but disabling it may be
  182. necessary in order to demangle truly complicated names. Note however
  183. that if the recursion limit is disabled then stack exhaustion is
  184. possible and any bug reports about such an event will be rejected.
  185. </p>
  186. <p>The <samp>-r</samp> option is a synonym for the
  187. <samp>--no-recurse-limit</samp> option. The <samp>-R</samp> option is a
  188. synonym for the <samp>--recurse-limit</samp> option.
  189. </p>
  190. </dd>
  191. <dt><code>-s <var>format</var></code></dt>
  192. <dt><code>--format=<var>format</var></code></dt>
  193. <dd><p><code>c++filt</code> can decode various methods of mangling, used by
  194. different compilers. The argument to this option selects which
  195. method it uses:
  196. </p>
  197. <dl compact="compact">
  198. <dt><code>auto</code></dt>
  199. <dd><p>Automatic selection based on executable (the default method)
  200. </p></dd>
  201. <dt><code>gnu</code></dt>
  202. <dd><p>the one used by the <small>GNU</small> C++ compiler (g++)
  203. </p></dd>
  204. <dt><code>lucid</code></dt>
  205. <dd><p>the one used by the Lucid compiler (lcc)
  206. </p></dd>
  207. <dt><code>arm</code></dt>
  208. <dd><p>the one specified by the C++ Annotated Reference Manual
  209. </p></dd>
  210. <dt><code>hp</code></dt>
  211. <dd><p>the one used by the HP compiler (aCC)
  212. </p></dd>
  213. <dt><code>edg</code></dt>
  214. <dd><p>the one used by the EDG compiler
  215. </p></dd>
  216. <dt><code>gnu-v3</code></dt>
  217. <dd><p>the one used by the <small>GNU</small> C++ compiler (g++) with the V3 ABI.
  218. </p></dd>
  219. <dt><code>java</code></dt>
  220. <dd><p>the one used by the <small>GNU</small> Java compiler (gcj)
  221. </p></dd>
  222. <dt><code>gnat</code></dt>
  223. <dd><p>the one used by the <small>GNU</small> Ada compiler (GNAT).
  224. </p></dd>
  225. </dl>
  226. </dd>
  227. <dt><code>--help</code></dt>
  228. <dd><p>Print a summary of the options to <code>c++filt</code> and exit.
  229. </p>
  230. </dd>
  231. <dt><code>--version</code></dt>
  232. <dd><p>Print the version number of <code>c++filt</code> and exit.
  233. </p></dd>
  234. </dl>
  235. <blockquote>
  236. <p><em>Warning:</em> <code>c++filt</code> is a new utility, and the details of its
  237. user interface are subject to change in future releases. In particular,
  238. a command-line option may be required in the future to decode a name
  239. passed as an argument on the command line; in other words,
  240. </p>
  241. <div class="example">
  242. <pre class="example">c++filt <var>symbol</var>
  243. </pre></div>
  244. <p>may in a future release become
  245. </p>
  246. <div class="example">
  247. <pre class="example">c++filt <var>option</var> <var>symbol</var>
  248. </pre></div>
  249. </blockquote>
  250. <div class="footnote">
  251. <hr>
  252. <h4 class="footnotes-heading">Footnotes</h4>
  253. <h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
  254. <p>MS-DOS does not allow <kbd>+</kbd> characters in file names, so on
  255. MS-DOS this program is named <code>CXXFILT</code>.</p>
  256. </div>
  257. <hr>
  258. <div class="header">
  259. <p>
  260. 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>
  261. </div>
  262. </body>
  263. </html>