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 /print.html | |
parent | da792f6afb36c4a03f51e618b64e6bd5e27fb3fd (diff) | |
download | notes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.tar.gz notes-09fbbdde83fa792aa98eee0377971a9c5a7b8be5.zip |
deploy: d5772f62300453d98ad0cfa8334efe0b62a7d157
Diffstat (limited to 'print.html')
-rw-r--r-- | print.html | 63 |
1 files changed, 62 insertions, 1 deletions
@@ -1916,6 +1916,14 @@ thread name <name> inferior <id> Switch to inferior with <id>. </code></pre> +<h2 id="shell-commands"><a class="header" href="#shell-commands">Shell commands</a></h2> +<pre><code class="language-markdown"> shell <shell_cmd> + Run the shell_cmd and print the output, can also contain a pipeline. + + pipe <gdb_cmd> | <shell_cmd> + Evaluate the gdb_cmd and run the shell_cmd which receives the output + of the gdb_cmd via stdin. +</code></pre> <h2 id="source-file-locations"><a class="header" href="#source-file-locations">Source file locations</a></h2> <pre><code class="language-markdown"> dir <path> Add <path> to the beginning of the searh path for source files. @@ -1956,7 +1964,14 @@ thread name <name> set logging redirect <on/off> on: only log to file. off: log to file and tty. + + set logging overwrite <on/off> + on: Truncate log file on each run. + off: Append to logfile (default). </code></pre> +<blockquote> +<p>Logging options should be configured before logging is turned on.</p> +</blockquote> <h1 id="text-user-interface-tui"><a class="header" href="#text-user-interface-tui">Text user interface (TUI)</a></h1> <pre><code class="language-markdown"> C-x a Toggle UI. C-l Redraw UI (curses UI can be messed up after the debugee prints to @@ -2133,6 +2148,21 @@ New value = 3 set (s=0x7fffffffe594, v=3) at test.c:5 5 } </code></pre> +<h2 id="shell-commands-1"><a class="header" href="#shell-commands-1">Shell commands</a></h2> +<pre><code class="language-markdown"># Run shell commands. + +(gdb) shell zcat /proc/config.gz | grep CONFIG_KVM= +CONFIG_KVM=m + +# Pipe gdb command to shell command. + +(gdb) pipe info proc mapping | grep libc + 0x7ffff7a1a000 0x7ffff7a42000 0x28000 0x0 r--p /usr/lib/libc.so.6 + 0x7ffff7a42000 0x7ffff7b9d000 0x15b000 0x28000 r-xp /usr/lib/libc.so.6 + 0x7ffff7b9d000 0x7ffff7bf2000 0x55000 0x183000 r--p /usr/lib/libc.so.6 + 0x7ffff7bf2000 0x7ffff7bf6000 0x4000 0x1d7000 r--p /usr/lib/libc.so.6 + 0x7ffff7bf6000 0x7ffff7bf8000 0x2000 0x1db000 rw-p /usr/lib/libc.so.6 +</code></pre> <h1 id="know-bugs"><a class="header" href="#know-bugs">Know Bugs</a></h1> <h2 id="workaround-command--finish-bug"><a class="header" href="#workaround-command--finish-bug">Workaround <code>command + finish</code> bug</a></h2> <p>When using <code>finish</code> inside a <code>command</code> block, commands after <code>finish</code> are not @@ -3465,12 +3495,43 @@ objdump -C --disassemble=foo::bar <bin> </ul> <div style="break-before: page; page-break-before: always;"></div><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> <div style="break-before: page; page-break-before: always;"></div><h1 id="c"><a class="header" href="#c">c++</a></h1> <p>openstd <a href="https://www.open-std.org/jtc1/sc22/wg21/docs/standards">cpp standards</a>.</p> <p>Source files of most examples is available <a href="https://github.com/johannst/notes/tree/master/src/development/c%2B%2B">here</a>.</p> |