Posts

Showing posts from October, 2018

Shell

How to delete by word in Shell? alt + backspace

git

Convention: %H : commit hash %h : abbreviated commit hash How to how logs of one given file git log --pretty=oneline file name How to show just the file names changed in a patch? git show %H --name-only  How to do a git squash? e.g. If I want to squash the two commits on HEAD. (a) git rebase -i HEAD~2 git will bring all a editor with the following message: pick 8157e2b Test 1. pick 05532ed Test 2. (b) change the second 'pick' to 'squash', which means squash commit 2 (Test2) into commit 1 (Test1) (c) Save and quite. git will combine the two commits together and bring up a new editor. Like: # This is a combination of 2 commits. # The first commit's message is: Test 1. # This is the 2nd commit message: Test 2. Edit the message again and save and quite. Like Test1 && Test2 Successfully rebased and updated refs/heads/master. If you do a 'git log' after the combination, you will find the new combin...

gdb

How to set gdb to follow the child process as well? By typing in  set follow-fork-mode child when launched gdb and before running. By default, when a program  forks , GDB will continue to debug the parent process and the  child  process will run unimpeded. If you want to  follow  the  child  process instead of the parent process, use the command  set follow - fork - mode  .  Set  the debugger response to a program call of  fork  or vfork . When you want to debug B in another process which is a child process of A, then you have to set this mode.

Unix/Linux

How to create  a symbolic or soft link?     syntax:       ln [-s]      source                          symbolic link e.g:  ln -s src/build/llvm/install/bin  ./my_bin How to grep all file exclude a ctag file : tags? alias gnt='grep -rn --exclude="tags"' How to get the current directory of the running script? DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" Bash maintains a number of variables including  BASH_SOURCE  which is an array of source file pathnames. ${}  acts as a kind of quoting for variables. $()  acts as a kind of quoting for commands but they're run in their own context. dirname  gives you the path portion of the provided argument. cd  changes the current directory. pwd  gives the current path. &&  is a logical  and  but is used in this instanc...

vim

Shortcut key for right click mouse to insert copied content      Shift + Insert     How to searach a line begin with a number end with 970 space?    "/^[0-9].*970 " and enter, don't forget the . before *!! Search across line? Search patterns that contains szeroext in two consecutive lines: zeroext.*\(\_s.*\)\{0,3\}\_szeroext.* Search pattern across lines like: ... szeroext... ... szeroext... .... rem... zeroext.*\(\_s.*\)\{0,1\}\_szeroext.*\_s.*rem.* Set vim to show lines? :set number

Markdown

How to start a new line? end the current line with 2+ spaces, and hit return to start a new line.

llvm

How to print out cce hidden options? ./cce-llc --help-hidden | less Filter dbg output by mangled function names -filter-print-funcs=<function names>    - Only print IR for functions whose name match this for all print-[before|after][-all] options How to print out just detailed dbg information for one pass? Instead of use -debug to print everything which is overwhelmingly too much, you can use -mllvm -debug-only=path-name, e.g: -mllvm -debug-only=machine-licm How to print a CFG of function to 'dot' file? -dot-cfg-only: Print CFG of function to 'dot' file (with no function bodies) This pass, only available in  opt , prints the control flow graph into a  .dot  graph, omitting the function bodies. This graph can then be processed with the "dot" tool to convert it to postscript or some other suitable format. e.g: clang++ hello.cpp -S -emit-llvm opt -dot-cfg-only hello.ll dot -Tpdf cfg.main.dot -o cfg.main.pdf