diff options
author | johannst <johannst@users.noreply.github.com> | 2024-03-28 18:31:33 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2024-03-28 18:31:33 +0000 |
commit | 09fbbdde83fa792aa98eee0377971a9c5a7b8be5 (patch) | |
tree | 8ffcb846477fbe2535b2741d5f2c55ee08d42b17 /development | |
parent | da792f6afb36c4a03f51e618b64e6bd5e27fb3fd (diff) | |
download | notes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.tar.gz notes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.zip |
deploy: d5772f62300453d98ad0cfa8334efe0b62a7d157
Diffstat (limited to 'development')
-rw-r--r-- | development/c++filt.html | 33 |
1 files changed, 32 insertions, 1 deletions
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,12 +178,43 @@ <main> <h1 id="cfilt1"><a class="header" href="#cfilt1">c++filt(1)</a></h1> <h2 id="demangle-symbol"><a class="header" href="#demangle-symbol">Demangle symbol</a></h2> -<pre><code class="language-markdown"> c++-filt <symbol_str> +<pre><code class="language-markdown"> c++-filt [opts] <symbol_str> + -t Try to also demangle types. </code></pre> <h2 id="demangle-stream"><a class="header" href="#demangle-stream">Demangle stream</a></h2> <p>For example dynamic symbol table:</p> <pre><code class="language-markdown"> readelf -W --dyn-syms <elf> | c++filt </code></pre> +<h2 id="demangle-types"><a class="header" href="#demangle-types">Demangle types</a></h2> +<pre><code class="language-c++">// 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>); +} +</code></pre> +<p>Build and run:</p> +<pre><code class="language-sh">$ 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> +</code></pre> </main> |