diff options
author | johannst <johannst@users.noreply.github.com> | 2024-01-23 01:39:29 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2024-01-23 01:39:29 +0000 |
commit | 6dbf014773f5f8ac0b0e291392dfde518de94daf (patch) | |
tree | f48b103633621acc4c4d6b272fd67f3d86cc2ae2 /print.html | |
parent | c4fdf1c5f2c9ebedd0dedba4449c015f98aecda5 (diff) | |
download | notes-6dbf014773f5f8ac0b0e291392dfde518de94daf.tar.gz notes-6dbf014773f5f8ac0b0e291392dfde518de94daf.zip |
deploy: 8c9fd06e839c06717dd2dcb067371a5e1fc71801
Diffstat (limited to 'print.html')
-rw-r--r-- | print.html | 127 |
1 files changed, 114 insertions, 13 deletions
@@ -89,7 +89,7 @@ <nav id="sidebar" class="sidebar" aria-label="Table of contents"> <div class="sidebar-scrollbox"> - <ol class="chapter"><li class="chapter-item expanded affix "><a href="intro.html">Introduction</a></li><li class="chapter-item expanded "><a href="tools/index.html"><strong aria-hidden="true">1.</strong> Tools</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="tools/zsh.html"><strong aria-hidden="true">1.1.</strong> zsh</a></li><li class="chapter-item expanded "><a href="tools/bash.html"><strong aria-hidden="true">1.2.</strong> bash</a></li><li class="chapter-item expanded "><a href="tools/fish.html"><strong aria-hidden="true">1.3.</strong> fish</a></li><li class="chapter-item expanded "><a href="tools/tmux.html"><strong aria-hidden="true">1.4.</strong> tmux</a></li><li class="chapter-item expanded "><a href="tools/git.html"><strong aria-hidden="true">1.5.</strong> git</a></li><li class="chapter-item expanded "><a href="tools/awk.html"><strong aria-hidden="true">1.6.</strong> awk</a></li><li class="chapter-item expanded "><a href="tools/emacs.html"><strong aria-hidden="true">1.7.</strong> emacs</a></li><li class="chapter-item expanded "><a href="tools/gpg.html"><strong aria-hidden="true">1.8.</strong> gpg</a></li><li class="chapter-item expanded "><a href="tools/gdb.html"><strong aria-hidden="true">1.9.</strong> gdb</a></li><li class="chapter-item expanded "><a href="tools/gdbserver.html"><strong aria-hidden="true">1.10.</strong> gdbserver</a></li><li class="chapter-item expanded "><a href="tools/radare2.html"><strong aria-hidden="true">1.11.</strong> radare2</a></li><li class="chapter-item expanded "><a href="tools/qemu.html"><strong aria-hidden="true">1.12.</strong> qemu</a></li><li class="chapter-item expanded "><a href="tools/pacman.html"><strong aria-hidden="true">1.13.</strong> pacman</a></li><li class="chapter-item expanded "><a href="tools/dot.html"><strong aria-hidden="true">1.14.</strong> dot</a></li><li class="chapter-item expanded "><a href="tools/ffmpeg.html"><strong aria-hidden="true">1.15.</strong> ffmpeg</a></li><li class="chapter-item expanded "><a href="tools/column.html"><strong aria-hidden="true">1.16.</strong> column</a></li><li class="chapter-item expanded "><a href="tools/sort.html"><strong aria-hidden="true">1.17.</strong> sort</a></li><li class="chapter-item expanded "><a href="tools/sed.html"><strong aria-hidden="true">1.18.</strong> sed</a></li></ol></li><li class="chapter-item expanded "><a href="monitor/index.html"><strong aria-hidden="true">2.</strong> Resource analysis & monitor</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="monitor/lsof.html"><strong aria-hidden="true">2.1.</strong> lsof</a></li><li class="chapter-item expanded "><a href="monitor/ss.html"><strong aria-hidden="true">2.2.</strong> ss</a></li><li class="chapter-item expanded "><a href="monitor/pidstat.html"><strong aria-hidden="true">2.3.</strong> pidstat</a></li><li class="chapter-item expanded "><a href="monitor/pgrep.html"><strong aria-hidden="true">2.4.</strong> pgrep</a></li><li class="chapter-item expanded "><a href="monitor/pmap.html"><strong aria-hidden="true">2.5.</strong> pmap</a></li><li class="chapter-item expanded "><a href="monitor/pstack.html"><strong aria-hidden="true">2.6.</strong> pstack</a></li></ol></li><li class="chapter-item expanded "><a href="trace_profile/index.html"><strong aria-hidden="true">3.</strong> Trace and Profile</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="trace_profile/strace.html"><strong aria-hidden="true">3.1.</strong> strace</a></li><li class="chapter-item expanded "><a href="trace_profile/ltrace.html"><strong aria-hidden="true">3.2.</strong> ltrace</a></li><li class="chapter-item expanded "><a href="trace_profile/perf.html"><strong aria-hidden="true">3.3.</strong> perf</a></li><li class="chapter-item expanded "><a href="trace_profile/oprofile.html"><strong aria-hidden="true">3.4.</strong> OProfile</a></li><li class="chapter-item expanded "><a href="trace_profile/time.html"><strong aria-hidden="true">3.5.</strong> time</a></li></ol></li><li class="chapter-item expanded "><a href="binary/index.html"><strong aria-hidden="true">4.</strong> Binary</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="binary/od.html"><strong aria-hidden="true">4.1.</strong> od</a></li><li class="chapter-item expanded "><a href="binary/xxd.html"><strong aria-hidden="true">4.2.</strong> xxd</a></li><li class="chapter-item expanded "><a href="binary/readelf.html"><strong aria-hidden="true">4.3.</strong> readelf</a></li><li class="chapter-item expanded "><a href="binary/objdump.html"><strong aria-hidden="true">4.4.</strong> objdump</a></li><li class="chapter-item expanded "><a href="binary/nm.html"><strong aria-hidden="true">4.5.</strong> nm</a></li></ol></li><li class="chapter-item expanded "><a href="development/index.html"><strong aria-hidden="true">5.</strong> Development</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="development/c++filt.html"><strong aria-hidden="true">5.1.</strong> c++filt</a></li><li class="chapter-item expanded "><a href="development/c++.html"><strong aria-hidden="true">5.2.</strong> c++</a></li><li class="chapter-item expanded "><a href="development/glibc.html"><strong aria-hidden="true">5.3.</strong> glibc</a></li><li class="chapter-item expanded "><a href="development/gcc.html"><strong aria-hidden="true">5.4.</strong> gcc</a></li><li class="chapter-item expanded "><a href="development/cmake.html"><strong aria-hidden="true">5.5.</strong> cmake</a></li><li class="chapter-item expanded "><a href="development/make.html"><strong aria-hidden="true">5.6.</strong> make</a></li><li class="chapter-item expanded "><a href="development/ld.so.html"><strong aria-hidden="true">5.7.</strong> ld.so</a></li><li class="chapter-item expanded "><a href="development/symbolver.html"><strong aria-hidden="true">5.8.</strong> symbol versioning</a></li><li class="chapter-item expanded "><a href="development/python.html"><strong aria-hidden="true">5.9.</strong> python</a></li><li class="chapter-item expanded "><a href="development/gcov.html"><strong aria-hidden="true">5.10.</strong> gcov</a></li><li class="chapter-item expanded "><a href="development/pgo.html"><strong aria-hidden="true">5.11.</strong> pgo</a></li></ol></li><li class="chapter-item expanded "><a href="linux/index.html"><strong aria-hidden="true">6.</strong> Linux</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="linux/systemd.html"><strong aria-hidden="true">6.1.</strong> systemd</a></li><li class="chapter-item expanded "><a href="linux/coredump.html"><strong aria-hidden="true">6.2.</strong> coredump</a></li><li class="chapter-item expanded "><a href="linux/ptrace_scope.html"><strong aria-hidden="true">6.3.</strong> ptrace_scope</a></li><li class="chapter-item expanded "><a href="linux/cryptsetup.html"><strong aria-hidden="true">6.4.</strong> cryptsetup</a></li><li class="chapter-item expanded "><a href="linux/swap.html"><strong aria-hidden="true">6.5.</strong> swap</a></li><li class="chapter-item expanded "><a href="linux/input.html"><strong aria-hidden="true">6.6.</strong> input</a></li><li class="chapter-item expanded "><a href="linux/acl.html"><strong aria-hidden="true">6.7.</strong> acl</a></li><li class="chapter-item expanded "><a href="linux/zfs.html"><strong aria-hidden="true">6.8.</strong> zfs</a></li></ol></li><li class="chapter-item expanded "><a href="network/index.html"><strong aria-hidden="true">7.</strong> Network</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="network/tcpdump.html"><strong aria-hidden="true">7.1.</strong> tcpdump</a></li><li class="chapter-item expanded "><a href="network/tshark.html"><strong aria-hidden="true">7.2.</strong> tshark</a></li><li class="chapter-item expanded "><a href="network/firewall-cmd.html"><strong aria-hidden="true">7.3.</strong> firewall-cmd</a></li><li class="chapter-item expanded "><a href="network/nftables.html"><strong aria-hidden="true">7.4.</strong> nftables</a></li></ol></li><li class="chapter-item expanded "><a href="web/index.html"><strong aria-hidden="true">8.</strong> Web</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="web/html.html"><strong aria-hidden="true">8.1.</strong> html</a></li><li class="chapter-item expanded "><a href="web/css.html"><strong aria-hidden="true">8.2.</strong> css</a></li><li class="chapter-item expanded "><a href="web/chartjs.html"><strong aria-hidden="true">8.3.</strong> chartjs</a></li></ol></li><li class="chapter-item expanded "><a href="arch/index.html"><strong aria-hidden="true">9.</strong> Arch</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="arch/x86_64.html"><strong aria-hidden="true">9.1.</strong> x86_64</a></li><li class="chapter-item expanded "><a href="arch/arm64.html"><strong aria-hidden="true">9.2.</strong> arm64</a></li><li class="chapter-item expanded "><a href="arch/armv7.html"><strong aria-hidden="true">9.3.</strong> armv7</a></li><li class="chapter-item expanded "><a href="arch/riscv.html"><strong aria-hidden="true">9.4.</strong> riscv</a></li></ol></li></ol> + <ol class="chapter"><li class="chapter-item expanded affix "><a href="intro.html">Introduction</a></li><li class="chapter-item expanded "><a href="tools/index.html"><strong aria-hidden="true">1.</strong> Tools</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="tools/zsh.html"><strong aria-hidden="true">1.1.</strong> zsh</a></li><li class="chapter-item expanded "><a href="tools/bash.html"><strong aria-hidden="true">1.2.</strong> bash</a></li><li class="chapter-item expanded "><a href="tools/fish.html"><strong aria-hidden="true">1.3.</strong> fish</a></li><li class="chapter-item expanded "><a href="tools/tmux.html"><strong aria-hidden="true">1.4.</strong> tmux</a></li><li class="chapter-item expanded "><a href="tools/git.html"><strong aria-hidden="true">1.5.</strong> git</a></li><li class="chapter-item expanded "><a href="tools/awk.html"><strong aria-hidden="true">1.6.</strong> awk</a></li><li class="chapter-item expanded "><a href="tools/emacs.html"><strong aria-hidden="true">1.7.</strong> emacs</a></li><li class="chapter-item expanded "><a href="tools/gpg.html"><strong aria-hidden="true">1.8.</strong> gpg</a></li><li class="chapter-item expanded "><a href="tools/gdb.html"><strong aria-hidden="true">1.9.</strong> gdb</a></li><li class="chapter-item expanded "><a href="tools/gdbserver.html"><strong aria-hidden="true">1.10.</strong> gdbserver</a></li><li class="chapter-item expanded "><a href="tools/radare2.html"><strong aria-hidden="true">1.11.</strong> radare2</a></li><li class="chapter-item expanded "><a href="tools/qemu.html"><strong aria-hidden="true">1.12.</strong> qemu</a></li><li class="chapter-item expanded "><a href="tools/pacman.html"><strong aria-hidden="true">1.13.</strong> pacman</a></li><li class="chapter-item expanded "><a href="tools/dot.html"><strong aria-hidden="true">1.14.</strong> dot</a></li><li class="chapter-item expanded "><a href="tools/ffmpeg.html"><strong aria-hidden="true">1.15.</strong> ffmpeg</a></li><li class="chapter-item expanded "><a href="tools/column.html"><strong aria-hidden="true">1.16.</strong> column</a></li><li class="chapter-item expanded "><a href="tools/sort.html"><strong aria-hidden="true">1.17.</strong> sort</a></li><li class="chapter-item expanded "><a href="tools/sed.html"><strong aria-hidden="true">1.18.</strong> sed</a></li></ol></li><li class="chapter-item expanded "><a href="monitor/index.html"><strong aria-hidden="true">2.</strong> Resource analysis & monitor</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="monitor/lsof.html"><strong aria-hidden="true">2.1.</strong> lsof</a></li><li class="chapter-item expanded "><a href="monitor/ss.html"><strong aria-hidden="true">2.2.</strong> ss</a></li><li class="chapter-item expanded "><a href="monitor/pidstat.html"><strong aria-hidden="true">2.3.</strong> pidstat</a></li><li class="chapter-item expanded "><a href="monitor/pgrep.html"><strong aria-hidden="true">2.4.</strong> pgrep</a></li><li class="chapter-item expanded "><a href="monitor/pmap.html"><strong aria-hidden="true">2.5.</strong> pmap</a></li><li class="chapter-item expanded "><a href="monitor/pstack.html"><strong aria-hidden="true">2.6.</strong> pstack</a></li></ol></li><li class="chapter-item expanded "><a href="trace_profile/index.html"><strong aria-hidden="true">3.</strong> Trace and Profile</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="trace_profile/time.html"><strong aria-hidden="true">3.1.</strong> time</a></li><li class="chapter-item expanded "><a href="trace_profile/strace.html"><strong aria-hidden="true">3.2.</strong> strace</a></li><li class="chapter-item expanded "><a href="trace_profile/ltrace.html"><strong aria-hidden="true">3.3.</strong> ltrace</a></li><li class="chapter-item expanded "><a href="trace_profile/perf.html"><strong aria-hidden="true">3.4.</strong> perf</a></li><li class="chapter-item expanded "><a href="trace_profile/oprofile.html"><strong aria-hidden="true">3.5.</strong> OProfile</a></li><li class="chapter-item expanded "><a href="trace_profile/callgrind.html"><strong aria-hidden="true">3.6.</strong> callgrind</a></li></ol></li><li class="chapter-item expanded "><a href="binary/index.html"><strong aria-hidden="true">4.</strong> Binary</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="binary/od.html"><strong aria-hidden="true">4.1.</strong> od</a></li><li class="chapter-item expanded "><a href="binary/xxd.html"><strong aria-hidden="true">4.2.</strong> xxd</a></li><li class="chapter-item expanded "><a href="binary/readelf.html"><strong aria-hidden="true">4.3.</strong> readelf</a></li><li class="chapter-item expanded "><a href="binary/objdump.html"><strong aria-hidden="true">4.4.</strong> objdump</a></li><li class="chapter-item expanded "><a href="binary/nm.html"><strong aria-hidden="true">4.5.</strong> nm</a></li></ol></li><li class="chapter-item expanded "><a href="development/index.html"><strong aria-hidden="true">5.</strong> Development</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="development/c++filt.html"><strong aria-hidden="true">5.1.</strong> c++filt</a></li><li class="chapter-item expanded "><a href="development/c++.html"><strong aria-hidden="true">5.2.</strong> c++</a></li><li class="chapter-item expanded "><a href="development/glibc.html"><strong aria-hidden="true">5.3.</strong> glibc</a></li><li class="chapter-item expanded "><a href="development/gcc.html"><strong aria-hidden="true">5.4.</strong> gcc</a></li><li class="chapter-item expanded "><a href="development/cmake.html"><strong aria-hidden="true">5.5.</strong> cmake</a></li><li class="chapter-item expanded "><a href="development/make.html"><strong aria-hidden="true">5.6.</strong> make</a></li><li class="chapter-item expanded "><a href="development/ld.so.html"><strong aria-hidden="true">5.7.</strong> ld.so</a></li><li class="chapter-item expanded "><a href="development/symbolver.html"><strong aria-hidden="true">5.8.</strong> symbol versioning</a></li><li class="chapter-item expanded "><a href="development/python.html"><strong aria-hidden="true">5.9.</strong> python</a></li><li class="chapter-item expanded "><a href="development/gcov.html"><strong aria-hidden="true">5.10.</strong> gcov</a></li><li class="chapter-item expanded "><a href="development/pgo.html"><strong aria-hidden="true">5.11.</strong> pgo</a></li></ol></li><li class="chapter-item expanded "><a href="linux/index.html"><strong aria-hidden="true">6.</strong> Linux</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="linux/systemd.html"><strong aria-hidden="true">6.1.</strong> systemd</a></li><li class="chapter-item expanded "><a href="linux/coredump.html"><strong aria-hidden="true">6.2.</strong> coredump</a></li><li class="chapter-item expanded "><a href="linux/ptrace_scope.html"><strong aria-hidden="true">6.3.</strong> ptrace_scope</a></li><li class="chapter-item expanded "><a href="linux/cryptsetup.html"><strong aria-hidden="true">6.4.</strong> cryptsetup</a></li><li class="chapter-item expanded "><a href="linux/swap.html"><strong aria-hidden="true">6.5.</strong> swap</a></li><li class="chapter-item expanded "><a href="linux/input.html"><strong aria-hidden="true">6.6.</strong> input</a></li><li class="chapter-item expanded "><a href="linux/acl.html"><strong aria-hidden="true">6.7.</strong> acl</a></li><li class="chapter-item expanded "><a href="linux/zfs.html"><strong aria-hidden="true">6.8.</strong> zfs</a></li></ol></li><li class="chapter-item expanded "><a href="network/index.html"><strong aria-hidden="true">7.</strong> Network</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="network/tcpdump.html"><strong aria-hidden="true">7.1.</strong> tcpdump</a></li><li class="chapter-item expanded "><a href="network/tshark.html"><strong aria-hidden="true">7.2.</strong> tshark</a></li><li class="chapter-item expanded "><a href="network/firewall-cmd.html"><strong aria-hidden="true">7.3.</strong> firewall-cmd</a></li><li class="chapter-item expanded "><a href="network/nftables.html"><strong aria-hidden="true">7.4.</strong> nftables</a></li></ol></li><li class="chapter-item expanded "><a href="web/index.html"><strong aria-hidden="true">8.</strong> Web</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="web/html.html"><strong aria-hidden="true">8.1.</strong> html</a></li><li class="chapter-item expanded "><a href="web/css.html"><strong aria-hidden="true">8.2.</strong> css</a></li><li class="chapter-item expanded "><a href="web/chartjs.html"><strong aria-hidden="true">8.3.</strong> chartjs</a></li></ol></li><li class="chapter-item expanded "><a href="arch/index.html"><strong aria-hidden="true">9.</strong> Arch</a></li><li><ol class="section"><li class="chapter-item expanded "><a href="arch/x86_64.html"><strong aria-hidden="true">9.1.</strong> x86_64</a></li><li class="chapter-item expanded "><a href="arch/arm64.html"><strong aria-hidden="true">9.2.</strong> arm64</a></li><li class="chapter-item expanded "><a href="arch/armv7.html"><strong aria-hidden="true">9.3.</strong> armv7</a></li><li class="chapter-item expanded "><a href="arch/riscv.html"><strong aria-hidden="true">9.4.</strong> riscv</a></li></ol></li></ol> </div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"> <div class="sidebar-resize-indicator"></div> @@ -1095,6 +1095,20 @@ list-keys -t vi-copy list keymaps for vi-copy mode git push origin --tags .... push local tags to origin (or other remote) </code></pre> +<h2 id="merging"><a class="header" href="#merging">Merging</a></h2> +<pre><code class="language-markdown"> git merge [opt] <commit> .... integrate changes from <commit> since + opt: current branch and <commit> diverged + --squash ................ merge all commits into a single one + --no-commit ............. dont generate commit if the merge succeeds + + git merge-base <commit> <commit> + get the common ancestor, since both commits diverged + + git rebase -i <upstream> .... interactively rebase on <upstream>, also supports actions + like squashing, editing, rewording, etc of commits + + git cherry-pick <commit> .... apply commit on current branch +</code></pre> <h2 id="worktree"><a class="header" href="#worktree">Worktree</a></h2> <p>Worktrees allow to maintain multiple working trees in the filesystem linked to the same repository (shared .git folder).</p> @@ -1143,7 +1157,9 @@ the same repository (shared .git folder).</p> git apply --stat <PATCH> ... see which files the patch would change git apply --check <PATCH> .. see if the patch can be applied cleanly - git apply <PATCH> .......... apply the patch locally without creating a commit + git apply [-3] <PATCH> ..... apply the patch locally without creating a commit, + if the patch does not cleanly apply -3 allows for + a 3-way merge # eg: generate patches for each commit from initial commit on git format-patch -N $(git rev-list --max-parents=0 HEAD) @@ -2571,6 +2587,16 @@ echo -e 'aa\nbb\ncc\ndd' | sed '$d' # Delete range of lines. echo -e 'aa\nbb\ncc\ndd' | sed '1,3d' # dd + +# Delete lines matching pattern. +echo -e 'aa\nbb\ncc\ndd' | sed '/bb/d' +# aa +# cc +# dd + +# Delete lines NOT matching pattern. +echo -e 'aa\nbb\ncc\ndd' | sed '/bb/!d' +# bb </code></pre> <h3 id="insert-lines"><a class="header" href="#insert-lines">Insert lines</a></h3> <pre><code class="language-sh"># Insert before line. @@ -2722,6 +2748,7 @@ major_pagefault: Happens when the page needed is NOT in memory, the kernel -u <usr> only show matching for user <usr> -l additionally list command -a additionally list command + arguments + -x match exactly </code></pre> <h2 id="debug-newest-process"><a class="header" href="#debug-newest-process">Debug newest process</a></h2> <p>For example attach gdb to newest zsh process from <code>$USER</code>.</p> @@ -2741,12 +2768,17 @@ opts: </code></pre> <div style="break-before: page; page-break-before: always;"></div><h1 id="trace-and-profile"><a class="header" href="#trace-and-profile">Trace and Profile</a></h1> <ul> +<li><a href="trace_profile/./time.html">time</a></li> <li><a href="trace_profile/./strace.html">strace</a></li> <li><a href="trace_profile/./ltrace.html">ltrace</a></li> <li><a href="trace_profile/./perf.html">perf</a></li> <li><a href="trace_profile/./oprofile.html">OProfile</a></li> -<li><a href="trace_profile/./time.html">time</a></li> +<li><a href="trace_profile/./callgrind.html">callgrind</a></li> </ul> +<div style="break-before: page; page-break-before: always;"></div><h1 id="usrbintime1"><a class="header" href="#usrbintime1">/usr/bin/time(1)</a></h1> +<pre><code class="language-markdown"># statistics of process run +/usr/bin/time -v <cmd> +</code></pre> <div style="break-before: page; page-break-before: always;"></div><h1 id="strace1"><a class="header" href="#strace1">strace(1)</a></h1> <pre><code class="language-markdown">strace [opts] [prg] -f .......... follow child processes on fork(2) @@ -2853,10 +2885,68 @@ opreport [opt] FILE ophelp show supported hw/sw events </code></pre> -<div style="break-before: page; page-break-before: always;"></div><h1 id="usrbintime1"><a class="header" href="#usrbintime1">/usr/bin/time(1)</a></h1> -<pre><code class="language-markdown"># statistics of process run -/usr/bin/time -v <cmd> +<div style="break-before: page; page-break-before: always;"></div><h1 id="callgrind"><a class="header" href="#callgrind">callgrind</a></h1> +<p>Callgrind is a tracing profiler to record the function call history of a target +program. It is part of the <a href="https://valgrind.org/docs/manual/cl-manual.html">valgrind</a> tool suite.</p> +<p>Profiling data is collected by instrumentation rather than sampling of the +target program.</p> +<p>Callgrind does not capture the actual time spent in a function but computes the +cost of a function based on the instructions fetched (<code>Ir = Instruction read</code>). +Therefore effects like slow IO are not reflected, which should be kept in mind +when analyzing callgrind results.</p> +<p>By default the profiler data is dumped when the target process is terminating, +but <a href="https://valgrind.org/docs/manual/cl-manual.html#cl-manual.callgrind_control-options">callgrind_control</a> allows for interactive control of callgrind.</p> +<pre><code class="language-bash"># Run a program under callgrind. +valgrind --tool=callgrind -- <prog> + +# Interactive control of callgrind. +callgrind_control [opts] + opts: + -b ............. show current backtrace + -e ............. show current event counters + -s ............. show current stats + --dump[=file] .. dump current collection + -i=on|off ...... turn instrumentation on|off +</code></pre> +<p>Results can be analyzed by using one of the following tools</p> +<ul> +<li><a href="https://valgrind.org/docs/manual/cl-manual.html#cl-manual.callgrind_annotate-options">callgrind_annotate</a> (cli)</li> +<li><a href="https://kcachegrind.github.io/html/Home.html">kcachegrind</a> (ui)</li> +</ul> +<p>The following is a collection of frequently used callgrind options.</p> +<pre><code class="language-bash">valgrind --tool=callgrind [opts] -- <prog> + opts: + --callgrind-out-file=<file> .... output file, rather than callgrind.out.<pid> + --dump-instr=<yes|no> .......... annotation on instrucion level, + allows for asm annotations + + --instr-atstart=<yes|no> ....... control if instrumentation is enabled from + beginning of the program + + --separate-threads=<yes|no> .... create separate output files per thread, + appends -<thread_id> to the output file +</code></pre> +<h2 id="profile-specific-part-of-the-target"><a class="header" href="#profile-specific-part-of-the-target">Profile specific part of the target</a></h2> +<p>Programmatically enable/disable instrumentation using the macros defined in +the callgrind header.</p> +<pre><code class="language-c">#include <valgrind/callgrind.h> + +int main() { + // init .. + + CALLGRIND_START_INSTRUMENTATION; + compute(); + CALLGRIND_STOP_INSTRUMENTATION; + + // shutdown .. +} </code></pre> +<blockquote> +<p>In this case, callgrind should be launched with <code>--instr-atstart=no</code>.</p> +</blockquote> +<p>Alternatively instrumentation can be controlled with <code>callgrind_control -i on/off</code>.</p> +<p>The files <a href="trace_profile/callgrind/cg_example.cc">cg_example.cc</a> and +<a href="trace_profile/callgrind/Makefile">Makefile</a> provide a full example.</p> <div style="break-before: page; page-break-before: always;"></div><h1 id="binary"><a class="header" href="#binary">Binary</a></h1> <ul> <li><a href="binary/./od.html">od</a></li> @@ -2945,13 +3035,15 @@ the <code>.rodata</code> section as follows:</p> </code></pre> <div style="break-before: page; page-break-before: always;"></div><h1 id="objdump1"><a class="header" href="#objdump1">objdump(1)</a></h1> <pre><code class="language-markdown"> objdump [opts] <elf> - -M intel use intil syntax - -d disassemble text section - -D disassemble all sections - -S mix disassembly with source code - -C demangle - -j <section> display info for section - --[no-]show-raw-insn [dont] show object code next to disassembly + -M intel use intil syntax + -d disassemble text section + -D disassemble all sections + --disassemble=<sym> disassemble symbol <sym> + -S mix disassembly with source code + -C demangle + -j <section> display info for section + --[no-]show-raw-insn [dont] show object code next to disassembly + --visualize-jumps[=color] visualize jumps with ascii art, optionally color arrows </code></pre> <h2 id="disassemble-section"><a class="header" href="#disassemble-section">Disassemble section</a></h2> <p>For example <code>.plt</code> section:</p> @@ -2990,6 +3082,15 @@ objcopy -O binary --only-section .text test test-bin # Disassemble raw binary. objdump -D -b binary -m i386:x86-64 test-bin </code></pre> +<h2 id="example-disassemble-specific-symbol"><a class="header" href="#example-disassemble-specific-symbol">Example: disassemble specific symbol</a></h2> +<pre><code class="language-bash"># Disassemble main(). +objdump --disassemble=main <bin> +# Disassemble 'foo::bar()' (mangled). +objdump --disassemble=_ZN3foo3barEvr <bin> + +# Disassemble 'foo::bar()' (demangled), requires -C +objdump -C --disassemble=foo::bar <bin> +</code></pre> <div style="break-before: page; page-break-before: always;"></div><h1 id="nm1"><a class="header" href="#nm1">nm(1)</a></h1> <pre><code class="language-markdown"> nm [opts] <elf> -C demangle |