diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/doc/html/manual/ext_demangling.html | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/doc/html/manual/ext_demangling.html')
-rw-r--r-- | libstdc++-v3/doc/html/manual/ext_demangling.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libstdc++-v3/doc/html/manual/ext_demangling.html b/libstdc++-v3/doc/html/manual/ext_demangling.html new file mode 100644 index 000000000..0120bc2b0 --- /dev/null +++ b/libstdc++-v3/doc/html/manual/ext_demangling.html @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Chapter 27. Demangling</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"/><meta name="keywords" content=" ISO C++ , library "/><link rel="home" href="../spine.html" title="The GNU C++ Library"/><link rel="up" href="extensions.html" title="Part III. Extensions"/><link rel="prev" href="ext_io.html" title="Chapter 26. Input and Output"/><link rel="next" href="ext_concurrency.html" title="Chapter 28. Concurrency"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 27. Demangling</th></tr><tr><td align="left"><a accesskey="p" href="ext_io.html">Prev</a> </td><th width="60%" align="center">Part III. + Extensions + +</th><td align="right"> <a accesskey="n" href="ext_concurrency.html">Next</a></td></tr></table><hr/></div><div class="chapter" title="Chapter 27. Demangling"><div class="titlepage"><div><div><h2 class="title"><a id="manual.ext.demangle"/>Chapter 27. Demangling</h2></div></div></div><p> + Transforming C++ ABI identifiers (like RTTI symbols) into the + original C++ source identifiers is called + <span class="quote">“<span class="quote">demangling.</span>”</span> + </p><p> + If you have read the <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01115.html">source + documentation for <code class="code">namespace abi</code></a> then you are + aware of the cross-vendor C++ ABI in use by GCC. One of the + exposed functions is used for demangling, + <code class="code">abi::__cxa_demangle</code>. + </p><p> + In programs like <span class="command"><strong>c++filt</strong></span>, the linker, and other tools + have the ability to decode C++ ABI names, and now so can you. + </p><p> + (The function itself might use different demanglers, but that's the + whole point of abstract interfaces. If we change the implementation, + you won't notice.) + </p><p> + Probably the only times you'll be interested in demangling at runtime + are when you're seeing <code class="code">typeid</code> strings in RTTI, or when + you're handling the runtime-support exception classes. For example: + </p><pre class="programlisting"> +#include <exception> +#include <iostream> +#include <cxxabi.h> + +struct empty { }; + +template <typename T, int N> + struct bar { }; + + +int main() +{ + int status; + char *realname; + + // exception classes not in <stdexcept>, thrown by the implementation + // instead of the user + std::bad_exception e; + realname = abi::__cxa_demangle(e.what(), 0, 0, &status); + std::cout << e.what() << "\t=> " << realname << "\t: " << status << '\n'; + free(realname); + + + // typeid + bar<empty,17> u; + const std::type_info &ti = typeid(u); + + realname = abi::__cxa_demangle(ti.name(), 0, 0, &status); + std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n'; + free(realname); + + return 0; +} + </pre><p> + This prints + </p><pre class="screen"> + <code class="computeroutput"> + St13bad_exception => std::bad_exception : 0 + 3barI5emptyLi17EE => bar<empty, 17> : 0 + </code> + </pre><p> + The demangler interface is described in the source documentation + linked to above. It is actually written in C, so you don't need to + be writing C++ in order to demangle C++. (That also means we have to + use crummy memory management facilities, so don't forget to free() + the returned char array.) + </p></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td align="left"><a accesskey="p" href="ext_io.html">Prev</a> </td><td align="center"><a accesskey="u" href="extensions.html">Up</a></td><td align="right"> <a accesskey="n" href="ext_concurrency.html">Next</a></td></tr><tr><td align="left" valign="top">Chapter 26. Input and Output </td><td align="center"><a accesskey="h" href="../spine.html">Home</a></td><td align="right" valign="top"> Chapter 28. Concurrency</td></tr></table></div></body></html> |