{"doc_urls":["tools/index.html#tools","tools/zsh.html#zsh1","tools/zsh.html#keybindings","tools/zsh.html#completion","tools/zsh.html#installation","tools/zsh.html#completion-variables","tools/zsh.html#completion-functions","tools/zsh.html#example","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#completion","tools/bash.html#example","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#staging","tools/git.html#remote","tools/git.html#branching","tools/git.html#resetting","tools/git.html#tags","tools/git.html#diff","tools/git.html#log","tools/git.html#file-history","tools/git.html#patching","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#access-last-fields-in-records","tools/awk.html#capture-in-variables","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/gdb.html#gdb1","tools/gdb.html#cli","tools/gdb.html#interactive-usage","tools/gdb.html#user-commands-macros","tools/gdb.html#hooks","tools/gdb.html#examples","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#know-bugs","tools/gdb.html#workaround-command--finish-bug","tools/radare2.html#radare21","tools/radare2.html#print","tools/radare2.html#flags","tools/radare2.html#help","tools/radare2.html#relocation","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#ipv4-tcp-connections-in-established-state","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/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/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#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#useful-functions","development/make.html#substitution-references","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_preload-initialization-order-and-link-map","development/ld.so.html#dynamic-linking-x86_64","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#addressing","arch/x86_64.html#size-directives","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#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"],"index":{"documentStore":{"docInfo":{"0":{"body":10,"breadcrumbs":1,"title":1},"1":{"body":0,"breadcrumbs":2,"title":1},"10":{"body":16,"breadcrumbs":2,"title":1},"100":{"body":12,"breadcrumbs":2,"title":1},"101":{"body":3,"breadcrumbs":2,"title":1},"102":{"body":0,"breadcrumbs":2,"title":1},"103":{"body":42,"breadcrumbs":2,"title":1},"104":{"body":180,"breadcrumbs":3,"title":2},"105":{"body":25,"breadcrumbs":4,"title":3},"106":{"body":24,"breadcrumbs":2,"title":1},"107":{"body":0,"breadcrumbs":2,"title":1},"108":{"body":13,"breadcrumbs":5,"title":4},"109":{"body":9,"breadcrumbs":7,"title":6},"11":{"body":60,"breadcrumbs":2,"title":1},"110":{"body":36,"breadcrumbs":6,"title":5},"111":{"body":0,"breadcrumbs":3,"title":2},"112":{"body":27,"breadcrumbs":5,"title":4},"113":{"body":0,"breadcrumbs":2,"title":1},"114":{"body":11,"breadcrumbs":2,"title":1},"115":{"body":16,"breadcrumbs":2,"title":1},"116":{"body":9,"breadcrumbs":2,"title":1},"117":{"body":15,"breadcrumbs":2,"title":1},"118":{"body":5,"breadcrumbs":3,"title":3},"119":{"body":102,"breadcrumbs":4,"title":1},"12":{"body":93,"breadcrumbs":2,"title":1},"120":{"body":0,"breadcrumbs":4,"title":1},"121":{"body":10,"breadcrumbs":5,"title":2},"122":{"body":21,"breadcrumbs":6,"title":3},"123":{"body":9,"breadcrumbs":7,"title":4},"124":{"body":4,"breadcrumbs":8,"title":5},"125":{"body":26,"breadcrumbs":4,"title":1},"126":{"body":50,"breadcrumbs":7,"title":4},"127":{"body":6,"breadcrumbs":5,"title":2},"128":{"body":22,"breadcrumbs":4,"title":1},"129":{"body":14,"breadcrumbs":6,"title":3},"13":{"body":24,"breadcrumbs":3,"title":2},"130":{"body":12,"breadcrumbs":4,"title":1},"131":{"body":6,"breadcrumbs":4,"title":1},"132":{"body":5,"breadcrumbs":2,"title":2},"133":{"body":64,"breadcrumbs":3,"title":1},"134":{"body":25,"breadcrumbs":3,"title":1},"135":{"body":27,"breadcrumbs":3,"title":1},"136":{"body":11,"breadcrumbs":3,"title":1},"137":{"body":128,"breadcrumbs":3,"title":1},"138":{"body":0,"breadcrumbs":3,"title":1},"139":{"body":15,"breadcrumbs":6,"title":4},"14":{"body":26,"breadcrumbs":2,"title":1},"140":{"body":17,"breadcrumbs":6,"title":4},"141":{"body":43,"breadcrumbs":3,"title":1},"142":{"body":6,"breadcrumbs":3,"title":1},"143":{"body":5,"breadcrumbs":1,"title":1},"144":{"body":45,"breadcrumbs":2,"title":1},"145":{"body":34,"breadcrumbs":4,"title":3},"146":{"body":76,"breadcrumbs":4,"title":3},"147":{"body":19,"breadcrumbs":2,"title":1},"148":{"body":6,"breadcrumbs":4,"title":3},"149":{"body":7,"breadcrumbs":4,"title":3},"15":{"body":64,"breadcrumbs":4,"title":3},"150":{"body":11,"breadcrumbs":3,"title":2},"151":{"body":15,"breadcrumbs":6,"title":5},"152":{"body":55,"breadcrumbs":2,"title":1},"153":{"body":36,"breadcrumbs":2,"title":1},"154":{"body":8,"breadcrumbs":3,"title":2},"155":{"body":7,"breadcrumbs":2,"title":1},"156":{"body":7,"breadcrumbs":1,"title":1},"157":{"body":0,"breadcrumbs":2,"title":1},"158":{"body":3,"breadcrumbs":3,"title":2},"159":{"body":10,"breadcrumbs":3,"title":2},"16":{"body":35,"breadcrumbs":2,"title":1},"160":{"body":0,"breadcrumbs":2,"title":1},"161":{"body":14,"breadcrumbs":3,"title":2},"162":{"body":0,"breadcrumbs":2,"title":1},"163":{"body":62,"breadcrumbs":4,"title":3},"164":{"body":34,"breadcrumbs":4,"title":3},"165":{"body":0,"breadcrumbs":2,"title":1},"166":{"body":0,"breadcrumbs":2,"title":1},"167":{"body":15,"breadcrumbs":2,"title":1},"168":{"body":0,"breadcrumbs":2,"title":1},"169":{"body":90,"breadcrumbs":3,"title":2},"17":{"body":123,"breadcrumbs":2,"title":1},"170":{"body":9,"breadcrumbs":3,"title":2},"171":{"body":0,"breadcrumbs":2,"title":1},"172":{"body":27,"breadcrumbs":4,"title":3},"173":{"body":0,"breadcrumbs":5,"title":4},"174":{"body":36,"breadcrumbs":3,"title":2},"175":{"body":68,"breadcrumbs":3,"title":2},"176":{"body":0,"breadcrumbs":3,"title":2},"177":{"body":14,"breadcrumbs":3,"title":2},"178":{"body":16,"breadcrumbs":2,"title":1},"179":{"body":17,"breadcrumbs":3,"title":2},"18":{"body":66,"breadcrumbs":2,"title":1},"180":{"body":23,"breadcrumbs":2,"title":1},"181":{"body":0,"breadcrumbs":2,"title":1},"182":{"body":38,"breadcrumbs":3,"title":2},"183":{"body":128,"breadcrumbs":6,"title":5},"184":{"body":246,"breadcrumbs":4,"title":3},"185":{"body":2,"breadcrumbs":1,"title":1},"186":{"body":21,"breadcrumbs":2,"title":1},"187":{"body":0,"breadcrumbs":2,"title":1},"188":{"body":62,"breadcrumbs":4,"title":3},"189":{"body":15,"breadcrumbs":3,"title":2},"19":{"body":0,"breadcrumbs":2,"title":1},"190":{"body":31,"breadcrumbs":3,"title":2},"191":{"body":34,"breadcrumbs":2,"title":1},"192":{"body":40,"breadcrumbs":3,"title":2},"193":{"body":0,"breadcrumbs":4,"title":3},"194":{"body":40,"breadcrumbs":4,"title":3},"195":{"body":23,"breadcrumbs":4,"title":3},"196":{"body":14,"breadcrumbs":4,"title":3},"197":{"body":15,"breadcrumbs":4,"title":3},"198":{"body":29,"breadcrumbs":2,"title":1},"199":{"body":31,"breadcrumbs":4,"title":3},"2":{"body":53,"breadcrumbs":2,"title":1},"20":{"body":19,"breadcrumbs":3,"title":2},"200":{"body":94,"breadcrumbs":3,"title":2},"201":{"body":42,"breadcrumbs":2,"title":1},"202":{"body":14,"breadcrumbs":2,"title":1},"203":{"body":0,"breadcrumbs":2,"title":1},"204":{"body":40,"breadcrumbs":4,"title":3},"205":{"body":52,"breadcrumbs":5,"title":4},"206":{"body":0,"breadcrumbs":2,"title":1},"207":{"body":47,"breadcrumbs":2,"title":1},"208":{"body":18,"breadcrumbs":2,"title":1},"209":{"body":18,"breadcrumbs":3,"title":2},"21":{"body":19,"breadcrumbs":2,"title":1},"210":{"body":0,"breadcrumbs":6,"title":5},"211":{"body":35,"breadcrumbs":4,"title":3},"212":{"body":8,"breadcrumbs":4,"title":3},"213":{"body":3,"breadcrumbs":4,"title":3},"214":{"body":15,"breadcrumbs":2,"title":1},"215":{"body":52,"breadcrumbs":3,"title":2},"216":{"body":36,"breadcrumbs":4,"title":3},"217":{"body":139,"breadcrumbs":3,"title":2},"218":{"body":12,"breadcrumbs":2,"title":1},"22":{"body":25,"breadcrumbs":3,"title":2},"23":{"body":51,"breadcrumbs":2,"title":1},"24":{"body":39,"breadcrumbs":4,"title":3},"25":{"body":8,"breadcrumbs":3,"title":2},"26":{"body":8,"breadcrumbs":3,"title":2},"27":{"body":0,"breadcrumbs":3,"title":2},"28":{"body":10,"breadcrumbs":1,"title":0},"29":{"body":14,"breadcrumbs":2,"title":1},"3":{"body":0,"breadcrumbs":2,"title":1},"30":{"body":4,"breadcrumbs":2,"title":1},"31":{"body":5,"breadcrumbs":2,"title":1},"32":{"body":11,"breadcrumbs":2,"title":1},"33":{"body":24,"breadcrumbs":2,"title":1},"34":{"body":24,"breadcrumbs":2,"title":1},"35":{"body":19,"breadcrumbs":2,"title":1},"36":{"body":24,"breadcrumbs":3,"title":2},"37":{"body":28,"breadcrumbs":2,"title":1},"38":{"body":19,"breadcrumbs":2,"title":1},"39":{"body":19,"breadcrumbs":2,"title":1},"4":{"body":36,"breadcrumbs":2,"title":1},"40":{"body":86,"breadcrumbs":3,"title":2},"41":{"body":119,"breadcrumbs":2,"title":1},"42":{"body":128,"breadcrumbs":2,"title":1},"43":{"body":24,"breadcrumbs":3,"title":2},"44":{"body":0,"breadcrumbs":2,"title":1},"45":{"body":7,"breadcrumbs":2,"title":1},"46":{"body":21,"breadcrumbs":2,"title":1},"47":{"body":55,"breadcrumbs":2,"title":1},"48":{"body":50,"breadcrumbs":2,"title":1},"49":{"body":35,"breadcrumbs":2,"title":1},"5":{"body":25,"breadcrumbs":3,"title":2},"50":{"body":22,"breadcrumbs":2,"title":1},"51":{"body":27,"breadcrumbs":2,"title":1},"52":{"body":19,"breadcrumbs":3,"title":2},"53":{"body":109,"breadcrumbs":2,"title":1},"54":{"body":64,"breadcrumbs":2,"title":1},"55":{"body":27,"breadcrumbs":2,"title":1},"56":{"body":28,"breadcrumbs":3,"title":2},"57":{"body":18,"breadcrumbs":2,"title":1},"58":{"body":45,"breadcrumbs":3,"title":2},"59":{"body":37,"breadcrumbs":2,"title":1},"6":{"body":89,"breadcrumbs":3,"title":2},"60":{"body":29,"breadcrumbs":3,"title":2},"61":{"body":29,"breadcrumbs":3,"title":2},"62":{"body":72,"breadcrumbs":4,"title":3},"63":{"body":0,"breadcrumbs":2,"title":1},"64":{"body":18,"breadcrumbs":3,"title":2},"65":{"body":19,"breadcrumbs":5,"title":4},"66":{"body":39,"breadcrumbs":3,"title":2},"67":{"body":25,"breadcrumbs":6,"title":5},"68":{"body":0,"breadcrumbs":2,"title":1},"69":{"body":74,"breadcrumbs":2,"title":1},"7":{"body":77,"breadcrumbs":2,"title":1},"70":{"body":21,"breadcrumbs":3,"title":2},"71":{"body":40,"breadcrumbs":2,"title":1},"72":{"body":50,"breadcrumbs":2,"title":1},"73":{"body":77,"breadcrumbs":2,"title":1},"74":{"body":57,"breadcrumbs":2,"title":1},"75":{"body":51,"breadcrumbs":2,"title":1},"76":{"body":24,"breadcrumbs":2,"title":1},"77":{"body":43,"breadcrumbs":2,"title":1},"78":{"body":24,"breadcrumbs":2,"title":1},"79":{"body":19,"breadcrumbs":2,"title":1},"8":{"body":0,"breadcrumbs":2,"title":1},"80":{"body":32,"breadcrumbs":3,"title":2},"81":{"body":22,"breadcrumbs":2,"title":1},"82":{"body":39,"breadcrumbs":2,"title":1},"83":{"body":23,"breadcrumbs":3,"title":2},"84":{"body":26,"breadcrumbs":2,"title":1},"85":{"body":38,"breadcrumbs":2,"title":1},"86":{"body":49,"breadcrumbs":2,"title":1},"87":{"body":24,"breadcrumbs":2,"title":1},"88":{"body":28,"breadcrumbs":2,"title":1},"89":{"body":16,"breadcrumbs":2,"title":1},"9":{"body":0,"breadcrumbs":2,"title":1},"90":{"body":21,"breadcrumbs":2,"title":1},"91":{"body":4,"breadcrumbs":4,"title":3},"92":{"body":13,"breadcrumbs":3,"title":2},"93":{"body":55,"breadcrumbs":3,"title":2},"94":{"body":10,"breadcrumbs":4,"title":3},"95":{"body":14,"breadcrumbs":4,"title":3},"96":{"body":19,"breadcrumbs":3,"title":2},"97":{"body":26,"breadcrumbs":4,"title":3},"98":{"body":46,"breadcrumbs":2,"title":1},"99":{"body":32,"breadcrumbs":3,"title":2}},"docs":{"0":{"body":"zsh bash fish tmux git awk emacs gpg gdb radare2","breadcrumbs":"Tools","id":"0","title":"Tools"},"1":{"body":"","breadcrumbs":"Tools » zsh(1)","id":"1","title":"zsh(1)"},"10":{"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 » Generator","id":"10","title":"Generator"},"100":{"body":"sec secret key ssb secret subkey pub public key sub public subkey","breadcrumbs":"Tools » Abbreviations","id":"100","title":"Abbreviations"},"101":{"body":"http://pgp.mit.edu http://keyserver.ubuntu.com hkps://pgp.mailbox.org","breadcrumbs":"Tools » Keyservers","id":"101","title":"Keyservers"},"102":{"body":"","breadcrumbs":"Tools » gdb(1)","id":"102","title":"gdb(1)"},"103":{"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","breadcrumbs":"Tools » CLI","id":"103","title":"CLI"},"104":{"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 set follow-fork-mode Specify which process to follow when debuggee makes a fork(2) syscall. sharedlibrary [] Load symbols of shared libs loaded by debugee. Optionally use to filter libs for symbol loading. break [-qualified] thread Set a breakpoint only for a specific thread. -qualified: Tred as fully qualified symbol (quiet handy to set breakpoints on C symbols in C++ contexts) 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. info functions [] List functions matching . List all functions if no provided. info variables [] List variables matching . List all variables if no provided. 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 » Interactive usage","id":"104","title":"Interactive usage"},"105":{"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 » User commands (macros)","id":"105","title":"User commands (macros)"},"106":{"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 » Hooks","id":"106","title":"Hooks"},"107":{"body":"","breadcrumbs":"Tools » Examples","id":"107","title":"Examples"},"108":{"body":"This creates a catchpoint for the SIGSEGV signal and attached the command to it. catch signal SIGSEGV command bt c end","breadcrumbs":"Tools » Catch SIGSEGV and execute commands","id":"108","title":"Catch SIGSEGV and execute commands"},"109":{"body":"gdb --batch -ex 'thread 1' -ex 'bt' -p ","breadcrumbs":"Tools » Run backtrace on thread 1 (batch mode)","id":"109","title":"Run backtrace on thread 1 (batch mode)"},"11":{"body":"# default param\nbar=${foo:-some_val} # if $foo set, then bar=$foo else bar=some_val # 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 » Parameter","id":"11","title":"Parameter"},"110":{"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 » Script gdb for automating debugging sessions","id":"110","title":"Script gdb for automating debugging sessions"},"111":{"body":"","breadcrumbs":"Tools » Know Bugs","id":"111","title":"Know Bugs"},"112":{"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 » Workaround command + finish bug","id":"112","title":"Workaround command + finish bug"},"113":{"body":"","breadcrumbs":"Tools » radare2(1)","id":"113","title":"radare2(1)"},"114":{"body":"pd [@ ] # print disassembly for instructions # with optional temporary seek to ","breadcrumbs":"Tools » print","id":"114","title":"print"},"115":{"body":"fs # list flag-spaces fs # select flag-space f # print flags of selected flag-space","breadcrumbs":"Tools » flags","id":"115","title":"flags"},"116":{"body":"?*~ # '?*' list all commands and '~' grep for ?*~... # '..' less mode /'...' interactive search","breadcrumbs":"Tools » help","id":"116","title":"help"},"117":{"body":"> r2 -B # open mapped to addr oob # reopen current file at ","breadcrumbs":"Tools » relocation","id":"117","title":"relocation"},"118":{"body":"lsof pidstat pgrep pmap pstack","breadcrumbs":"Resource analysis & monitor","id":"118","title":"Resource analysis & monitor"},"119":{"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(8)","id":"119","title":"lsof(8)"},"12":{"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 Wit 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 » Pathname","id":"12","title":"Pathname"},"120":{"body":"","breadcrumbs":"Resource analysis & monitor » Examples","id":"120","title":"Examples"},"121":{"body":"Show open files with file flags for process: lsof +fg -p ","breadcrumbs":"Resource analysis & monitor » File flags","id":"121","title":"File flags"},"122":{"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 » Open TCP connections","id":"122","title":"Open TCP connections"},"123":{"body":"Show open connections to localhost for $USER: lsof -a -u $USER -i @localhost","breadcrumbs":"Resource analysis & monitor » Open connection to specific host","id":"123","title":"Open connection to specific host"},"124":{"body":"lsof -i 4TCP -s TCP:ESTABLISHED","breadcrumbs":"Resource analysis & monitor » IPv4 TCP connections in ESTABLISHED state","id":"124","title":"IPv4 TCP connections in ESTABLISHED state"},"125":{"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(1)","id":"125","title":"pidstat(1)"},"126":{"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 » Page fault and memory utilization","id":"126","title":"Page fault and memory utilization"},"127":{"body":"pidstat -d -p [interval] [count]","breadcrumbs":"Resource analysis & monitor » I/O statistics","id":"127","title":"I/O statistics"},"128":{"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(1)","id":"128","title":"pgrep(1)"},"129":{"body":"For example attach gdb to newest zsh process from $USER. gdb -p $(pgrep -n -u $USER zsh)","breadcrumbs":"Resource analysis & monitor » Debug newest process","id":"129","title":"Debug newest process"},"13":{"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","breadcrumbs":"Tools » I/O redirection","id":"13","title":"I/O redirection"},"130":{"body":"pmap Dump virtual memory map of process. Compared to /proc//maps it shows the size of the mappings.","breadcrumbs":"Resource analysis & monitor » pmap(1)","id":"130","title":"pmap(1)"},"131":{"body":"pstack Dump stack for all threads of process.","breadcrumbs":"Resource analysis & monitor » pstack(1)","id":"131","title":"pstack(1)"},"132":{"body":"strace ltrace perf OProfile time","breadcrumbs":"Trace and Profile","id":"132","title":"Trace and Profile"},"133":{"body":"strace [opts] [prg] -f .......... follow child processes on fork(2) -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 : 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(1)","id":"133","title":"strace(1)"},"134":{"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 -f -e signal -p ","breadcrumbs":"Trace and Profile » Examples","id":"134","title":"Examples"},"135":{"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(1)","id":"135","title":"ltrace(1)"},"136":{"body":"List which program/libs call into libstdc++: ltrace -l '*libstdc++*' -C -o ltrace.log ./main","breadcrumbs":"Trace and Profile » Example","id":"136","title":"Example"},"137":{"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(1)","id":"137","title":"perf(1)"},"138":{"body":"","breadcrumbs":"Trace and Profile » Flamegraph","id":"138","title":"Flamegraph"},"139":{"body":"perf record -g -e cpu-cycles -p \nperf script | FlameGraph/stackcollapse-perf.pl | FlameGraph/flamegraph.pl > cycles-flamegraph.svg","breadcrumbs":"Trace and Profile » Flamegraph with single event trace","id":"139","title":"Flamegraph with single event trace"},"14":{"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 » Explanation","id":"14","title":"Explanation"},"140":{"body":"perf record -g -e cpu-cycles,page-faults -p \nperf script --per-event-dump\n# fold & generate as above","breadcrumbs":"Trace and Profile » Flamegraph with multiple event traces","id":"140","title":"Flamegraph with multiple event traces"},"141":{"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","id":"141","title":"OProfile"},"142":{"body":"# statistics of process run\n/usr/bin/time -v ","breadcrumbs":"Trace and Profile » /usr/bin/time(1)","id":"142","title":"/usr/bin/time(1)"},"143":{"body":"od xxd readelf objdump nm","breadcrumbs":"Binary","id":"143","title":"Binary"},"144":{"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(1)","id":"144","title":"od(1)"},"145":{"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 » ASCII to hex string","id":"145","title":"ASCII to hex string"},"146":{"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 » Extract parts of file","id":"146","title":"Extract parts of file"},"147":{"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(1)","id":"147","title":"xxd(1)"},"148":{"body":"echo -n 'aabb' | xxd -p >> 61616262","breadcrumbs":"Binary » ASCII to hex stream","id":"148","title":"ASCII to hex stream"},"149":{"body":"echo -n '61616262' | xxd -p -r >> aabb","breadcrumbs":"Binary » Hex to binary stream","id":"149","title":"Hex to binary stream"},"15":{"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 [] specifies the names of supported options, eg f:c f: means -f option with an argument c means -c option without an argument specifies a variable name which getopts fills with the last parsed option argument optionally specify argument string to parse, by default getopts parses $@","breadcrumbs":"Tools » Argument parsing with getopts","id":"15","title":"Argument parsing with getopts"},"150":{"body":"echo -n '\\x7fELF' | xxd -p | xxd -p -r | file -p - >> ELF","breadcrumbs":"Binary » ASCII to binary","id":"150","title":"ASCII to binary"},"151":{"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 » ASCII to C array (hex encoded)","id":"151","title":"ASCII to C array (hex encoded)"},"152":{"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(1)","id":"152","title":"readelf(1)"},"153":{"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(1)","id":"153","title":"objdump(1)"},"154":{"body":"For example .plt section: objdump -j .plt -d ","breadcrumbs":"Binary » Disassemble section","id":"154","title":"Disassemble section"},"155":{"body":"nm [opts] -C demangle -u undefined only","breadcrumbs":"Binary » nm(1)","id":"155","title":"nm(1)"},"156":{"body":"c++filt c++ glibc gcc [make] (./make.md) ld.so","breadcrumbs":"Development","id":"156","title":"Development"},"157":{"body":"","breadcrumbs":"Development » c++filt(1)","id":"157","title":"c++filt(1)"},"158":{"body":"c++-filt ","breadcrumbs":"Development » Demangle symbol","id":"158","title":"Demangle symbol"},"159":{"body":"For example dynamic symbol table: readelf -W --dyn-syms | c++filt","breadcrumbs":"Development » Demangle stream","id":"159","title":"Demangle stream"},"16":{"body":"#!/bin/bash\nfunction parse_args() { while getopts \"f:c\" PARAM; do case $PARAM in f) echo \"GOT -f $OPTARG\";; c) echo \"GOT -c\";; *) echo \"ERR: print usage\"; exit 1;; esac done # users responsibility to reset OPTIND OPTIND=0\n} parse_args -f xxx -c\nparse_args -f yyy","breadcrumbs":"Tools » Example","id":"16","title":"Example"},"160":{"body":"","breadcrumbs":"Development » c++","id":"160","title":"c++"},"161":{"body":"Force compile error to see what auto is deduced to. auto foo = bar(); // force compile error\ntypename decltype(foo)::_;","breadcrumbs":"Development » Type deduction","id":"161","title":"Type deduction"},"162":{"body":"","breadcrumbs":"Development » glibc","id":"162","title":"glibc"},"163":{"body":"Trace memory allocation and de-allocation to detect memory leaks. Need to call mtrace(3) to install the tracing hooks. If we can't modify the binary to call mtrace we can create a small shared library and pre-load it. // libmtrace.c\n#include \n__attribute__((constructor)) static void init_mtrace() { mtrace(); } Compile as: gcc -shared -fPIC -o libmtrace.so libmtrace.c To generate the trace file run: export MALLOC_TRACE=\nLD_PRELOAD=./libmtrace.so Note : If MALLOC_TRACE is not set mtrace won't install tracing hooks. To get the results of the trace file: mtrace $MALLOC_TRACE","breadcrumbs":"Development » malloc tracer mtrace(3)","id":"163","title":"malloc tracer mtrace(3)"},"164":{"body":"Configure action when glibc detects memory error. export MALLOC_CHECK_= Useful values: 1 print detailed error & continue\n3 print detailed error + stack trace + memory mappings & abort\n7 print simple error message + stack trace + memory mappings & abort","breadcrumbs":"Development » malloc check mallopt(3)","id":"164","title":"malloc check mallopt(3)"},"165":{"body":"","breadcrumbs":"Development » gcc(1)","id":"165","title":"gcc(1)"},"166":{"body":"","breadcrumbs":"Development » CLI","id":"166","title":"CLI"},"167":{"body":"While debugging can be helpful to just pre-process files. gcc -E [-dM] ... -E run only preprocessor -dM list only #define statements","breadcrumbs":"Development » Preprocessing","id":"167","title":"Preprocessing"},"168":{"body":"","breadcrumbs":"Development » Builtins","id":"168","title":"Builtins"},"169":{"body":"Give the compiler a hint which branch is hot, so it can lay out the code accordingly to reduce number of jump instructions. See on compiler explorer . echo \"\nextern void foo();\nextern void bar();\nvoid run0(int x) { if (__builtin_expect(x,0)) { foo(); } else { bar(); }\n}\nvoid run1(int x) { if (__builtin_expect(x,1)) { foo(); } else { bar(); }\n}\n\" | gcc -O2 -S -masm=intel -o /dev/stdout -xc - Will generate something similar to the following. run0: bar is on the path without branch run1: foo is on the path without branch run0: test edi, edi jne .L4 xor eax, eax jmp bar\n.L4: xor eax, eax jmp foo\nrun1: test edi, edi je .L6 xor eax, eax jmp foo\n.L6: xor eax, eax jmp bar","breadcrumbs":"Development » __builtin_expect(expr, cond)","id":"169","title":"__builtin_expect(expr, cond)"},"17":{"body":"The complete builtin is used to interact with the completion system. complete # print currently installed completion handler\ncomplete -F # install as completion handler for \ncomplete -r # uninstall completion handler for Variables available in completion functions: # in\n$1 # \n$2 # current word\n$3 # privous word COMP_WORDS # array with current command line words\nCOMP_CWORD # index into COMP_WORDS with current cursor position # out\nCOMPREPLY # array with possible completions The compgen builtin is used to generate possible matches by comparing word against words generated by option. compgen