gdb(gnu symbolic debugger)簡單地說就是乙個除錯工具。它是乙個受通用公共許可證即gpl保護的自由軟體。像所有的偵錯程式一樣,gdb可以讓你除錯乙個程式,包括讓程式在你希望的地方停下,此時你可以檢視變數、暫存器、記憶體及堆疊。更進一步你可以修改變數及記憶體值。gdb是乙個功能很強大的偵錯程式,它可以除錯多種語言。在此我們僅涉及 c 和 c++ 的除錯,而不包括其它語言。還有一點要說明的是,gdb是乙個偵錯程式,而不像 vc 是乙個整合環境。你可以使用一些前端工具如xxgdb、ddd等。他們都有圖形化介面,因此使用更方便,但它們僅是gdb的一層外殼。因此,你仍應熟悉gdb命令。事實上,當你使用這些圖形化介面時間較長時,你才會發現熟悉gdb命令的重要性。
starting :
command
effect
gdbgdb < file >
running and stopping:
command
effect
quit
exit gdb
runrun program
run 1 2 3
run program with command-line arguments 1 2 3
kill
stop the program
ctrl-d
exit gdb
breakpoints :
command
effect
break sum
set breakpoint at the entry to function sum
break *0x80483c3
set breakpoint at address 0x80483c3
delete 1
delete breakpoint 1
disable 1
disable the breakpoint 1
enable 1
enable breakpoint 1
delete
delete all breakpoints
clear
sum clear any breakpoints at the entry to function sum
execution
command
effect
stepi
execute one instruction
stepi 4
execute four instructions
nexti
like stepi, but proceedthrough function calls without stopping
step
execute one c statement
continue
resume execution until the next breakpoint
until 3
continue executing until program hits breakpoint 3
finish
resume execution until current function returns
call sum(1, 2)
call sum(1,2) and print return value
examining code
command
effect
disas
disassemble current function
disas sum
disassemble function sum
disas 0x80483b7
disassemble function around 0x80483b7
disas 0x80483b7 0x80483c7
disassemble code within specified address range
print /x $rip
print program counter in hex
print /d $rip
print program counter in decimal
print /t $rip
print program counter in binary
examining data
command
effect
print /d $rax
print contents of %rax in decimal
print /x $rax
print contents of %rax in hex
print /t $rax
print contents of %rax in binary
print /d (int)$rax
print contents of %rax in decimal after sign-extending lower 32-bits.
print 0x100
print decimal representation of 0x100
print /x 555
print hex representation of 555
print /x ($rsp+8)
print (contents of %rsp) + 8 in hex
print *(int *) 0xbffff890
print integer at address 0xbffff890
print *(int *) ($rsp+8)
print integer at address %rsp + 8
print (char *) 0xbfff890
examine a string stored at 0xbffff890
x/w 0xbffff890
examine (4-byte) word starting at address
0xbffff890
x/w $rsp
examine (4-byte) word starting at address in $rsp
x/wd $rsp
examine (4-byte) word starting at address in $rsp.
x/2w $rsp
examine two (4-byte) words starting at address in $rsp
x/2wd $rsp
examine two (4-byte) words starting at address in $rsp.
x/g $rsp
examine (8-byte) word starting at address in $rsp.
x/gd $rsp
examine (8-byte) word starting at address in $rsp.
x/a $rsp
examine address in $rsp. print as offset from previous global symbol.
x/s 0xbffff890
examine a string stored at 0xbffff890
x/20b sum
examine first 20 opcode bytes of function sum
x/10i sum
examine first 10 instructions of function sum
useful information
command
effect
backtrace
print the current address and stack backtrace
where
print the current address and stack backtrace
info program
print current status of the program)
info functions
print functions in program
info stack
print backtrace of the stack)
info frame
print information about the current stack frame
info registers
print registers and their contents
info breakpoints
print status of user-settable breakpoints
display /fmt expr
print expression expr using format fmtevery time gdb stops
undisplay
turn off display mode
help
get information about gdb
vim常見使用命令
一般模式 在linux終端中輸入 vim 檔名 就進入了一般模式,但不能輸入文字。命令模式 在一般模式下按 冒號 就會進入命令模式,左下角會有乙個冒號出現,此時可以敲入命令並執行 按esc可回到一般模式。vim filename 開啟或新建檔案,並將游標置於第一行首 vim n filename 開...
IDEA常見使用命令
1.f7 debug的時候,如果當前行是乙個方法,則進入當前方法體內。如果該方法體內還有方法,則不會進入內嵌的方法 2.f8 debug的時候,如果當前行是乙個方法,則不進入當前方法體內 3.f9 debug的時候,恢復程式執行,如果該斷點下邊的 還有斷點,則停到下乙個斷點上 4.alt f8 de...
git常見使用命令
2 檢視當前分支狀態 3 檢視當前有哪些分支 4 在工作區的第一次修改被放入暫存區,準備提交 5 暫存區的修改提交 6 推送到遠端倉庫 7 取回遠端主機某個分支的更新,再與本地的指定分支合併 8 從當前分支切換到 dev 分支 9 建立並切換新分支 拉取遠端分支到本地分支 本地不存在此分支 10 檢...