[20220316]完善vim gdb.vim外掛.txt

lfree發表於2022-03-17

[20220316]完善vim gdb.vim外掛.txt

--//上午使用發現一個小問題,二進位制時前面沒有0b,補上。
29 = 11101

# cat gdb.vim
"" gdb Low version for linux
""noremap <Leader>px Yp!!sed -e 's+^+p /x +'  >\| /tmp/gdb.txt && gdb -q  -x /tmp/gdb.txt \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
""noremap <Leader>pd Yp!!sed -e 's+^+p /d +'  >\| /tmp/gdb.txt && gdb -q  -x /tmp/gdb.txt \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
""noremap <Leader>po Yp!!sed -e 's+^+p /o +'  >\| /tmp/gdb.txt && gdb -q  -x /tmp/gdb.txt \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
""noremap <Leader>pt Yp!!sed -e 's+^+p /t +'  >\| /tmp/gdb.txt && gdb -q  -x /tmp/gdb.txt \| awk 'NR==1{print $NF}'<CR>kA = <ESC>Ji0b
""noremap <Leader>pb Yp!!sed -e 's+^+p /t +'  >\| /tmp/gdb.txt && gdb -q  -x /tmp/gdb.txt \| awk 'NR==1{print "0b"$NF}'<CR>kA = <ESC>J

"" gdb high version for linux
"" noremap <Leader>px Yp!!sed -e 's+^+p /x +' \| gdb -q \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
"" noremap <Leader>pd Yp!!sed -e 's+^+p /d +' \| gdb -q \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
"" noremap <Leader>po Yp!!sed -e 's+^+p /o +' \| gdb -q \| awk 'NR==1{print $NF}'<CR>kA = <ESC>J
"" noremap <Leader>pt Yp!!sed -e 's+^+p /t +' \| gdb -q \| awk 'NR==1{print $NF}'<CR>kA = <ESC>Ji0b

"" gdb for windwows, you must be cygwin + gdb.
noremap <Leader>px Yp!!sed -e "s+^+p /x +" \| gdb -q \| gawk "NR==1{print $NF}"<CR>kA = <ESC>J
noremap <Leader>pd Yp!!sed -e "s+^+p /d +" \| gdb -q \| gawk "NR==1{print $NF}"<CR>kA = <ESC>J
noremap <Leader>po Yp!!sed -e "s+^+p /o +" \| gdb -q \| gawk "NR==1{print $NF}"<CR>kA = <ESC>J
noremap <Leader>pt Yp!!sed -e "s+^+p /t +" \| gdb -q \| gawk "NR==1{print $NF}"<CR>kA = <ESC>Ji0b
""noremap <Leader>pb Yp!!sed -e "s+^+p /t +" \| gdb -q \| gawk "NR==1{printf "\0b\%s",$NF}"<CR>kA = <ESC>J
noremap <Leader>pb Yp!!sed -e "s+^+p /t +" \| gdb -q \| gawk "NR==1{print \"0b\"$NF}"<CR>kA = <ESC>J

--//測試如下:
29 = 0b11101

--//另外還發現一個小問題就是因為Cygwin64 Terminal下也有一個bc.exe命令, 如果呼叫這個結尾會多輸出1個^M
12+12 = 24^M

--//為了避免這個輸出,修改PATH環境變數,將D:\tools\cygwin64\bin路徑放在最後。
--//如果透過gawk輸出0b有點麻煩,特別在windows下,有點奇怪的是%也要轉義。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2871534/,如需轉載,請註明出處,否則將追究法律責任。

相關文章