From f0cf514eb3ca30c5170e534c3861ad73996c7726 Mon Sep 17 00:00:00 2001
From: johannst
Date: Tue, 22 Aug 2023 21:38:08 +0000
Subject: deploy: 9bb639287cae88b32fc1b17b7a4b494340e54434
---
404.html | 2 +-
arch/arm64.html | 2 +-
arch/armv7.html | 2 +-
arch/index.html | 2 +-
arch/riscv.html | 3 +-
arch/x86_64.html | 3 +-
binary/index.html | 2 +-
binary/nm.html | 2 +-
binary/objdump.html | 2 +-
binary/od.html | 2 +-
binary/readelf.html | 2 +-
binary/xxd.html | 2 +-
css/general.css | 1 +
css/print.css | 8 -
css/variables.css | 10 ++
development/c++.html | 188 ++++++++++++++++++++++-
development/c++filt.html | 2 +-
development/gcc.html | 2 +-
development/gcov.html | 6 +-
development/glibc.html | 2 +-
development/index.html | 3 +-
development/ld.so.html | 2 +-
development/make.html | 2 +-
development/pgo.html | 363 ++++++++++++++++++++++++++++++++++++++++++++
development/python.html | 2 +-
development/symbolver.html | 3 +-
index.html | 2 +-
intro.html | 2 +-
linux/acl.html | 2 +-
linux/coredump.html | 2 +-
linux/cryptsetup.html | 2 +-
linux/index.html | 6 +-
linux/input.html | 12 +-
linux/ptrace_scope.html | 2 +-
linux/swap.html | 2 +-
linux/systemd.html | 12 +-
linux/zfs.html | 2 +-
monitor/index.html | 2 +-
monitor/lsof.html | 2 +-
monitor/pgrep.html | 2 +-
monitor/pidstat.html | 2 +-
monitor/pmap.html | 2 +-
monitor/pstack.html | 2 +-
monitor/ss.html | 2 +-
network/firewall-cmd.html | 2 +-
network/index.html | 2 +-
network/nftables.html | 2 +-
network/tcpdump.html | 2 +-
print.html | 354 +++++++++++++++++++++++++++++++++++++++++-
searchindex.js | 2 +-
searchindex.json | 2 +-
tools/awk.html | 2 +-
tools/bash.html | 2 +-
tools/dot.html | 2 +-
tools/emacs.html | 2 +-
tools/fish.html | 2 +-
tools/gdb.html | 2 +-
tools/gdbserver.html | 2 +-
tools/git.html | 4 +-
tools/gpg.html | 2 +-
tools/index.html | 2 +-
tools/pacman.html | 2 +-
tools/qemu.html | 2 +-
tools/radare2.html | 2 +-
tools/tmux.html | 2 +-
tools/zsh.html | 2 +-
trace_profile/index.html | 2 +-
trace_profile/ltrace.html | 2 +-
trace_profile/oprofile.html | 2 +-
trace_profile/perf.html | 2 +-
trace_profile/strace.html | 2 +-
trace_profile/time.html | 2 +-
web/chartjs.html | 2 +-
web/html.html | 2 +-
web/index.html | 2 +-
75 files changed, 999 insertions(+), 97 deletions(-)
create mode 100644 development/pgo.html
diff --git a/404.html b/404.html
index 1c9d37b..aab1998 100644
--- a/404.html
+++ b/404.html
@@ -84,7 +84,7 @@
diff --git a/arch/arm64.html b/arch/arm64.html
index 925737d..82fc9a5 100644
--- a/arch/arm64.html
+++ b/arch/arm64.html
@@ -83,7 +83,7 @@
diff --git a/arch/armv7.html b/arch/armv7.html
index 5d4a108..2ead03f 100644
--- a/arch/armv7.html
+++ b/arch/armv7.html
@@ -83,7 +83,7 @@
diff --git a/arch/index.html b/arch/index.html
index daa09a4..82fa063 100644
--- a/arch/index.html
+++ b/arch/index.html
@@ -83,7 +83,7 @@
diff --git a/arch/riscv.html b/arch/riscv.html
index 7d35e9a..7d5ccec 100644
--- a/arch/riscv.html
+++ b/arch/riscv.html
@@ -83,7 +83,7 @@
@@ -245,6 +245,7 @@ required when compiling natively on riscv.
+openstd cpp standards .
Source files of most examples is available here .
Force compile error to see what auto
is deduced to.
@@ -178,6 +179,191 @@
// force compile error
typename decltype(foo)::_;
+
+The strict aliasing
rules describe via which alias
a value can be accessed.
+
+Informal: an alias
is a reference / pointer to a value.
+
+Accessing a value through an alias that violates the strict aliasing rules is
+undefined behavior (UB)
.
+Examples below on godbolt .
+int i = 0;
+
+// Valid aliasing (signed / unsigned type).
+*reinterpret_cast<signed int*>(&i);
+*reinterpret_cast<unsigned int*>(&i);
+
+// Valid aliasing (cv qualified type).
+*reinterpret_cast<const int*>(&i);
+*reinterpret_cast<const unsigned*>(&i);
+
+// Valid aliasing (byte type).
+*reinterpret_cast<char*>(&i);
+*reinterpret_cast<std::byte*>(&i);
+
+// Invalid aliasing, dereferencing pointer is UB.
+*reinterpret_cast<short*>(&i);
+*reinterpret_cast<float*>(&i);
+
+
+NOTE: Casting pointer to invalid aliasing type is not directly UB, but
+dereferencing the pointer is UB.
+
+short s[2] = { 1, 2 };
+
+// Invalid aliasing (UB) - type punning, UB to deref ptr (int has stricter
+// alignment requirements than short).
+*reinterpret_cast<int*>(s);
+
+
+// Arbitrary byte pointer.
+char c[4] = { 1, 2, 3, 4 };
+
+// Invalid aliasing (UB) - type punning, UB to deref ptr (int has stricter
+// alignment requirements than char).
+*reinterpret_cast<int*>(c);
+
+At the time of writing, the current c++ std draft
+contains the following.
+If a program attempts to access the stored value of an object through a glvalue
+whose type is not **similar** (7.3.6) to one of the following types the
+behavior is undefined [44]
+
+(11.1) the dynamic type of the object,
+(11.2) a type that is the signed or unsigned type corresponding to the dynamic
+ type of the object, or
+(11.3) a char, unsigned char, or std::byte type.
+
+[44]: The intent of this list is to specify those circumstances in which an
+ object can or cannot be aliased.
+
+The paragraph is short but one also needs to understand the meaning of
+similar (similar_types ) .
+This paragraph is actually somewhat more explicit in the c++17 std .
+If a program attempts to access the stored value of an object through a glvalue
+of other than one of the following types the behavior is undefined [63]
+
+(11.1) the dynamic type of the object,
+(11.2) a cv-qualified version of the dynamic type of the object,
+(11.3) a type similar (as defined in 7.5) to the dynamic type of the object,
+(11.4) a type that is the signed or unsigned type corresponding to the dynamic
+ type of the object,
+(11.5) a type that is the signed or unsigned type corresponding to a
+ cv-qualified version of the dynamic type of the object,
+(11.6) an aggregate or union type that includes one of the aforementioned types
+ among its elements or non- static data members (including, recursively,
+ an element or non-static data member of a subaggregate or contained
+ union),
+(11.7) a type that is a (possibly cv-qualified) base class type of the dynamic
+ type of the object,
+(11.8) a char, unsigned char, or std::byte type.
+
+[63]: The intent of this list is to specify those circumstances in which an
+ object may or may not be aliased.
+
+Additional references:
+
+
+What is the Strict Aliasing Rule and Why do we care
+The article shows a small example how the compiler may optimized using the
+strict aliasing rules.
+int alias(int* i, char* c) {
+ *i = 1;
+ *c = 'a'; // char* may alias int*
+ return *i;
+}
+
+int noalias(int* i, short* s) {
+ *i = 1;
+ *s = 2; // short* does not alias int*
+ return *i;
+}
+
+alias(int*, char*):
+mov DWORD PTR [rdi] ,0x1 ; *i = 1;
+mov BYTE PTR [rsi], 0x61 ; *c = 'a';
+mov eax,DWORD PTR [rdi] ; Must reload, char* can alias int*.
+ret
+
+noalias(int*, short*):
+mov DWORD PTR [rdi], 0x1 ; *i = 1;
+mov WORD PTR [rsi], 0x2 ; *s = 2;
+mov eax,0x1 ; Must not reload, short* can not alias int*.
+ret
+
+
+
+reinterpret_cast type aliasing
+
+
+Any object pointer type T1*
can be converted to another object pointer
+type cv T2*
. This is exactly equivalent to static_cast<cv T2*>(static_cast<cv void*>(expression))
(which implies that if T2's
+alignment requirement is not stricter than T1's, the value of the pointer
+does not change and conversion of the resulting pointer back to its
+original type yields the original value). In any case, the resulting
+pointer may only be dereferenced safely if allowed by the type aliasing
+rules (see below).
+
+
+int I;
+char* X = reinterpret_cast<char*>(&I); // Valid, char allowed to alias int.
+*X = 42;
+int* Y = reinterpret_cast<int*>(X); // Cast back to original type.
+*Y = 1337; // safe
+
+char C[4];
+int* P = reinterpret_cast<int*>(C); // Cast is ok, not yet UB.
+*P = 1337; // UB, violates strict aliasing / alignment rules.
+ // https://stackoverflow.com/questions/52492229/c-byte-array-to-int
+
+
+
+On gcc
strict aliasing is enabled starting with -O2
.
+for i in {0..3} g s; do echo "-O$i $(g++ -Q --help=optimizers -O$i | grep fstrict-aliasing)"; done
+-O0 -fstrict-aliasing [disabled]
+-O1 -fstrict-aliasing [disabled]
+-O2 -fstrict-aliasing [enabled]
+-O3 -fstrict-aliasing [enabled]
+-Og -fstrict-aliasing [disabled]
+-Os -fstrict-aliasing [enabled]
+
+
+
+
+The __restrict
keyword allows the programmer to tell the compiler that two
+pointer will not alias each other.
+int alias(int* a, int* b) {
+ *a = 1;
+ *b = 2;
+ return *a;
+}
+
+// alias(int*, int*): # @alias(int*, int*)
+// mov dword ptr [rdi], 1
+// mov dword ptr [rsi], 2
+// mov eax, dword ptr [rdi]
+// ret
+
+int noalias(int* __restrict a, int* __restrict b) {
+ *a = 1;
+ *b = 2;
+ return *a;
+}
+
+// noalias(int*, int*): # @noalias(int*, int*)
+// mov dword ptr [rdi], 1
+// mov dword ptr [rsi], 2
+// mov eax, 1
+// ret
+
+However this should only be used with care and in a narrow scope, as it is easy
+to violate self defined contract, see godbolt .
+
+The correct way to do type-punning
in c++:
+
+std::bit_cast
(c++20)
+std::memcpy
+
#include <iostream>
diff --git a/development/c++filt.html b/development/c++filt.html
index 1468f2a..e7b7614 100644
--- a/development/c++filt.html
+++ b/development/c++filt.html
@@ -83,7 +83,7 @@
diff --git a/development/gcc.html b/development/gcc.html
index 4490222..c8a236a 100644
--- a/development/gcc.html
+++ b/development/gcc.html
@@ -83,7 +83,7 @@
diff --git a/development/gcov.html b/development/gcov.html
index e065a03..6103b8d 100644
--- a/development/gcov.html
+++ b/development/gcov.html
@@ -83,7 +83,7 @@
@@ -265,7 +265,7 @@ clean:
-
+
@@ -279,7 +279,7 @@ clean:
-
+
diff --git a/development/glibc.html b/development/glibc.html
index 7961bf3..2807110 100644
--- a/development/glibc.html
+++ b/development/glibc.html
@@ -83,7 +83,7 @@
diff --git a/development/index.html b/development/index.html
index edd1fef..696e124 100644
--- a/development/index.html
+++ b/development/index.html
@@ -83,7 +83,7 @@
@@ -180,6 +180,7 @@
symbol versioning
python
gcov
+pgo
diff --git a/development/ld.so.html b/development/ld.so.html
index 8a88d42..110cc1c 100644
--- a/development/ld.so.html
+++ b/development/ld.so.html
@@ -83,7 +83,7 @@
diff --git a/development/make.html b/development/make.html
index 630715d..36d174a 100644
--- a/development/make.html
+++ b/development/make.html
@@ -83,7 +83,7 @@
diff --git a/development/pgo.html b/development/pgo.html
new file mode 100644
index 0000000..b928df6
--- /dev/null
+++ b/development/pgo.html
@@ -0,0 +1,363 @@
+
+
+
+
+
+
pgo - Notes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+pgo
is an optimization technique to optimize a program for its usual
+workload.
+It is applied in two phases:
+
+Collect profiling data (best with representative benchmarks).
+Optimize program based on collected profiling data.
+
+The following simple program is used as demonstrator.
+#include <stdio.h>
+
+#define NOINLINE __attribute__((noinline))
+
+NOINLINE void foo() { puts("foo()"); }
+NOINLINE void bar() { puts("bar()"); }
+
+int main(int argc, char *argv[]) {
+ if (argc == 2) {
+ foo();
+ } else {
+ bar();
+ }
+}
+
+
+On the actual machine with clang 15.0.7
, the following code is generated for
+the main()
function.
+# clang -o test test.c -O3
+
+0000000000001160 <main>:
+ 1160: 50 push rax
+ ; Jump if argc != 2.
+ 1161: 83 ff 02 cmp edi,0x2
+ 1164: 75 09 jne 116f <main+0xf>
+ ; foor() is on the hot path (fall-through).
+ 1166: e8 d5 ff ff ff call 1140 <_Z3foov>
+ 116b: 31 c0 xor eax,eax
+ 116d: 59 pop rcx
+ 116e: c3 ret
+ ; bar() is on the cold path (branch).
+ 116f: e8 dc ff ff ff call 1150 <_Z3barv>
+ 1174: 31 c0 xor eax,eax
+ 1176: 59 pop rcx
+ 1177: c3 ret
+
+The following shows how to compile with profiling instrumentation and how to
+optimize the final program with the collected profiling data (llvm
+pgo ).
+The arguments to ./test
are chosen such that 9/10
runs call bar()
, which
+is currently on the cold path
.
+# Compile test program with profiling instrumentation.
+clang -o test test.cc -O3 -fprofile-instr-generate
+
+# Collect profiling data from multiple runs.
+for i in {0..10}; do
+ LLVM_PROFILE_FILE="prof.clang/%p.profraw" ./test $(seq 0 $i)
+done
+
+# Merge raw profiling data into single profile data.
+llvm-profdata merge -o pgo.profdata prof.clang/*.profraw
+
+# Optimize test program with profiling data.
+clang -o test test.cc -O3 -fprofile-use=pgo.profdata
+
+
+NOTE: If LLVM_PROFILE_FILE
is not given the profile data is written to
+default.profraw
which is re-written on each run. If the LLVM_PROFILE_FILE
+contains a %m
in the filename, a unique integer will be generated and
+consecutive runs will update the same generated profraw file,
+LLVM_PROFILE_FILE
can specify a new file every time, however that requires
+more storage in general.
+
+After optimizing the program with the profiling data, the main()
function
+looks as follows.
+0000000000001060 <main>:
+ 1060: 50 push rax
+ ; Jump if argc == 2.
+ 1061: 83 ff 02 cmp edi,0x2
+ 1064: 74 09 je 106f <main+0xf>
+ ; bar() is on the hot path (fall-through).
+ 1066: e8 e5 ff ff ff call 1050 <_Z3barv>
+ 106b: 31 c0 xor eax,eax
+ 106d: 59 pop rcx
+ 106e: c3 ret
+ ; foo() is on the cold path (branch).
+ 106f: e8 cc ff ff ff call 1040 <_Z3foov>
+ 1074: 31 c0 xor eax,eax
+ 1076: 59 pop rcx
+ 1077: c3 ret
+
+
+With gcc 13.2.1
on the current machine, the optimizer puts bar()
on the
+hot path
by default.
+0000000000001040 <main>:
+ 1040: 48 83 ec 08 sub rsp,0x8
+ ; Jump if argc == 2.
+ 1044: 83 ff 02 cmp edi,0x2
+ 1047: 74 0c je 1055 <main+0x15>
+ ; bar () is on the hot path (fall-through).
+ 1049: e8 22 01 00 00 call 1170 <_Z3barv>
+ 104e: 31 c0 xor eax,eax
+ 1050: 48 83 c4 08 add rsp,0x8
+ 1054: c3 ret
+ ; foo() is on the cold path (branch).
+ 1055: e8 06 01 00 00 call 1160 <_Z3foov>
+ 105a: eb f2 jmp 104e <main+0xe>
+ 105c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]
+
+
+The following shows how to compile with profiling instrumentation and how to
+optimize the final program with the collected profiling data.
+The arguments to ./test
are chosen such that 2/3
runs call foo()
, which
+is currently on the cold path
.
+gcc -o test test.cc -O3 -fprofile-generate
+./test 1
+./test 1
+./test 2 2
+gcc -o test test.cc -O3 -fprofile-use
+
+
+NOTE: Consecutive runs update the generated test.gcda
profile data file
+rather than re-write it.
+
+After optimizing the program with the profiling data, the main()
function
+0000000000001040 <main.cold>:
+ ; bar() is on the cold path (branch).
+ 1040: e8 05 00 00 00 call 104a <_Z3barv>
+ 1045: e9 25 00 00 00 jmp 106f <main+0xf>
+
+0000000000001060 <main>:
+ 1060: 51 push rcx
+ ; Jump if argc != 2.
+ 1061: 83 ff 02 cmp edi,0x2
+ 1064: 0f 85 d6 ff ff ff jne 1040 <main.cold>
+ ; for() is on the hot path (fall-through).
+ 106a: e8 11 01 00 00 call 1180 <_Z3foov>
+ 106f: 31 c0 xor eax,eax
+ 1071: 5a pop rdx
+ 1072: c3 ret
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/development/python.html b/development/python.html
index 0362177..cb9d6af 100644
--- a/development/python.html
+++ b/development/python.html
@@ -83,7 +83,7 @@
diff --git a/development/symbolver.html b/development/symbolver.html
index a968cbd..1b82a41 100644
--- a/development/symbolver.html
+++ b/development/symbolver.html
@@ -83,7 +83,7 @@
@@ -372,6 +372,7 @@ func_v2
Binutils ld: Symbol Versioning
LSB: Symbol Versioning
How To Write Shared Libraries
+
LSB: ELF File Format
diff --git a/index.html b/index.html
index bddfc9a..404c7a2 100644
--- a/index.html
+++ b/index.html
@@ -83,7 +83,7 @@
diff --git a/intro.html b/intro.html
index bddfc9a..404c7a2 100644
--- a/intro.html
+++ b/intro.html
@@ -83,7 +83,7 @@
diff --git a/linux/acl.html b/linux/acl.html
index 5a420e3..44bf5dd 100644
--- a/linux/acl.html
+++ b/linux/acl.html
@@ -83,7 +83,7 @@
diff --git a/linux/coredump.html b/linux/coredump.html
index d9ff589..62fb21d 100644
--- a/linux/coredump.html
+++ b/linux/coredump.html
@@ -83,7 +83,7 @@
diff --git a/linux/cryptsetup.html b/linux/cryptsetup.html
index 730ff00..35ebd61 100644
--- a/linux/cryptsetup.html
+++ b/linux/cryptsetup.html
@@ -83,7 +83,7 @@
diff --git a/linux/index.html b/linux/index.html
index 00bf1ee..12cb51b 100644
--- a/linux/index.html
+++ b/linux/index.html
@@ -83,7 +83,7 @@
@@ -185,7 +185,7 @@
-
+
@@ -199,7 +199,7 @@
-
+
diff --git a/linux/input.html b/linux/input.html
index f2daab7..3e5ac2e 100644
--- a/linux/input.html
+++ b/linux/input.html
@@ -83,7 +83,7 @@
@@ -172,7 +172,7 @@
Some notes on using /dev/input/*
device driver files.
-These device files are created by the [mousedev] driver.
+These device files are created by the mousedev driver.
/dev/input/mouseX
represents the input stream for a SINGLE mouse device.
/dev/input/mice
represents the merged input stream for ALL mouse devices.
@@ -187,9 +187,9 @@
sudo cat /dev/input/mice | od -tx1 -w3 -v
-These device files are created by the [evdev] driver.
+These device files are created by the evdev driver.
-/dev/input/eventX
represents the generic input event interface a SINGLE input deivece.
+/dev/input/eventX
represents the generic input event interface a SINGLE input device.
Input events are encoded as given by the input_event
struct below. Reading
from the eventX
device file will always yield whole number of input events.
@@ -203,7 +203,7 @@ from the eventX
device file will always yield whole number of input
On most 64bit machines the raw data stream can be inspected as follows.
sudo cat /dev/input/event4 | od -tx1 -w24 -v
-
+
To find out which device file is assigned to which input device the following
file /proc/bus/input/devices
in the proc filesystem can be consulted.
This yields entries as follows and shows which Handlers
are assigned to which
@@ -286,8 +286,6 @@ int main(int argc, char* argv[]) {
}
}
-
[mousedev]: TODO /home/johannst/dev/linux/drivers/input/mousedev.c
-[evdev]: TODO /home/johannst/dev/linux/drivers/input/evdev.c
diff --git a/linux/ptrace_scope.html b/linux/ptrace_scope.html
index d17440d..0dc2437 100644
--- a/linux/ptrace_scope.html
+++ b/linux/ptrace_scope.html
@@ -83,7 +83,7 @@
diff --git a/linux/swap.html b/linux/swap.html
index 1a8a5d4..be1d6aa 100644
--- a/linux/swap.html
+++ b/linux/swap.html
@@ -83,7 +83,7 @@
diff --git a/linux/systemd.html b/linux/systemd.html
index 5ebe003..65a6dc4 100644
--- a/linux/systemd.html
+++ b/linux/systemd.html
@@ -83,7 +83,7 @@
@@ -175,6 +175,9 @@
systemctl [opts] [cmd]
[opts]
--user
+ --type=TYPE List only given types eg, service, timer, socket (use --type=help for a list)
+ --state=STATE List only given states eg running, enabled (use --state=help for a list)
+ --failed List only failed services
[cmd]
list-units <pattern> List units in memory
@@ -192,6 +195,13 @@
cat <unit> Print unit file
show <unit> Show properties of unit
+
+# List all system failed units.
+systemctl --failed
+
+# List all user failed units.
+systemctl --user --failed
+
# Generate unit
mkdir -p ~/.config/systemd/user
diff --git a/linux/zfs.html b/linux/zfs.html
index aac907f..0da0103 100644
--- a/linux/zfs.html
+++ b/linux/zfs.html
@@ -83,7 +83,7 @@
diff --git a/monitor/index.html b/monitor/index.html
index 797a9f4..2c6544f 100644
--- a/monitor/index.html
+++ b/monitor/index.html
@@ -83,7 +83,7 @@
diff --git a/monitor/lsof.html b/monitor/lsof.html
index f9c98bb..5bb272d 100644
--- a/monitor/lsof.html
+++ b/monitor/lsof.html
@@ -83,7 +83,7 @@
diff --git a/monitor/pgrep.html b/monitor/pgrep.html
index 1361680..b26d139 100644
--- a/monitor/pgrep.html
+++ b/monitor/pgrep.html
@@ -83,7 +83,7 @@
diff --git a/monitor/pidstat.html b/monitor/pidstat.html
index d2652e5..155aad6 100644
--- a/monitor/pidstat.html
+++ b/monitor/pidstat.html
@@ -83,7 +83,7 @@
diff --git a/monitor/pmap.html b/monitor/pmap.html
index ebc033a..84d6179 100644
--- a/monitor/pmap.html
+++ b/monitor/pmap.html
@@ -83,7 +83,7 @@
diff --git a/monitor/pstack.html b/monitor/pstack.html
index 86a7ad1..0560217 100644
--- a/monitor/pstack.html
+++ b/monitor/pstack.html
@@ -83,7 +83,7 @@
diff --git a/monitor/ss.html b/monitor/ss.html
index de9dadd..31576ef 100644
--- a/monitor/ss.html
+++ b/monitor/ss.html
@@ -83,7 +83,7 @@
diff --git a/network/firewall-cmd.html b/network/firewall-cmd.html
index d6bf236..c1b2a90 100644
--- a/network/firewall-cmd.html
+++ b/network/firewall-cmd.html
@@ -83,7 +83,7 @@
diff --git a/network/index.html b/network/index.html
index 5a5a400..61ad5c1 100644
--- a/network/index.html
+++ b/network/index.html
@@ -83,7 +83,7 @@
diff --git a/network/nftables.html b/network/nftables.html
index c89fdeb..92a19c2 100644
--- a/network/nftables.html
+++ b/network/nftables.html
@@ -83,7 +83,7 @@
diff --git a/network/tcpdump.html b/network/tcpdump.html
index 033b923..014f826 100644
--- a/network/tcpdump.html
+++ b/network/tcpdump.html
@@ -83,7 +83,7 @@
diff --git a/print.html b/print.html
index f09b78b..c0dea2b 100644
--- a/print.html
+++ b/print.html
@@ -84,7 +84,7 @@
@@ -1021,7 +1021,7 @@ list-keys -t vi-copy list keymaps for vi-copy mode
git show --stat <commit> ................ show files changed by <commit>
git show <commit> [<file>] .............. show diffs for <commit>
- git git show <commit>:<file> ............ show <file> at <commit>
+ git show <commit>:<file> ................ show <file> at <commit>
git format-patch <opt> <since>/<revision range>
@@ -2736,6 +2736,7 @@ objdump -D -b binary -m i386:x86-64 test-bin
symbol versioning
python
gcov
+pgo
@@ -2746,6 +2747,7 @@ objdump -D -b binary -m i386:x86-64 test-bin
readelf -W --dyn-syms <elf> | c++filt
+openstd cpp standards .
Source files of most examples is available here .
Force compile error to see what auto
is deduced to.
@@ -2754,6 +2756,191 @@ objdump -D -b binary -m i386:x86-64 test-bin
// force compile error
typename decltype(foo)::_;
+
+The strict aliasing
rules describe via which alias
a value can be accessed.
+
+Informal: an alias
is a reference / pointer to a value.
+
+Accessing a value through an alias that violates the strict aliasing rules is
+undefined behavior (UB)
.
+Examples below on godbolt .
+int i = 0;
+
+// Valid aliasing (signed / unsigned type).
+*reinterpret_cast<signed int*>(&i);
+*reinterpret_cast<unsigned int*>(&i);
+
+// Valid aliasing (cv qualified type).
+*reinterpret_cast<const int*>(&i);
+*reinterpret_cast<const unsigned*>(&i);
+
+// Valid aliasing (byte type).
+*reinterpret_cast<char*>(&i);
+*reinterpret_cast<std::byte*>(&i);
+
+// Invalid aliasing, dereferencing pointer is UB.
+*reinterpret_cast<short*>(&i);
+*reinterpret_cast<float*>(&i);
+
+
+NOTE: Casting pointer to invalid aliasing type is not directly UB, but
+dereferencing the pointer is UB.
+
+short s[2] = { 1, 2 };
+
+// Invalid aliasing (UB) - type punning, UB to deref ptr (int has stricter
+// alignment requirements than short).
+*reinterpret_cast<int*>(s);
+
+
+// Arbitrary byte pointer.
+char c[4] = { 1, 2, 3, 4 };
+
+// Invalid aliasing (UB) - type punning, UB to deref ptr (int has stricter
+// alignment requirements than char).
+*reinterpret_cast<int*>(c);
+
+At the time of writing, the current c++ std draft
+contains the following.
+If a program attempts to access the stored value of an object through a glvalue
+whose type is not **similar** (7.3.6) to one of the following types the
+behavior is undefined [44]
+
+(11.1) the dynamic type of the object,
+(11.2) a type that is the signed or unsigned type corresponding to the dynamic
+ type of the object, or
+(11.3) a char, unsigned char, or std::byte type.
+
+[44]: The intent of this list is to specify those circumstances in which an
+ object can or cannot be aliased.
+
+The paragraph is short but one also needs to understand the meaning of
+similar (similar_types ) .
+This paragraph is actually somewhat more explicit in the c++17 std .
+If a program attempts to access the stored value of an object through a glvalue
+of other than one of the following types the behavior is undefined [63]
+
+(11.1) the dynamic type of the object,
+(11.2) a cv-qualified version of the dynamic type of the object,
+(11.3) a type similar (as defined in 7.5) to the dynamic type of the object,
+(11.4) a type that is the signed or unsigned type corresponding to the dynamic
+ type of the object,
+(11.5) a type that is the signed or unsigned type corresponding to a
+ cv-qualified version of the dynamic type of the object,
+(11.6) an aggregate or union type that includes one of the aforementioned types
+ among its elements or non- static data members (including, recursively,
+ an element or non-static data member of a subaggregate or contained
+ union),
+(11.7) a type that is a (possibly cv-qualified) base class type of the dynamic
+ type of the object,
+(11.8) a char, unsigned char, or std::byte type.
+
+[63]: The intent of this list is to specify those circumstances in which an
+ object may or may not be aliased.
+
+Additional references:
+
+
+What is the Strict Aliasing Rule and Why do we care
+The article shows a small example how the compiler may optimized using the
+strict aliasing rules.
+int alias(int* i, char* c) {
+ *i = 1;
+ *c = 'a'; // char* may alias int*
+ return *i;
+}
+
+int noalias(int* i, short* s) {
+ *i = 1;
+ *s = 2; // short* does not alias int*
+ return *i;
+}
+
+alias(int*, char*):
+mov DWORD PTR [rdi] ,0x1 ; *i = 1;
+mov BYTE PTR [rsi], 0x61 ; *c = 'a';
+mov eax,DWORD PTR [rdi] ; Must reload, char* can alias int*.
+ret
+
+noalias(int*, short*):
+mov DWORD PTR [rdi], 0x1 ; *i = 1;
+mov WORD PTR [rsi], 0x2 ; *s = 2;
+mov eax,0x1 ; Must not reload, short* can not alias int*.
+ret
+
+
+
+reinterpret_cast type aliasing
+
+
+Any object pointer type T1*
can be converted to another object pointer
+type cv T2*
. This is exactly equivalent to static_cast<cv T2*>(static_cast<cv void*>(expression))
(which implies that if T2's
+alignment requirement is not stricter than T1's, the value of the pointer
+does not change and conversion of the resulting pointer back to its
+original type yields the original value). In any case, the resulting
+pointer may only be dereferenced safely if allowed by the type aliasing
+rules (see below).
+
+
+int I;
+char* X = reinterpret_cast<char*>(&I); // Valid, char allowed to alias int.
+*X = 42;
+int* Y = reinterpret_cast<int*>(X); // Cast back to original type.
+*Y = 1337; // safe
+
+char C[4];
+int* P = reinterpret_cast<int*>(C); // Cast is ok, not yet UB.
+*P = 1337; // UB, violates strict aliasing / alignment rules.
+ // https://stackoverflow.com/questions/52492229/c-byte-array-to-int
+
+
+
+On gcc
strict aliasing is enabled starting with -O2
.
+for i in {0..3} g s; do echo "-O$i $(g++ -Q --help=optimizers -O$i | grep fstrict-aliasing)"; done
+-O0 -fstrict-aliasing [disabled]
+-O1 -fstrict-aliasing [disabled]
+-O2 -fstrict-aliasing [enabled]
+-O3 -fstrict-aliasing [enabled]
+-Og -fstrict-aliasing [disabled]
+-Os -fstrict-aliasing [enabled]
+
+
+
+
+The __restrict
keyword allows the programmer to tell the compiler that two
+pointer will not alias each other.
+int alias(int* a, int* b) {
+ *a = 1;
+ *b = 2;
+ return *a;
+}
+
+// alias(int*, int*): # @alias(int*, int*)
+// mov dword ptr [rdi], 1
+// mov dword ptr [rsi], 2
+// mov eax, dword ptr [rdi]
+// ret
+
+int noalias(int* __restrict a, int* __restrict b) {
+ *a = 1;
+ *b = 2;
+ return *a;
+}
+
+// noalias(int*, int*): # @noalias(int*, int*)
+// mov dword ptr [rdi], 1
+// mov dword ptr [rsi], 2
+// mov eax, 1
+// ret
+
+However this should only be used with care and in a narrow scope, as it is easy
+to violate self defined contract, see godbolt .
+
+The correct way to do type-punning
in c++:
+
+std::bit_cast
(c++20)
+std::memcpy
+
#include <iostream>
@@ -3904,6 +4091,7 @@ func_v2
Binutils ld: Symbol Versioning
LSB: Symbol Versioning
How To Write Shared Libraries
+LSB: ELF File Format
@@ -4085,6 +4273,146 @@ clean:
1: 16: return 0;
-: 17:}
+
+pgo
is an optimization technique to optimize a program for its usual
+workload.
+It is applied in two phases:
+
+Collect profiling data (best with representative benchmarks).
+Optimize program based on collected profiling data.
+
+The following simple program is used as demonstrator.
+#include <stdio.h>
+
+#define NOINLINE __attribute__((noinline))
+
+NOINLINE void foo() { puts("foo()"); }
+NOINLINE void bar() { puts("bar()"); }
+
+int main(int argc, char *argv[]) {
+ if (argc == 2) {
+ foo();
+ } else {
+ bar();
+ }
+}
+
+
+On the actual machine with clang 15.0.7
, the following code is generated for
+the main()
function.
+# clang -o test test.c -O3
+
+0000000000001160 <main>:
+ 1160: 50 push rax
+ ; Jump if argc != 2.
+ 1161: 83 ff 02 cmp edi,0x2
+ 1164: 75 09 jne 116f <main+0xf>
+ ; foor() is on the hot path (fall-through).
+ 1166: e8 d5 ff ff ff call 1140 <_Z3foov>
+ 116b: 31 c0 xor eax,eax
+ 116d: 59 pop rcx
+ 116e: c3 ret
+ ; bar() is on the cold path (branch).
+ 116f: e8 dc ff ff ff call 1150 <_Z3barv>
+ 1174: 31 c0 xor eax,eax
+ 1176: 59 pop rcx
+ 1177: c3 ret
+
+The following shows how to compile with profiling instrumentation and how to
+optimize the final program with the collected profiling data (llvm
+pgo ).
+The arguments to ./test
are chosen such that 9/10
runs call bar()
, which
+is currently on the cold path
.
+# Compile test program with profiling instrumentation.
+clang -o test test.cc -O3 -fprofile-instr-generate
+
+# Collect profiling data from multiple runs.
+for i in {0..10}; do
+ LLVM_PROFILE_FILE="prof.clang/%p.profraw" ./test $(seq 0 $i)
+done
+
+# Merge raw profiling data into single profile data.
+llvm-profdata merge -o pgo.profdata prof.clang/*.profraw
+
+# Optimize test program with profiling data.
+clang -o test test.cc -O3 -fprofile-use=pgo.profdata
+
+
+NOTE: If LLVM_PROFILE_FILE
is not given the profile data is written to
+default.profraw
which is re-written on each run. If the LLVM_PROFILE_FILE
+contains a %m
in the filename, a unique integer will be generated and
+consecutive runs will update the same generated profraw file,
+LLVM_PROFILE_FILE
can specify a new file every time, however that requires
+more storage in general.
+
+After optimizing the program with the profiling data, the main()
function
+looks as follows.
+0000000000001060 <main>:
+ 1060: 50 push rax
+ ; Jump if argc == 2.
+ 1061: 83 ff 02 cmp edi,0x2
+ 1064: 74 09 je 106f <main+0xf>
+ ; bar() is on the hot path (fall-through).
+ 1066: e8 e5 ff ff ff call 1050 <_Z3barv>
+ 106b: 31 c0 xor eax,eax
+ 106d: 59 pop rcx
+ 106e: c3 ret
+ ; foo() is on the cold path (branch).
+ 106f: e8 cc ff ff ff call 1040 <_Z3foov>
+ 1074: 31 c0 xor eax,eax
+ 1076: 59 pop rcx
+ 1077: c3 ret
+
+
+With gcc 13.2.1
on the current machine, the optimizer puts bar()
on the
+hot path
by default.
+0000000000001040 <main>:
+ 1040: 48 83 ec 08 sub rsp,0x8
+ ; Jump if argc == 2.
+ 1044: 83 ff 02 cmp edi,0x2
+ 1047: 74 0c je 1055 <main+0x15>
+ ; bar () is on the hot path (fall-through).
+ 1049: e8 22 01 00 00 call 1170 <_Z3barv>
+ 104e: 31 c0 xor eax,eax
+ 1050: 48 83 c4 08 add rsp,0x8
+ 1054: c3 ret
+ ; foo() is on the cold path (branch).
+ 1055: e8 06 01 00 00 call 1160 <_Z3foov>
+ 105a: eb f2 jmp 104e <main+0xe>
+ 105c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]
+
+
+The following shows how to compile with profiling instrumentation and how to
+optimize the final program with the collected profiling data.
+The arguments to ./test
are chosen such that 2/3
runs call foo()
, which
+is currently on the cold path
.
+gcc -o test test.cc -O3 -fprofile-generate
+./test 1
+./test 1
+./test 2 2
+gcc -o test test.cc -O3 -fprofile-use
+
+
+NOTE: Consecutive runs update the generated test.gcda
profile data file
+rather than re-write it.
+
+After optimizing the program with the profiling data, the main()
function
+0000000000001040 <main.cold>:
+ ; bar() is on the cold path (branch).
+ 1040: e8 05 00 00 00 call 104a <_Z3barv>
+ 1045: e9 25 00 00 00 jmp 106f <main+0xf>
+
+0000000000001060 <main>:
+ 1060: 51 push rcx
+ ; Jump if argc != 2.
+ 1061: 83 ff 02 cmp edi,0x2
+ 1064: 0f 85 d6 ff ff ff jne 1040 <main.cold>
+ ; for() is on the hot path (fall-through).
+ 106a: e8 11 01 00 00 call 1180 <_Z3foov>
+ 106f: 31 c0 xor eax,eax
+ 1071: 5a pop rdx
+ 1072: c3 ret
+
systemd
@@ -4102,6 +4430,9 @@ clean:
systemctl [opts] [cmd]
[opts]
--user
+ --type=TYPE List only given types eg, service, timer, socket (use --type=help for a list)
+ --state=STATE List only given states eg running, enabled (use --state=help for a list)
+ --failed List only failed services
[cmd]
list-units <pattern> List units in memory
@@ -4119,6 +4450,13 @@ clean:
cat <unit> Print unit file
show <unit> Show properties of unit
+
+# List all system failed units.
+systemctl --failed
+
+# List all user failed units.
+systemctl --user --failed
+
# Generate unit
mkdir -p ~/.config/systemd/user
@@ -4360,7 +4698,7 @@ For example as systemd
service:
Some notes on using /dev/input/*
device driver files.
-These device files are created by the [mousedev] driver.
+These device files are created by the mousedev driver.
/dev/input/mouseX
represents the input stream for a SINGLE mouse device.
/dev/input/mice
represents the merged input stream for ALL mouse devices.
@@ -4375,9 +4713,9 @@ For example as systemd
service:
sudo cat /dev/input/mice | od -tx1 -w3 -v
-These device files are created by the [evdev] driver.
+These device files are created by the evdev driver.
-/dev/input/eventX
represents the generic input event interface a SINGLE input deivece.
+/dev/input/eventX
represents the generic input event interface a SINGLE input device.
Input events are encoded as given by the input_event
struct below. Reading
from the eventX
device file will always yield whole number of input events.
@@ -4391,7 +4729,7 @@ from the eventX
device file will always yield whole number of input
On most 64bit machines the raw data stream can be inspected as follows.
sudo cat /dev/input/event4 | od -tx1 -w24 -v
-
+
To find out which device file is assigned to which input device the following
file /proc/bus/input/devices
in the proc filesystem can be consulted.
This yields entries as follows and shows which Handlers
are assigned to which
@@ -4474,8 +4812,6 @@ int main(int argc, char* argv[]) {
}
}
-[mousedev]: TODO /home/johannst/dev/linux/drivers/input/mousedev.c
-[evdev]: TODO /home/johannst/dev/linux/drivers/input/evdev.c
This describes POSIX
acl.
@@ -5430,6 +5766,7 @@ Hi ASM-World!
GNU Assembler
GNU Assembler Directives
GNU Assembler x86_64
dependent features
+juicebox-asm
an x86_64
jit assembler playground
keywords: arm64, aarch64, abi
@@ -5975,6 +6312,7 @@ required when compiling natively on riscv.
diff --git a/searchindex.js b/searchindex.js
index dfb23ed..0e38f04 100644
--- a/searchindex.js
+++ b/searchindex.js
@@ -1 +1 @@
-Object.assign(window.search, {"doc_urls":["intro.html#notes","tools/index.html#tools","tools/zsh.html#zsh1","tools/zsh.html#keybindings","tools/zsh.html#parameter","tools/zsh.html#variables","tools/zsh.html#expansion-flags","tools/zsh.html#argument-parsing-with-zparseopts","tools/zsh.html#example","tools/zsh.html#regular-expressions","tools/zsh.html#completion","tools/zsh.html#installation","tools/zsh.html#completion-variables","tools/zsh.html#completion-functions","tools/zsh.html#example-1","tools/zsh.html#example-with-optional-arguments","tools/bash.html#bash1","tools/bash.html#expansion","tools/bash.html#generator","tools/bash.html#parameter","tools/bash.html#pathname","tools/bash.html#io-redirection","tools/bash.html#explanation","tools/bash.html#argument-parsing-with-getopts","tools/bash.html#example","tools/bash.html#regular-expressions","tools/bash.html#completion","tools/bash.html#example-1","tools/fish.html#fish1","tools/fish.html#quick-info","tools/fish.html#variables","tools/fish.html#setunset-variables","tools/fish.html#lists","tools/fish.html#special-variables-lists","tools/fish.html#command-handling","tools/fish.html#io-redirection","tools/fish.html#control-flow","tools/fish.html#if--else","tools/fish.html#switch","tools/fish.html#while-loop","tools/fish.html#for-loop","tools/fish.html#functions","tools/fish.html#autoloading","tools/fish.html#helper","tools/fish.html#prompt","tools/fish.html#useful-builtins","tools/fish.html#keymaps","tools/fish.html#debug","tools/tmux.html#tmux1","tools/tmux.html#tmux-cli","tools/tmux.html#scripting","tools/tmux.html#bindings","tools/tmux.html#command-mode","tools/git.html#git1","tools/git.html#working-areas","tools/git.html#staging","tools/git.html#remote","tools/git.html#branching","tools/git.html#tags","tools/git.html#log--commit-history","tools/git.html#diff--commit-info","tools/git.html#patching","tools/git.html#resetting","tools/git.html#submodules","tools/git.html#inspection","tools/git.html#revision-specifier","tools/awk.html#awk1","tools/awk.html#input-processing","tools/awk.html#program","tools/awk.html#special-pattern","tools/awk.html#special-variables","tools/awk.html#special-statements--functions","tools/awk.html#examples","tools/awk.html#filter-records","tools/awk.html#negative-patterns","tools/awk.html#access-last-fields-in-records","tools/awk.html#capture-in-variables","tools/awk.html#capture-in-array","tools/awk.html#run-shell-command-and-capture-output","tools/emacs.html#emacs1","tools/emacs.html#help","tools/emacs.html#package-manager","tools/emacs.html#window","tools/emacs.html#buffer","tools/emacs.html#ibuffer","tools/emacs.html#isearch","tools/emacs.html#occur","tools/emacs.html#grep","tools/emacs.html#yankpaste","tools/emacs.html#register","tools/emacs.html#blockrect","tools/emacs.html#mass-edit","tools/emacs.html#narrow","tools/emacs.html#org","tools/emacs.html#org-source","tools/emacs.html#comapny","tools/emacs.html#tags","tools/emacs.html#lisp","tools/emacs.html#ido","tools/emacs.html#evil","tools/emacs.html#dired","tools/gpg.html#gpg1","tools/gpg.html#generate-new-keypair","tools/gpg.html#list-keys","tools/gpg.html#edit-keys","tools/gpg.html#export--import-keys","tools/gpg.html#search--send-keys","tools/gpg.html#encrypt-passphrase","tools/gpg.html#encrypt-public-key","tools/gpg.html#signing","tools/gpg.html#signing-detached","tools/gpg.html#abbreviations","tools/gpg.html#keyservers","tools/gpg.html#examples","tools/gpg.html#list-basic-key-information-from-file-with-long-keyids","tools/gpg.html#extend-expiring-key","tools/gdb.html#gdb1","tools/gdb.html#cli","tools/gdb.html#interactive-usage","tools/gdb.html#misc","tools/gdb.html#breakpoints","tools/gdb.html#watchpoints","tools/gdb.html#catchpoints","tools/gdb.html#inspection","tools/gdb.html#signal-handling","tools/gdb.html#multi-threading","tools/gdb.html#multi-process","tools/gdb.html#source-file-locations","tools/gdb.html#configuration","tools/gdb.html#text-user-interface-tui","tools/gdb.html#user-commands-macros","tools/gdb.html#hooks","tools/gdb.html#examples","tools/gdb.html#automatically-print-next-instr","tools/gdb.html#conditional-breakpoints","tools/gdb.html#set-breakpoint-on-all-threads-except-one","tools/gdb.html#catch-sigsegv-and-execute-commands","tools/gdb.html#run-backtrace-on-thread-1-batch-mode","tools/gdb.html#script-gdb-for-automating-debugging-sessions","tools/gdb.html#hook-to-automatically-save-breakpoints-on-quit","tools/gdb.html#watchpoint-on-struct--class-member","tools/gdb.html#know-bugs","tools/gdb.html#workaround-command--finish-bug","tools/gdbserver.html#gdbserver1","tools/gdbserver.html#cli","tools/gdbserver.html#example","tools/radare2.html#radare21","tools/radare2.html#print","tools/radare2.html#flags","tools/radare2.html#help","tools/radare2.html#relocation","tools/radare2.html#examples","tools/radare2.html#patch-file-alter-bytes","tools/radare2.html#assemble--disassmble-rasm2","tools/qemu.html#qemu1","tools/qemu.html#keybindings","tools/qemu.html#vm-config-snippet","tools/qemu.html#cpu--ram","tools/qemu.html#graphic--display","tools/qemu.html#boot-menu","tools/qemu.html#block-devices","tools/qemu.html#usb","tools/qemu.html#debugging","tools/qemu.html#io-redirection","tools/qemu.html#network","tools/qemu.html#shared-drives","tools/qemu.html#debug-logging","tools/qemu.html#tracing","tools/qemu.html#vm-snapshots","tools/qemu.html#vm-migration","tools/qemu.html#appendix-direct-kernel-boot","tools/qemu.html#appendix-cheap-instruction-tracer","tools/qemu.html#references","tools/pacman.html#pacman1","tools/pacman.html#remote-package-repositories","tools/pacman.html#remove-packages","tools/pacman.html#local-package-database","tools/pacman.html#local-file-database","tools/pacman.html#hacks","tools/dot.html#dot1","tools/dot.html#example-dot-file-to-copy--paste-from","tools/dot.html#references","monitor/index.html#resource-analysis--monitor","monitor/lsof.html#lsof8","monitor/lsof.html#examples","monitor/lsof.html#file-flags","monitor/lsof.html#open-tcp-connections","monitor/lsof.html#open-connection-to-specific-host","monitor/lsof.html#open-connection-to-specific-port","monitor/lsof.html#ipv4-tcp-connections-in-established-state","monitor/ss.html#ss8","monitor/ss.html#examples","monitor/pidstat.html#pidstat1","monitor/pidstat.html#page-fault-and-memory-utilization","monitor/pidstat.html#io-statistics","monitor/pgrep.html#pgrep1","monitor/pgrep.html#debug-newest-process","monitor/pmap.html#pmap1","monitor/pstack.html#pstack1","trace_profile/index.html#trace-and-profile","trace_profile/strace.html#strace1","trace_profile/strace.html#examples","trace_profile/ltrace.html#ltrace1","trace_profile/ltrace.html#example","trace_profile/perf.html#perf1","trace_profile/perf.html#flamegraph","trace_profile/perf.html#flamegraph-with-single-event-trace","trace_profile/perf.html#flamegraph-with-multiple-event-traces","trace_profile/oprofile.html#oprofile","trace_profile/time.html#usrbintime1","binary/index.html#binary","binary/od.html#od1","binary/od.html#ascii-to-hex-string","binary/od.html#extract-parts-of-file","binary/xxd.html#xxd1","binary/xxd.html#ascii-to-hex-stream","binary/xxd.html#hex-to-binary-stream","binary/xxd.html#ascii-to-binary","binary/xxd.html#ascii-to-c-array-hex-encoded","binary/readelf.html#readelf1","binary/objdump.html#objdump1","binary/objdump.html#disassemble-section","binary/objdump.html#example-disassemble-raw-binary","binary/nm.html#nm1","development/index.html#development","development/c++filt.html#cfilt1","development/c++filt.html#demangle-symbol","development/c++filt.html#demangle-stream","development/c++.html#c","development/c++.html#type-deduction","development/c++.html#variadic-templates--parameter-pack-","development/c++.html#forwarding-reference--fwd-ref-","development/c++.html#example-any_of-template-meta-function","development/c++.html#example--sfinae---enable_if-","development/c++.html#example-minimal-templatized-test-registry","development/c++.html#example-concepts-pre-c20","development/c++.html#template-selection-with-partially--fully-specializations","development/c++.html#example-perfect-forwarding","development/glibc.html#glibc","development/glibc.html#malloc-tracer--mtrace3","development/glibc.html#malloc-check--mallopt3","development/gcc.html#gcc1","development/gcc.html#cli","development/gcc.html#preprocessing","development/gcc.html#target-options","development/gcc.html#warnings--optimizations","development/gcc.html#builtins","development/gcc.html#__builtin_expectexpr-cond","development/gcc.html#abi-linux","development/make.html#make1","development/make.html#anatomy-of-make-rules","development/make.html#pattern-rules--automatic-variables","development/make.html#pattern-rules","development/make.html#automatic-variables","development/make.html#arguments","development/make.html#useful-functions","development/make.html#substitution-references","development/make.html#patsubst--ref-","development/make.html#filter","development/make.html#filter-out","development/make.html#abspath","development/ld.so.html#ldso8","development/ld.so.html#environment-variables","development/ld.so.html#ld_library_path-and-dlopen3","development/ld.so.html#ld_preload-initialization-order-and-link-map","development/ld.so.html#dynamic-linking-x86_64","development/symbolver.html#elf-symbol-versioning","development/symbolver.html#example-version-script","development/symbolver.html#references","development/python.html#python","development/python.html#decorator--run-","development/python.html#walrus-operator--run-","development/python.html#unittest---run-","development/python.html#doctest---run-","development/python.html#timeit","development/gcov.html#gcov1","development/gcov.html#example","linux/index.html#linux","linux/systemd.html#systemd","linux/systemd.html#systemctl","linux/systemd.html#example-trivial-user-unit","linux/systemd.html#journalctl","linux/systemd.html#references","linux/coredump.html#core5","linux/coredump.html#naming-of-coredump-files","linux/coredump.html#control-which-segments-are-dumped","linux/coredump.html#some-examples-out-there","linux/coredump.html#coredumpctl-systemd","linux/coredump.html#apport-ubuntu","linux/ptrace_scope.html#ptrace_scope","linux/cryptsetup.html#cryptsetup8","linux/cryptsetup.html#example-create-luks-encrypted-disk","linux/cryptsetup.html#example-using-an-existing-luks-device","linux/swap.html#swap","linux/swap.html#list-active-swap-areas","linux/swap.html#manual-swapfile-setup","linux/swap.html#using-dphys-swapfile-service","linux/input.html#linux-input","linux/input.html#mousex--mice","linux/input.html#eventx","linux/input.html#identifyin-device-files","linux/input.html#example-toying-with-devinputeventx","linux/acl.html#access-control-list-acl","linux/acl.html#show-acl-entries","linux/acl.html#modify-acl-entries","linux/acl.html#masking-of-acl-entries","linux/acl.html#references","linux/zfs.html#zfs","linux/zfs.html#zfs-pool-management","linux/zfs.html#create-modify-and-destroy-zfs-pools","linux/zfs.html#inspect-zfs-pools","linux/zfs.html#modify-vdevs","linux/zfs.html#replace-faulty-disk","linux/zfs.html#import-or-export-zfs-pools","linux/zfs.html#zfs-dataset-management","linux/zfs.html#create-and-destroy-zfs-datasets","linux/zfs.html#list-all-zfs-datasets","linux/zfs.html#mount-zfs-datasets","linux/zfs.html#encrypted-datasets","linux/zfs.html#manage-zfs-encryption-keys","linux/zfs.html#manage-dataset-properties","linux/zfs.html#snapshots","linux/zfs.html#access-control-list","linux/zfs.html#example-zfs-pool-import-during-startup-systemd","network/index.html#network","network/tcpdump.html#tcpdump1","network/tcpdump.html#cli","network/tcpdump.html#examples","network/tcpdump.html#capture-packets-from-remote-host","network/firewall-cmd.html#firewall-cmd1","network/firewall-cmd.html#list-current-status-of-the-firewall","network/firewall-cmd.html#add-entries","network/firewall-cmd.html#remove-entries","network/firewall-cmd.html#references","network/nftables.html#nftables","network/nftables.html#ruleset","network/nftables.html#examples-save-rules-to-files-and-re-apply","network/nftables.html#example-fully-trace-evaluation-of-nftables-rules","network/nftables.html#example-ipv4-port-forwarding","network/nftables.html#example-base-vs-regular-chain","network/nftables.html#mental-model-for-netfilter-packet-flow","web/index.html#web","web/html.html#html","web/html.html#collapsible-element","web/html.html#minimal-2-column-layout","web/html.html#minimal-grid-area","web/html.html#minimal-tabs","web/chartjs.html#chartjs","web/chartjs.html#minimal-example-with--external--tooltips","arch/index.html#arch","arch/x86_64.html#x86_64","arch/x86_64.html#registers","arch/x86_64.html#general-purpose-register","arch/x86_64.html#special-register","arch/x86_64.html#flags-register","arch/x86_64.html#model-specific-register-msr","arch/x86_64.html#size-directives","arch/x86_64.html#addressing","arch/x86_64.html#string-instructions","arch/x86_64.html#example-simple-memset","arch/x86_64.html#sysv-x86_64-abi","arch/x86_64.html#passing-arguments-to-functions","arch/x86_64.html#return-values-from-functions","arch/x86_64.html#caller-saved-registers","arch/x86_64.html#callee-saved-registers","arch/x86_64.html#stack","arch/x86_64.html#function-prologue--epilogue","arch/x86_64.html#asm-skeleton","arch/x86_64.html#references","arch/arm64.html#arm64","arch/arm64.html#registers","arch/arm64.html#general-purpose-registers","arch/arm64.html#special-registers-per-el","arch/arm64.html#instructions-cheatsheet","arch/arm64.html#accessing-system-registers","arch/arm64.html#control-flow","arch/arm64.html#addressing","arch/arm64.html#offset","arch/arm64.html#index","arch/arm64.html#pair-access","arch/arm64.html#procedure-call-standard-arm64--aapcs64-","arch/arm64.html#passing-arguments-to-functions","arch/arm64.html#return-values-from-functions","arch/arm64.html#callee-saved-registers","arch/arm64.html#stack","arch/arm64.html#frame-chain","arch/arm64.html#function-prologue--epilogue","arch/arm64.html#asm-skeleton","arch/arm64.html#references","arch/armv7.html#armv7a","arch/armv7.html#registers","arch/armv7.html#general-purpose-registers","arch/armv7.html#special-registers","arch/armv7.html#cpsr-register","arch/armv7.html#instructions-cheatsheet","arch/armv7.html#accessing-system-registers","arch/armv7.html#control-flow","arch/armv7.html#loadstore","arch/armv7.html#procedure-call-standard-arm--aapcs32-","arch/armv7.html#passing-arguments-to-functions","arch/armv7.html#return-values-from-functions","arch/armv7.html#callee-saved-registers","arch/armv7.html#stack","arch/armv7.html#frame-chain","arch/armv7.html#function-prologue--epilogue","arch/armv7.html#asm-skeleton","arch/armv7.html#references","arch/riscv.html#riscv","arch/riscv.html#registers","arch/riscv.html#general-purpose-registers","arch/riscv.html#asm-skeleton","arch/riscv.html#references"],"index":{"documentStore":{"docInfo":{"0":{"body":8,"breadcrumbs":2,"title":1},"1":{"body":14,"breadcrumbs":2,"title":1},"10":{"body":0,"breadcrumbs":3,"title":1},"100":{"body":16,"breadcrumbs":3,"title":1},"101":{"body":21,"breadcrumbs":3,"title":1},"102":{"body":4,"breadcrumbs":5,"title":3},"103":{"body":13,"breadcrumbs":4,"title":2},"104":{"body":55,"breadcrumbs":4,"title":2},"105":{"body":19,"breadcrumbs":5,"title":3},"106":{"body":14,"breadcrumbs":5,"title":3},"107":{"body":19,"breadcrumbs":4,"title":2},"108":{"body":26,"breadcrumbs":5,"title":3},"109":{"body":55,"breadcrumbs":3,"title":1},"11":{"body":36,"breadcrumbs":3,"title":1},"110":{"body":32,"breadcrumbs":4,"title":2},"111":{"body":12,"breadcrumbs":3,"title":1},"112":{"body":3,"breadcrumbs":3,"title":1},"113":{"body":0,"breadcrumbs":3,"title":1},"114":{"body":5,"breadcrumbs":9,"title":7},"115":{"body":28,"breadcrumbs":5,"title":3},"116":{"body":0,"breadcrumbs":3,"title":1},"117":{"body":52,"breadcrumbs":3,"title":1},"118":{"body":0,"breadcrumbs":4,"title":2},"119":{"body":66,"breadcrumbs":3,"title":1},"12":{"body":25,"breadcrumbs":4,"title":2},"120":{"body":112,"breadcrumbs":3,"title":1},"121":{"body":37,"breadcrumbs":3,"title":1},"122":{"body":66,"breadcrumbs":3,"title":1},"123":{"body":31,"breadcrumbs":3,"title":1},"124":{"body":42,"breadcrumbs":4,"title":2},"125":{"body":28,"breadcrumbs":4,"title":2},"126":{"body":43,"breadcrumbs":4,"title":2},"127":{"body":33,"breadcrumbs":5,"title":3},"128":{"body":77,"breadcrumbs":3,"title":1},"129":{"body":20,"breadcrumbs":6,"title":4},"13":{"body":93,"breadcrumbs":4,"title":2},"130":{"body":25,"breadcrumbs":5,"title":3},"131":{"body":24,"breadcrumbs":3,"title":1},"132":{"body":0,"breadcrumbs":3,"title":1},"133":{"body":24,"breadcrumbs":6,"title":4},"134":{"body":25,"breadcrumbs":4,"title":2},"135":{"body":18,"breadcrumbs":7,"title":5},"136":{"body":13,"breadcrumbs":6,"title":4},"137":{"body":9,"breadcrumbs":8,"title":6},"138":{"body":36,"breadcrumbs":7,"title":5},"139":{"body":20,"breadcrumbs":7,"title":5},"14":{"body":62,"breadcrumbs":3,"title":1},"140":{"body":203,"breadcrumbs":6,"title":4},"141":{"body":0,"breadcrumbs":4,"title":2},"142":{"body":27,"breadcrumbs":6,"title":4},"143":{"body":0,"breadcrumbs":3,"title":1},"144":{"body":13,"breadcrumbs":3,"title":1},"145":{"body":12,"breadcrumbs":3,"title":1},"146":{"body":0,"breadcrumbs":3,"title":1},"147":{"body":11,"breadcrumbs":3,"title":1},"148":{"body":16,"breadcrumbs":3,"title":1},"149":{"body":9,"breadcrumbs":3,"title":1},"15":{"body":69,"breadcrumbs":5,"title":3},"150":{"body":15,"breadcrumbs":3,"title":1},"151":{"body":0,"breadcrumbs":3,"title":1},"152":{"body":19,"breadcrumbs":6,"title":4},"153":{"body":18,"breadcrumbs":5,"title":3},"154":{"body":11,"breadcrumbs":3,"title":1},"155":{"body":31,"breadcrumbs":3,"title":1},"156":{"body":37,"breadcrumbs":5,"title":3},"157":{"body":40,"breadcrumbs":4,"title":2},"158":{"body":30,"breadcrumbs":4,"title":2},"159":{"body":10,"breadcrumbs":4,"title":2},"16":{"body":0,"breadcrumbs":3,"title":1},"160":{"body":105,"breadcrumbs":4,"title":2},"161":{"body":41,"breadcrumbs":3,"title":1},"162":{"body":18,"breadcrumbs":3,"title":1},"163":{"body":48,"breadcrumbs":4,"title":2},"164":{"body":11,"breadcrumbs":3,"title":1},"165":{"body":22,"breadcrumbs":4,"title":2},"166":{"body":20,"breadcrumbs":4,"title":2},"167":{"body":32,"breadcrumbs":3,"title":1},"168":{"body":38,"breadcrumbs":4,"title":2},"169":{"body":89,"breadcrumbs":4,"title":2},"17":{"body":0,"breadcrumbs":3,"title":1},"170":{"body":30,"breadcrumbs":6,"title":4},"171":{"body":63,"breadcrumbs":6,"title":4},"172":{"body":22,"breadcrumbs":3,"title":1},"173":{"body":0,"breadcrumbs":3,"title":1},"174":{"body":33,"breadcrumbs":5,"title":3},"175":{"body":9,"breadcrumbs":4,"title":2},"176":{"body":37,"breadcrumbs":5,"title":3},"177":{"body":31,"breadcrumbs":5,"title":3},"178":{"body":57,"breadcrumbs":3,"title":1},"179":{"body":2,"breadcrumbs":3,"title":1},"18":{"body":16,"breadcrumbs":3,"title":1},"180":{"body":91,"breadcrumbs":7,"title":5},"181":{"body":8,"breadcrumbs":3,"title":1},"182":{"body":6,"breadcrumbs":6,"title":3},"183":{"body":102,"breadcrumbs":5,"title":1},"184":{"body":0,"breadcrumbs":5,"title":1},"185":{"body":10,"breadcrumbs":6,"title":2},"186":{"body":21,"breadcrumbs":7,"title":3},"187":{"body":9,"breadcrumbs":8,"title":4},"188":{"body":10,"breadcrumbs":8,"title":4},"189":{"body":4,"breadcrumbs":9,"title":5},"19":{"body":69,"breadcrumbs":3,"title":1},"190":{"body":52,"breadcrumbs":5,"title":1},"191":{"body":28,"breadcrumbs":5,"title":1},"192":{"body":26,"breadcrumbs":5,"title":1},"193":{"body":50,"breadcrumbs":8,"title":4},"194":{"body":6,"breadcrumbs":6,"title":2},"195":{"body":22,"breadcrumbs":5,"title":1},"196":{"body":14,"breadcrumbs":7,"title":3},"197":{"body":27,"breadcrumbs":5,"title":1},"198":{"body":6,"breadcrumbs":5,"title":1},"199":{"body":5,"breadcrumbs":4,"title":2},"2":{"body":0,"breadcrumbs":3,"title":1},"20":{"body":92,"breadcrumbs":3,"title":1},"200":{"body":135,"breadcrumbs":4,"title":1},"201":{"body":26,"breadcrumbs":4,"title":1},"202":{"body":27,"breadcrumbs":4,"title":1},"203":{"body":11,"breadcrumbs":4,"title":1},"204":{"body":128,"breadcrumbs":4,"title":1},"205":{"body":0,"breadcrumbs":4,"title":1},"206":{"body":15,"breadcrumbs":7,"title":4},"207":{"body":17,"breadcrumbs":7,"title":4},"208":{"body":43,"breadcrumbs":4,"title":1},"209":{"body":6,"breadcrumbs":4,"title":1},"21":{"body":38,"breadcrumbs":4,"title":2},"210":{"body":5,"breadcrumbs":2,"title":1},"211":{"body":45,"breadcrumbs":3,"title":1},"212":{"body":34,"breadcrumbs":5,"title":3},"213":{"body":76,"breadcrumbs":5,"title":3},"214":{"body":19,"breadcrumbs":3,"title":1},"215":{"body":6,"breadcrumbs":5,"title":3},"216":{"body":7,"breadcrumbs":5,"title":3},"217":{"body":11,"breadcrumbs":4,"title":2},"218":{"body":15,"breadcrumbs":7,"title":5},"219":{"body":55,"breadcrumbs":3,"title":1},"22":{"body":26,"breadcrumbs":3,"title":1},"220":{"body":36,"breadcrumbs":3,"title":1},"221":{"body":8,"breadcrumbs":4,"title":2},"222":{"body":101,"breadcrumbs":6,"title":4},"223":{"body":7,"breadcrumbs":3,"title":1},"224":{"body":10,"breadcrumbs":2,"title":1},"225":{"body":0,"breadcrumbs":3,"title":1},"226":{"body":3,"breadcrumbs":4,"title":2},"227":{"body":10,"breadcrumbs":4,"title":2},"228":{"body":5,"breadcrumbs":3,"title":1},"229":{"body":14,"breadcrumbs":4,"title":2},"23":{"body":64,"breadcrumbs":5,"title":3},"230":{"body":93,"breadcrumbs":6,"title":4},"231":{"body":141,"breadcrumbs":6,"title":4},"232":{"body":69,"breadcrumbs":7,"title":5},"233":{"body":248,"breadcrumbs":5,"title":3},"234":{"body":208,"breadcrumbs":7,"title":5},"235":{"body":314,"breadcrumbs":6,"title":4},"236":{"body":231,"breadcrumbs":7,"title":5},"237":{"body":127,"breadcrumbs":5,"title":3},"238":{"body":0,"breadcrumbs":3,"title":1},"239":{"body":62,"breadcrumbs":5,"title":3},"24":{"body":35,"breadcrumbs":3,"title":1},"240":{"body":34,"breadcrumbs":5,"title":3},"241":{"body":0,"breadcrumbs":3,"title":1},"242":{"body":0,"breadcrumbs":3,"title":1},"243":{"body":41,"breadcrumbs":3,"title":1},"244":{"body":18,"breadcrumbs":4,"title":2},"245":{"body":25,"breadcrumbs":4,"title":2},"246":{"body":0,"breadcrumbs":3,"title":1},"247":{"body":104,"breadcrumbs":4,"title":2},"248":{"body":9,"breadcrumbs":4,"title":2},"249":{"body":0,"breadcrumbs":3,"title":1},"25":{"body":58,"breadcrumbs":4,"title":2},"250":{"body":27,"breadcrumbs":5,"title":3},"251":{"body":0,"breadcrumbs":6,"title":4},"252":{"body":36,"breadcrumbs":4,"title":2},"253":{"body":81,"breadcrumbs":4,"title":2},"254":{"body":20,"breadcrumbs":3,"title":1},"255":{"body":0,"breadcrumbs":4,"title":2},"256":{"body":14,"breadcrumbs":4,"title":2},"257":{"body":12,"breadcrumbs":4,"title":2},"258":{"body":16,"breadcrumbs":3,"title":1},"259":{"body":17,"breadcrumbs":4,"title":2},"26":{"body":123,"breadcrumbs":3,"title":1},"260":{"body":23,"breadcrumbs":3,"title":1},"261":{"body":0,"breadcrumbs":3,"title":1},"262":{"body":38,"breadcrumbs":4,"title":2},"263":{"body":30,"breadcrumbs":4,"title":2},"264":{"body":128,"breadcrumbs":7,"title":5},"265":{"body":246,"breadcrumbs":5,"title":3},"266":{"body":422,"breadcrumbs":6,"title":3},"267":{"body":278,"breadcrumbs":6,"title":3},"268":{"body":13,"breadcrumbs":4,"title":1},"269":{"body":0,"breadcrumbs":3,"title":1},"27":{"body":66,"breadcrumbs":3,"title":1},"270":{"body":59,"breadcrumbs":4,"title":2},"271":{"body":45,"breadcrumbs":5,"title":3},"272":{"body":43,"breadcrumbs":4,"title":2},"273":{"body":28,"breadcrumbs":4,"title":2},"274":{"body":8,"breadcrumbs":3,"title":1},"275":{"body":98,"breadcrumbs":3,"title":1},"276":{"body":140,"breadcrumbs":3,"title":1},"277":{"body":8,"breadcrumbs":2,"title":1},"278":{"body":0,"breadcrumbs":3,"title":1},"279":{"body":55,"breadcrumbs":3,"title":1},"28":{"body":0,"breadcrumbs":3,"title":1},"280":{"body":31,"breadcrumbs":6,"title":4},"281":{"body":46,"breadcrumbs":3,"title":1},"282":{"body":4,"breadcrumbs":3,"title":1},"283":{"body":27,"breadcrumbs":3,"title":1},"284":{"body":77,"breadcrumbs":5,"title":3},"285":{"body":87,"breadcrumbs":5,"title":3},"286":{"body":0,"breadcrumbs":4,"title":2},"287":{"body":48,"breadcrumbs":4,"title":2},"288":{"body":18,"breadcrumbs":4,"title":2},"289":{"body":43,"breadcrumbs":3,"title":1},"29":{"body":19,"breadcrumbs":4,"title":2},"290":{"body":64,"breadcrumbs":3,"title":1},"291":{"body":154,"breadcrumbs":7,"title":5},"292":{"body":36,"breadcrumbs":7,"title":5},"293":{"body":0,"breadcrumbs":3,"title":1},"294":{"body":7,"breadcrumbs":6,"title":4},"295":{"body":59,"breadcrumbs":5,"title":3},"296":{"body":42,"breadcrumbs":6,"title":4},"297":{"body":6,"breadcrumbs":4,"title":2},"298":{"body":62,"breadcrumbs":4,"title":2},"299":{"body":59,"breadcrumbs":3,"title":1},"3":{"body":96,"breadcrumbs":3,"title":1},"30":{"body":19,"breadcrumbs":3,"title":1},"300":{"body":30,"breadcrumbs":5,"title":3},"301":{"body":172,"breadcrumbs":5,"title":3},"302":{"body":78,"breadcrumbs":6,"title":4},"303":{"body":6,"breadcrumbs":5,"title":3},"304":{"body":41,"breadcrumbs":5,"title":3},"305":{"body":34,"breadcrumbs":5,"title":3},"306":{"body":3,"breadcrumbs":3,"title":1},"307":{"body":75,"breadcrumbs":3,"title":1},"308":{"body":4,"breadcrumbs":5,"title":3},"309":{"body":50,"breadcrumbs":7,"title":5},"31":{"body":25,"breadcrumbs":4,"title":2},"310":{"body":29,"breadcrumbs":5,"title":3},"311":{"body":96,"breadcrumbs":4,"title":2},"312":{"body":94,"breadcrumbs":5,"title":3},"313":{"body":56,"breadcrumbs":6,"title":4},"314":{"body":4,"breadcrumbs":5,"title":3},"315":{"body":13,"breadcrumbs":6,"title":4},"316":{"body":5,"breadcrumbs":5,"title":3},"317":{"body":16,"breadcrumbs":5,"title":3},"318":{"body":39,"breadcrumbs":4,"title":2},"319":{"body":31,"breadcrumbs":6,"title":4},"32":{"body":52,"breadcrumbs":3,"title":1},"320":{"body":22,"breadcrumbs":5,"title":3},"321":{"body":51,"breadcrumbs":3,"title":1},"322":{"body":29,"breadcrumbs":5,"title":3},"323":{"body":26,"breadcrumbs":9,"title":7},"324":{"body":4,"breadcrumbs":2,"title":1},"325":{"body":0,"breadcrumbs":3,"title":1},"326":{"body":59,"breadcrumbs":3,"title":1},"327":{"body":0,"breadcrumbs":3,"title":1},"328":{"body":17,"breadcrumbs":6,"title":4},"329":{"body":5,"breadcrumbs":5,"title":2},"33":{"body":39,"breadcrumbs":5,"title":3},"330":{"body":31,"breadcrumbs":7,"title":4},"331":{"body":41,"breadcrumbs":5,"title":2},"332":{"body":29,"breadcrumbs":5,"title":2},"333":{"body":5,"breadcrumbs":4,"title":1},"334":{"body":60,"breadcrumbs":3,"title":1},"335":{"body":13,"breadcrumbs":3,"title":1},"336":{"body":10,"breadcrumbs":8,"title":6},"337":{"body":54,"breadcrumbs":8,"title":6},"338":{"body":31,"breadcrumbs":6,"title":4},"339":{"body":140,"breadcrumbs":7,"title":5},"34":{"body":8,"breadcrumbs":4,"title":2},"340":{"body":1,"breadcrumbs":7,"title":5},"341":{"body":2,"breadcrumbs":2,"title":1},"342":{"body":0,"breadcrumbs":3,"title":1},"343":{"body":19,"breadcrumbs":4,"title":2},"344":{"body":55,"breadcrumbs":6,"title":4},"345":{"body":128,"breadcrumbs":5,"title":3},"346":{"body":50,"breadcrumbs":4,"title":2},"347":{"body":0,"breadcrumbs":3,"title":1},"348":{"body":236,"breadcrumbs":6,"title":4},"349":{"body":4,"breadcrumbs":2,"title":1},"35":{"body":8,"breadcrumbs":4,"title":2},"350":{"body":21,"breadcrumbs":3,"title":1},"351":{"body":0,"breadcrumbs":3,"title":1},"352":{"body":62,"breadcrumbs":5,"title":3},"353":{"body":15,"breadcrumbs":4,"title":2},"354":{"body":102,"breadcrumbs":4,"title":2},"355":{"body":14,"breadcrumbs":6,"title":4},"356":{"body":40,"breadcrumbs":4,"title":2},"357":{"body":52,"breadcrumbs":3,"title":1},"358":{"body":116,"breadcrumbs":4,"title":2},"359":{"body":17,"breadcrumbs":5,"title":3},"36":{"body":0,"breadcrumbs":4,"title":2},"360":{"body":0,"breadcrumbs":5,"title":3},"361":{"body":40,"breadcrumbs":5,"title":3},"362":{"body":23,"breadcrumbs":5,"title":3},"363":{"body":14,"breadcrumbs":5,"title":3},"364":{"body":15,"breadcrumbs":5,"title":3},"365":{"body":29,"breadcrumbs":3,"title":1},"366":{"body":31,"breadcrumbs":5,"title":3},"367":{"body":94,"breadcrumbs":4,"title":2},"368":{"body":47,"breadcrumbs":3,"title":1},"369":{"body":14,"breadcrumbs":3,"title":1},"37":{"body":10,"breadcrumbs":2,"title":0},"370":{"body":0,"breadcrumbs":3,"title":1},"371":{"body":40,"breadcrumbs":5,"title":3},"372":{"body":52,"breadcrumbs":6,"title":4},"373":{"body":0,"breadcrumbs":4,"title":2},"374":{"body":18,"breadcrumbs":5,"title":3},"375":{"body":38,"breadcrumbs":4,"title":2},"376":{"body":0,"breadcrumbs":3,"title":1},"377":{"body":47,"breadcrumbs":3,"title":1},"378":{"body":18,"breadcrumbs":3,"title":1},"379":{"body":18,"breadcrumbs":4,"title":2},"38":{"body":14,"breadcrumbs":3,"title":1},"380":{"body":0,"breadcrumbs":7,"title":5},"381":{"body":35,"breadcrumbs":5,"title":3},"382":{"body":8,"breadcrumbs":5,"title":3},"383":{"body":3,"breadcrumbs":5,"title":3},"384":{"body":27,"breadcrumbs":3,"title":1},"385":{"body":52,"breadcrumbs":4,"title":2},"386":{"body":36,"breadcrumbs":5,"title":3},"387":{"body":141,"breadcrumbs":4,"title":2},"388":{"body":27,"breadcrumbs":3,"title":1},"389":{"body":10,"breadcrumbs":3,"title":1},"39":{"body":4,"breadcrumbs":3,"title":1},"390":{"body":0,"breadcrumbs":3,"title":1},"391":{"body":23,"breadcrumbs":5,"title":3},"392":{"body":8,"breadcrumbs":4,"title":2},"393":{"body":55,"breadcrumbs":4,"title":2},"394":{"body":0,"breadcrumbs":4,"title":2},"395":{"body":18,"breadcrumbs":5,"title":3},"396":{"body":50,"breadcrumbs":4,"title":2},"397":{"body":96,"breadcrumbs":3,"title":1},"398":{"body":0,"breadcrumbs":7,"title":5},"399":{"body":44,"breadcrumbs":5,"title":3},"4":{"body":88,"breadcrumbs":3,"title":1},"40":{"body":5,"breadcrumbs":3,"title":1},"400":{"body":11,"breadcrumbs":5,"title":3},"401":{"body":3,"breadcrumbs":5,"title":3},"402":{"body":26,"breadcrumbs":3,"title":1},"403":{"body":65,"breadcrumbs":4,"title":2},"404":{"body":19,"breadcrumbs":5,"title":3},"405":{"body":165,"breadcrumbs":4,"title":2},"406":{"body":21,"breadcrumbs":3,"title":1},"407":{"body":9,"breadcrumbs":3,"title":1},"408":{"body":4,"breadcrumbs":3,"title":1},"409":{"body":55,"breadcrumbs":5,"title":3},"41":{"body":11,"breadcrumbs":3,"title":1},"410":{"body":143,"breadcrumbs":4,"title":2},"411":{"body":5,"breadcrumbs":3,"title":1},"42":{"body":24,"breadcrumbs":3,"title":1},"43":{"body":24,"breadcrumbs":3,"title":1},"44":{"body":19,"breadcrumbs":3,"title":1},"45":{"body":24,"breadcrumbs":4,"title":2},"46":{"body":28,"breadcrumbs":3,"title":1},"47":{"body":19,"breadcrumbs":3,"title":1},"48":{"body":19,"breadcrumbs":3,"title":1},"49":{"body":86,"breadcrumbs":4,"title":2},"5":{"body":79,"breadcrumbs":3,"title":1},"50":{"body":119,"breadcrumbs":3,"title":1},"51":{"body":128,"breadcrumbs":3,"title":1},"52":{"body":24,"breadcrumbs":4,"title":2},"53":{"body":0,"breadcrumbs":3,"title":1},"54":{"body":23,"breadcrumbs":4,"title":2},"55":{"body":7,"breadcrumbs":3,"title":1},"56":{"body":21,"breadcrumbs":3,"title":1},"57":{"body":77,"breadcrumbs":3,"title":1},"58":{"body":45,"breadcrumbs":3,"title":1},"59":{"body":46,"breadcrumbs":5,"title":3},"6":{"body":79,"breadcrumbs":4,"title":2},"60":{"body":58,"breadcrumbs":5,"title":3},"61":{"body":109,"breadcrumbs":3,"title":1},"62":{"body":50,"breadcrumbs":3,"title":1},"63":{"body":64,"breadcrumbs":3,"title":1},"64":{"body":27,"breadcrumbs":3,"title":1},"65":{"body":28,"breadcrumbs":4,"title":2},"66":{"body":18,"breadcrumbs":3,"title":1},"67":{"body":45,"breadcrumbs":4,"title":2},"68":{"body":37,"breadcrumbs":3,"title":1},"69":{"body":29,"breadcrumbs":4,"title":2},"7":{"body":48,"breadcrumbs":5,"title":3},"70":{"body":29,"breadcrumbs":4,"title":2},"71":{"body":86,"breadcrumbs":5,"title":3},"72":{"body":0,"breadcrumbs":3,"title":1},"73":{"body":18,"breadcrumbs":4,"title":2},"74":{"body":7,"breadcrumbs":4,"title":2},"75":{"body":19,"breadcrumbs":6,"title":4},"76":{"body":39,"breadcrumbs":4,"title":2},"77":{"body":34,"breadcrumbs":4,"title":2},"78":{"body":25,"breadcrumbs":7,"title":5},"79":{"body":0,"breadcrumbs":3,"title":1},"8":{"body":40,"breadcrumbs":3,"title":1},"80":{"body":74,"breadcrumbs":3,"title":1},"81":{"body":21,"breadcrumbs":4,"title":2},"82":{"body":40,"breadcrumbs":3,"title":1},"83":{"body":50,"breadcrumbs":3,"title":1},"84":{"body":77,"breadcrumbs":3,"title":1},"85":{"body":57,"breadcrumbs":3,"title":1},"86":{"body":51,"breadcrumbs":3,"title":1},"87":{"body":24,"breadcrumbs":3,"title":1},"88":{"body":43,"breadcrumbs":3,"title":1},"89":{"body":24,"breadcrumbs":3,"title":1},"9":{"body":46,"breadcrumbs":4,"title":2},"90":{"body":19,"breadcrumbs":3,"title":1},"91":{"body":32,"breadcrumbs":4,"title":2},"92":{"body":22,"breadcrumbs":3,"title":1},"93":{"body":39,"breadcrumbs":3,"title":1},"94":{"body":23,"breadcrumbs":4,"title":2},"95":{"body":26,"breadcrumbs":3,"title":1},"96":{"body":38,"breadcrumbs":3,"title":1},"97":{"body":49,"breadcrumbs":3,"title":1},"98":{"body":24,"breadcrumbs":3,"title":1},"99":{"body":28,"breadcrumbs":3,"title":1}},"docs":{"0":{"body":"A personal collection of notes and cheatsheets. Source code is located at johannst/notes .","breadcrumbs":"Introduction » Notes","id":"0","title":"Notes"},"1":{"body":"zsh bash fish tmux git awk emacs gpg gdb gdbserver radare2 qemu pacman dot","breadcrumbs":"Tools » Tools","id":"1","title":"Tools"},"10":{"body":"","breadcrumbs":"Tools » zsh » Completion","id":"10","title":"Completion"},"100":{"body":"key fn description\n-------------------------- i open sub-dir in same buffer + create new directory C copy file/dir q quit","breadcrumbs":"Tools » emacs » dired","id":"100","title":"dired"},"101":{"body":"gpg -o|--output Specify output file -a|--armor Create ascii output -u|--local-user Specify key for signing -r|--recipient Encrypt for user","breadcrumbs":"Tools » gpg » gpg(1)","id":"101","title":"gpg(1)"},"102":{"body":"gpg --full-generate-key","breadcrumbs":"Tools » gpg » Generate new keypair","id":"102","title":"Generate new keypair"},"103":{"body":"gpg -k / --list-key # public keys\ngpg -K / --list-secret-keys # secret keys","breadcrumbs":"Tools » gpg » List keys","id":"103","title":"List keys"},"104":{"body":"gpg --edit-key Gives prompt to modify KEY ID, common commands: help show help\nsave save & quit list list keys and user IDs\nkey select subkey \nuid select user ID expire change expiration of selected key adduid add user ID\ndeluid delete selected user ID addkey add subkey\ndelkey delete selected subkey","breadcrumbs":"Tools » gpg » Edit keys","id":"104","title":"Edit keys"},"105":{"body":"gpg --export --armor --output \ngpg --export-secret-key --armor --output \ngpg --import ","breadcrumbs":"Tools » gpg » Export & Import Keys","id":"105","title":"Export & Import Keys"},"106":{"body":"gpg --keyserver --send-keys \ngpg --keyserver --search-keys ","breadcrumbs":"Tools » gpg » Search & Send keys","id":"106","title":"Search & Send keys"},"107":{"body":"Encrypt file using passphrase and write encrypted data to .gpg. gpg --symmetric # Decrypt using passphrase\ngpg -o --decrypt .gpg","breadcrumbs":"Tools » gpg » Encrypt (passphrase)","id":"107","title":"Encrypt (passphrase)"},"108":{"body":"Encrypt file with public key of specified recipient and write encrypted data to .gpg. gpg --encrypt -r foo@bar.de # Decrypt at foos side (private key required)\ngpg -o --decrypt .gpg","breadcrumbs":"Tools » gpg » Encrypt (public key)","id":"108","title":"Encrypt (public key)"},"109":{"body":"Generate a signed file and write to .gpg. # Sign with private key of foo@bar.de\ngpg --sign -u foor@bar.de # Verify with public key of foo@bar.de\ngpg --verify # Extract content from signed file\ngpg -o --decrypt .gpg Without -u use first private key in list gpg -K for signing. Files can also be signed and encrypted at once, gpg will first sign the file and then encrypt it. gpg --sign --encrypt -r ","breadcrumbs":"Tools » gpg » Signing","id":"109","title":"Signing"},"11":{"body":"Completion functions are provided via files and need to be placed in a location covered by $fpath. By convention the completion files are names as _. A completion skeleton for the command foo, stored in _foo #compdef _foo foo function _foo() { ...\n} Alternatively one can install a completion function explicitly by calling compdef .","breadcrumbs":"Tools » zsh » Installation","id":"11","title":"Installation"},"110":{"body":"Generate a detached signature and write to .asc. Send .asc along with when distributing. gpg --detach-sign --armor -u foor@bar.de # Verify\ngpg --verify .asc Without -u use first private key in list gpg -K for signing.","breadcrumbs":"Tools » gpg » Signing (detached)","id":"110","title":"Signing (detached)"},"111":{"body":"sec secret key ssb secret subkey pub public key sub public subkey","breadcrumbs":"Tools » gpg » Abbreviations","id":"111","title":"Abbreviations"},"112":{"body":"http://pgp.mit.edu http://keyserver.ubuntu.com hkps://pgp.mailbox.org","breadcrumbs":"Tools » gpg » Keyservers","id":"112","title":"Keyservers"},"113":{"body":"","breadcrumbs":"Tools » gpg » Examples","id":"113","title":"Examples"},"114":{"body":"gpg --keyid-format 0xlong ","breadcrumbs":"Tools » gpg » List basic key information from file with long keyids","id":"114","title":"List basic key information from file with long keyids"},"115":{"body":"gpg --edit-key # By default we are on the primary key, can switch to sub key.\ngpg> key 1 # Update the expire date.\ngpg> expire gpg> save # Update keyserver(s) and/or export new pub keyfile.","breadcrumbs":"Tools » gpg » Extend expiring key","id":"115","title":"Extend expiring key"},"116":{"body":"","breadcrumbs":"Tools » gdb » gdb(1)","id":"116","title":"gdb(1)"},"117":{"body":"gdb [opts] [prg [-c coredump | -p pid]] gdb [opts] --args prg opts: -p attach to pid -c use -x execute script before prompt -ex execute command before prompt --tty set I/O tty for debugee --batch run in batch mode, exit after processing options (eg used for scripting)","breadcrumbs":"Tools » gdb » CLI","id":"117","title":"CLI"},"118":{"body":"","breadcrumbs":"Tools » gdb » Interactive usage","id":"118","title":"Interactive usage"},"119":{"body":"tty Set as tty for debugee. Make sure nobody reads from target tty, easiest is to spawn a shell and run following in target tty: > while true; do sleep 1024; done sharedlibrary [] Load symbols of shared libs loaded by debugee. Optionally use to filter libs for symbol loading. display [/FMT] Print every time debugee stops. Eg print next instr, see examples below. undisplay [] Delete display expressions either all or one referenced by . info display List display expressions.","breadcrumbs":"Tools » gdb » Misc","id":"119","title":"Misc"},"12":{"body":"Following variables are available in Completion functions: $words # array with command line in words\n$#words # number words\n$CURRENT # index into $words for cursor position\n$words[CURRENT-1] # previous word (relative to cursor position)","breadcrumbs":"Tools » zsh » Completion Variables","id":"12","title":"Completion Variables"},"120":{"body":"break [-qualified] thread Set a breakpoint only for a specific thread. -qualified: Treat as fully qualified symbol (quiet handy to set breakpoints on C symbols in C++ contexts) break if Set conditional breakpoint (see examples below). delete [] Delete breakpoint either all or one referenced by . info break List breakpoints. cond Make existing breakpoint conditional with . tbreak Set temporary breakpoint, will be deleted when hit. Same syntax as `break`. rbreak Set breakpoints matching , where matching internally is done on: .*.* command [] Define commands to run after breakpoint hit. If is not specified attach command to last created breakpoint. Command block terminated with 'end' token. : Space separates list, eg 'command 2 5-8' to run command for breakpoints: 2,5,6,7,8. save break Save breakpoints to . Can be loaded with the `source` command.","breadcrumbs":"Tools » gdb » Breakpoints","id":"120","title":"Breakpoints"},"121":{"body":"watch [-location|-l] [thread ] Create a watchpoint for , will break if is written to. Watchpoints respect scope of variables, -l can be used to watch the memory location instead. rwatch ... Sets a read watchpoint, will break if is read from. awatch ... Sets an access watchpoint, will break if is written to or read from.","breadcrumbs":"Tools » gdb » Watchpoints","id":"121","title":"Watchpoints"},"122":{"body":"catch load [] Stop when shared libraries are loaded, optionally specify a to stop only on matches. catch unload [] Stop when shared libraries are unloaded, optionally specify a to stop only on matches. catch throw Stop when an exception is thrown. catch rethrow Stop when an exception is rethrown. catch catch Stop when an exception is caught. catch fork Stop at calls to fork (also stops at clones, as some systems implement fork via clone). catch syscall [ ..] Stop at syscall. If no argument is given, stop at all syscalls. Optionally give a list of syscalls to stop at.","breadcrumbs":"Tools » gdb » Catchpoints","id":"122","title":"Catchpoints"},"123":{"body":"info functions [] List functions matching . List all functions if no provided. info variables [] List variables matching . List all variables if no provided. info register [ ..] Dump content of all registers or only the specified ister.","breadcrumbs":"Tools » gdb » Inspection","id":"123","title":"Inspection"},"124":{"body":"info handle [] Print how to handle . If no specified print for all signals. handle Configure how gdb handles sent to debugee. : stop/nostop Catch signal in gdb and break. print/noprint Print message when gdb catches signal. pass/nopass Pass signal down to debugee. catch signal Create a catchpoint for .","breadcrumbs":"Tools » gdb » Signal handling","id":"124","title":"Signal handling"},"125":{"body":"info thread List all threads. thread apply [] Run command on all threads listed by (space separated list). When 'all' is specified as the is run on all threads. thread name The for the current thread.","breadcrumbs":"Tools » gdb » Multi-threading","id":"125","title":"Multi-threading"},"126":{"body":"set follow-fork-mode Specify which process to follow when debuggee makes a fork(2) syscall. set detach-on-frok Turn on/off detaching from new child processes (on by default). Turning this off allows to debug multiple processes (inferiors) with one gdb session. info inferiors List all processes gdb debugs. inferior Switch to inferior with .","breadcrumbs":"Tools » gdb » Multi-process","id":"126","title":"Multi-process"},"127":{"body":"dir Add to the beginning of the searh path for source files. show dir Show current search path. set substitute-path Add substitution rule checked during source file lookup. show substitute-path Show current substitution rules.","breadcrumbs":"Tools » gdb » Source file locations","id":"127","title":"Source file locations"},"128":{"body":"set disassembly-flavor Set the disassembly style \"flavor\". set pagination Turn on/off gdb's pagination. set breakpoint pending on: always set pending breakpoints. off: error when trying to set pending breakpoints. auto: interatively query user to set breakpoint. set print pretty Turn on/off pertty printing of structures. set style enabled Turn on/off styling (eg colored output). set logging Enable output logging to file (default gdb.txt). set logging file Change output log file to set logging redirect on: only log to file. off: log to file and tty.","breadcrumbs":"Tools » gdb » Configuration","id":"128","title":"Configuration"},"129":{"body":"C-x a Toggle UI. C-l Redraw UI (curses UI can be messed up after the debugee prints to stdout/stderr). C-x o Change focus.","breadcrumbs":"Tools » gdb » Text user interface (TUI)","id":"129","title":"Text user interface (TUI)"},"13":{"body":"_describe simple completion, just words + description _arguments sophisticated completion, allow to specify actions Completion with _describe _describe MSG COMP MSG simple string with header message COMP array of completions where each entry is \"opt:description\" function _foo() { local -a opts opts=('bla:desc for bla' 'blu:desc for blu') _describe 'foo-msg' opts\n}\ncompdef _foo foo foo -- foo-msg --\nbla -- desc for bla\nblu -- desc for blu Completion with _arguments _arguments SPEC [SPEC...] where SPEC can have one of the following forms: OPT[DESC]:MSG:ACTION for option flags N:MSG:ACTION for positional arguments Available actions (op1 op2) list possible matches\n->VAL set $state=VAL and continue, `$state` can be checked later in switch case\nFUNC call func to generate matches\n{STR} evaluate `STR` to generate matches","breadcrumbs":"Tools » zsh » Completion Functions","id":"13","title":"Completion Functions"},"130":{"body":"Gdb allows to create & document user commands as follows: define # cmds end document # docu end To get all user commands or documentations one can use: help user-defined help ","breadcrumbs":"Tools » gdb » User commands (macros)","id":"130","title":"User commands (macros)"},"131":{"body":"Gdb allows to create two types of command hooks hook- will be run before hookpost- will be run after define hook- # cmds end define hookpost- # cmds end","breadcrumbs":"Tools » gdb » Hooks","id":"131","title":"Hooks"},"132":{"body":"","breadcrumbs":"Tools » gdb » Examples","id":"132","title":"Examples"},"133":{"body":"When ever the debugee stops automatically print the memory at the current instruction pointer ($rip x86) and format as instruction /i. # rip - x86 display /i $rip # step instruction, after the step the next instruction is automatically printed si","breadcrumbs":"Tools » gdb » Automatically print next instr","id":"133","title":"Automatically print next instr"},"134":{"body":"Create conditional breakpoints for a function void foo(int i) in the debugee. # Create conditional breakpoint b foo if i == 42 b foo # would create bp 2 # Make existing breakpoint conditional cond 2 if i == 7","breadcrumbs":"Tools » gdb » Conditional breakpoints","id":"134","title":"Conditional breakpoints"},"135":{"body":"Create conditional breakpoint using the $_thread convenience variable . # Create conditional breakpoint on all threads except thread 12. b foo if $_thread != 12","breadcrumbs":"Tools » gdb » Set breakpoint on all threads except one","id":"135","title":"Set breakpoint on all threads except one"},"136":{"body":"This creates a catchpoint for the SIGSEGV signal and attached the command to it. catch signal SIGSEGV command bt c end","breadcrumbs":"Tools » gdb » Catch SIGSEGV and execute commands","id":"136","title":"Catch SIGSEGV and execute commands"},"137":{"body":"gdb --batch -ex 'thread 1' -ex 'bt' -p ","breadcrumbs":"Tools » gdb » Run backtrace on thread 1 (batch mode)","id":"137","title":"Run backtrace on thread 1 (batch mode)"},"138":{"body":"To script gdb add commands into a file and pass it to gdb via -x. For example create run.gdb: set pagination off break mmap command info reg rdi rsi rdx bt c end #initial drop c This script can be used as: gdb --batch -x ./run.gdb -p ","breadcrumbs":"Tools » gdb » Script gdb for automating debugging sessions","id":"138","title":"Script gdb for automating debugging sessions"},"139":{"body":"define break-save save breakpoint $arg0.gdb.bp\nend\ndefine break-load source $arg0.gdb.bp\nend define hook-quit break-save quit\nend","breadcrumbs":"Tools » gdb » Hook to automatically save breakpoints on quit","id":"139","title":"Hook to automatically save breakpoints on quit"},"14":{"body":"Skeleton to copy/paste for writing simple completions. Assume a program foo with the following interface: foo -c green|red|blue -s low|high -f -d -h The completion handler could be implemented as follows in a file called _foo: #compdef _foo foo function _foo_color() { local colors=() colors+=('green:green color') colors+=('red:red color') colors+=('blue:blue color') _describe \"color\" colors\n} function _foo() { _arguments \\ \"-c[define color]:color:->s_color\" \\ \"-s[select sound]:sound:(low high)\" \\ \"-f[select file]:file:_files\" \\ \"-d[select dir]:dir:_files -/\" \\ \"-h[help]\" case $state in s_color) _foo_color;; esac\n}","breadcrumbs":"Tools » zsh » Example","id":"14","title":"Example"},"140":{"body":"A symbolic watchpoint defined on a member variable for debugging is only valid as long as the expression is in scope. Once out of scope the watchpoint gets deleted. When debugging some memory corruption we want to keep the watchpoint even the expression goes out of scope to find the location that overrides the variable and introduces the corruption. (gdb) l\n1 struct S { int v; };\n2\n3 void set(struct S* s, int v) {\n4 s->v = v;\n5 }\n6\n7 int main() {\n8 struct S s;\n9 set(&s, 1);\n10 set(&s, 2);\n11 set(&s, 3);\n... (gdb) s\nset (s=0x7fffffffe594, v=1) at test.c:4\n4 s->v = v; # Define a new watchpoint on the member of the struct. The expression however\n# is only valid in the current functions scope. (gdb) watch s->v\nHardware watchpoint 2: s->v (gdb) c\nHardware watchpoint 2: s->v\nOld value = 0\nNew value = 1\nset (s=0x7fffffffe594, v=1) at test.c:5\n5 } # The watchpoint gets deleted as soon as we leave the function scope. (gdb) c\nWatchpoint 2 deleted because the program has left the block in\nwhich its expression is valid.\nmain () at test.c:10\n10 set(&s, 2); (gdb) p &s->v\n$1 = (int *) 0x7fffffffe594 # Define a watchpoint o the address of the member variable of the s instance.\n# This of course only makes sense as long as the s instance is not moved in memory. (gdb) watch *0x7fffffffe594\nHardware watchpoint 3: *0x7fffffffe594 (gdb) c\nHardware watchpoint 3: *0x7fffffffe594\nOld value = 1\nNew value = 2\nset (s=0x7fffffffe594, v=2) at test.c:5\n5 } (gdb) c\nHardware watchpoint 3: *0x7fffffffe594\nOld value = 2\nNew value = 3\nset (s=0x7fffffffe594, v=3) at test.c:5\n5 }","breadcrumbs":"Tools » gdb » Watchpoint on struct / class member","id":"140","title":"Watchpoint on struct / class member"},"141":{"body":"","breadcrumbs":"Tools » gdb » Know Bugs","id":"141","title":"Know Bugs"},"142":{"body":"When using finish inside a command block, commands after finish are not executed. To workaround that bug one can create a wrapper function which calls finish. define handler bt finish info reg rax end command handler end","breadcrumbs":"Tools » gdb » Workaround command + finish bug","id":"142","title":"Workaround command + finish bug"},"143":{"body":"","breadcrumbs":"Tools » gdbserver » gdbserver(1)","id":"143","title":"gdbserver(1)"},"144":{"body":"gdbserver [opts] comm prog [args] opts: --disable-randomization --no-disable-randomization comm: host:port tty","breadcrumbs":"Tools » gdbserver » CLI","id":"144","title":"CLI"},"145":{"body":"# Start gdbserver.\ngdbserver localhost:1234 /bin/ls # Attach gdb.\ngdb -ex 'target remote localhost:1234'","breadcrumbs":"Tools » gdbserver » Example","id":"145","title":"Example"},"146":{"body":"","breadcrumbs":"Tools » radare2 » radare2(1)","id":"146","title":"radare2(1)"},"147":{"body":"pd [@ ] # print disassembly for instructions # with optional temporary seek to ","breadcrumbs":"Tools » radare2 » print","id":"147","title":"print"},"148":{"body":"fs # list flag-spaces fs # select flag-space f # print flags of selected flag-space","breadcrumbs":"Tools » radare2 » flags","id":"148","title":"flags"},"149":{"body":"?*~ # '?*' list all commands and '~' grep for ?*~... # '..' less mode /'...' interactive search","breadcrumbs":"Tools » radare2 » help","id":"149","title":"help"},"15":{"body":"For this example we assume that the command foo takes at least three optional arguments such as foo arg1 arg2 arg3 [argN..] function _foo() { _arguments \\ \"1:opt 1:(a b c)\" \\ \":opt next:(d e f)\" \\ \"*:opt all:(u v w)\"\n} Explanation: 1:MSG:ACTION sets completion for the first optional argument :MSG:ACTION sets completion for the next optional argument *:MSG:ACTION sets completion for the optional argument where none of the previous rules apply, so in our example for arg3, argN... _files is a zsh builtin utility function to complete files/dirs see zsh completion functions zsh completion utility functions","breadcrumbs":"Tools » zsh » Example with optional arguments","id":"15","title":"Example with optional arguments"},"150":{"body":"> r2 -B # open mapped to addr oob # reopen current file at ","breadcrumbs":"Tools » radare2 » relocation","id":"150","title":"relocation"},"151":{"body":"","breadcrumbs":"Tools » radare2 » Examples","id":"151","title":"Examples"},"152":{"body":"> r2 [-w] oo+ # re-open for write if -w was not passed s # seek to position wv # write 4 byte (dword)","breadcrumbs":"Tools » radare2 » Patch file (alter bytes)","id":"152","title":"Patch file (alter bytes)"},"153":{"body":"rasm2 -L # list supported archs > rasm2 -a x86 'mov eax, 0xdeadbeef' b8efbeadde > rasm2 -a x86 -d \"b8efbeadde\" mov eax, 0xdeadbeef","breadcrumbs":"Tools » radare2 » Assemble / Disassmble (rasm2)","id":"153","title":"Assemble / Disassmble (rasm2)"},"154":{"body":"All the examples & notes use qemu-system-x86_64 but in most cases this can be swapped with the system emulator for other architectures.","breadcrumbs":"Tools » qemu » qemu(1)","id":"154","title":"qemu(1)"},"155":{"body":"Graphic mode: Ctrl+Alt+g release mouse capture from VM Ctrl+Alt+1 switch to display of VM\nCtrl+Alt+2 switch to qemu monitor No graphic mode: Ctrl+a h print help\nCtrl+a x exit emulator\nCtrl+a c switch between monitor and console","breadcrumbs":"Tools » qemu » Keybindings","id":"155","title":"Keybindings"},"156":{"body":"Following command-line gives a good starting point to assemble a VM: qemu-system-x86_64 \\ -cpu host -enable-kvm -smp 4 \\ -m 8G \\ -vga virtio -display sdl,gl=on \\ -boot menu=on \\ -cdrom \\ -hda \\ -device qemu-xhci,id=xhci \\ -device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408,id=capture-card","breadcrumbs":"Tools » qemu » VM config snippet","id":"156","title":"VM config snippet"},"157":{"body":"# Emulate host CPU in guest VM, enabling all supported host featured (requires KVM).\n# List available CPUs `qemu-system-x86_64 -cpu help`.\n-cpu host # Enable KVM instead software emulation.\n-enable-kvm # Configure number of guest CPUs.\n-smp # Configure size of guest RAM.\n-m 8G","breadcrumbs":"Tools » qemu » CPU & RAM","id":"157","title":"CPU & RAM"},"158":{"body":"# Use sdl window as display and enable openGL context.\n-display sdl,gl=on # Use vnc server as display (eg on display `:42` here).\n-display vnc=localhost:42 # Confifure virtio as 3D video graphic accelerator (requires virgl in guest).\n-vga virtio","breadcrumbs":"Tools » qemu » Graphic & Display","id":"158","title":"Graphic & Display"},"159":{"body":"# Enables boot menu to select boot device (enter with `ESC`).\n-boot menu=on","breadcrumbs":"Tools » qemu » Boot Menu","id":"159","title":"Boot Menu"},"16":{"body":"","breadcrumbs":"Tools » bash » bash(1)","id":"16","title":"bash(1)"},"160":{"body":"# Attach cdrom drive with iso to a VM.\n-cdrom # Attach disk drive to a VM.\n-hda # Generic way to configure & attach a drive to a VM.\n-drive file=,format=qcow2 Create a disk with qemu-img To create a qcow2 disk (qemu copy-on-write) of size 10G: qemu-img create -f qcow2 disk.qcow2 10G The disk does not contain any partitions or a partition table. We can format the disk from within the guest as following example: # Create `gpt` partition table.\nsudo parted /dev/sda mktable gpt # Create two equally sized primary partitions.\nsudo parted /dev/sda mkpart primary 0% 50%\nsudo parted /dev/sda mkpart primary 50% 100% # Create filesystem on each partition.\nsudo mkfs.ext3 /dev/sda1\nsudo mkfs.ext4 /dev/sda2 lsblk -f /dev/sda NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT sda ├─sda1 ext3 .... └─sda2 ext4 ....","breadcrumbs":"Tools » qemu » Block devices","id":"160","title":"Block devices"},"161":{"body":"Host Controller # Add XHCI USB controller to the VM (supports USB 3.0, 2.0, 1.1).\n# `id=xhci` creates a usb bus named `xhci`.\n-device qemu-xhci,id=xhci USB Device # Pass-through USB device from host identified by vendorid & productid and\n# attach to usb bus `xhci.0` (defined with controller `id`).\n-device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408","breadcrumbs":"Tools » qemu » USB","id":"161","title":"USB"},"162":{"body":"# Open gdbstub on tcp `` (`-s` shorthand for `-gdb tcp::1234`).\n-gdb tcp:: # Freeze guest CPU at startup and wait for debugger connection.\n-S","breadcrumbs":"Tools » qemu » Debugging","id":"162","title":"Debugging"},"163":{"body":"# Create raw tcp server for `serial IO` and wait until a client connects\n# before executing the guest.\n-serial tcp:localhost:12345,server,wait # Create telnet server for `serial IO` and wait until a client connects\n# before executing the guest.\n-serial telnet:localhost:12345,server,wait # Configure redirection for the QEMU `mointor`, arguments similar to `-serial`\n# above.\n-monitor ... In server mode use nowait to execute guest without waiting for a client connection.","breadcrumbs":"Tools » qemu » IO redirection","id":"163","title":"IO redirection"},"164":{"body":"# Redirect host tcp port `1234` to guest port `4321`.\n-nic user,hostfwd=tcp:localhost:1234-:4321","breadcrumbs":"Tools » qemu » Network","id":"164","title":"Network"},"165":{"body":"# Attach a `virtio-9p-pci` device to the VM.\n# The guest requires 9p support and can mount the shared drive as:\n# mount -t 9p -o trans=virtio someName /mnt\n-virtfs local,id=someName,path=,mount_tag=someName,security_model=none","breadcrumbs":"Tools » qemu » Shared drives","id":"165","title":"Shared drives"},"166":{"body":"# List debug items.\n-d help # Write debug log to file instead stderr.\n-D # Examples\n-d in_asm Log executed guest instructions.","breadcrumbs":"Tools » qemu » Debug logging","id":"166","title":"Debug logging"},"167":{"body":"# List name of all trace points.\n-trace help # Enable trace points matching pattern and optionally write trace to file.\n-trace [,file=] # Enable trace points for all events listed in the file.\n# File must contain one event/pattern per line.\n-trace events=","breadcrumbs":"Tools » qemu » Tracing","id":"167","title":"Tracing"},"168":{"body":"VM snapshots require that there is at least on qcow2 disk attached to the VM ( VM Snapshots ). Commands for qemu Monitor or QMP : # List available snapshots.\ninfo snapshots # Create/Load/Delete snapshot with name .\nsavevm \nloadvm \ndelvm The snapshot can also be directly specified when invoking qemu as: qemu-system-x86_64 \\ -loadvm \\ ...","breadcrumbs":"Tools » qemu » VM snapshots","id":"168","title":"VM snapshots"},"169":{"body":"Online migration example: # Start machine 1 on host ABC.\nqemu-system-x86_64 -monitor stdio -cdrom # Prepare machine 2 on host DEF as migration target.\n# Listen for any connection on port 12345.\nqemu-system-x86_64 -monitor stdio -incoming tcp:0.0.0.0:12345 # Start migration from the machine 1 monitor console.\n(qemu) migrate tcp:DEF:12345 Save to external file example: ```bash\n# Start machine 1.\nqemu-system-x86_64 -monitor stdio -cdrom # Save VM state to file.\n(qemu) migrate \"exec:gzip -c > vm.gz\" # Load VM from file.\nqemu-system-x86_64 -monitor stdio -incoming \"exec: gzip -d -c vm.gz\" The migration source machine and the migration target machine should be launched with the same parameters.","breadcrumbs":"Tools » qemu » VM Migration","id":"169","title":"VM Migration"},"17":{"body":"","breadcrumbs":"Tools » bash » Expansion","id":"17","title":"Expansion"},"170":{"body":"Example command line to directly boot a Kernel with an initrd ramdisk. qemu-system-x86_64 \\ -cpu host \\ -enable-kvm \\ -kernel /arch/x86/boot/bzImage \\ -append \"earlyprintk=ttyS0 console=ttyS0 nokaslr init=/init debug\" \\ -initrd /initramfs.cpio.gz \\ ... Instructions to build a minimal Kernel and initrd .","breadcrumbs":"Tools » qemu » Appendix: Direct Kernel boot","id":"170","title":"Appendix: Direct Kernel boot"},"171":{"body":"test: test.s as -o test.o test.s ld -o test test.o testc.o trace: test qemu-x86_64 -singlestep -d nochain,cpu ./test 2>&1 | awk '/RIP/ { print $$1; }' clean: $(RM) test test-bin test.o .section .text, \"ax\" .global _start\n_start: xor %rax, %rax mov $0x8, %rax\n1: cmp $0, %rax je 2f dec %rax jmp 1b\n2: # x86-64 exit(2) syscall mov $0, %rdi mov $60, %rax syscall","breadcrumbs":"Tools » qemu » Appendix: Cheap instruction tracer","id":"171","title":"Appendix: Cheap instruction tracer"},"172":{"body":"QEMU USB QEMU IMG QEMU Tools QEMU System QEMU Invocation (command line args) QEMU Monitor QEMU machine protocol (QMP) QEMU VM Snapshots","breadcrumbs":"Tools » qemu » References","id":"172","title":"References"},"173":{"body":"","breadcrumbs":"Tools » pacman » pacman(1)","id":"173","title":"pacman(1)"},"174":{"body":"pacman -Sy refresh package database\npacman -S install pkg\npacman -Ss search remote package database\npacman -Si get info for pkg\npacman -Su upgrade installed packages\npacman -Sc clean local package cache","breadcrumbs":"Tools » pacman » Remote package repositories","id":"174","title":"Remote package repositories"},"175":{"body":"pacman -Rsn uninstall package and unneeded deps + config files","breadcrumbs":"Tools » pacman » Remove packages","id":"175","title":"Remove packages"},"176":{"body":"Local package database of installed packages. pacman -Q list all installed packages\npacman -Qs search local package database\npacman -Ql list files installed by pkg\npacman -Qo query package that owns file\npacman -Qe only list explicitly installed packages","breadcrumbs":"Tools » pacman » Local package database","id":"176","title":"Local package database"},"177":{"body":"Local file database which allows to search packages owning certain files. Also searches non installed packages, but database must be synced. pacman -Fy refresh file database\npacman -Fl list files in pkg (must not be installed)\npacman -Fx search","breadcrumbs":"Tools » pacman » Local file database","id":"177","title":"Local file database"},"178":{"body":"Uninstall all orphaned packages (including config files) that were installed as dependencies. pacman -Rsn $(pacman -Qtdq) List explicitly installed packages that are not required as dependency by any package and sort by size. pacman -Qetq | xargs pacman -Qi | awk '/Name/ { name=$3 } /Installed Size/ { printf \"%8.2f%s %s\\n\", $4, $5, name }' | sort -h Install package into different root directory but keep using the default database. pacman --root abc --dbpath /var/lib/pacman -S mingw-w64-gcc","breadcrumbs":"Tools » pacman » Hacks","id":"178","title":"Hacks"},"179":{"body":"Online playground","breadcrumbs":"Tools » dot » dot(1)","id":"179","title":"dot(1)"},"18":{"body":"# generate sequence from n to m\n{n..m}\n# generate sequence from n to m step by s\n{n..m..s} # expand cartesian product\n{a,b}{c,d}","breadcrumbs":"Tools » bash » Generator","id":"18","title":"Generator"},"180":{"body":"Can be rendered to svg with the following command. dot -T svg -o g.svg g.dot Example dot file. // file: g.dot\ndigraph { // Render ranks from left to right. rankdir=LR // Make background transparent. bgcolor=transparent // Global node attributes. node [shape=box] // Global edge attributes. edge [style=dotted,color=red] // Add nodes & edge. stage1 -> stage2 // Add multiple edges at once. stage2 -> { stage3_1, stage3_2 } // Add edge with custom attributes. stage3_2 -> stage4 [label=\"some text\"] // Set custom attributes for specific node. stage4 [color=green,fillcolor=lightgray,style=\"filled,dashed\",label=\"s4\"] // Create a subgraph. This can be used to group nodes/edges or as scope for // global node/edge attributes. // If the name starts with 'cluster' a border is drawn. subgraph cluster_1 { stage5_1 stage5_2 } // Add some edges to subgraph nodes. stage3_1 -> { stage5_1, stage5_2 }\n} Rendered svg file. g.svg","breadcrumbs":"Tools » dot » Example dot file to copy & paste from.","id":"180","title":"Example dot file to copy & paste from."},"181":{"body":"DOT language Attributes Node shapes Colors User manual","breadcrumbs":"Tools » dot » References","id":"181","title":"References"},"182":{"body":"lsof ss pidstat pgrep pmap pstack","breadcrumbs":"Resource analysis & monitor » Resource analysis & monitor","id":"182","title":"Resource analysis & monitor"},"183":{"body":"lsof -r ..... repeatedly execute command ervery seconds -a ......... AND slection filters instead ORing (OR: default) -p ... filter by +fg ........ show file flags for file descripros -n ......... don't convert network addr to hostnames -P ......... don't convert network port to service names -i <@h[:p]>. show connections to h (hostname|ip addr) with optional port p -s ... in conjunction with '-i' filter for protocol in state -U ......... show unix domain sockets ('@' indicates abstract sock name, see unix(7)) file flags: R/W/RW ..... read/write/read-write CR ......... create AP ......... append TR ......... truncate -s protocols TCP, UDP -s states (TCP) CLOSED, IDLE, BOUND, LISTEN, ESTABLISHED, SYN_SENT, SYN_RCDV, ESTABLISHED, CLOSE_WAIT, FIN_WAIT1, CLOSING, LAST_ACK, FIN_WAIT_2, TIME_WAIT -s states (UDP) Unbound, Idle","breadcrumbs":"Resource analysis & monitor » lsof » lsof(8)","id":"183","title":"lsof(8)"},"184":{"body":"","breadcrumbs":"Resource analysis & monitor » lsof » Examples","id":"184","title":"Examples"},"185":{"body":"Show open files with file flags for process: lsof +fg -p ","breadcrumbs":"Resource analysis & monitor » lsof » File flags","id":"185","title":"File flags"},"186":{"body":"Show open tcp connections for $USER: lsof -a -u $USER -i TCP Note : -a ands the results. If -a is not given all open files matching $USER and all tcp connections are listed ( ored ).","breadcrumbs":"Resource analysis & monitor » lsof » Open TCP connections","id":"186","title":"Open TCP connections"},"187":{"body":"Show open connections to localhost for $USER: lsof -a -u $USER -i @localhost","breadcrumbs":"Resource analysis & monitor » lsof » Open connection to specific host","id":"187","title":"Open connection to specific host"},"188":{"body":"Show open connections to port :1234 for $USER: lsof -a -u $USER -i :1234","breadcrumbs":"Resource analysis & monitor » lsof » Open connection to specific port","id":"188","title":"Open connection to specific port"},"189":{"body":"lsof -i 4TCP -s TCP:ESTABLISHED","breadcrumbs":"Resource analysis & monitor » lsof » IPv4 TCP connections in ESTABLISHED state","id":"189","title":"IPv4 TCP connections in ESTABLISHED state"},"19":{"body":"# default value\nbar=${foo:-some_val} # if $foo set, then bar=$foo else bar=some_val # alternate value\nbar=${foo:+bla $foo} # if $foo set, then bar=\"bla $foo\" else bar=\"\" # check param set\nbar=${foo:?msg} # if $foo set, then bar=$foo else exit and print msg # indirect\nFOO=foo\nBAR=FOO\nbar=${!BAR} # deref value of BAR -> bar=$FOO # prefix\n${foo#prefix} # remove prefix when expanding $foo\n# suffix\n${foo%suffix} # remove suffix when expanding $foo # substitute\n${foo/pattern/string} # replace pattern with string when expanding foo\n# pattern starts with\n# '/' replace all occurences of pattern\n# '#' pattern match at beginning\n# '%' pattern match at end Note: prefix/suffix/pattern are expanded as pathnames .","breadcrumbs":"Tools » bash » Parameter","id":"19","title":"Parameter"},"190":{"body":"ss [option] [filter] [option] -p ..... Show process using socket -l ..... Show sockets in listening state -4/-6 .. Show IPv4/6 sockets -x ..... Show unix sockets -n ..... Show numeric ports (no resolve) -O ..... Oneline output per socket [filter] dport/sport PORT .... Filter for destination/source port dst/src ADDR ........ Filter for destination/source address and/or .............. Logic operator ==/!= ............... Comparison operator (EXPR) .............. Group exprs","breadcrumbs":"Resource analysis & monitor » ss » ss(8)","id":"190","title":"ss(8)"},"191":{"body":"Show all tcp IPv4 sockets connecting to port 443: ss -4 'dport 443' Show all tcp IPv4 sockets that don't connect to port 443 or connect to address 1.2.3.4. ss -4 'dport != 443 or dst 1.2.3.4'","breadcrumbs":"Resource analysis & monitor » ss » Examples","id":"191","title":"Examples"},"192":{"body":"pidstat [opt] [interval] [cont] -U [user] show username instead UID, optionally only show for user -r memory statistics -d I/O statistics -h single line per process and no lines with average","breadcrumbs":"Resource analysis & monitor » pidstat » pidstat(1)","id":"192","title":"pidstat(1)"},"193":{"body":"pidstat -r -p [interval] [count] minor_pagefault: Happens when the page needed is already in memory but not allocated to the faulting process, in that case the kernel only has to create a new page-table entry pointing to the shared physical page (not required to load a memory page from disk). major_pagefault: Happens when the page needed is NOT in memory, the kernel has to create a new page-table entry and populate the physical page (required to load a memory page from disk).","breadcrumbs":"Resource analysis & monitor » pidstat » Page fault and memory utilization","id":"193","title":"Page fault and memory utilization"},"194":{"body":"pidstat -d -p [interval] [count]","breadcrumbs":"Resource analysis & monitor » pidstat » I/O statistics","id":"194","title":"I/O statistics"},"195":{"body":"pgrep [opts] -n only list newest matching process -u only show matching for user -l additionally list command -a additionally list command + arguments","breadcrumbs":"Resource analysis & monitor » pgrep » pgrep(1)","id":"195","title":"pgrep(1)"},"196":{"body":"For example attach gdb to newest zsh process from $USER. gdb -p $(pgrep -n -u $USER zsh)","breadcrumbs":"Resource analysis & monitor » pgrep » Debug newest process","id":"196","title":"Debug newest process"},"197":{"body":"pmap [opts] Dump virtual memory map of process. Compared to /proc//maps it shows the size of the mappings.\nopts: -p show full path in the mapping -x show details (eg RSS usage of each segment)","breadcrumbs":"Resource analysis & monitor » pmap » pmap(1)","id":"197","title":"pmap(1)"},"198":{"body":"pstack Dump stack for all threads of process.","breadcrumbs":"Resource analysis & monitor » pstack » pstack(1)","id":"198","title":"pstack(1)"},"199":{"body":"strace ltrace perf OProfile time","breadcrumbs":"Trace and Profile » Trace and Profile","id":"199","title":"Trace and Profile"},"2":{"body":"","breadcrumbs":"Tools » zsh » zsh(1)","id":"2","title":"zsh(1)"},"20":{"body":"* match any string\n? match any single char\n\\\\ match backslash\n[abc] match any char of 'a' 'b' 'c'\n[a-z] match any char between 'a' - 'z'\n[^ab] negate, match all not 'a' 'b'\n[:class:] match any char in class, available: alnum,alpha,ascii,blank,cntrl,digit,graph,lower, print,punct,space,upper,word,xdigit With extglob shell option enabled it is possible to have more powerful patterns. In the following pattern-list is one ore more patterns separated by | char. ?(pattern-list) matches zero or one occurrence of the given patterns\n*(pattern-list) matches zero or more occurrences of the given patterns\n+(pattern-list) matches one or more occurrences of the given patterns\n@(pattern-list) matches one of the given patterns\n!(pattern-list) matches anything except one of the given patterns Note: shopt -s extglob/shopt -u extglob to enable/disable extglob option.","breadcrumbs":"Tools » bash » Pathname","id":"20","title":"Pathname"},"200":{"body":"strace [opts] [prg] -f .......... follow child processes on fork(2) -ff ......... follow fork and separate output file per child -p .... attach to running process -s ... max string size, truncate of longer (default: 32) -e ... expression for trace filtering -o ... log output into -c .......... dump syscall statitics at the end -C .......... like -c but dump regular ouput as well -k .......... dump stack trace for each syscall -P ... only trace syscall accesing path -y .......... print paths for FDs -tt ......... print absolute timestamp (with us precision) -r .......... print relative timestamp -z .......... log only successful syscalls -Z .......... log only failed syscalls -n .......... print syscall numbers -y .......... translate fds (eg file path, socket) -yy ......... translate fds with all information (eg IP) -x .......... print non-ASCII chars as hex string : trace=syscall[,syscall] .... trace only syscall listed trace=file ................. trace all syscall that take a filename as arg trace=process .............. trace process management related syscalls trace=signal ............... trace signal related syscalls signal ..................... trace signals delivered to the process","breadcrumbs":"Trace and Profile » strace » strace(1)","id":"200","title":"strace(1)"},"201":{"body":"Trace open(2) & socket(2) syscalls for a running process + child processes: strace -f -e trace=open,socket -p Trace signals delivered to a running process: strace -e signal -e 'trace=!all' -p ","breadcrumbs":"Trace and Profile » strace » Examples","id":"201","title":"Examples"},"202":{"body":"ltrace [opts] [prg] -f .......... follow child processes on fork(2) -p .... attach to running process -o ... log output into -l . show who calls into lib matched by -C .......... demangle","breadcrumbs":"Trace and Profile » ltrace » ltrace(1)","id":"202","title":"ltrace(1)"},"203":{"body":"List which program/libs call into libstdc++: ltrace -l '*libstdc++*' -C -o ltrace.log ./main","breadcrumbs":"Trace and Profile » ltrace » Example","id":"203","title":"Example"},"204":{"body":"perf list show supported hw/sw events perf stat -p .. show stats for running process -I ... show stats periodically over interval -e ... filter for events perf top -p .. show stats for running process -F ... sampling frequency -K ........ hide kernel threads perf record -p ............... record stats for running process -F ................ sampling frequency --call-graph .. [fp, dwarf, lbr] method how to caputre backtrace fp : use frame-pointer, need to compile with -fno-omit-frame-pointer dwarf: use .cfi debug information lbr : use hardware last branch record facility -g ..................... short-hand for --call-graph fp -e ................ filter for events perf report -n .................... annotate symbols with nr of samples --stdio ............... report to stdio, if not presen tui mode -g graph,0.5,caller ... show caller based call chains with value >0.5 Useful : page-faults minor-faults major-faults cpu-cycles` task-clock","breadcrumbs":"Trace and Profile » perf » perf(1)","id":"204","title":"perf(1)"},"205":{"body":"","breadcrumbs":"Trace and Profile » perf » Flamegraph","id":"205","title":"Flamegraph"},"206":{"body":"perf record -g -e cpu-cycles -p \nperf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > cycles-flamegraph.svg","breadcrumbs":"Trace and Profile » perf » Flamegraph with single event trace","id":"206","title":"Flamegraph with single event trace"},"207":{"body":"perf record -g -e cpu-cycles,page-faults -p \nperf script --per-event-dump\n# fold & generate as above","breadcrumbs":"Trace and Profile » perf » Flamegraph with multiple event traces","id":"207","title":"Flamegraph with multiple event traces"},"208":{"body":"operf -g -p -g ...... caputre call-graph information opreport [opt] FILE show time spent per binary image -l ...... show time spent per symbol -c ...... show callgraph information (see below) -a ...... add column with time spent accumulated over child nodes ophelp show supported hw/sw events","breadcrumbs":"Trace and Profile » OProfile » OProfile","id":"208","title":"OProfile"},"209":{"body":"# statistics of process run\n/usr/bin/time -v ","breadcrumbs":"Trace and Profile » time » /usr/bin/time(1)","id":"209","title":"/usr/bin/time(1)"},"21":{"body":"Note: The trick with bash I/O redirection is to interpret from left-to-right. # stdout & stderr to file\ncommand >file 2>&1\n# equivalent\ncommand &>file # stderr to stdout & stdout to file\ncommand 2>&1 >file The article Bash One-Liners Explained, Part III: All about redirections contains some nice visualization to explain bash redirections.","breadcrumbs":"Tools » bash » I/O redirection","id":"21","title":"I/O redirection"},"210":{"body":"od xxd readelf objdump nm","breadcrumbs":"Binary » Binary","id":"210","title":"Binary"},"211":{"body":"od [opts] -An don't print addr info -tx4 print hex in 4 byte chunks -ta print as named character -tc printable chars or backslash escape -w4 print 4 bytes per line -j skip bytes from (hex if start with 0x) -N dump bytes (hex of start with 0x)","breadcrumbs":"Binary » od » od(1)","id":"211","title":"od(1)"},"212":{"body":"echo -n AAAABBBB | od -An -w4 -tx4 >> 41414141 >> 42424242 echo -n '\\x7fELF\\n' | od -tx1 -ta -tc >> 0000000 7f 45 4c 46 0a # tx1 >> del E L F nl # ta >> 177 E L F \\n # tc","breadcrumbs":"Binary » od » ASCII to hex string","id":"212","title":"ASCII to hex string"},"213":{"body":"For example .rodata section from an elf file. We can use readelf to get the offset into the file where the .rodata section starts. readelf -W -S foo >> Section Headers: >> [Nr] Name Type Address Off Size ES Flg Lk Inf Al >> ... >> [15] .rodata PROGBITS 00000000004009c0 0009c0 000030 00 A 0 0 16 With the offset of -j 0x0009c0 we can dump -N 0x30 bytes from the beginning of the .rodata section as follows: od -j 0x0009c0 -N 0x30 -tx4 -w4 foo >> 0004700 00020001 >> 0004704 00000000 >> * >> 0004740 00000001 >> 0004744 00000002 >> 0004750 00000003 >> 0004754 00000004 Note : Numbers starting with 0x will be interpreted as hex by od.","breadcrumbs":"Binary » od » Extract parts of file","id":"213","title":"Extract parts of file"},"214":{"body":"xxd [opts] -p dump continuous hexdump -r convert hexdump into binary ('revert') -e dump as little endian mode -i output as C array","breadcrumbs":"Binary » xxd » xxd(1)","id":"214","title":"xxd(1)"},"215":{"body":"echo -n 'aabb' | xxd -p >> 61616262","breadcrumbs":"Binary » xxd » ASCII to hex stream","id":"215","title":"ASCII to hex stream"},"216":{"body":"echo -n '61616262' | xxd -p -r >> aabb","breadcrumbs":"Binary » xxd » Hex to binary stream","id":"216","title":"Hex to binary stream"},"217":{"body":"echo -n '\\x7fELF' | xxd -p | xxd -p -r | file -p - >> ELF","breadcrumbs":"Binary » xxd » ASCII to binary","id":"217","title":"ASCII to binary"},"218":{"body":"xxd -i <(echo -n '\\x7fELF') >> unsigned char _proc_self_fd_11[] = { >> 0x7f, 0x45, 0x4c, 0x46 >> }; >> unsigned int _proc_self_fd_11_len = 4;","breadcrumbs":"Binary » xxd » ASCII to C array (hex encoded)","id":"218","title":"ASCII to C array (hex encoded)"},"219":{"body":"readelf [opts] -W|--wide wide output, dont break output at 80 chars -h print ELF header -S print section headers -l print program headers + segment mapping -d print .dynamic section (dynamic link information) --syms print symbol tables (.symtab .dynsym) --dyn-syms print dynamic symbol table (exported symbols for dynamic linker) -r print relocation sections (.rel.*, .rela.*)","breadcrumbs":"Binary » readelf » readelf(1)","id":"219","title":"readelf(1)"},"22":{"body":"j>&i Duplicate fd i to fd j, making j a copy of i. See dup2(2) . Example: command 2>&1 >file duplicate fd 1 to fd 2, effectively redirecting stderr to stdout redirect stdout to file","breadcrumbs":"Tools » bash » Explanation","id":"22","title":"Explanation"},"220":{"body":"objdump [opts] -M intel use intil syntax -d disassemble text section -D disassemble all sections -S mix disassembly with source code -C demangle -j display info for section --[no-]show-raw-insn [dont] show object code next to disassembly","breadcrumbs":"Binary » objdump » objdump(1)","id":"220","title":"objdump(1)"},"221":{"body":"For example .plt section: objdump -j .plt -d ","breadcrumbs":"Binary » objdump » Disassemble section","id":"221","title":"Disassemble section"},"222":{"body":"This can be helpful for example as a cheap analysis tool when toying with JIT generating code. We could just write thee binary code buffer to a file and disassemble with objdump. To re-create that case, we just assemble and link some ELF file and then create a raw binary of the text section with objcopy. # file: test.s\n.section .text, \"ax\" .global _start\n_start: xor %rax, %rax mov $0x8, %rax\n1: cmp $0, %rax je 2f dec %rax jmp 1b\n2: # x86-64 exit(2) syscall mov $0, %rdi mov $60, %rax syscall # Assemble & link.\nas -o test.o test.s\nld -o test test.o testc.o\n# ELF -> binary (only take .text section).\nobjcopy -O binary --only-section .text test test-bin # Disassemble raw binary.\nobjdump -D -b binary -m i386:x86-64 test-bin","breadcrumbs":"Binary » objdump » Example: disassemble raw binary","id":"222","title":"Example: disassemble raw binary"},"223":{"body":"nm [opts] -C demangle -u undefined only","breadcrumbs":"Binary » nm » nm(1)","id":"223","title":"nm(1)"},"224":{"body":"c++filt c++ glibc gcc make ld.so symbol versioning python gcov","breadcrumbs":"Development » Development","id":"224","title":"Development"},"225":{"body":"","breadcrumbs":"Development » c++filt » c++filt(1)","id":"225","title":"c++filt(1)"},"226":{"body":"c++-filt ","breadcrumbs":"Development » c++filt » Demangle symbol","id":"226","title":"Demangle symbol"},"227":{"body":"For example dynamic symbol table: readelf -W --dyn-syms | c++filt","breadcrumbs":"Development » c++filt » Demangle stream","id":"227","title":"Demangle stream"},"228":{"body":"Source files of most examples is available here .","breadcrumbs":"Development » c++ » c++","id":"228","title":"c++"},"229":{"body":"Force compile error to see what auto is deduced to. auto foo = bar(); // force compile error\ntypename decltype(foo)::_;","breadcrumbs":"Development » c++ » Type deduction","id":"229","title":"Type deduction"},"23":{"body":"The getopts builtin uses following global variables: OPTARG, value of last option argument OPTIND, index of the next argument to process (user must reset) OPTERR, display errors if set to 1 getopts