aboutsummaryrefslogtreecommitdiffhomepage
path: root/development/c++filt.html
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2024-03-28 18:31:33 +0000
committerjohannst <johannst@users.noreply.github.com>2024-03-28 18:31:33 +0000
commit09fbbdde83fa792aa98eee0377971a9c5a7b8be5 (patch)
tree8ffcb846477fbe2535b2741d5f2c55ee08d42b17 /development/c++filt.html
parentda792f6afb36c4a03f51e618b64e6bd5e27fb3fd (diff)
downloadnotes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.tar.gz
notes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.zip
deploy: d5772f62300453d98ad0cfa8334efe0b62a7d157
Diffstat (limited to 'development/c++filt.html')
-rw-r--r--development/c++filt.html33
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 &lt;symbol_str&gt;
+<pre><code class="language-markdown"> c++-filt [opts] &lt;symbol_str&gt;
+ -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 &lt;elf&gt; | 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 &lt;cstdio&gt;
+#include &lt;typeinfo&gt;
+
+#define P(ty) printf(#ty " -&gt; %s\n", typeid(ty).name())
+
+template &lt;typename T = void&gt;
+struct Foo {};
+
+int main() {
+ P(int);
+ P(unsigned char);
+ P(Foo&lt;&gt;);
+ P(Foo&lt;int&gt;);
+}
+</code></pre>
+<p>Build and run:</p>
+<pre><code class="language-sh">$ clang++ type.cc &amp;&amp; ./a.out | c++filt
+int -&gt; i
+unsigned char -&gt; h
+Foo&lt;&gt; -&gt; 3FooIvE
+Foo&lt;int&gt; -&gt; 3FooIiE
+
+$ clang++ type.cc &amp;&amp; ./a.out | c++filt -t
+int -&gt; int
+unsigned char -&gt; unsigned char
+Foo&lt;&gt; -&gt; Foo&lt;void&gt;
+Foo&lt;int&gt; -&gt; Foo&lt;int&gt;
+</code></pre>
</main>