From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- libstdc++-v3/doc/html/manual/ext_demangling.html | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 libstdc++-v3/doc/html/manual/ext_demangling.html (limited to 'libstdc++-v3/doc/html/manual/ext_demangling.html') 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 @@ + + +Chapter 27. Demangling

+ Transforming C++ ABI identifiers (like RTTI symbols) into the + original C++ source identifiers is called + demangling. +

+ If you have read the source + documentation for namespace abi then you are + aware of the cross-vendor C++ ABI in use by GCC. One of the + exposed functions is used for demangling, + abi::__cxa_demangle. +

+ In programs like c++filt, the linker, and other tools + have the ability to decode C++ ABI names, and now so can you. +

+ (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.) +

+ Probably the only times you'll be interested in demangling at runtime + are when you're seeing typeid strings in RTTI, or when + you're handling the runtime-support exception classes. For example: +

+#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;
+}
+   

+ This prints +

+   
+      St13bad_exception       => std::bad_exception   : 0
+      3barI5emptyLi17EE       => bar<empty, 17>       : 0
+   
+   

+ 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.) +

-- cgit v1.2.3