From 09fbbdde83fa792aa98eee0377971a9c5a7b8be5 Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 28 Mar 2024 18:31:33 +0000 Subject: deploy: d5772f62300453d98ad0cfa8334efe0b62a7d157 --- development/c++filt.html | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'development') diff --git a/development/c++filt.html b/development/c++filt.html index b6065fe..3c69659 100644 --- a/development/c++filt.html +++ b/development/c++filt.html @@ -178,11 +178,42 @@

c++filt(1)

Demangle symbol

-
  c++-filt <symbol_str>
+
  c++-filt [opts] <symbol_str>
+    -t    Try to also demangle types.
 

Demangle stream

For example dynamic symbol table:

  readelf -W --dyn-syms <elf> | c++filt
+
+

Demangle types

+
// file: type.cc
+#include <cstdio>
+#include <typeinfo>
+
+#define P(ty) printf(#ty " -> %s\n", typeid(ty).name())
+
+template <typename T = void>
+struct Foo {};
+
+int main() {
+  P(int);
+  P(unsigned char);
+  P(Foo<>);
+  P(Foo<int>);
+}
+
+

Build and run:

+
$ clang++ type.cc && ./a.out | c++filt
+int -> i
+unsigned char -> h
+Foo<> -> 3FooIvE
+Foo<int> -> 3FooIiE
+
+$ clang++ type.cc && ./a.out | c++filt -t
+int -> int
+unsigned char -> unsigned char
+Foo<> -> Foo<void>
+Foo<int> -> Foo<int>
 
-- cgit v1.2.3